cross platform browser automation tests sdp

Post on 15-Jul-2015

142 Views

Category:

Software

3 Downloads

Preview:

Click to see full reader

TRANSCRIPT

Copyright © SELA Software & Education Labs, Ltd. | 14-18 Baruch Hirsch St., Bnei Brak 51202, Israel | www.selagroup.com

Cross Browser Platform in Automation

Testing

Oren Ashkenazy

Mail: orena@sela.co.il

Blog: http://blogs.microsoft.co.il/oren604/

Cross Platform Browser Testing

Intro to Selenium

Selenium Architecture

Selenium IDE

Selenium WebDriver

JavaScriptExecuter

WebDriverJS

Selenium Server

Agenda

Cross platform Browser Testing

Advantages…

• Greater Test Coverage

• Increased Reusability

• Business advantage

• Secure Deployment To Production

Test Plan

Multiple Test Plan Capacity Work

𝐗 𝐧𝐮𝐦𝐛𝐞𝐫 𝐨𝐟 𝐜𝐨𝐧𝐟𝐢𝐠𝐮𝐫𝐚𝐫𝐢𝐨𝐧𝐬=

The Solution…

Selenium Architecture

Code Behind

Browser Drivers

C# Java Ruby Python 2

WebDriver API

IE Firefox Chrome Safari

Demo

Selenium IDE – Record & Running A

Test

Demo

VS & Selenium Webdriver

IWebDriver Basic Methods

Actions

Clear();

Click();

FindElement(string);

Array/List FindElements(string,string…);

SendKeys(string);

Submit();

Explore

GetAttribute(); (Id, ClassName, etc)

GetCSSValue(); (font-size, color, etc)

Enable;

Selected();

Size();

Text;

IJavaScriptExecuter

Demo

Execute JS with Selenium WebDriver

Execute JS with Selenium WebDriver

Get the running browser agent/webdriver type

IJavaScriptExecutor js = (IJavaScriptExecutor)driver;

String BrowserAgent = (String)((IJavaScriptExecutor)driver).ExecuteScript("return navigator.userAgent;");

Execute JS with Selenium WebDriver

Pass browserAgent to the test method

public void FillAcountHolderData(IWebDriver driver, User user, string BrowserAgent)

{

if (BrowserAgent.Contains(“FireFox”)

} { // todo….

}

if (BrowserAgent.Contains(“Chrome”)

{ // todo….

}

}

Cross Platform Testing

Reference for automation browser platforms:

https://code.google.com/p/selenium/w/list?q=label:WebDriver

WebDriverJS

+ =

The difference between WebDriver to

WebDriverJS

Sync

Asynchronous

C# Java Ruby

JavaScript

Demo

WebDriverJS

Open source web testing frameworks

Selenium Server - Agenda

What Is Selenium Server?

What Is Selenium Grid?

Setting the hub (Server)

Setting the node (Client)

Using DesiredCapabilities

What Is Selenium Server?

Selenium Code

Remote Control

Selenium Sever

IEFi

refo

xC

hro

me

Safa

ri

Dri

vers

What Is Selenium Grid?

Selenium Code

Remote Control

Hub

Selenium Sever (Win 7 + Chrome)

Selenium Sever (Win 8 + IE)

Selenium Sever (Centos +

Firefox)

Ch

rom

e

Dri

ver

IE D

rive

rFi

refo

x D

rive

r

Demo

Setting the Hub

Install & Configure

• What to Install?o JRE (Java Runtime Environment)o Selenium Server (JAR File)

• How To Configure The Hub?o Run CMD o Go to the path you downloaded the Jar file: CD “Path Name”o Type the command: java -jar “jar file name” -role hub

o After running this command you will receive an output of the selenium server address (The default address is http://127.0.0.1:4444

o Leave CMD window open while you want the selenium server process to keep running

Demo

Setting up a server node

Setting up a server node

• How to configure?

o Run CMD

o Go to the path you downloaded the Jar file: CD “Path Name”

o Type the command: java -jar “Jar File Name” -role node -hub http://localhost:4444/grid/register

o Validate the node server is up by going to:

http://localhost:4444/grid/console

Demo

Running a Test

Use the RemoteWebDriver and the DesiredCapabilities object to define which browser, version and platform you wish to use

private IWebDriver driver = new RemoteWebDriver (new Uri("http://localhost:4444/wd/hub"),

DesiredCapabilities.Firefox());

Running a test using the grid

In this example the test will run on machine/s that have IOS and Firefox driver

private IWebDriver driver = new RemoteWebDriver(new Uri("http://localhost:4444/wd/hub"),

new DesiredCapabilities("Firefox", "", new Platform(PlatformType.Mac)));

Using a specific configuration

Selenium Grid Wiki

More information:

https://code.google.com/p/selenium/wiki/Grid2

Questions

top related