This site is in read only mode. Please continue to browse, but replying, likes, and other actions are disabled for now.
101 / 169
May 2015

Not a reply to a specific thread. Just be aware that the -bp (bootstrap port) is critical on the node setup for running in parallel. Without this setting, the nodes will error when receiving requests from the hub. Spent way too many hours working on a solution when running without the bp set.

Nodes are successfully registered with Hub BUT script is always execute on one device only.

Following are the JSON
1:
{
"capabilities":
[
{
"browserName": "android",
"version": "4.4.2",
"maxInstances": 5,
"platform": "ANDROID",
"deviceName": "226CF65ED0ABE221"
}
],
"configuration":
{
"nodeTimeout":120,
"cleanUpCycle":2000,
"timeout":2000000,
"proxy": "org.openqa.grid.selenium.proxy.DefaultRemoteProxy",
"url":"http://127.0.0.1:4723/wd/hub",
"maxSession": 20,
"port": 4723,
"host": "127.0.0.1",
"register": true,
"registerCycle": 5000,
"hub": "127.0.0.1:4441/grid/register",
"hubPort": 4441,
"hubHost": "localhost",
"role": "node"
}
}

2:
{
"capabilities":
[
{
"browserName": "android",
"version": "4.4.2",
"maxInstances": 5,
"platform": "ANDROID",
"deviceName": "9EDCBB229B2DD02D"
}
],
"configuration":
{
"nodeTimeout":120,
"cleanUpCycle":2000,
"timeout":2000000,
"proxy": "org.openqa.grid.selenium.proxy.DefaultRemoteProxy",
"url":"http://127.0.0.1:3300/wd/hub",
"maxSession": 20,
"port": 3300,
"host": "127.0.0.1",
"register": true,
"registerCycle": 5000,
"hub": "127.0.0.1:4441/grid/register",
"hubPort": 4441,
"hubHost": "localhost",
"role": "node"
}
}

