What is Selenium Grid?

Selenium Grid helps user to run the script on multiple web browsers in different operating systems.

Grid uses Hub-Node architecture in which only one hub is there and rest of the nodes act as slaves.

Hub node architecture means if the user has to execute approximately 100 test cases at the same time, then it will be distributed across 5 machines and every machine will run and execute 20 test cases.

Even these test cases can be run in a combination with different browsers and operating systems. Here, these machines can have the different OS on which you can perform different test cases for different web browsers.

Why Grid :

Today, too many web browsers are being used by the users to access websites. These web browsers may be Opera, Safari, Firefox, or Internet Explorer etc.

Even every browser has different versions available that they can run on a various and different OS that may be Windows, Mac or Ubuntu Linux based OS.

Being a tester or application developer, you will try to give the best experience to your user while accessing their website on the internet.

Even you will also go the extra mile to provide them world-class experiences. You are right here, as trying and providing best user experiences is your responsibility, so the application must be tested rigorously before providing it to the customer

But sometimes it is not feasible for the testers to test website for every browser and for every OS. As it is like a challenge for them and below we have discussed where Kotlin Selenium helps the testers to test application easily even in a separate and different environment combination.

Selenium kotlin helps the testers in testing applications in various environments, so by using it, the users can easily test their applications in the virtual environment.

Hub / Master :

The hub can also be understood as a server which acts as the central point where the tests would be triggered.

A Selenium Grid has only one Hub and it is launched on a single machine once.

The hub is the central point that will receive test requests and distribute them to the right nodes. The distribution is done on a capabilities basis, meaning a test requiring a set of capabilities will only be distributed to nodes offering that set or subset of capabilities.

Because a test's desired capabilities are just what the name implies, desired, the hub cannot guarantee that it will locate a node fully matching the requested desired capabilities set.

Start the Hub :
Open a command prompt and navigate to the directory where you copied the selenium-server-standalone.jar file. You start the hub by passing the -role hub flag to the standalone server:


							java -jar selenium-server-standalone.jar -role hub
							

The hub will listen to port 4444 by default. You can view the status of the hub by opening a browser window and navigating to http://localhost:4444/grid/console

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.

Start the Node :


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


							
import org.openqa.selenium.Platform
import org.openqa.selenium.remote.RemoteWebDriver
import org.openqa.selenium.remote.DesiredCapabilities
import java.net.URL
fun main(args: Array) {
    //hub URL
    val hubUrl = URL("http://localhost:4444/grid/register")
    //creating instance to Desired Capabilities class
    val dCap = DesiredCapabilities()
    //set the browser name
    dCap.browserName = "firefox"
    //set the os
    dCap.platform = Platform.WINDOWS
    val driver = RemoteWebDriver(hubUrl, dCap)
    driver.get("https://chercher.tech")
    //remaining normal code
}
							

Things to remember :

  • You can execute multiple tests on different browsers and multiple platforms on the node machines.
  • Grids uses Master/Hub and Slave/node concepts to run the test cases on different nodes
  • You can have only one Hub machine
  • Choosing the node is not possible when we have more than one node with similar settings
  • You can also configure Hub to work with latest technologies like docker and Kubernates
  • You can configure your local machine as Both Node and Hub at same time

About Author

Myself KarthiQ, I am the author of this blog, I know ways to write a good article but some how I donot have the skills to make it to reach people, would you like help me to reach more people By sharing this Article in the social media.

Share this Article Facebook
You can also share knowledge by Adding a topic here


Comment / Suggestion Section
Point our Mistakes and Post Your Suggestions
Copyright © CherCher Tech