Connecting appium server to selenium grid for android


#21

@rgonalo @Arvind_Patel ,

i tried again it didnt work. Everything will execute in a single device i.e nexus 5 irrespective of parallel or sequential

Below are the test cases,testng.xml and config files:

public class Calculator {

DesiredCapabilities capabilities;
  AppiumDriver driver;

@Parameters ("Device_ID") 
@BeforeMethod
public void setUp(String device)throws MalformedURLException {
	System.out.println(Thread.currentThread().getId());
	switch(device)
	{
	case "4df70d325d884031":
                 			capabilities = new DesiredCapabilities();
                 			//capabilities.setCapability(CapabilityType.BROWSER_NAME, "Android");
                 			//capabilities.setCapability("deviceName", "Default");
                 			capabilities.setCapability(CapabilityType.VERSION, "4.3");
                 			capabilities.setCapability("browserName", "chrome");
                 			//capabilities.setCapability(CapabilityType.PLATFORM, "Android");
                 			capabilities.setCapability("deviceName", "m0");
                 			capabilities.setCapability("platformName", "Android");
                 			//capabilities.setCapability(capabilityName, value)
                 			//capabilities.setCapability("appPackage", "com.google.android.apps.maps");
                 			//capabilities.setCapability("appActivity", "com.google.android.maps.MapsActivity");
                 			break;
	default: System.out.println("nim thatha kottidara ee config du mobile???");
			 break;
	}
              //driver= new AppiumDriver(new URL("http://127.0.0.1:4723/wd/hub"), cap);                                                                                                                                  // (you can get it from
                                                                                                                                                                                                              // apk info app)
                        
                    driver   = new AppiumDriver(new URL("http://localhost:4444/wd/hub"), capabilities);
}
@Test
public void verifyCalculator() throws InterruptedException
{
	driver.get("http://www.google.com");
	Thread.sleep(10000);
	System.out.println("launched...");
	System.out.println(driver.getSessionId());
    }

@AfterMethod
public void destroy()
{
driver.close();
//driver.quit();
}
}


public class ZoomPinch
{
static DesiredCapabilities capabilities;
static AppiumDriver driver;
static WebDriverWait wait;

@Parameters("Device_ID")
 @BeforeMethod
 public void setup(String device)throws Exception 
{
	System.out.println(Thread.currentThread().getId());
	switch(device)
	{
	case "085d3b920c928938":
	  capabilities = new DesiredCapabilities();
      //capabilities.setCapability(CapabilityType.BROWSER_NAME, "");
       //capabilities.setCapability("browserName", "Chrome");
      capabilities.setCapability(CapabilityType.VERSION, "5.0");
      capabilities.setCapability("deviceName", "hammerhead");
      capabilities.setCapability("platformName", "Android");
      capabilities.setCapability("appPackage", "com.davemorrissey.labs.subscaleview.sample");
      capabilities.setCapability("appActivity", "com.davemorrissey.labs.subscaleview.sample.MainActivity");
      break;
	default:System.out.println("nim thatha kottidara ee config du mobile???");
	 		break;
	}
	 driver= new AppiumDriver(new URL("http://localhost:4444/wd/hub"), capabilities); 
      
      //driver = new AppiumDriver(new URL("http://localhost:4444/wd/hub"), capabilities);
}
 @Test
 public void zoom() throws MalformedURLException
 { 
	 System.out.println(driver.getSessionId());
	 
      try {
		Thread.sleep(4000);
	} catch (InterruptedException e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
	}
      driver.findElementById("com.davemorrissey.labs.subscaleview.sample:id/basicFeatures").click();
      //android.view.View
      CommonFunctionLibrary cobj=new CommonFunctionLibrary(driver);
      cobj.zoomOnElement(cobj,"id", "com.davemorrissey.labs.subscaleview.sample:id/imageView");
      cobj.pinchOnElement(cobj,"id", "com.davemorrissey.labs.subscaleview.sample:id/imageView");
 }
 @AfterMethod
 public void tearDown()
 {
	 driver.quit();
 }

}