Script capabilities:
For node 1:
@Parameters(value={"device_id1", "device_id2"})
@BeforeSuite//The annotated method will be run before all tests in this suite have run.
public static WebDriver atStart(@Optional("nnn") String device_id1, String device_id2) throws InterruptedException, IOException
{

        System.out.println("in Samsung galaxy: "+device_id1);
        if ("226CF65ED0ABE221".equals(device_id1))//FOR SAMSUNG GALAXY NOTE
        {
            capabilities=new DesiredCapabilities();

            File app = new File(applicationPath);
            capabilities.setCapability("automationName", "Appium");
            capabilities.setCapability(CapabilityType.BROWSER_NAME, "android");
            capabilities.setCapability("deviceName", device_id1);
            //capabilities.setCapability("udid", device_id);
            capabilities.setCapability("platformVersion", "4.4.2");
            capabilities.setCapability(CapabilityType.PLATFORM,"ANDROID");
            capabilities.setCapability("platformName", "ANDROID");
            capabilities.setCapability("app", app.getAbsolutePath());
            capabilities.setCapability("appPackage", "com.avaamo.android.staging"); 
            capabilities.setCapability("appActivity", "com.avaamo.android.ui.LandingActivity"); 
            //setting new command timeout for selenium server
            capabilities.setCapability("newCommandTimeout", "2000000");//33.33 mins

        }

For Node 2:
if("9EDCBB229B2DD02D".equals(device_id2))
{
capabilities=new DesiredCapabilities();

            File app1 = new File(applicationPath);
            capabilities.setCapability("automationName", "Appium");
            capabilities.setCapability(CapabilityType.BROWSER_NAME,"android");
            capabilities.setCapability("deviceName",device_id2);
            //capabilities.setCapability("udid",device_id);
            capabilities.setCapability("platformVersion", "4.4.2");
            capabilities.setCapability(CapabilityType.PLATFORM,"ANDROID");
            capabilities.setCapability("platformName","ANDROID");
            capabilities.setCapability("app", app1.getAbsolutePath());
            capabilities.setCapability("appPackage", "com.avaamo.android.staging"); 
            capabilities.setCapability("appActivity", "com.avaamo.android.ui.LandingActivity"); 

            //setting new command timeout for selenium server
            capabilities.setCapability("newCommandTimeout", "2000000");//33.33 mins
        }

return driver = new AndroidDriver(new URL("http://127.0.0.1:4441/wd/hub"), capabilities);

@Hassan_Radi @Appium_Master @rgonalo Can any one please suggest?

You are trying to select the node with deviceName, but the hub does not use this capability.
The hub only reads browserName, version, platform and applicationName. The other capabilities (deviceName, platformVersion, platformName, ...) are Appium capabilities, not used by the hub.

In your case, you could use "applicationName" capability instead of "deviceName":

Add the capability to each node JSON:

"applicationName": "226CF65ED0ABE221"
"applicationName": "9EDCBB229B2DD02D"

And add the capability to each test:

capabilities.setCapability("applicationName", device_id1);
capabilities.setCapability("applicationName", device_id2);

Thanks @rgonalo !

I updated the files as you suggested.
Still the script is running on one device only. (for device id 1)
I cross checked the device ids and both are correct.
Can you please suggest?

Json file 1 configuration part:
{
"capabilities":
[
{
"browserName": "android",
"version": "4.4.2",
"maxInstances": 5,
"platform": "ANDROID",
"applicationName": "226CF65ED0ABE221"
}
],

Json file 2 configuration part:
{
"capabilities":
[
{
"browserName": "android",
"version": "4.4.2",
"maxInstances": 5,
"platform": "ANDROID",
"applicationName": "9EDCBB229B2DD02D"
}
],

Added
capabilities.setCapability("applicationName", device_id1);
capabilities.setCapability("applicationName", device_id2);
to the script.

@Appium_Master @rgonalo @Hassan_Radi Can you please help in?

I changed the port of a node that is not running and re run the script and unfortunately the script run on the same node that is not specified for.
The same node run on 4723 and 3000 ports though the json files are different for each.
I had started the nodes from cmd prompt. but later only changed jsons and restated appium gui (did not closed and reopened the appium GUI)

Surprising that hub only executes the script on one node though connected to both.

Appium log from the node where script is executed:
info: --> POST /wd/hub/session {"desiredCapabilities":{"app":"D:\APKs\Automated_Projects\abc_staging.apk","appPackage":"com.avaamo.android.staging","appActivity":"com.avaamo.android.ui.LandingActivity","newCommandTimeout":"2000000","platformVersion":"4.4","automationName":"Appium","browserName":"Android","platformName":"Android","deviceName":"30345C56DC2000EC","applicationName":"2636B827A05E6BB3","platform":"ANDROID"}}

info: Client User-Agent string: Apache-HttpClient/4.3.4 (java 1.5)
info: [debug] The following desired capabilities were provided, but not recognized by appium. They will be passed on to any other services running on this server. : applicationName, platform
info: [debug] Using local app from desired caps: D:\APKs\Automated_Projects\abc_staging.apk

I am sure something small is mismatched but I crosschecked the node files and the capabilities provided in script too.

hi @Appium_Master
my machine ip is like 192.168.X.X but public ip 125.X.X.X is mapped to my machine.if i am hosting any website in that machine, i can access that web page by typing public ip url(125.X.X.X/mywebsite).but when i mentioning public ip in my appium script it is saying like invalid address of the remote server. how to run my script in that machine from any where in the world or any network or any ip segment.How can i achive this?

The Appium server seems to have removed the file or maybe it is experiencing some technical issue. Please copy/paste the next few lines in a text file:

{
"capabilities":
[
{
"browserName": "ANDROID",
"device": "LG Nexus5",
"version":"4.4.2",
"maxInstances": 1,
"platform":"ANDROID"
}
],
"configuration":
{
"cleanUpCycle":2000,
"timeout":10000,
"proxy": "org.openqa.grid.selenium.proxy.DefaultRemoteProxy",
"url":"http://localhost:4723/wd/hub",
"maxSession": 1,
"port": 4723,
"host": "localhost",
"register": true,
"registerCycle": 5000,
"hubPort": 4444,
"hubHost": "localhost"
}
}

@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?

ok. got it .. seems like that i messed up with driver capabilities here.
Thanks this tutorial help me a lot

Hi @cool18ap

Can you please share what fixed the problem and files in details that you implemented?

I am facing the same problem.

Thanks!

Hello , @Nitin_Thite i have created new driver for another device for another port
The issue in this line

d2= new AndroidDriver(new URL("http://127.0.0.1:4730/wd/hub"), capabilities1);

I assigned capabilities of first driver to second.That was very silly mistake otherwise it was working fine

Has anyone tried using cucumber-jvm/junit/spring to run parallel tests? I have an existing framework that i would like to enhance with parallel test capability.

9 days later

Hello,

  I successfully configured my selenium grid with appium. I successfully created to driver for two different android devices . Lets say d1 and d2 . now i want to maintain sink in between them means my driver does some operation using d1 and then after completing that another operation on driver d2. When i am doing operation on d2 another driver d1 should be ideal
  But when i am doing operation on 2nd driver then on first device the app is in background after switching to first device

it gives me error that session is not valid.please help me out here, what should i do? should i implement multi-threading ? or is there any way to put first driver on ideal state while second is doing that operation ?

Has anyone managed to distribute the tests across available devices? This is a native grid functionality, but it doesnt seem to work well with Appium (as you can only run one device per session). A solution, preferably in java, would be helpful - or pointers, I am looking into it myself but seem to be stuck.

Hi Karthi,

Can you please provide me the steps to find my divece connected in grid console. I am trying for past theree days and i can't able to see my device connected in the grid console. I followed the same steps but the command used,
node appium -a 192.168.48.71 -p 4723 --udid 4d00ce6e4a625139 -bp 5522 --nodeconfig C:/Program Files/Appium/nodeconfig.json
is not working. From which location we need to run this command. Please help me.

Regards,
B.Krishnaswamy.

Hi rgonalo,

Can you please provide me the steps to find my divece connected in
grid console. I am trying for past theree days and i can't able to see
my device connected in the grid console. I followed the same steps but
the command used,
node appium -a 192.168.48.71 -p 4723 --udid 4d00ce6e4a625139 -bp 5522 --nodeconfig C:/Program Files/Appium/nodeconfig.json
is not working. From which location we need to run this command. Please help me.

Please tell me the correct steps from starting the selenuim server. Please tell the correct file path from which the command need to be execcuted.

Regards,
B.Krishnaswamy.

@Appium_Master @Arvind_Patel am trying to run a appium script in Two devices [ Node 1(nexus ) , Node 2(Sony) ] in MAC using Selenium Grid concept

I have done the following
1) Created a Hub by using
java -jar selenium-server-standalone-2.45.0.jar -role hub
2) Triggered the nodes as below
NEXUS Device:
node /Applications/Appium.app/Contents/Resources/node_modules/appium/bin/appium.js -a 192.168.1.120 -p 3482 --nodeconfig "/Users/mobilecoe/Desktop/Karthik/Selenium Grid/Nexusin3482.json" --udid 05cd6a0af0ddb24e

Sony Xperia :

node /Applications/Appium.app/Contents/Resources/node_modules/appium/bin/appium.js -a 192.168.1.120 -p 4723 --nodeconfig "/Users/mobilecoe/Desktop/Karthik/Selenium Grid/Sonyin3483.json" --udid BX903K4MC3

Please find below my script and TestNG file

package com.cognizant.grid;

import java.net.MalformedURLException;
import java.net.URL;

import io.appium.java_client.AppiumDriver;
import io.appium.java_client.android.AndroidDriver;
import io.appium.java_client.remote.MobileCapabilityType;

import org.openqa.selenium.By;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.remote.RemoteWebDriver;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Parameters;
import org.testng.annotations.Test;

public class SeleniumGrid_mobile {
 AppiumDriver driver;	
@Parameters({"browserName","platform","deviceName","version"})	
@BeforeMethod
public void beforeMethod(String browserName, String platform, String deviceName, String version ) throws MalformedURLException{
	
	
	
	   DesiredCapabilities capabilities = DesiredCapabilities.android();
	   capabilities.setCapability("browserName", browserName);
	   capabilities.setCapability("platform", platform);
	   capabilities.setCapability("deviceName", deviceName);
	   capabilities.setCapability("version", version);
	   
	   
	   //capabilities.setCapability(MobileCapabilityType.AUTOMATION_NAME,"Appium");
	   
	   driver   = new AndroidDriver(new URL("http://localhost:4444/wd/hub"), capabilities);
	
	
}
@Test
public void myTest() throws InterruptedException{
	
	System.out.println("inside");
    driver.get("http://gmail.com/");
    Thread.sleep(2000);
    driver.findElement(By.id("Email")).sendKeys("avkkkkkkkk");
    Thread.sleep(5000); 
	
}

@AfterMethod()
public void afterMethod(){
	
	driver.quit();
}

	
}

And my TestNG xml file is

<?xml version="1.0" encoding="UTF-8"?>
<suite name="Selenium Grid" verbose="1" >
  <test name="SeleniumGrid_Sony" >
     
     <parameter name="browserName" value="Chrome"/>
     <parameter name="platform" value="Android"/>
     <parameter name="deviceName" value="BX903K4MC3"/>
     <parameter name="version" value="4.3"/>
      
    <classes>
      <class name="com.cognizant.grid.SeleniumGrid_mobile"/>
      
    </classes>
 </test>
 
  <test name="SeleniumGrid_Nexus" >
     
     <parameter name="browserName" value="Chrome"/>
     <parameter name="platform" value="Android"/>
     <parameter name="deviceName" value="05cd6a0af0ddb24e"/>
     <parameter name="version" value="5.0"/>
      
    <classes>
      <class name="com.cognizant.grid.SeleniumGrid_mobile"/>
      
    </classes>
 </test>
</suite>

I am getting the an message as below in the Hub

19:48:42.887 INFO - Got a request to create a new session: Capabilities [{platform=ANDROID, deviceName=BX903K4MC3, platformName=Android, browserName=Chrome, version=4.3}]
19:48:43.061 INFO - Got a request to create a new session: Capabilities [{platform=ANDROID, deviceName=05cd6a0af0ddb24e, platformName=Android, browserName=Chrome, version=5.0}]

But the script is not getting triggered and it shows as

==============================================
Selenium Grid
Total tests run: 2, Failures: 0, Skips: 2
Configuration Failures: 2, Skips: 2
===============================================

org.openqa.selenium.WebDriverException: Error forwarding the new session cannot find : Capabilities [{platform=ANDROID, deviceName=BX903K4MC3, platformName=Android, browserName=Chrome, version=4.3}]
Command duration or timeout: 248 milliseconds
Build info: version: '2.45.0', revision: '32a636c', time: '2015-03-05 22:01:35'
System info: host: 'MobileCoes-MacBook-Pro.local', ip: '192.168.1.120', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.9.4', java.version: '1.7.0_55'
Driver info: io.appium.java_client.android.AndroidDriver
	at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
	at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
	at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
	at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:204)
	at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:156)
	at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:599)
	at io.appium.java_client.AppiumDriver.execute(AppiumDriver.java:180)
	at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:240)
	at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:126)
	at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:153)
	at io.appium.java_client.AppiumDriver.<init>(AppiumDriver.java:109)
	at io.appium.java_client.android.AndroidDriver.<init>(AndroidDriver.java:39)
	at com.cognizant.grid.SeleniumGrid_mobile.beforeMethod(SeleniumGrid_mobile.java:35)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:606)
	at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:84)
	at org.testng.internal.Invoker.invokeConfigurationMethod(Invoker.java:564)
	at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:213)
	at org.testng.internal.Invoker.invokeMethod(Invoker.java:653)
	at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:901)
	at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1231)
	at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:127)
	at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:111)
	at org.testng.TestRunner.privateRun(TestRunner.java:767)
	at org.testng.TestRunner.run(TestRunner.java:617)
	at org.testng.SuiteRunner.runTest(SuiteRunner.java:334)
	at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:329)
	at org.testng.SuiteRunner.privateRun(SuiteRunner.java:291)
	at org.testng.SuiteRunner.run(SuiteRunner.java:240)
	at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
	at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)
	at org.testng.TestNG.runSuitesSequentially(TestNG.java:1224)
	at org.testng.TestNG.runSuitesLocally(TestNG.java:1149)

