Selenium Grid 2-Parallel Execution


Selenium Grid allows to access to run the test cases with different  machine with multiple browser. It works as a parallel  execution. Selenium grid is automated testing execution on Distributed systems in parallel.

Architecture of Selenium Grid:

Selenium grid consists one hub which control all the nodes which is registered on hub.Node is working as a port and each node is capable to open multiple browser.Every single machine working as a hub and a hub can have multiple nodes.

hubnodegrid

Installation of Selenium Grid:

For installing the selenium grid we have to install selenium server jar file. Now we will start the hub configuration in your local machine, For making the hub we open the terminal type the command.

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

Now we open the browser and type http://localhost:4444 we will get the selenium grid screen.

gridconsole

Now we take next step we will make nodes. By default a single node will work as a operating system same as host and will five firefox, chrome Instance  and one Internet Explorer. Now we open the terminal and follow the command.

gridconsole1

gridport

Code for Selenium Grid:

package datatest;

import java.net.MalformedURLException;
import java.net.URL;

import org.openqa.selenium.By;
import org.openqa.selenium.Platform;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.remote.RemoteWebDriver;
import org.testng.annotations.Parameters;
import org.testng.annotations.Test;

public class SearchTest {

@Parameters("browser")
@Test
public void Testfind(String b) throws MalformedURLException{

DesiredCapabilities cap = null;

if(b.equals("firefox")){
cap = DesiredCapabilities.firefox();
cap.setBrowserName("firefox");
cap.setPlatform(Platform.ANY);
}else if (b.equals("chrome")){
cap = DesiredCapabilities.chrome();
cap.setBrowserName("chrome");
cap.setPlatform(Platform.ANY);
}else if (b.equals("iexplore")){
cap = DesiredCapabilities.internetExplorer();
cap.setBrowserName("iexplore");
cap.setPlatform(Platform.WINDOWS);
}

RemoteWebDriver driver = new RemoteWebDriver(new URL("http://localhost:4444/wd/hub"),cap);
driver.get("http://gmail.com");
driver.findElement(By.id("Email")).sendKeys("deepak@gmail.com");
driver.findElement(By.id("Passwd")).sendKeys(".............");

}

}
} 

 

This entry was posted in Scala. Bookmark the permalink.

One Response to Selenium Grid 2-Parallel Execution

  1. deepika says:

    your information is really well explained and i got more knowledge about your postings , it is really helpful thus it is nice.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s