testng.xml:

xml version=“1.0” encoding=“UTF-8”
DOCTYPE suite SYSTEM “http://testng.org/testng-1.0.dtd
suite name=“Suite” parallel=“none”
test name=“Test1”
parameter name=“Device_ID” value=“085d3b920c928938”
classes
class name=“Test.ZoomPinch”
classes
test
test name=“Test2”
parameter name=“Device_ID” value=“4df70d325d884031”
classes
class name=“Test.Calculator”
classes
test
suite


Json Config:

{
“capabilities”:
[
{
“browserName”: “chrome”,
“version”: “5.0”,
“maxInstances”: 1,
“platform”: “ANDROID”,
“deviceName”: “hammerhead”
}
],
“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
}
}

{
“capabilities”:
[
{
“browserName”: “chrome”,
“version”: “4.3”,
“maxInstances”: 1,
“platform”: “ANDROID”,
“deviceName”: “m0”
}
],
“configuration”:
{
“nodeTimeout”:120,
“port”:4723,
“hubPort”:4444,
“proxy”: “org.openqa.grid.selenium.proxy.DefaultRemoteProxy”,
“url”:“http://127.0.0.1:4723/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
}
}

Please help . not sure whats going wrong… :frowning:


#22

You must set the device id when starting the Appium server (parameter --udid) or creating the driver (capability udid). Without this configuration, the Appium server executes the test in the first device that it finds.

In your example, you can add the capability with:

capabilities.setCapability("udid", device);

Or launch both Appium servers with --udid:

node . --nodeconfig nodeConfig.json -p 4723 --udid 4df70d325d884031
node . --nodeconfig nodeConfig1.json -p 4728 --udid 085d3b920c928938

Appium doc: http://appium.io/slate/en/master/?ruby#running-your-tests-with-appium


#23

@rgonalo thanks for your guidance…it worked… :smile:


#24

@rgonalo @Hassan_Radi @Arvind_Patel,

I am trying to run the my test cases parallel on 3 devices connected to my machine

I am trying to launch the same test cases for different devices using the method described below.
[Launching and stopping appium server programatically][1].

Please can you guide me on how to launch appium server programmatically using node config.json.

  1. I launching grid through command prompt: java -jar selenium-server-standalone.jar -role hub
  2. I am executing the below code to launch appium server with nodeconfig.json

Below is the Code which i am trying to execute:

package Test;

import io.appium.java_client.AppiumDriver;

import java.io.IOException;
import java.net.URL;

import org.apache.commons.exec.CommandLine;
import org.apache.commons.exec.DefaultExecuteResultHandler;
import org.apache.commons.exec.DefaultExecutor;
import org.apache.commons.exec.ExecuteException;
import org.apache.commons.exec.Executor;
import org.openqa.selenium.remote.CapabilityType;
import org.openqa.selenium.remote.DesiredCapabilities;

public class NewTrial
{
public static void main(String[] args) throws ExecuteException, IOException
{
AppiumDriver driver;
DefaultExecuteResultHandler resultHandler;
Executor executor ;
CommandLine command = new CommandLine(“cmd”);
command.addArgument("/c");
command.addArgument(“C:\Users\mkarthik\Documents\selenium\Appium\node.exe”);
command.addArgument(“C:\Users\mkarthik\Documents\selenium\Appium\node_modules\appium\bin\appium.js”);
command.addArgument("–nodeconfig");
command.addArgument(“C:\Users\mkarthik\Documents\nodeconfig.json”);
command.addArgument("–bootstrap-port");
command.addArgument(“4724”);
resultHandler = new DefaultExecuteResultHandler();
executor = new DefaultExecutor();
executor.setExitValue(1);
System.out.println("command: "+command);
executor.execute(command, resultHandler);

	DesiredCapabilities capabilities=new DesiredCapabilities();
	URL url=new URL("http://localhost:4444/wd/hub");
	
	capabilities.setCapability(CapabilityType.VERSION, "5.0");
      capabilities.setCapability("deviceName", "hammerhead");
      capabilities.setCapability("platformName", "Android");
	capabilities.setCapability("udid","085d3b920c928938");
	
	 driver   = new AppiumDriver(url, capabilities);
	 driver.get("http://www.google.com");


}

}