Can you please help me on this ?

I am getting a

org.openqa.selenium.WebDriverException: Error forwarding the new session cannot find : Capabilities [{platform=ANDROID, platformName=Android, browserName=Chrome, applicationName=BX903K4MC3, version=4.3}]

I have connected 2 Android devices one with version 4.3 and another in version 5.0
with device name as BX903K4MC3 & 05cd6a0af0ddb24e

Am I missing some configuration ??? can @Appium_Master , @Arvind_Patel , @Hassan_Radi or any other can help me on this ?

It should be "deviceName" not "applicationName".

Hi , Based on the some of the earlier post in this page i have changed to applicationName from deviceName , after this now one device [ first device in adb devices list ] alone is getting executed in the grid

  17:29:22.432 INFO - Got a request to create a new session: Capabilities [{automationName=Appium, platform=ANDROID, deviceName=BX903K4MC3, platformName=Android, browserName=Chrome, version=4.3}]
17:29:22.626 INFO - Got a request to create a new session: Capabilities [{automationName=Appium, platform=ANDROID, deviceName=05cd6a0af0ddb24e, platformName=Android, browserName=Chrome, version=5.0}]
17:29:22.626 INFO - Available nodes: [host :http://127.0.0.1:4723, host :http://127.0.0.1:4725]
17:29:22.626 INFO - Trying to create a new session on node host :http://127.0.0.1:4723
17:29:22.627 INFO - Trying to create a new session on test slot {platform=ANDROID, browserName=Chrome, maxInstances=3, applicationName=05cd6a0af0ddb24e, version=5.0}
17:29:24.406 WARN - Failed to check status of node: server response code : 500

I am getting an error message as check status of node failed for the second node

As the documentation mentions65, you have to use different
server arguments for the following:

-p the main Appium port
-U the device id
-bp the Appium bootstrap port
--chromedriver-port the chromedriver port (if using webviews or chrome)
--selendroid-port

Hi all,

I'm getting below error while connecting to Grid using Appium , the second device getting error and one device is executing fine.

error: Unhandled error: Error: read ECONNRESET
at errnoException (net.js:905:11)
at TCP.onread (net.js:559:19) context: [POST /wd/hub/session {"desiredCapabilities...

Error Coming while running multiple sessions using appium.Please let me know if any one knows about this.

I'm using different ports 4723, 4724 for two devices.

Thanks,
Bhaskar.

Hi All @Appium_Master @Hassan_Radi @Arvind_Patel @rgonalo ,
I have reduced the capabilties listed and now i am able to run my scripts sequentially one after the another . But when i tried the same with parallel flow in One device the script runs fine and in another device the script throws " An unknown server-side error occurred while processing the command.","origValue":"Did not successfully proxy server command and it shows a Blank while screen in the device

    executing cmd: /Users/mobilecoe/Documents/adt-bundle-mac-x86_64-20140321/sdk/platform-tools/adb -s BX903K4MC3 shell "am force-stop com.android.chrome"
info: --> GET /wd/hub/status {}
info: [debug] Proxying command to 127.0.0.1:9515
info: [debug] Making http request with opts: {"url":"http://127.0.0.1:9515/wd/hub/status","method":"GET"}
info: [debug] Responding to client with error: {"status":13,"value":{"message":"An unknown server-side error occurred while processing the command.","origValue":"Did not successfully proxy server command"},"sessionId":null}
info: <-- GET /wd/hub/status 500 33.144 ms - 176 
info: [debug] Stopping logcat capture
info: [debug] Logcat terminated with code null, signal SIGTERM
info: [debug] Cleaning up appium session

@vijayakarthikeyan
Most of us in this forum are facing the same issue, If you see my video which I uploaded on youtube I clearly mentioned that. Parallel test only work if one device is slower than second or you can put sleep in b/w calling the devices in code. It will run one after other but you will get parallel test reports.

Hi @Appium_Master @Arvind_Patel @rgonalo @Hassan_Radi . Now I am able to run my test case parallely and sequentially for Android devices

I will post all the steps below to run the scripts parallely

1) START THE HUB

java -jar selenium-server-standalone-2.45.0.jar -role hub -hub http://xxxxxxxxx:4444/grid/register

2) START THE APPIUM NODE
FIRST DEVICE :
node /Applications/Appium.app/Contents/Resources/node_modules/appium/bin/appium.js -a 192.168.1.109 -p 4723 --nodeconfig "/Users/mobilecoe/Desktop/Karthik/Selenium Grid/Nexusin4723localwithmachineIP.json" --udid xxxxxxxxxxxxx --bootstrap-port 2252 --chromedriver-port 4735

SECOND DEVICE:

node /Applications/Appium.app/Contents/Resources/node_modules/appium/bin/appium.js -a 192.168.1.109 -p 4725 --nodeconfig "/Users/mobilecoe/Desktop/Karthik/Selenium Grid/Sonyin4725localusingMachineIP.json" --udid xxxxxxxxx --bootstrap-port 2251 --chromedriver-port 4733

NOTE: I am using Mac

3) Create the TestNG project with the xml setting pointing the desired capabilities

