I see. Seems, you don’t have applicationName in your node2.
Then in your capability, you don’t have applicationName capability to instruct hub to route your commands to a particular appium node.
Add this in your test script’s capability:
capabilities.setCapability("applicationName", "Asus");
Now execute. And see the hub will always route your execution to your node-1.
i mentioned applicationName in both node but still not working can you tell me how to write applicationName capability for both device in scripts capabilities.
capabilities.setCapability(“applicationName”, “Asus”); this is excepting only asus device
If you are using testng, parameterize the applicationName.
can you please show me a example for that ? because i am not using testng xml so with out xml can you please suggest me how to do it
I use dataProvider for this:
@DataProvider(name = "helloDP", parallel = true)
public Object[][] dataProvider() {
return new Object[][] {
{"Asus", "4dxxxxxxxx"},
{"Nexus", "3axxxxxxxx"}
};
}
@Test
public void myTest(String applicationName, String deviceName) {
// Add your caps here with applicationName
}
Make sure you start your two appium nodes with respective device id by passing -U.
still not running please check my sample caps what i am doing wrong
@DataProvider(name = “helloDP”, parallel=true)
public Object[][] dataProvider(){
return new Object[][]{
{“Asus”,“FCAZGU007688H3D”},
{“htc”,“LC58VY659198”}};}
@Test
public RemoteWebDriver myTest(String applicationName, String deviceName) throws Exception{
DesiredCapabilities capabilities = new DesiredCapabilities();
File app = new File ("/Users/RajShekhar_DiroLabs/Desktop/Appium/dirAlpha-debug.apk");
capabilities.setCapability(MobileCapabilityType.DEVICE_NAME,"Android");
capabilities.setCapability(MobileCapabilityType.PLATFORM_NAME,"Android");
capabilities.setCapability(MobileCapabilityType.NEW_COMMAND_TIMEOUT, "100");
capabilities.setCapability("applicationNAME", " ");
capabilities.setCapability(MobileCapabilityType.APP, app.getAbsolutePath());
RemoteWebDriver driver = new RemoteWebDriver(new URL("http://10.2.10.45:4444/wd/hub") , capabilities);
// driver = new RemoteWebDriver(new URL(“http://10.2.10.45:+port+/grid/register”) , capabilities);
driver.manage().timeouts().implicitlyWait(120, TimeUnit.SECONDS);
driver.findElement(By.id("name id")).sendKeys("skafhkas");
driver.findElement(By.id("fkllkafaf")).click();
driver.findElement(By.id("fklasflkf")).click();
return driver;
}
@AfterMethod()
public void afterMethod(){
RemoteWebDriver driver = new RemoteWebDriver(DesiredCapabilities.android());
driver.quit();
}
Replace the above line in test method to:
capabilities.setCapability("applicationName", applicationName);
The applicationName is the parameter value that you get it from your data provider.
Hi bro,
its still not working in my case shows me logs on hub only
12:02:24.033 INFO - Got a request to create a new session: Capabilities [{appPackage=com.diro, appActivity=directory_new_ui.Diro_Login, app=/Users/RajShekhar_DiroLabs/Desktop/Appium/dirAlpha-debug.apk, platformName=Android, deviceName=Android, applicationName=Object[][]}]
In nodes have’t get any request.
Desiredcapabilities
@DataProvider(name = “helloDP”, parallel=true)
public Object[][] dataProvider(){
return new Object[][]{
{“Asus”,“FCAZGU007688H3D”},
{“htc”,“LC58VY659198”}};}
public static RemoteWebDriver LunchApplication(String applicationName, String deviceName) throws Exception {
try{
File app = new File ("/Users/RajShekhar_DiroLabs/Desktop/Appium/dirAlpha-debug.apk");
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability(MobileCapabilityType.PLATFORM_NAME,MobilePlatform.ANDROID);
capabilities.setCapability(MobileCapabilityType.DEVICE_NAME,"Android");
capabilities.setCapability("appPackage","com.diro");
capabilities.setCapability("appActivity", "directory_new_ui.Diro_Login");
capabilities.setCapability("applicationName",applicationName);
capabilities.setCapability(MobileCapabilityType.APP, app.getAbsolutePath());
RemoteWebDriver driver = new RemoteWebDriver(new URL("http://10.2.10.45:4444/wd/hub") , capabilities);
Log.info("Application launched successfully");
}catch (Exception e){
Log.error("Class Utils | Method LunchApplication | Exception desc : "+e.getMessage());
throw (e);
}
RemoteWebDriver driver = null;
return driver;
}
call class as
driver = Utils.LunchApplication("Object[][]","deviceName");
please suggest me more, i am stuck in it