@Arvind_Patel @Hassan_Radi
I have configured my android devices to selenium grid with ports 4728 and 4730 below
node1.json
{
"capabilities":
[
{
"browserName": "Android",
"version":"5.0.1",
"maxInstances": 3,
"platform":"ANDROID",
"deviceName":"ZX1D63ZXZ6"
}
],
"configuration":
{
"nodeTimeout":120,
"port":4730,
"hubPort":4444,
"proxy": "org.openqa.grid.selenium.proxy.DefaultRemoteProxy",
"url":"http://127.0.0.1:4730/wd/hub",
"hub": "127.0.0.1:4444/grid/register",
"hubHost":"127.0.0.1",
"nodePolling":2000,
"registerCycle":10000,
"register":true,
"cleanUpCycle":2000,
"timeout":30000,
"maxSession":1
}
}
node2.json
{
"capabilities":
[
{
"browserName": "Android",
"version":"5.1",
"maxInstances": 3,
"platform":"ANDROID",
"deviceName":"0aee8e8b02e4223e"
}
],
"configuration":
{
"nodeTimeout":120,
"port":4728,
"hubPort":4444,
"proxy": "org.openqa.grid.selenium.proxy.DefaultRemoteProxy",
"url":"http://127.0.0.1:4728/wd/hub",
"hub": "127.0.0.1:4444/grid/register",
"hubHost":"127.0.0.1",
"nodePolling":2000,
"registerCycle":10000,
"register":true,
"cleanUpCycle":2000,
"timeout":30000,
"maxSession":1
}
}
My selenium grid hub is running on port 4444 And my appiium is on 4723 port
grid_configuration.json
{
"capabilities":
[
{
"browserName": "ANDROID",
"version":"5.0.1",
"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",
"host": "127.0.0.1",
"port": "4723",
"maxSession": 1,
"register": true,
"registerCycle": 5000,
"hubPort": 4444,
"hubHost": "127.0.0.1"
}
}
This is my JSON . I have added this grid_config.json file path to appium setting to Selenium Grid Configuration file.
Now my two android devices are running on different port, right?
This is my java code
import io.appium.java_client.AppiumDriver;
import io.appium.java_client.android.AndroidDriver;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.testng.annotations.Test;
//import java.net.ServerSocket;
public class sample_test extends initializtion{
AppiumDriver d1,d2;
@Test
public void two_driver(){
DesiredCapabilities capabilities1= new DesiredCapabilities();
capabilities1.setCapability("deviceName","Nexus");
capabilities1.setCapability("platformVersion", "5.1");
capabilities2.setCapability("appPackage",package name);
capabilities2.setCapability("appActivity", main activity);
capabilities1.setCapability("udid", "0aee8e8b02e4223e");
// capabilities.setCapability("appActivity", "com.whatsapp.Main");
try {
d1 = new AndroidDriver(new URL("http://127.0.0.1:4728/wd/hub"), capabilities1);
} catch (MalformedURLException e) {
// TODO Auto-generated catch block
System.out.println("Not able to start application");
e.printStackTrace();
}
d1.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS);
DesiredCapabilities capabilities2= new DesiredCapabilities();
capabilities2.setCapability("deviceName","Moto G 2");
capabilities2.setCapability("platformVersion", "5.0.1");
//capabilities.setCapability("app",app.getAbsolutepath());
capabilities2.setCapability("appPackage",package name);
capabilities2.setCapability("appActivity", main activity);
capabilities2.setCapability("udid", "ZX1D63ZXZ6");
try {
d2= new AndroidDriver(new URL("http://127.0.0.1:4730/wd/hub"), capabilities1);
} catch (MalformedURLException e) {
// TODO Auto-generated catch block
System.out.println("Not able to start application");
e.printStackTrace();
}
d2.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS);
}
}
But my application is running on only one device , why?
What went wrong here?