24
1 Confidential and propriety Galil Software, Ltd. 2012 6/15/22 Author : Amir Najjar – Automation Development Lead. Selenium Grid + Cloud Based Solutions

How to work with Selenium Grid and Cloud Solutions

Embed Size (px)

Citation preview

Page 1: How to work with Selenium Grid and Cloud Solutions

1Confidential and propriety Galil Software, Ltd. 2012 Apr 18, 2023

Author : Amir Najjar – Automation Development Lead.

Selenium Grid + Cloud Based Solutions

Page 2: How to work with Selenium Grid and Cloud Solutions

2Confidential and propriety Galil Software, Ltd. 2012 19.8.12

Selenium Grid

- What is Selenium Grid?

- Tool for distributing tests across multiple physical or virtual machines simultaneously.

- Dramatically accelerates the testing process and returns a quick feedback.

- The code doesn’t need to be present on the machines which run the tests.

Page 3: How to work with Selenium Grid and Cloud Solutions

3Confidential and propriety Galil Software, Ltd. 2012 19.8.12

Distribute Tests across Machines:

There are 2 ways to distribute tests across multiple machines:

1) Use Selenium Grid

2) Distribute them by making relevant configurations using a CI system (TeamCity)

Page 4: How to work with Selenium Grid and Cloud Solutions

4Confidential and propriety Galil Software, Ltd. 2012 19.8.12

So how Does Selenium Grid Work? Hub and Node:

- Hub - central point where the tests would be triggered. A Selenium Grid has only one Hub and it is launched on a single machine once.

- Node - Nodes are the Selenium instances that are attached to the Hub which execute the tests. There can be one or more nodes in a grid which can be of any OS and can contain any of the Selenium supported browsers.

Page 5: How to work with Selenium Grid and Cloud Solutions

Run Selenium Tests on

Run Selenium Tests on

Run Selenium Tests on

Selenium Grid HUB (Server)

Distribute Tests to nodes

Page 6: How to work with Selenium Grid and Cloud Solutions

6Confidential and propriety Galil Software, Ltd. 2012 19.8.12

Working with the grid – 5 steps:

* Configuring the Hub

java –jar sel-server-standalone.jar –port 4444 –role hub –nodeTimeout 1000

* Configuring the Nodes

(server-standalone) java -jar D:\JAR\selenium-server-standalone-2.42.2.jar -role node -hub http://192.33.172.157:4444/grid/register -browser browserName=firefox -port 5555

* Develop the Script and Prepare the XML File

* Test Execution

* Result Analysis

Page 7: How to work with Selenium Grid and Cloud Solutions

7Confidential and propriety Galil Software, Ltd. 2012 19.8.12

Configuring the hub:

• After downloading the selenium server standalone, start the hub using the following command:

java -jar selenium-server-standalone-2.45.0.jar -port 4444 -role hub -nodeTimeout 1000

Now navigate to: http//localhost:4444

You will see that you have access to the hub, and you will also see that you still don’t have any configured nodes yet.

Page 8: How to work with Selenium Grid and Cloud Solutions

8Confidential and propriety Galil Software, Ltd. 2012 19.8.12

Configuring the nodes:

• Log on to the machine you would like to execute your tests on, download the selenium server standalone jar and invoke the following command:

java -jar C:\Selenium\selenium-server-standalone-2.45.0.jar -role node -hub http://192.168.173.100:4444/grid/register -browser browserName=firefox -port 5559

• Path to the server standalone jar• IP address of the hub• The port of the hub• The browser type you want to run on• The port of the node you want to run on

Now navigate back to: http//localhost:4444

You will see that you have a Firefox node configured already.

Note: to configure chrome and IE nodes, you will need to download the drivers according to your OS.

Page 9: How to work with Selenium Grid and Cloud Solutions

9

Data Sources

• <?xml version="1.0" encoding="UTF-8"?>• <!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">• <suite name="Suite" parallel="tests">

• <test name="Test With FF">• <parameter name="browser" value="firefox" />• <classes>• <class name=“com.amir.TestClass" />• </classes>• </test>

• <test name=“Test With Chrome">• <parameter name="browser" value="chrome" />• <classes>• <class name=" com.amir.TestClass " />• </classes>• </test>

• <test name=“Test with IE">• <parameter name="browser" value="ie" />• <classes>• <class name=" com.amir.TestClass " />• </classes>• </test>• • </suite>

Run the same test with a different browser parameter

Page 10: How to work with Selenium Grid and Cloud Solutions

10

Data Sources

