How to start appium node as Selenium Grid node

Selenium grid tool is one of tools of Selenium suite. This tool helpful to distribute automation test scripts on multiple environments(Cross browser, cross platform) run parallel or sequently.

Appium is mobile testing tool based on Selenium platform, so it’s support Selenium grid.

This block will be described how to configure it.

 

Steps:

  1. Start Android Emulator (I’m using Genymotion to create AVD)
  2. Get device name via adb command line <adb devices>
  3. Start selenium Grid Hub:

java -jar selenium-server-standalone-2.53.1.jar -role hub

start_grid_hub

4. Create node config json file to define Grid node and save as android_node.json:

{
“capabilities”:
[
{
“deviceName”: “192.168.59.101:5555”,
“browserName”: “Browser”,
“version”:”5.1.0″,
“maxInstances”: 1,
“platform”:”ANDROID”
}
],
“configuration”:
{
“cleanUpCycle”:2000,
“timeout”:30000,
“proxy”: “org.openqa.grid.selenium.proxy.DefaultRemoteProxy”,
“url”:”http://127.0.0.1:4723/wd/hub&#8221;,
“host”: “127.0.0.1”,
“port”: “4723”,
“maxSession”: 1,
“register”: true,
“registerCycle”: 5000,
“hubPort”: “4444”,
“hubHost”: “localhost”
}
}

5. Start appium node

appium –nodeconfig android_node.json

start_appium_node

then in hub command show:

regitered_node

5. Create java script to run :

public class Sample {

publicstaticAppiumDriverdriver;

public static void main(String[] args) throws MalformedURLException {

DesiredCapabilities caps = new DesiredCapabilities();

caps.setCapability(“platformName”, “Android”);

caps.setCapability(“platformVersion”, “5.1”);

caps.setCapability(“deviceName”, “192.168.59.101:5555”);

caps.setCapability(“app”, “”);

caps.setCapability(“browserName”, “Browser”);

driver = new AndroidDriver<>(new URL(“http://localhost:4444/wd/hub&#8221;), caps);

driver.manage().timeouts().implicitlyWait(80, TimeUnit.SECONDS);

driver.get(“https://tiki.vn&#8221;);

driver.close();

}

}

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

w

Connecting to %s