Cross platform browser automation tests sdp

32
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: [email protected] Blog: http://blogs.microsoft.co.il/oren604/

Transcript of Cross platform browser automation tests sdp

Page 1: Cross platform browser automation tests   sdp

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: [email protected]

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

Page 2: Cross platform browser automation tests   sdp

Cross Platform Browser Testing

Intro to Selenium

Selenium Architecture

Selenium IDE

Selenium WebDriver

JavaScriptExecuter

WebDriverJS

Selenium Server

Agenda

Page 3: Cross platform browser automation tests   sdp

Cross platform Browser Testing

Advantages…

• Greater Test Coverage

• Increased Reusability

• Business advantage

• Secure Deployment To Production

Page 4: Cross platform browser automation tests   sdp

Test Plan

Page 5: Cross platform browser automation tests   sdp

Multiple Test Plan Capacity Work

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

Page 6: Cross platform browser automation tests   sdp

Page 7: Cross platform browser automation tests   sdp

The Solution…

Page 8: Cross platform browser automation tests   sdp

Selenium Architecture

Code Behind

Browser Drivers

C# Java Ruby Python 2

WebDriver API

IE Firefox Chrome Safari

Page 9: Cross platform browser automation tests   sdp

Demo

Selenium IDE – Record & Running A

Test

Page 10: Cross platform browser automation tests   sdp

Demo

VS & Selenium Webdriver

Page 11: Cross platform browser automation tests   sdp

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;

Page 12: Cross platform browser automation tests   sdp

IJavaScriptExecuter

Page 13: Cross platform browser automation tests   sdp

Demo

Execute JS with Selenium WebDriver

Page 14: Cross platform browser automation tests   sdp

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;");

Page 15: Cross platform browser automation tests   sdp

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….

}

}

Page 16: Cross platform browser automation tests   sdp

Cross Platform Testing

Reference for automation browser platforms:

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

Page 17: Cross platform browser automation tests   sdp

WebDriverJS

+ =

Page 18: Cross platform browser automation tests   sdp

The difference between WebDriver to

WebDriverJS

Sync

Asynchronous

C# Java Ruby

JavaScript

Page 19: Cross platform browser automation tests   sdp

Demo

WebDriverJS

Page 20: Cross platform browser automation tests   sdp

Open source web testing frameworks

Page 21: Cross platform browser automation tests   sdp

Selenium Server - Agenda

What Is Selenium Server?

What Is Selenium Grid?

Setting the hub (Server)

Setting the node (Client)

Using DesiredCapabilities

Page 22: Cross platform browser automation tests   sdp

What Is Selenium Server?

Selenium Code

Remote Control

Selenium Sever

IEFi

refo

xC

hro

me

Safa

ri

Dri

vers

Page 23: Cross platform browser automation tests   sdp

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

Page 24: Cross platform browser automation tests   sdp

Demo

Setting the Hub

Page 25: Cross platform browser automation tests   sdp

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

Page 26: Cross platform browser automation tests   sdp

Demo

Setting up a server node

Page 27: Cross platform browser automation tests   sdp

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

Page 28: Cross platform browser automation tests   sdp

Demo

Running a Test

Page 29: Cross platform browser automation tests   sdp

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

Page 30: Cross platform browser automation tests   sdp

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

Page 31: Cross platform browser automation tests   sdp

Selenium Grid Wiki

More information:

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

Page 32: Cross platform browser automation tests   sdp

Questions