• Now, in order to differentiate between each test run you will have to receive the browser parameter which you stated in your xml runner using TestNG’s parametrized testing method, (@Parameters("browser") ) and then initialize each driver with the corresponding browser capabilities, using a remote webdriver.

Initalizing On Firefox: String Node = "http://192.100.70.50:5559/wd/hub"; DesiredCapabilities capability = DesiredCapabilities.firefox(); capability.setBrowserName("firefox"); driver = new RemoteWebDriver(new URL(Node), capability);

Initialize On Chrome: DesiredCapabilities cap = DesiredCapabilities.chrome(); cap.setBrowserName("chrome"); String Node = “http://192.100.71.50:5557/wd/hub"; driver = new RemoteWebDriver(new URL(Node), cap);

And so on.

Time to get back to the code:

Page 11: How to work with Selenium Grid and Cloud Solutions

11Confidential and propriety Galil Software, Ltd. 2012 19.8.12

There are 3 popular Cloud based solutions out there:

1) BrowserStack

2) SauceLabs

3) Rainforest

We will make a small comparison in order to determine what would suit selenium tests more

Cloud Based Solutions:

Page 12: How to work with Selenium Grid and Cloud Solutions

12Confidential and propriety Galil Software, Ltd. 2012 19.8.12

Rainforest BrowserStack SauceLabs

V V V WebDriver Compatible

7 8 6 Ease Of Use

X V V Video Recording of Tests

V V V CI Integration

V V V Cross Browser Testing

4 6 8 Community Support

6 8 8 Device Support

Need to request demo 100 Automation Hours 14 days Trial

Cloud Based Solutions:

Page 13: How to work with Selenium Grid and Cloud Solutions

13Confidential and propriety Galil Software, Ltd. 2012 19.8.12

What about the price???

SauceLabs

Page 14: How to work with Selenium Grid and Cloud Solutions

14Confidential and propriety Galil Software, Ltd. 2012 19.8.12

What about the price???BrowserStackhttps://www.browserstack.com/accounts/subscriptions1470USD (25 licenses)

Page 15: How to work with Selenium Grid and Cloud Solutions

15Confidential and propriety Galil Software, Ltd. 2012 19.8.12

Each VM can only run one browser instance, which means, if we want to go down to 30 minutes of run time, we will need about 25 Virtual Machines.

I have even double checked and asked one of BrowserStack’s representatives, here’s the e-mail:

Sounds good? YES! But Pricy $$$$!

Page 16: How to work with Selenium Grid and Cloud Solutions

16Confidential and propriety Galil Software, Ltd. 2012 19.8.12

Each VM can only run one browser instance!!! WHY???

The Reply to the E-mail:

Page 17: How to work with Selenium Grid and Cloud Solutions

17Confidential and propriety Galil Software, Ltd. 2012 19.8.12

So what about the price? Depends how much we use the machine!!

http://calculator.s3.amazonaws.com/index.html

Assuming we run 12 hours a day on a machine with 8 GB of RAM the monthly cost is 97 USD!

Assuming we run 12 hours a day on a machine with 4 GB of RAM the monthly cost is 49USD!

So what about Amazon EC2?Amazon has always been a good choice, technically, it is how we run tests on TC now, but with better machines

provided from amazon.

Page 18: How to work with Selenium Grid and Cloud Solutions

18Confidential and propriety Galil Software, Ltd. 2012 19.8.12

Just a brain Teaser taken from a survey done by a company called Tellerium :

Page 19: How to work with Selenium Grid and Cloud Solutions

19Confidential and propriety Galil Software, Ltd. 2012 19.8.12

More Teasers:

Page 20: How to work with Selenium Grid and Cloud Solutions

20Confidential and propriety Galil Software, Ltd. 2012 19.8.12

More Teasers:

Page 21: How to work with Selenium Grid and Cloud Solutions

21Confidential and propriety Galil Software, Ltd. 2012 19.8.12

A few Takeaways from the survey:

Page 22: How to work with Selenium Grid and Cloud Solutions

22Confidential and propriety Galil Software, Ltd. 2012 19.8.12

A few Takeaways from the survey:

Page 23: How to work with Selenium Grid and Cloud Solutions

23Confidential and propriety Galil Software, Ltd. 2012 19.8.12

A few Takeaways from the survey:

Page 24: How to work with Selenium Grid and Cloud Solutions

24Confidential and propriety Galil Software, Ltd. 2012 Apr 18, 2023

Author : Amir Najjar – Automation Development Lead.

Thank you!! Stay Tuned!! DEMO AHEAD!