02.Environment Setup(Selenium Grid)
- 01.About Pitalium
- 02.Environment Setup
- 03.Writing Test Code
- 04.Running a Test
- 05.Taking a Screenshot of a Specific DOM Element
- 06.Taking a Screenshot of a DOM Element with Scroll
- 07.Excluding Elements from Comparison Targets
- 08.Redefining of Correct Images
- 09.Running a Test in Mobile Devices
- 10.Pitalium Explorer
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 Google Chrome and Firefox and install them.
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.
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.
-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:
- Nodeの起動: for stating a node server.
- Grid2 - SeleniumHQ/selenium Wiki for setting optional parameters.
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 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