<?xml version="1.0" encoding="UTF-8"?>
<suite name="Selenium Grid" parallel="none" thread-count="2" verbose="1" >
  
     <test name="SeleniumGrid_Sony" >
     
     <parameter name="browserName" value="Chrome"/>
     <parameter name="platform" value="Android"/>
     <parameter name="deviceName" value="XXXXXXXXX"/>
     <parameter name="version" value="4.3"/>
     <parameter name="sleep" value="1000"/>
    <classes>
      <class name="com.cognizant.grid.SeleniumGrid_mobile"/>
      
    </classes>
 </test>
   <test name="SeleniumGrid_Nexus" >
     
     <parameter name="browserName" value="Chrome"/>
   	<parameter name="platform" value="Android"/>
     <parameter name="deviceName" value="XXXXXXXXXXXXX"/>
     <parameter name="version" value="5.0"/>
     <parameter name="sleep" value="15000"/>
      
    <classes>
      <class name="com.xxxxxx.grid.SeleniumGrid_mobile"/>
      
    </classes>
 </test>
    
 </suite>

And its working fine for me

@rgonalo
@Hassan_Radi
@Arvind_Patel
@karthik_holla

I have created a separate thread for this discussion but decided to include this question in this thread as it seems to be active.

I need help on running test cases from Selenium Grid server machine running as a hub with the devices connected to the node and here's what I have:

