SELENIUM GRID
PARALLEL/SEQUENTIAL EXECUTION
500 Test Cases
100 test cases
200 test cases
200 Test Cases
HUB
NODE 1
NODE 2 - 6666
NODE 3 - 7777
4444
5555
B – IE, FF, Chrome
B - Chrome
B - Firefox
How to configure hub and nodes
java -jar selenium-server-standalone-2.37.0.jar –role hub
STARTING A HUB
java -jar selenium-server-standalone-2.37.0.jar -role webdriver –hub http://localhost:4444/grid/register -port 5555
REGISTERING A NODE TO THE HUB
SETTING UP SUPPORTED BROWSER NAMES
java -jar selenium-server-standalone-2.37.0.jar -role webdriver -hub http://localhost:4444/grid/register -port 5555 -browser browserName=firefox -browser browserName=iexplore -browser browserName=chrome
SETTING UP MAX INSTANCES & SESSIONS
java -jar selenium-server-standalone-2.37.0.jar -role webdriver -hub
http://localhost:4444/grid/register -port 5555 -browser browserName=firefox
-browser browserName=iexplore -browser browserName=chrome,maxInstances=3
SETTING UP MAX INSTANCES
SETTING UP MAX SESSIONS
java -jar selenium-server-standalone-2.32.0.jar -role webdrive
r -hub http://localhost:4444/grid/register -port 5555 -browser browserName=firef
ox,maxInstances=4 -browser browserName=iexplore -browser
browserName=chrome,maxInstances=3 -maxSession 4
SETTING UP CHROME & IE DRIVERS
-Dwebdriver.chrome.driver= C:\Softwares\chromedriver.exe
SETTING UP CHROME DRIVER
FINAL COMMAND
Java -Dwebdriver.chrome.driver= C:\Softwares\chromedriver.exe
-Dwebdriver.ie.driver= C:\Softwares\IEDriverServer.exe
-jar selenium-server-standalone-2.32.0.jar -role webdriver
-hub http://localhost:4444/grid/register -port 5555 -browser
browserName=firefox,maxInstances=4 -browser browserName=iexplore -browser
browserName=chrome,maxInstances=3 -maxSession 4
SETTING UP IE DRIVER
-Dwebdriver.ie.driver= C:\Softwares\IEDriverServer.exe
WHAT WE HAVE SEEN SO FAR:
WHAT WE WILL SEE NOW:
Single test on a single node – serially on multiple browsers
public class testSearch {
@Test(dataProvider="getData")
public void doSearch(String text, String browser) throws MalformedURLException{
System.out.println(browser);
DesiredCapabilities capabilities = null;
if(browser.equals("firefox")){
capabilities = DesiredCapabilities.firefox();
capabilities.setBrowserName("firefox");
capabilities.setPlatform(Platform.ANY);
}else if(browser.equals("ie")){
capabilities = DesiredCapabilities.internetExplorer();
capabilities.setBrowserName("iexplore");
capabilities.setPlatform(Platform.WINDOWS);
}else if(browser.equals("chrome")){
capabilities = DesiredCapabilities.chrome();
capabilities.setBrowserName("chrome");
capabilities.setPlatform(Platform.ANY);
}
//require for WebDriver
RemoteWebDriver driver = new RemoteWebDriver(new URL("http://localhost:4444/wd/hub"), capabilities);
//RemoteWebDriver driver = new FirefoxDriver();
driver.get("http://google.com");
driver.findElement(By.name("q")).sendKeys(text);
}
@DataProvider
public Object[][] getData(){
Object[][] data = new Object[2][2];
data[0][0] = "selenium";
data[0][1] = "firefox";
data[1][0] = "selenium";
data[1][1] = "chrome";
return data;
}
Single test on a single node – Parallely on multiple browsers
public class testSearch {
@Test(dataProvider="getData")
public void doSearch(String text, String browser) throws MalformedURLException{
System.out.println(browser);
DesiredCapabilities capabilities = null;
if(browser.equals("firefox")){
capabilities = DesiredCapabilities.firefox();
capabilities.setBrowserName("firefox");
capabilities.setPlatform(Platform.ANY);
}else if(browser.equals("ie")){
capabilities = DesiredCapabilities.internetExplorer();
capabilities.setBrowserName("iexplore");
capabilities.setPlatform(Platform.WINDOWS);
}else if(browser.equals("chrome")){
capabilities = DesiredCapabilities.chrome();
capabilities.setBrowserName("chrome");
capabilities.setPlatform(Platform.ANY);
}
//require for WebDriver
RemoteWebDriver driver = new RemoteWebDriver(new URL("http://localhost:4444/wd/hub"), capabilities);
//RemoteWebDriver driver = new FirefoxDriver();
driver.get("http://google.com");
driver.findElement(By.name("q")).sendKeys(text);
}
@DataProvider (parallel=true)
public Object[][] getData(){
Object[][] data = new Object[2][2];
data[0][0] = "selenium";
data[0][1] = "firefox";
data[1][0] = "selenium";
data[1][1] = "chrome";
return data;
}
SETTING UP JSON FOR HUB & NODES
java -jar selenium-server-standalone-2.37.0.jar -role hub -hub Config hub.json
SETTING UP JSON FOR HUB
SETTING UP JSON FOR NODE
java -jar selenium-server-standalone-2.37.0.jar -role webdriver -nodeConfig node1.json