Below is the error i am getting:

command: cmd /c C:\Users\mkarthik\Documents\selenium\Appium\node.exe C:\Users\mkarthik\Documents\selenium\Appium\node_modules\appium\bin\appium.js --nodeconfig C:\Users\mkarthik\Documents\nodeconfig.json --bootstrap-port 4724
log4j:WARN No appenders could be found for logger (org.apache.http.client.protocol.RequestAddCookies).
log4j:WARN Please initialize the log4j system properly.
Exception in thread “main” org.openqa.selenium.WebDriverException: Error forwarding the new session Empty pool of VM for setup Capabilities [{deviceName=hammerhead, platformName=Android, udid=085d3b920c928938, version=5.0}]
Command duration or timeout: 249 milliseconds
Build info: version: ‘2.42.2’, revision: ‘6a6995d’, time: ‘2014-06-03 17:42:30’
System info: host: ‘mkarthik-W7’, ip: ‘192.168.56.1’, os.name: ‘Windows 7’, os.arch: ‘amd64’, os.version: ‘6.1’, java.version: ‘1.7.0_40’
Driver info: io.appium.java_client.AppiumDriver
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:88)
at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:240)
at org.openqa.selenium.remote.RemoteWebDriver.(RemoteWebDriver.java:126)
at org.openqa.selenium.remote.RemoteWebDriver.(RemoteWebDriver.java:153)
at io.appium.java_client.AppiumDriver.(AppiumDriver.java:44)
at Test.NewTrial.main(NewTrial.java:57)
Caused by: org.openqa.grid.common.exception.GridException: Error forwarding the new session Empty pool of VM for setup Capabilities [{deviceName=hammerhead, platformName=Android, udid=085d3b920c928938, version=5.0}]
at org.openqa.grid.web.servlet.handler.RequestHandler.process(RequestHandler.java:114)
at org.openqa.grid.web.servlet.DriverServlet.process(DriverServlet.java:83)
at org.openqa.grid.web.servlet.DriverServlet.doPost(DriverServlet.java:67)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
at org.seleniumhq.jetty7.servlet.ServletHolder.handle(ServletHolder.java:565)
at org.seleniumhq.jetty7.servlet.ServletHandler.doHandle(ServletHandler.java:479)
at org.seleniumhq.jetty7.server.session.SessionHandler.doHandle(SessionHandler.java:225)
at org.seleniumhq.jetty7.server.handler.ContextHandler.doHandle(ContextHandler.java:1031)
at org.seleniumhq.jetty7.servlet.ServletHandler.doScope(ServletHandler.java:406)
at org.seleniumhq.jetty7.server.session.SessionHandler.doScope(SessionHandler.java:186)
at org.seleniumhq.jetty7.server.handler.ContextHandler.doScope(ContextHandler.java:965)
at org.seleniumhq.jetty7.server.handler.ScopedHandler.handle(ScopedHandler.java:117)
at org.seleniumhq.jetty7.server.handler.HandlerWrapper.handle(HandlerWrapper.java:111)
at org.seleniumhq.jetty7.server.Server.handle(Server.java:349)
at org.seleniumhq.jetty7.server.AbstractHttpConnection.handleRequest(AbstractHttpConnection.java:452)
at org.seleniumhq.jetty7.server.BlockingHttpConnection.handleRequest(BlockingHttpConnection.java:47)
at org.seleniumhq.jetty7.server.AbstractHttpConnection.content(AbstractHttpConnection.java:894)
at org.seleniumhq.jetty7.server.AbstractHttpConnection$RequestHandler.content(AbstractHttpConnection.java:948)
at org.seleniumhq.jetty7.http.HttpParser.parseNext(HttpParser.java:857)
at org.seleniumhq.jetty7.http.HttpParser.parseAvailable(HttpParser.java:235)
at org.seleniumhq.jetty7.server.BlockingHttpConnection.handle(BlockingHttpConnection.java:66)
at org.seleniumhq.jetty7.server.bio.SocketConnector$ConnectorEndPoint.run(SocketConnector.java:254)
at org.seleniumhq.jetty7.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:599)
at org.seleniumhq.jetty7.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:534)
at java.lang.Thread.run(Unknown Source)
e[36minfoe[39m: Welcome to Appium v1.2.0 (REV e53f49c706a25242e66d36685c268b599cc18da5)
e[90mdebuge[39m: Non-default server args: {“nodeconfig”:“C:\Users\mkarthik\Documents\nodeconfig.json”}
e[36minfoe[39m: Appium REST http interface listener started on 0.0.0.0:4723
e[36minfoe[39m: LogLevel: debug
e[90mdebuge[39m: starting auto register thread for grid. Will try to register every 10000 ms.
e[90mdebuge[39m: Appium successfully registered with the grid on 127.0.0.1:4444
e[36minfoe[39m: e[37m–>e[39m e[37mGETe[39m e[37m/wd/hub/statuse[39m e[90m{}e[39m
e[90mdebuge[39m: Appium request initiated at /wd/hub/status
e[36minfoe[39m: e[37m<-- GET /wd/hub/status e[39me[32m200e[39me[90m 4.760 ms - 104e[39m e[90m{“status”:0,“value”:{“build”:{“version”:“1.2.0”,“revision”:“e53f49c706a25242e66d36685c268b599cc18da5”}}}e[39m
e[90mdebuge[39m: Request received with params: {}
e[90mdebuge[39m: Responding to client with success: {“status”:0,“value”:{“build”:{“version”:“1.2.0”,“revision”:“e53f49c706a25242e66d36685c268b599cc18da5”}}}
e[36minfoe[39m: e[37m–>e[39m e[37mGETe[39m e[37m/wd/hub/statuse[39m e[90m{}e[39m
e[90mdebuge[39m: Appium request initiated at /wd/hub/status
e[90mdebuge[39m: Request received with params: {}
e[90mdebuge[39m: Responding to client with success: {“status”:0,“value”:{“build”:{“version”:“1.2.0”,“revision”:“e53f49c706a25242e66d36685c268b599cc18da5”}}}
e[36minfoe[39m: e[37m<-- GET /wd/hub/status e[39me[32m200e[39me[90m 0.943 ms - 104e[39m e[90m{“status”:0,“value”:{“build”:{“version”:“1.2.0”,“revision”:“e53f49c706a25242e66d36685c268b599cc18da5”}}}e[39m
e[36minfoe[39m: e[37m–>e[39m e[37mGETe[39m e[37m/wd/hub/statuse[39m e[90m{}e[39m
e[90mdebuge[39m: Appium request initiated at /wd/hub/status
e[90mdebuge[39m: Request received with params: {}
e[90mdebuge[39m: Responding to client with success: {“status”:0,“value”:{“build”:{“version”:“1.2.0”,“revision”:“e53f49c706a25242e66d36685c268b599cc18da5”}}}
e[36minfoe[39m: e[37m<-- GET /wd/hub/status e[39me[32m200e[39me[90m 0.712 ms - 104e[39m e[90m{“status”:0,“value”:{“build”:{“version”:“1.2.0”,“revision”:“e53f49c706a25242e66d36685c268b599cc18da5”}}}e[39m
e[36minfoe[39m: e[37m–>e[39m e[37mGETe[39m e[37m/wd/hub/statuse[39m e[90m{}e[39m
e[90mdebuge[39m: Appium request initiated at /wd/hub/status
e[90mdebuge[39m: Request received with params: {}
e[90mdebuge[39m: Responding to client with success: {“status”:0,“value”:{“build”:{“version”:“1.2.0”,“revision”:“e53f49c706a25242e66d36685c268b599cc18da5”}}}
e[36minfoe[39m: e[37m<-- GET /wd/hub/status e[39me[32m200e[39me[90m 0.586 ms - 104e[39m e[90m{“status”:0,“value”:{“build”:{“version”:“1.2.0”,“revision”:“e53f49c706a25242e66d36685c268b599cc18da5”}}}e[39m
e[36minfoe[39m: e[37m–>e[39m e[37mGETe[39m e[37m/wd/hub/statuse[39m e[90m{}e[39m
e[90mdebuge[39m: Appium request initiated at /wd/hub/status
e[36minfoe[39m: e[37m<-- GET /wd/hub/status e[39me[32m200e[39me[90m 0.581 ms - 104e[39m e[90m{“status”:0,“value”:{“build”:{“version”:“1.2.0”,“revision”:“e53f49c706a25242e66d36685c268b599cc18da5”}}}e[39m
e[90mdebuge[39m: Request received with params: {}
e[90mdebuge[39m: Responding to client with success: {“status”:0,“value”:{“build”:{“version”:“1.2.0”,“revision”:“e53f49c706a25242e66d36685c268b599cc18da5”}}}
e[36minfoe[39m: e[37m–>e[39m e[37mGETe[39m e[37m/wd/hub/statuse[39m e[90m{}e[39m
e[90mdebuge[39m: Appium request initiated at /wd/hub/status
e[36minfoe[39m: e[37m<-- GET /wd/hub/status e[39me[32m200e[39me[90m 0.587 ms - 104e[39m e[90m{“status”:0,“value”:{“build”:{“version”:“1.2.0”,“revision”:“e53f49c706a25242e66d36685c268b599cc18da5”}}}e[39m
e[90mdebuge[39m: Request received with params: {}
e[90mdebuge[39m: Responding to client with success: {“status”:0,“value”:{“build”:{“version”:“1.2.0”,“revision”:“e53f49c706a25242e66d36685c268b599cc18da5”}}}
e[36minfoe[39m: e[37m–>e[39m e[37mGETe[39m e[37m/wd/hub/statuse[39m e[90m{}e[39m
e[90mdebuge[39m: Appium request initiated at /wd/hub/status
e[36minfoe[39m: e[37m<-- GET /wd/hub/status e[39me[32m200e[39me[90m 1.939 ms - 104e[39m e[90m{“status”:0,“value”:{“build”:{“version”:“1.2.0”,“revision”:“e53f49c706a25242e66d36685c268b599cc18da5”}}}e[39m
e[90mdebuge[39m: Request received with params: {}
e[90mdebuge[39m: Responding to client with success: {“status”:0,“value”:{“build”:{“version”:“1.2.0”,“revision”:“e53f49c706a25242e66d36685c268b599cc18da5”}}}
e[90mdebuge[39m: Appium request initiated at /wd/hub/status
e[36minfoe[39m: e[37m–>e[39m e[37mGETe[39m e[37m/wd/hub/statuse[39m e[90m{}e[39m
e[36minfoe[39m: e[37m<-- GET /wd/hub/status e[39me[32m200e[39me[90m 0.532 ms - 104e[39m e[90m{“status”:0,“value”:{“build”:{“version”:“1.2.0”,“revision”:“e53f49c706a25242e66d36685c268b599cc18da5”}}}e[39m
e[90mdebuge[39m: Request received with params: {}
e[90mdebuge[39m: Responding to client with success: {“status”:0,“value”:{“build”:{“version”:“1.2.0”,“revision”:“e53f49c706a25242e66d36685c268b599cc18da5”}}}
e[36minfoe[39m: e[37m–>e[39m e[37mGETe[39m e[37m/wd/hub/statuse[39m e[90m{}e[39m
e[90mdebuge[39m: Appium request initiated at /wd/hub/status
e[36minfoe[39m: e[37m<-- GET /wd/hub/status e[39me[32m200e[39me[90m 1.044 ms - 104e[39m e[90m{“status”:0,“value”:{“build”:{“version”:“1.2.0”,“revision”:“e53f49c706a25242e66d36685c268b599cc18da5”}}}e[39m
e[90mdebuge[39m: Request received with params: {}
e[90mdebuge[39m: Responding to client with success: {“status”:0,“value”:{“build”:{“version”:“1.2.0”,“revision”:“e53f49c706a25242e66d36685c268b599cc18da5”}}}
e[36minfoe[39m: e[37m–>e[39m e[37mGETe[39m e[37m/wd/hub/statuse[39m e[90m{}e[39m
e[90mdebuge[39m: Appium request initiated at /wd/hub/status
e[36minfoe[39m: e[37m<-- GET /wd/hub/status e[39me[32m200e[39me[90m 1.581 ms - 104e[39m e[90m{“status”:0,“value”:{“build”:{“version”:“1.2.0”,“revision”:“e53f49c706a25242e66d36685c268b599cc18da5”}}}e[39m
e[90mdebuge[39m: Request received with params: {}
e[90mdebuge[39m: Responding to client with success: {“status”:0,“value”:{“build”:{“version”:“1.2.0”,“revision”:“e53f49c706a25242e66d36685c268b599cc18da5”}}}
e[36minfoe[39m: e[37m–>e[39m e[37mGETe[39m e[37m/wd/hub/statuse[39m e[90m{}e[39m
e[90mdebuge[39m: Appium request initiated at /wd/hub/status
e[90mdebuge[39m: Request received with params: {}
e[90mdebuge[39m: Responding to client with success: {“status”:0,“value”:{“build”:{“version”:“1.2.0”,“revision”:“e53f49c706a25242e66d36685c268b599cc18da5”}}}
e[36minfoe[39m: e[37m<-- GET /wd/hub/status e[39me[32m200e[39me[90m 0.547 ms - 104e[39m e[90m{“status”:0,“value”:{“build”:{“version”:“1.2.0”,“revision”:“e53f49c706a25242e66d36685c268b599cc18da5”}}}e[39m
e[36minfoe[39m: e[37m–>e[39m e[37mGETe[39m e[37m/wd/hub/statuse[39m e[90m{}e[39m
e[90mdebuge[39m: Appium request initiated at /wd/hub/status
e[36minfoe[39m: e[37m<-- GET /wd/hub/status e[39me[32m200e[39me[90m 1.643 ms - 104e[39m e[90m{“status”:0,“value”:{“build”:{“version”:“1.2.0”,“revision”:“e53f49c706a25242e66d36685c268b599cc18da5”}}}e[39m
e[90mdebuge[39m: Request received with params: {}
e[90mdebuge[39m: Responding to client with success: {“status”:0,“value”:{“build”:{“version”:“1.2.0”,“revision”:“e53f49c706a25242e66d36685c268b599cc18da5”}}}
e[36minfoe[39m: e[37m–>e[39m e[37mGETe[39m e[37m/wd/hub/statuse[39m e[90m{}e[39m
e[90mdebuge[39m: Appium request initiated at /wd/hub/status
e[36minfoe[39m: e[37m<-- GET /wd/hub/status e[39me[32m200e[39me[90m 0.944 ms - 104e[39m e[90m{“status”:0,“value”:{“build”:{“version”:“1.2.0”,“revision”:“e53f49c706a25242e66d36685c268b599cc18da5”}}}e[39m
e[90mdebuge[39m: Request received with params: {}
e[90mdebuge[39m: Responding to client with success: {“status”:0,“value”:{“build”:{“version”:“1.2.0”,“revision”:“e53f49c706a25242e66d36685c268b599cc18da5”}}}
e[36minfoe[39m: e[37m–>e[39m e[37mGETe[39m e[37m/wd/hub/statuse[39m e[90m{}e[39m
e[36minfoe[39m: e[37m<-- GET /wd/hub/status e[39me[32m200e[39me[90m 1.161 ms - 104e[39m e[90m{“status”:0,“value”:{“build”:{“version”:“1.2.0”,“revision”:“e53f49c706a25242e66d36685c268b599cc18da5”}}}e[39m
e[90mdebuge[39m: Appium request initiated at /wd/hub/status
e[90mdebuge[39m: Request received with params: {}
e[90mdebuge[39m: Responding to client with success: {“status”:0,“value”:{“build”:{“version”:“1.2.0”,“revision”:“e53f49c706a25242e66d36685c268b599cc18da5”}}}

Below is the nodeconfig.json

{
“capabilities”:
[
{
“browserName”: “chrome”,
“version”: “5.0”,
“maxInstances”: 1,
“platform”: “ANDROID”,
“deviceName”: “hammerhead”
}
],
“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
}
}

Kindly help.

Thanks and regards,
M.Karthik


#25

If running more than one test session on the same machine, you need to make sure to provide different ports for each test. Have you done that???


#26

I just tried with the code which launches grid and appium. Its launching appium server and its registering using nodeconfig.json. I see that the grid console shows the mobile but when AppiumDriver driver = new AppiumDriver(new (“http://local host:4444/wd/hub”),capabilities); is executed its failing…


#27

does it fail with running only on one device??


#28

Yes have only one device connected to test…have attached the error info in my previous post…“error forwarding new session empty pool of vm for setup capabilities” is the error


#29

Hi all,

Any one has any lead on this?


#30

As far as I can see; this is a Grid related issue, please make sure that you are initializing the grid connection successfully. Follow this link for help. Just a small question; Are you running/connecting to a virtual machine??


#31

Hi @Hassan_Radi

I am able to see that appium is registered with the device and it is available as node at hub console…no I am not executing scripts on VM…hub , appium , and device all on local system


#32

hi All,

package Test;

import io.appium.java_client.AppiumDriver;

import java.io.IOException;
import java.net.URL;

import org.apache.commons.exec.CommandLine;
import org.apache.commons.exec.DefaultExecuteResultHandler;
import org.apache.commons.exec.DefaultExecutor;
import org.apache.commons.exec.ExecuteException;
import org.apache.commons.exec.Executor;
import org.openqa.selenium.remote.CapabilityType;
import org.openqa.selenium.remote.DesiredCapabilities;

public class NewTrial
{
public static void main(String[] args) throws ExecuteException, IOException, InterruptedException
{
AppiumDriver driver;
DefaultExecuteResultHandler resultHandler;
DefaultExecuteResultHandler resultHandler1;
Executor executor1 ;
Executor executor ;

	try{
	CommandLine command1 = new CommandLine("cmd");
	command1.addArgument("/c");
	command1.addArgument("java -jar C:\\Users\\mkarthik\\Downloads\\selenium-server-standalone-2.41.0.jar -role hub");
	resultHandler1 = new DefaultExecuteResultHandler();
	executor1 = new DefaultExecutor();
	executor1.setExitValue(1);
	System.out.println("command: "+command1);
	executor1.execute(command1, resultHandler1);
	
	Thread.sleep(10000);
	
	DesiredCapabilities capabilities=new DesiredCapabilities();
	URL url=new URL("http://localhost:4444/wd/hub");
	
	capabilities.setCapability(CapabilityType.VERSION, "5.0.1");
    capabilities.setCapability("deviceName", "hammerhead");
    capabilities.setCapability("platformName", "Android");
	capabilities.setCapability("udid","085d3b920c928938");
	capabilities.setBrowserName("chrome");
	
	
	Thread.sleep(25000);
	CommandLine command = new CommandLine("cmd");
	command.addArgument("/c");
	command.addArgument("C:\\Users\\mkarthik\\Documents\\selenium\\Appium\\node.exe");
    command.addArgument("C:\\Users\\mkarthik\\Documents\\selenium\\Appium\\node_modules\\appium\\bin\\appium.js");
    command.addArgument("--address");
    command.addArgument("127.0.0.1");
    command.addArgument("--port");
    command.addArgument("4728");
    command.addArgument("--udid");
    command.addArgument("085d3b920c928938");
	//command.addArgument("4724");
	//command.addArgument("--chromedriver-port");
	//command.addArgument("9515");
	command.addArgument("--nodeconfig");
	command.addArgument("C:\\Users\\mkarthik\\Desktop\\trial.json");
    resultHandler = new DefaultExecuteResultHandler();
	executor = new DefaultExecutor();
	executor.setExitValue(1);
	System.out.println("command: "+command);
	executor.execute(command, resultHandler);
	
	Thread.sleep(25000);
	
	 driver   = new AppiumDriver(url, capabilities);
	 driver.get("http://www.google.com");
	}
	catch(Exception e)
	{
		System.out.println(e.getMessage());
	}
	finally{
		
	}

}

}

Above code works fine… :smile:

Thanks and regards,
M.Karthik


#33

Hi Karthik,

According to above comments I can understand you are trying to execute your script on multiple devices parallel.

Were you able to successfully execute the script on multiple devices parallel. If yes please provide the steps.

Thanks
Srikanth


#34

**Hi **

I m new to Appium And I m currently working on parallel execution, I have some doubts from above comments

  1. What is difference in AppiumDriver and RemoteWebDriver?
  2. Which url have to provide in RemoteWebDriver ? is it hub IP with Port or Appium IP with port ?
    3.appium -a http://127.0.01 -port 2734 -udid 903etg763 -bp2734 --nodeconfig “E:\Appium\Nodeconfig.json”
    if i run the above command from cmd . its opening an appium with old IP and port
    which i used. so i want to know is that the same happening to you . To
    configure with hub , manually i m attached the Nodeconfig file in
    Appium (SeleniumGridConfigurationFile).

Kindly help me to solve the issue…


#35

Hello Everyone,

I just created video to execute appium script on multiple android devices using selenium grid.

Thanks
Srikanth


#36

@Srikanth_Katakam,

I am trying to launch chrome browser on Moto x (Android kit kat) and Nexus 5(Lolipop).

Following things are done in the code:
1)Launch grid
2)I am having a dataprovider which feeds the mobile info as objects one after the other to tests I have configured the dataprovider to provide the objects parallely. Using this information i am preparing the desired capabilities which will be used for initalizing appium driver.
3)Launch appium servers as per the configuration mentioned in the dataprovider object and register it with hub
4)Execute the test.

The problem i am facing is that tests are executed in a single device but is failing when trying to execute it on another device. I am suspecting time issue or some config issue.

Can you please post the code for the above video, it would be helpful.

Thanks and regards,
Karthik


#37

@karthik_holla,
@Srikanth_Katakam and @Appium_Master (Both are my accounts)

Whatever the test I executed using selenium grid was with Native apps/Hybrid apps. So Just now I tried with chrome browser and I was able to successfully execute the single scripts on both the devices Sequential one after another.
[I’m using Galaxy Note 2 and Galaxy Note 3 (both are in Android kit version)]


#38

@Srikanth_Katakam @Hassan_Radi @rgonalo
@Arvind_Patel @Appium_Master

Sequential execution i am able to do. But the question is that can test scripts be executed in parallel?

As per my observation parallel execution is not happening as chromedriver was created when executing on one of the mobile, until this process is killed or exited launching of chrome on another mobile was not possible.

Please let me know if this observation is correct?? also can you help with overcoming this issue?

Thanks and regards,
M.Karthik


#39

Hi all,

Any one has any lead on this?

Thanks and regards,
M.Karthik


#41

How to know mobile device connected as a node to the grid…pls let me know…!!! Thanks in advance @karthik_holla