Selenium 14: Selenium Grid


In this post, I will describe how to use Selenium Grid.

First of all, you can access Selenium Grid page from below address.

https://github.com/SeleniumHQ/selenium/wiki/Grid2[1]

Grid allows you to:

  • Scale by distributing tests on several machines ( parallel execution )
  • Manage multiple environments from a central point, making it easy to run the tests against a vast combination of browsers / OS.
  • Minimize the maintenance time for the grid by allowing you to implement custom hooks to leverage virtual infrastructure for instance. [1]

Now, please go to http://www.seleniumhq.org/download/ and download Selenium Standalone Server.

grid

Then, copy the .jar file to C:\Selenium\grid\ folder.

What are Hub and Nodes?

Basically, we have a Hub which is a server that we connect from our tests and we have Nodes, they can be on different machines and they register with the hub. Simply, we have a hub and several nodes, nodes are registered our hub and hub knows that which browsers are available. Hub sends requests to the nodes based on desired capabilities and executes the tests.

How to Start and Configure Hub and Nodes

The best way to start hub and node with .bat files for Windows also it is easier and tidier to configure them with .json files.

First, let’s start the hub by command window.

Hub Start Command: java -jar selenium-server-standalone-3.0.1.jar -role hub

and you can see the hub panel on your browser as follows.

Let’s start the node

We can start the node with command window as below command.

Node Start Command: java -jar selenium-server-standalone-3.0.1.jar -role node -hub http://localhost:4444/grid/register

and when you open the grid console you can see that the node registered with the hub.

selenium grid

When we wanted to use selenium grid in our tests we need to tell our grid where the required browser executable is located. Thus, we should start to the node as below command before writing our tests. We added the blue part.

Node Start Command with Chrome Driver Location: java -jar -Dwebdriver.chrome.driver=C:\Selenium\drivers\chrome\chromedriver.exe selenium-server-standalone-3.0.1.jar -role node -hub http://localhost:4444/grid/register 

I wrote a very simple test which clicks the Facebook login button. Before running below test, start the hub and the node with above command then run the test.

Selenium Grid Nodes and Hub Configurations by JSON

It is also described at https://github.com/SeleniumHQ/selenium/wiki/Grid2 page as shown below.

Hub Config: https://github.com/SeleniumHQ/selenium/blob/master/java/server/src/org/openqa/grid/common/defaults/DefaultHub.json

Node Config: https://github.com/SeleniumHQ/selenium/blob/master/java/server/src/org/openqa/grid/common/defaults/DefaultNodeWebDriver.json

I will use the same config which is located at above link. By using these configurations I created “starthub.bat” and “startnode.bat” files.

starthub.bat

startnode.bat

Start the HUB

Start the Node

Run the test again! When you run the test you will see that it will pass.

Thanks for reading.

All the best!
-Onur

javafx

Database Operations in JavaFX

By Onur Baskirt / Apr 1, 2016 / 56 Comments
Before started this section, please check the first article and learn How to Start JAVAFX! http://www.swtestacademy.com/getting-started-with-javafx/ At first, part of JavaFX tutorial series, we created a sample JavaFX project, designed the draft version of the UI and set up an...
extentreports

How to Write Smart XPath Locators

By Onur Baskirt / Sep 24, 2017 / 5 Comments
Hi all, in this tutorial, I will describe you how to write smart and non-brittle XPath locators. When we write our test scripts, we generally prefer to use id, name, class, etc. these kinds of locators. However, sometimes we could not...
extentreports

How to Write Effective CSS Locators

By Onur Baskirt / Oct 1, 2017 / 0 Comments
Hi all, in this tutorial, I will describe you how to write effective CSS locators to interrogate web elements for your automation projects. As a rule of thumb, your interrogation strategy should be in below order: First try to use...
rest assured

REST API Testing with Rest Assured

By Onur Baskirt / Mar 8, 2016 / 32 Comments
Outline In this post, I will explain what is API and API testing, what is the difference between SOAP and REST services, and how to test REST APIs with Rest Assured Library. What is API? API stands for Application Programming...
javafx

Getting Started with JavaFX

By Onur Baskirt / Mar 25, 2016 / 0 Comments
When I started to work in my current position, one of my task is to do manual operations for campaign products  every week. After the second week, I thought that I have to automate this task using a GUI based...
extentreports

Selenium-1: Quick Start to Automation with Selenium WebDriver & JAVA & JUnit & Maven & IntelliJ

By Onur Baskirt / Sep 8, 2015 / 26 Comments
Outline Selenium Webdriver is the most popular open source web test automation framework across the wide range of browsers and platforms. In this tutorial, you will learn how to do web test automation with Selenium Webdriver and the related tools....
extentreports

Selenium-11: Execute JavaScript with JavascriptExecutor

By Onur Baskirt / Jan 27, 2016 / 15 Comments
Outline Sometimes we cannot handle some conditions or problems with Webdriver, web controls don't react well against selenium commands. In this kind of situations, we use Javascript. It is useful for custom synchronizations, hide or show the web elements, change...
page object model

Page Object Model with C#

By Ege Aksoz / Jun 18, 2017 / 8 Comments
In the previous tutorial, we’ve taken the initial steps and entered the world of automated testing. We also wrote our first automated test. From this point on, since we are not just going to write one test, we need to...
extentreports

How to Select a Date From DatePicker Using Selenium

By Onur Baskirt / Aug 13, 2016 / 6 Comments
When you need to automate a airway, hotel, or similar websites you need to deal with Datepickers and some times it is a little bit cumbersome to select a specific date on the Datepicker or calendar.  In this post, I...

Getting Started with RobotFramework on Windows

By Onur Baskirt / Apr 25, 2016 / 12 Comments
What is RobotFramework? RobotFramework is a GENERIC test automation framework for acceptance testing and acceptance test-driven development (ATTD). What it means that you can do web, mobile, desktop and other test automation activities with related test libraries. These libraries can...
By | 2017-09-19T13:35:32+00:00 November 20th, 2016|Selenium, Test Automation, Web Automation|0 Comments

About the Author:

Onur Baskirt
Onur Baskirt is a senior IT professional with 10+ years of experience. He worked at Bahçesehir University, ST Microelectronics, Huawei and Ericsson as research assistant, design verification engineer and software test leader. Also, he worked as software test leader and software operations manager at Turkey's biggest technology retailer, Teknosa. Now, he is working as Head of Software Testing and Manager of two Development Teams at Kariyer.net. His current research areas are technical software testing, programming, and computer science. Formerly, he has several research works and papers on digital chip design & verification. His hobbies are sport, dancing, traveling, and nutrition. You can find detailed information about him on his linked-in page.

Leave A Comment