Blog
Tutorial(Pitalium: hifive regression test library) » 02.Environment Setup(Selenium Grid)

02.Environment Setup(Selenium Grid)

Last modified by kashi on 2017/04/13, 17:28

Through this tutorial we expect the environment as below.

  • Target broswers to test: Internet Explorer, Firefox and Google Chrome
  • OS: Windows 7 or 10

Pitalium uses Selenium WebDriver  and Selenium Grid  for multi-browser testing.
In this chapter we set up these tools to run multi-browser tests via Selenium Grid.

Prerequisities

Install Java

Download JDK from here and install it. The latest Selenium requires Java version >= 1.8.

Install Browsers

Get Required Files

Download files below and put them to root directory.
We expect C:\pitalium\ as root direcory.

Selenium Standalone Server

Download selenium-server-standalone-3.xx.x.jar from Selenium Download page.

If you use firefox 47.0 or later, you must use selenium 3.

Internet Explorer Driver Server

Download from The Internet Explorer Driver Server . Unzip the file and get the IEDriverServer.exe file.

Chrome Driver

Download chromedriver.exe from here 

Configure Internet Explorer

For Internet Explorer tests you should make some additional configuration on the browser.
See IEDriverServer wiki page(required configuration).

Start Selenium Grid Server

Start Hub Server

Execute the command below to start selenium server as hub.

java -jar C:/pitalium/selenium-server-standalone-3.3.1.jar -role hub

See also: Starting Selenium Grid Hub.

Start Node Server

Create a config file as below and save to C:\pitalium\NodeConfigBrowser.json, which describes browsers available on the server.

{
 "capabilities": [
    {
     "browserName": "firefox",
     "maxInstances": 3,
     "seleniumProtocol": "WebDriver"
    },
    {
     "browserName": "chrome",
     "maxInstances": 3,
     "seleniumProtocol": "WebDriver"
    },
    {
     "browserName": "internet explorer",
     "version": "11",
     "maxInstances": 1,
     "seleniumProtocol": "WebDriver"
    }
  ],
 "hub": "http://localhost:4444/grid/register"
 "register": true
}

See also: nodeConfig.jsonファイルの用意.

Then execute the command below to start the server.

java -Dwebdriver.ie.driver=C:/pitalium/IEDriverServer.exe ^
    -Dwebdriver.chrome.driver=C:/pitalium/chromedriver.exe ^
    -Dwebdriver.gecko.driver=C:/pitalium/geckodriver.exe ^
    -Dwebdriver.firefox.bin="C:\Program Files\Mozilla Firefox\firefox.exe" ^
    -jar C:/pitalium/selenium-server-standalone-2.46.0.jar ^
    -role node ^
    -nodeConfig C:/pitalium/NodeConfigBrowser.json

Note that you need to specify geckodriver.exe and firefox.exe.

See also:

If you can access http://localhost:4444/grid/console and see three kinds of icons of browsers as the below, you can register their browsers to the node server.

Run sample code

Through this getting-started-page  make a test class below and run it as a JUnit test.

import java.net.URL;
import org.junit.Test;
import org.openqa.selenium.Platform;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.remote.RemoteWebDriver;

public class SeleniumGridTestSample {
   @Test
   public void test() throws Exception {
        DesiredCapabilities capabilities = new DesiredCapabilities();
        capabilities.setPlatform(Platform.WINDOWS);
        capabilities.setBrowserName("internet explorer");

        RemoteWebDriver driver =
               new RemoteWebDriver(new URL("http://localhost:4444/wd/hub"), capabilities);
        driver.get("https://www.htmlhifive.com/");
        driver.quit();
   }
}

This example test class drives Internet Explorer via Selenium Grid Server and shows the front page of hifive developer site.

Next Step ⇒ 03.Writing Test Code

See also


Copyright (C) 2012-2017 NS Solutions Corporation, All Rights Reserved.