Search
 
 

Display results as :
 


Rechercher Advanced Search

Latest topics
» Selenium Script issue
Tue Dec 06, 2016 9:48 pm by njain213

» Difference between QTP, Selenium and Silk test
Tue Dec 06, 2016 7:58 pm by jessicacyrus1

» Where does selenium script pick browser from
Tue Dec 06, 2016 1:52 pm by janbaskt

» Safari throws an HTTP ERROR: 404
Tue Dec 06, 2016 1:51 pm by janbaskt

» Access Denied Error in Selenium RC
Tue Dec 06, 2016 1:51 pm by janbaskt

» Automating Flex application through selenium webdriver
Fri Dec 02, 2016 2:06 pm by abhinay.krs

» Starting with Selenium, what is Selenium?
Mon Nov 28, 2016 4:00 pm by Foma

» Getting started with Selenium
Mon Nov 28, 2016 3:23 pm by Rebbelx

» Selenium IDE Verify different Maps (Hybridview, Mapview etc.)
Fri Nov 25, 2016 9:56 pm by DJ87

Navigation
 Portal
 Index
 Memberlist
 Profile
 FAQ
 Search

GRID setup tutorial.

View previous topic View next topic Go down

GRID setup tutorial.

Post by Adviser on Tue Mar 15, 2016 2:51 pm

Hi Guys,

I have done selenium grid setup on 5 different node which contains 2 LINUX and 3 Windows node. I would like to share the setup information to reduce the R&D time on that, which is totally frustrating Sad. But not any more, It's just a simple example of working setup and feel free to modify as per your requirement.

Pr-requisite:

  1. download selenium standalone server on hub machine and setup Java also on all machines.
  2. download all the browser drivers which you want to supported on node and placed in a common directory.
  3. All machine should be on same network group otherwise you will have to do some effort to resolve the network and firewall issues.


Hub setup:
java -jar selenium-server-standalone-2.52.0.jar -role hub -port 4441


Node's setup:
java -jar selenium-server-standalone-2.52.0.jar -role webdriver -browser browserName=chrome -browser browserName=firefox -browser browserName="internet explorer" -hub [You must be registered and logged in to see this link.] -port 5566 -Dwebdriver.ie.driver=C:\Users\Advisor\Downloads\Selenium_browser_Driver\IEDriverServer_x64_2.52.2\IEDriverServer.exe  -Dwebdriver.chrome.driver=C:\Users\Advisor\Downloads\Selenium_browser_Driver\chromedriver_win32\chromedriver.exe

Make sure all nodes are successfully registered and communicate properly with hub. Now, setup your IDE for working with web driver. google it if you don't know , how to setup.

This is the java code for running your test using grid. But right now it will execute on a single node at a time. If want to execute it on all setup node at the same time. You will have to use TestNG framework parallel method to execute simultaneously.

Code:


import net.sourceforge.htmlunit.corejs.javascript.ast.SwitchCase;

import org.openqa.selenium.By;
import org.openqa.selenium.Platform;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.ie.InternetExplorerDriver;
import  org.openqa.selenium.remote.DesiredCapabilities;

import java.net.MalformedURLException;
import java.net.URL;
import java.util.Arrays;

import org.openqa.selenium.remote.RemoteWebDriver;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;
import org.testng.Assert;
import org.testng.annotations.AfterTest;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.Test;

import com.gargoylesoftware.htmlunit.javascript.host.file.File;

/**
 *
 * @author adviser
 * grid command for node
 * java -jar selenium-server-standalone-2.52.0.jar -role webdriver -browser browserName=chrome -browser browserName=firefox -browser browserName="internet explorer" -hub http://152.144.219.191:4441/grid/register -port 5566 -Dwebdriver.ie.driver=C:\Users\Advisor\Downloads\Selenium_browser_Driver\IEDriverServer_x64_2.52.2\IEDriverServer.exe  -Dwebdriver.chrome.driver=C:\Users\Advisor\Downloads\Selenium_browser_Driver\chromedriver_win32\chromedriver.exe
 */



public class GridDriver {
 
 private static WebDriver driver;
 private static String baseURL,nodeURL;
 
 public GridDriver(String  nodeURL,DesiredCapabilities capability) throws MalformedURLException{
 // TODO Auto-generated constructor stub
 this.driver =  new RemoteWebDriver(new URL(nodeURL),capability);
 }
 
 public static void main (String[] ars) throws MalformedURLException, InterruptedException{
 
 baseURL = "http://google.com/";
 //nodeURL = "http://152.144.219.11:5566/wd/hub";
 
 //new GridDriver("http://152.144.219.64:5599/wd/hub", setBrowserAndPlatform(driver,"firefox", Platform.LINUX));
 new GridDriver("http://152.144.219.11:5566/wd/hub", setBrowserAndPlatform(driver,"chrome", Platform.WINDOWS));
        //new GridDriver("http://152.144.219.11:5566/wd/hub", setBrowserAndPlatform(driver,"internet explorer", Platform.WINDOWS));
 // new GridDriver(driver, "http://152.144.219.58:5577/wd/hub", setBrowserAndPlatform("firefox", Platform.XP));
 driver.get(baseURL);
 //driver.wait(50000);
 WebElement element = (new WebDriverWait(driver, 10)).until(ExpectedConditions.presenceOfElementLocated(By.name("q")));
 Assert.assertEquals(driver.getTitle(),"Google");
 
 driver.quit();
 
 }
 
 private static DesiredCapabilities setBrowserAndPlatform(WebDriver driver,String browserName,Platform PlatformName){
 DesiredCapabilities capability = null;
 java.io.File file =null;
 String pathToIEdriver ="C:\\Selenium_browser_Driver\\IEDriverServer_x64_2.52.2\\IEDriverServer.exe";
 String pathToChromedriver ="C:\\Selenium_browser_Driver\\chromedriver_win32\\chromedriver.exe";
 switch (browserName) {
 case "firefox":
 capability= DesiredCapabilities.firefox();
 capability.setBrowserName(browserName);
 
 break;
 case "internet explorer":
 
 //java.io.File file = new java.io.File(pathToIEdriver);
 capability= DesiredCapabilities.internetExplorer();
 capability.setBrowserName(browserName);
 capability.setJavascriptEnabled(true);
 capability.setCapability(InternetExplorerDriver.INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS,true);
 
 break;
 
 case "chrome":
 file = new java.io.File(pathToChromedriver);        
        System.setProperty("webdriver.chrome.driver", file.getAbsolutePath());
 capability = DesiredCapabilities.chrome();
 capability.setBrowserName("chrome");
 capability.setCapability("chrome.switches", Arrays.asList("--start-maximized"));
 
 break;
 default:
 break;
 }
 
 capability.setPlatform(PlatformName);
 return capability;
 }
}







Hope this will help for newbie Smile . Best of luck for GRID.

_________________
Spread Your Knowledge About Selenium Tool.

Administrator
Email: [You must be registered and logged in to see this link.]
Forum: [You must be registered and logged in to see this link.]

Adviser
------------------------
------------------------

Posts : 379
Join date : 2009-07-30
Location : India

http://seleniumforum.forumotion.net

Back to top Go down

View previous topic View next topic Back to top

- Similar topics

 
Permissions in this forum:
You cannot reply to topics in this forum