I have a iMac running Mavericks (10.9.5) running Selenium Grid server as a hub. I also have a MacBook Air (running on Mavericks) running Selenium Grid as a node. Appium is running from terminal on port 5000 with --uuid parameter pointing to my iOS device connected to the node.

What works:

If the test cases are on the node, I'm able to run 2 devices in parallel from the node and the node is pointing to the Selenium Gid hub on the iMac.

What I wanted to achieve: (for troubleshooting, I'm only connected to one iOS device on the node).

I would like to have the test cases on the hub machine and this will give me a benefit of having the test scripts in one single location rather than duplicating on each of the nodes. I changed the DesiredCapabilities to point to the node and when I try to instantiate a new IOSDriver, I'm getting a "Session not created error: Bad app: Unable to locate the app". The app is located on the server hub and the path is all correct as I verified from the command line on the server with the stat command and it returns back the .app file. The following is the code that is run from the hub machine:

app = /Volumes/Server/Apps/iOS/SampleApp.app (the sample app is lying on the server from where the following code is running:
File appPath = new File(app);
capabilities.setCapability("app", appPath.getAbsolutePath());
IOSDriver iOSDriver= new IOSDriver (new URL(http://nodeipaddress:5000), capabilities);
The code is throwing exception on the last line when it is trying to instantiate a new IOSDriver.

But, the same code works when run from the node as shown below. Also, the SampleApp.app is lying on the node.
app = /Volumes/Node/Apps/iOS/SampleApp.app
File appPath = new File(app);
capabilities.setCapability("app", appPath.getAbsolutePath());
IOSDriver iOSDriver= new IOSDriver (new URL(http://hubipaddress:4444), capabilities);

I tried the following:
1.changed from getAbsolutePath to getCanonicalPath() and it fails with the same error
2.Changed the path to System.getProperty("user.dir") + "../../Node/Apps/iOS and this doesn't work too.

Ideally, I wanted to keep the test cases in one location and remote execute on the devices connected to the node. Please help.

So, to summarize, when the test cases are run from the hub machine (Machine 1) with the .app lying in a folder on the hub machine, I would like the .app to be installed on the device connected to the node (Machine 2) while the test cases are running from Machine 1.

Thanks.

Anybody?

No matter how I change my code, I'm getting Bad app error (App path needs to be absolute.....blah...blah...blah), when trying to run the code from the hub while the devices are connected to a node (different machine) with appium listening on port 5000 and selenium grid running as a node.

Please help.

Hi @appium_ia,

App capability can be a local path or a remote url (http://appium.io/slate/en/master/?ruby#appium-server-capabilities).
If you have a local path with Selenium Grid, Appium searches the app in the node machine, not in the hub machine.
You should use a remote url or a shared folder path that can be accessed from any node machine.

Hi tried all the workarounds mentioned in the above blog but at a time I am able to run test on only one device. For second its throwing error: "org.openqa.selenium.SessionNotCreatedException: A new session could not be created. (Original error: The following desired capabilities are required, but were not provided: deviceName)"

My capabilities looks like:

package automation.appium.grid;

import io.appium.java_client.AppiumDriver;
import io.appium.java_client.android.AndroidDriver;
import io.appium.java_client.remote.MobileCapabilityType;

import java.net.MalformedURLException;
import java.net.URL;

import org.openqa.selenium.remote.CapabilityType;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.Parameters;

import automation.drivers.Config;

public class Driver {
DesiredCapabilities capabilities1;
DesiredCapabilities capabilities2;
public AppiumDriver driver1 = null;
public AppiumDriver driver2 = null;
@Parameters ("Device_ID")
@BeforeTest
public void setUp(String device) throws Exception {

 	 
	System.out.println(device);
	switch(device)
	{
	case "4df742b317683077":
 capabilities1 = new DesiredCapabilities();

 capabilities1.setCapability("platformVersion", "4.3");
 capabilities1.setCapability("browserName", "Android");
 capabilities1.setCapability("platformName", "ANDROID");
 capabilities1.setCapability("udid", "4df742b317683077");
	capabilities1.setCapability("deviceName","samsung GT-N7100");
 capabilities1.setCapability("app","C:\\Users\\rishi.kumar.khanna\\Desktop\\Q1BB-978.apk");
 capabilities1.setCapability("appActivity","com.bluebird.mobile.BluebirdLauncher");
 capabilities1.setCapability("appPackage", "com.bluebird.mobile");
 capabilities1.setCapability("appWaitActivity", "com.bluebird.mobile.BluebirdEULAActivity");
 capabilities1.setCapability("port", "4723");
 break;
	default: System.out.println("no mob exists...");
	break;
	}

	 driver1 = new AndroidDriver(new URL("http://localhost:4444/wd/hub"), capabilities1);             
}


@Parameters("Device_ID")
@BeforeTest
	public void setup(String device)throws Exception 
	{
	switch(device)
	{
	case "052d6d76002e47df":
	capabilities2 = new DesiredCapabilities();
	
	capabilities2.setCapability("platformVersion", "5.1.1");
	 capabilities2.setCapability("browserName", "Android");
	 capabilities2.setCapability("platformName", "Android");
	
capabilities2.setCapability("udid", "052d6d76002e47df");

	capabilities2.setCapability("deviceName","google Nexus 5");
	 capabilities2.setCapability("app","C:\\Users\\rishi.kumar.khanna\\Desktop\\Q1BB-978.apk");
	 capabilities2.setCapability("appActivity","com.bluebird.mobile.BluebirdLauncher");
	 capabilities2.setCapability("appPackage", "com.bluebird.mobile");
	 capabilities2.setCapability("appWaitActivity", "com.bluebird.mobile.BluebirdEULAActivity");
	 capabilities2.setCapability("port", "4740");
	break;
	default:System.out.println("no mob...exists");
	break;
	}
	//driver= new AndroidDriver(new URL("http://127.0.0.1:4723/wd/hub"), capabilities); 
    driver2 = new AndroidDriver(new URL("http://localhost:4444/wd/hub"), capabilities2);
}

}

Anyone any solution for my issue? Tried a lot different things with no success

WORKING GREAT with Caveats!!

Finally, I was able to achieve what I need. To rephrase, this is my setup:

Selenium Grid Hub: Running on iMac with Yosemite/Maveicks (Also tried with Windows 10 Preview using Bootcamp). Source for the test scripts are on the hub and NOT on each of the nodes. This is very important as I wanted to have the source in one single location for getting latest from SVN.

Selenium Grid Node: Running on MacBook Air:
Connected 2 devices (iPhone 6+ and Samsung Note II). Each of the devices are running on different appium ports. Selenium grid node are instantiated on each of the ports appium is listening (more on this later).

For debugging purposes, I installed IntelliJ on the hub machine (iMac) and when the test cases start running, I was seeing parallel run on both the devices at the same time (on the node machine). So far so good. I did the same with Windows 10 Preview (on the hub) and it works extremely well too. So, Windows hub can talk to Mac nodes. Awesome!

Now, the issue: I wanted to see if it works with Windows node. I disconnected the Android device (Samsung Note II) and plugged in to Windows 7 laptop while the hub is running on Windows 10 Preview (I think Windows OS shouldn't matter here). When I ran the test case from the hub on Windows 10 Preview, at the line where the AndroidDriver is instantiated, I got a Internet Explorer Driver error asking me to set this: System.setProperty("webdriver.ie.driver", "C:\SeleniumDrivers\IEDriverServer.exe");

I did this on both the server and the node (both running on Windows OS). Then, I got one more new error:
org.openqa.selenium.WebDriverException: Unexpected error launching Internet Explorer. Protected Mode settings are not the same for all zones. Enable Protected Mode must be set to the same value (enabled or disabled) for all zones. (WARNING: The server did not provide any stacktrace information).

My first question is I'm at loss on why these errors about Internet Explorer are happening when I'm trying to run an Android native app on the phone connected to a node remotely. These kind of issues are not happening when both the hub and the node are on OS X and also when the hub is on Windows 10 Preview and the node is on OS X. These pesky errors only happen when both the hub and node are on Windows OS. I haven't tried where the hub is on OS X and the node is on Windows 7.

And here's the snippet that I'm using to instantiate appium servers and grid nodes on the node machine:
C:\Program Files\nodejs>node C:\Users\username\AppData\Roaming\npm\node_mod
ules\appium\bin\appium.js --port 6000 --bootstrap-port 6025 --udid "android device id" --app-pkg "android package name" --app-activity "android activity name"

C:\Automation\Server>java -jar selenium-server-standalone.jar -role node -browse
r browserName=Android,version=4.3,maxinstance=1,platform=WINDOWS,applicationName
="udid" -Dwebdriver.ie.driver=C:\WebDrivers\IEDriverServer.exe -hub http://hubip:4444/grid/register3 -port 6000

I have to add the -Dwebdriver.ie.driver to make the nasty InternetExplorer Driver location failure to go away. Still getting the protected zone error.

Puzzled on why all of these when I'm trying to run a native android app on and android phone connected to a Windows OS node.
Btw, is the browsername correct? I'm just automating a native iPhone and a Android app.

Anybody, with any thoughts?

Thanks.

1 month later

Is there anything for python like TestNG? i have configured everything, my only problem is how to run parallel Tests, any help will be good.

All examples using the .xml file are for Java, i want to know if there is something like that for python.

Thanks

21 days later

Responding to client with error: {"status":33,"value":{"message":"A new session could not be created. (Original error: The following desired capabilities are required, but were not provided: deviceName)","origValue":"The following desired capabilities are required, but were not provided: deviceName"},"sessionId":null}

config files as below:
File 1:
{
"capabilities":
[
{
"browserName":"android",
"version":"4.4.2",
"maxInstances":5,
"platform":"ANDROID",
"applicationName": "2636B827AA05E6BB3"
}
],
"configuration":
{
"nodeTimeout":120,
"cleanUpCycle":2000,
"timeout":10000,
"proxy":"org.openqa.grid.selenium.proxy.DefaultRemoteProxy",
"url":"http://127.0.0.1:5566/wd/hub",
"maxSession":2,
"port":5566,
"register":true,
"registerCycle":5000,
"hub": "127.0.0.1:4441/grid/register",
"hubPort": 4441,
"hubHost": "127.0.0.1",
"role":"node"
}
}

File 2:
{
"capabilities":
[
{
"browserName":"android",
"version":"4.4",
"maxInstances":5,
"platform":"ANDROID",
"applicationName": "3061755BF088DF45"
}
],
"configuration":
{
"nodeTimeout":120,
"cleanUpCycle":2000,
"timeout":10000,
"proxy":"org.openqa.grid.selenium.proxy.DefaultRemoteProxy",
"url":"http://127.0.0.1:5577/wd/hub",
"maxSession":2,
"port":5577,
"register":true,
"registerCycle": 5000,
"hub": "127.0.0.1:4441/grid/register",
"hubPort": 4441,
"hubHost": "127.0.0.1",
"role":"node"
}
}

Selenium code:
for node 1:

@Parameters(value={"device_id1","device_id2", "ApplicationPath"})
@BeforeSuite//The annotated method will be run before all tests in this suite have run.
public static void atStart(@Optional("nnn") String device_id1, String device_id2, String ApplicationPath) throws InterruptedException, IOException
{
File app = new File(ApplicationPath);
capabilities=new DesiredCapabilities();
capabilities=DesiredCapabilities.android();

        if ("2636B827AA05E6BB3".equals(device_id1))//FOR SAMSUNG GALAXY NOTE
        {
            System.out.println("in Samsung galaxy: "+device_id1);
            capabilities.setCapability("automationName", "Appium");
            capabilities.setCapability(CapabilityType.BROWSER_NAME, "android");
            //capabilities.setCapability("crazyNodeName", "One");

            //samsung-sm_n750-3204da2a5075c0b5//micromax-micromax_a311-8a2d363//samsung-nexus_s-30345C56DC2000EC
            capabilities.setCapability("applicationName", device_id1);
            capabilities.setCapability("udid", device_id1);
            capabilities.setCapability("deviceName","samsung-nexus_s-30345C56DC2000EC");//
            capabilities.setCapability("platformVersion", "4.4.2");//Or//capabilities.setCapability(CapabilityType.VERSION, "4.1.2");
            capabilities.setCapability(CapabilityType.PLATFORM,"ANDROID");
            capabilities.setCapability("platformName", "ANDROID");//Or//capabilities.setCapability(CapabilityType.PLATFORM, "Android");
            capabilities.setCapability("app", app.getAbsolutePath());
            capabilities.setCapability("appPackage", "com.avaamo.android.staging"); //Replace with your app's package
            capabilities.setCapability("appActivity", "com.avaamo.android.ui.LandingActivity"); //Replace with app's Activity
            //setting new command timeout for selenium server
            capabilities.setCapability("newCommandTimeout", "2000000");//33.33 mins

                try
                {
                    driver = new AndroidDriver(new URL("http://127.0.0.1:4441/wd/hub"), capabilities);
                }
                catch (Exception e)
                {
                    System.out.println("didnt work for !" +device_id1);
                }

}

:: The same code with some values change for node 2.

Can anyone please help understanding whats going wrong, or possible solution?

@Hassan_Radi @appium @appium_ia @Arvind_Patel

I have added deviceName in json files and have put the same in capabilities in script.
though I don't see any progress.