Search
 
 

Display results as :
 


Rechercher Advanced Search

Latest topics
» how to connect DB in selenium webriver
Fri Oct 06, 2017 4:09 pm by anbarasi

» How find any text in browser screen and click on it?
Thu Oct 05, 2017 2:02 pm by sandeepkommineni

» Selenium Webdriver
Tue Oct 03, 2017 1:35 pm by PiyushBiswas

» GRID setup tutorial.
Wed Sep 27, 2017 4:29 pm by johnyapp

» Drag & Drop Between Windows Using Selenium Driver
Wed Sep 27, 2017 2:10 pm by 26rondel

» Check if window is closed / verify input
Sat Sep 23, 2017 10:21 pm by brainstir

» How to work on pages with AJAX in selenium?
Mon Sep 18, 2017 6:08 pm by azharuddin

» pause test until user press a key like F2
Wed Aug 09, 2017 11:10 pm by djnforce

» Selecting the input for auto populating element
Sat Jul 29, 2017 7:53 pm by kdabbara

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.]
avatar
Adviser
------------------------
------------------------

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

http://seleniumforum.forumotion.net

Back to top Go down

selenium grid setup

Post by johnyapp on Wed Sep 27, 2017 4:29 pm

Hi,


In this section, you will use 2 machines. The first machine will be the system that will run the hub while the other machine will run a node. For simplicity, let us call the machine where the hub runs as "Machine A" while the machine where the node runs will be "Machine B." It is also important to note their IP addresses. Let us say that Machine A has an IP address of 192.168.1.3 while Machine B has an IP of 192.168.1.4.



Thank you @ Tekslate

johnyapp

Posts : 1
Join date : 2017-09-27
Age : 28
Location : Hyderabad

https://tekslate.com/

Back to top Go down

View previous topic View next topic Back to top


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