Connecting appium server to selenium grid for android


#144

@Hassan_Radi
please xplain “load the same file using Appium .exe application” what you mean and how to achievwe


#145

@Hassan_Radi
Thanks a lot, my silly mistake has wasted your time, path in json was to be “jars” instead of “jar” :smpersevere:


#146

@Hassan_Radi Please guide

My node are:
node1.json

{
“capabilities”: [
{
“browserName”: “Android”,
“version”: “5.1”,
“maxInstances”: 3,
“platform”: “ANDROID”,
“deviceName”: “X1033”
}
],
“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
}
}

node2.json

{
“capabilities”: [
{
“browserName”: “Android”,
“version”: “5.1.1”,
“maxInstances”: 3,
“platform”: “ANDROID”,
“deviceName”: “emulator_1”
}
],
“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
}
}

Started HUB

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

Started Nodes

node appium -a 127.0.0.1 -p 4723 --nodeconfig D:\TehnologyWork\Softwares\jars\node1.json

node appium -a 127.0.0.1 -p 4728 --nodeconfig D:\TehnologyWork\Softwares\jars\node2.json

When I execute test for any device, always script runs in one appium server which is started firstly i.e. node1.

public static ThreadLocal<AndroidDriver> dr = new ThreadLocal<AndroidDriver>();

@BeforeMethod
@Parameters(“deviceName”)
public void beforeMethod(String deviceName) throws MalformedURLException{
try{
if(deviceName.equals(“XT1033”)){
AndroidDriver driver = null;
DesiredCapabilities capabilities=new DesiredCapabilities();
capabilities.setCapability(“platformName”, “Android”);
capabilities.setCapability(“platformVersion”,“5.1”);
capabilities.setCapability(“deviceName”, deviceName);
capabilities.setCapability(“app”,System.getProperty(“user.dir”) + “/resources/app-Channel31-debug.apk”);
URL serverAddress = new URL(“http://127.0.0.1:4444/wd/hub”);
driver = new AndroidDriver(serverAddress, capabilities);
setDriver(driver);

  	}
  	if(deviceName.equals("emulator_1")){
  		AndroidDriver<MobileElement>  driver = null;
  		DesiredCapabilities capabilities=new DesiredCapabilities();
  		capabilities.setCapability("platformName", "Android");
  		capabilities.setCapability("platformVersion","5.1.1");
  		capabilities.setCapability("deviceName", deviceName);
  		capabilities.setCapability("app",System.getProperty("user.dir") + "/resources/american swan- prod.apk");
  		URL serverAddress = new URL("http://127.0.0.1:4444/wd/hub");
  		driver = new AndroidDriver<MobileElement>(serverAddress, capabilities);
  		setDriver(driver);
  	}
  }

#147

Hi @tovaibhav1,
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 this case, you could add version capability to each test:

capabilities.setCapability("version","5.1");
capabilities.setCapability("version","5.1.1");

#148

I can see there are some success using appium grid over Selenium but is there one person that managed to do this using windows (without emulator!) simply** two Android devices**?


#149

Hello all,

I’m trying to have some mobile automated tests running with appium and selenium grid. Once i done all configuration stuff and added grid nodes, how do i run my tests parallely in both devices?

Here’s my setUp():

desired_caps = {}
	desired_caps['platformName'] = 'Android'
	desired_caps['platformVersion'] = '5.1'
	desired_caps['deviceName'] = ''
	desired_caps['app'] = os.path.abspath(os.path.join(os.path.dirname(__file__), 'C:/Users/andre.mendes/Desktop/workspace/powerpro/apps/powerpro.apk'))
	desired_caps['appPackage'] = 'com.psafe.powerpro'
	desired_caps['appActivity'] = '.MainActivity'
	desired_caps['noReset'] = False
	self.driver = webdriver.Remote('http://127.0.0.1:4444/wd/hub', desired_caps)
	self.driver.implicitly_wait(15)	

What it supposed to be in deviceName in this case?

If i leave it blank, here’s what i got:

C:\Users\andre.mendes\Desktop\workspace\powerpro>java -jar selenium-server-standalone-2.44.0.jar -role hub

19:16:58.691 INFO - Launching a selenium grid server

2016-02-18 19:16:59.937:INFO:osjs.Server:jetty-7.x.y-SNAPSHOT

2016-02-18 19:16:59.968:INFO:osjsh.ContextHandler:startedo.s.j.s.ServletContextHandler{/,null}2016-02-18 19:16:59.995:INFO:osjs.AbstractConnector:[email protected]:4444

19:49:48.183 INFO - Got a request to create a new session: Capabilities[{app=C:\Users\andre.mendes\Desktop\workspace\powerpro\apps\powerpro.apk, appPackage=com.psafe.powerpro, appActivity=.MainActivity, noReset=true, platformVersion=5.1, platformName=Android, deviceName=}]

19:49:48.183 INFO - Available nodes: [host :http://127.0.0.1:4723, host :http://127.0.0.1:4733]

 19:49:48.183 INFO - Trying to create a new session on node host :http://127.0.0.1:4723

19:49:48.183 INFO - Trying to create a new session on test slot {newCommandTimeout=30, browserName=Android, maxInstances=1, version=5.1,deviceName=0429058934,deviceReadyTimeout=5, platform=ANDROID}

I only can run the first node registered in grid. In this case http://127.0.0.1:4723.

I even tried to create a script with two setup(), each one to each device, but even this way, tests only ran in this same device (http://127.0.0.1:4723)


How to start mobile automated tests using selenium grid in python?
#150

Have you found a solution to run parallel tests with python?


#151

Yes that is possible with real devices


#152

I have started working on running parallel android devices by using grid.My Problem is the app installed and opened both connected devices properly.but it has not typed any values which i have given. After that it shows error message in setup method.
Can anyone help me for this issue???


#153

Hi rgonalo,
I have been facing some issues in Appium Grid. The hub has connected to the node properly.I have connected two devices for testing.The App has installed both devices and then stopped working.Herewith I have attached the code for reference.Please Specify me where the problem is.

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

import java.io.File;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.concurrent.TimeUnit;

import org.junit.Test;
import org.openqa.selenium.By;
import org.openqa.selenium.remote.CapabilityType;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.AfterTest;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.Parameters;

public class AppiumGrid {

 private AndroidDriver driver = null;
 public String appionlicatPath = "E:/sample.apk";
 public String MobileDevice_1 ="D1";
 public String MobileDevice_2 ="D2";
 public static  DesiredCapabilities capabilities = new DesiredCapabilities(); 
 AppiumDriver d1,d2;

 @BeforeTest
 
 @Parameters("Device_ID")

 public void startAppium(String DeviceID) throws MalformedURLException, InterruptedException{
  
  if(DeviceID.equalsIgnoreCase("mobile1")){
   setcapabilities(appionlicatPath, MobileDevice_1,"Appium");
           }
  
  if(DeviceID.equalsIgnoreCase("mobile2")){
   setcapabilities(appionlicatPath, MobileDevice_2,"Appium");
           }
  
  
  driver =  new AndroidDriver(new URL("http://127.0.0.1:4444/wd/hub"),capabilities);
  driver.manage().timeouts().implicitlyWait(80, TimeUnit.SECONDS);
  
  
 }

 

    @Test()
    public void loginTest() throws InterruptedException{
    	
    	Thread.sleep(1000);
    	
    	{
         System.out.println("Driver"+driver);

         String app_package_name = "sample/id";
         
        By userId = By.id(app_package_name + "username");

   
   By password = By.id(app_package_name + "password");

   

   

   driver.findElement(userId).sendKeys("***********************");
   driver.findElement(password).sendKeys("****************);
   driver.findElement(login_Button).click(); 
   
  
    	}
  
    }
    
 public void setcapabilities(String apppath,String device,String automation){
  
  DesiredCapabilities capabilities1= new DesiredCapabilities();

  capabilities1.setCapability("deviceName","G000H404540508AB");	
  capabilities1.setCapability("platformVersion", "5.1.1");	           	  
  capabilities1.setCapability("udid", "G000H404540508AB");
   capabilities1.setCapability("appActivity", "com.entappia.mhhs");
   
  try {
   d1 = new AndroidDriver(new URL("http://127.0.0.1:4723/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(CapabilityType.BROWSER_NAME, "Android");
  capabilities2.setCapability("deviceName","G000H4045405088W");
  //capabilities2.setCapability(CapabilityType.VERSION, "5.1.1");
  capabilities2.setCapability("platformVersion", "5.1");
  //capabilities2.setCapability(CapabilityType.PLATFORM, "ANDROID");
  capabilities2.setCapability("udid", "G000H4045405088W");
  
  
  try {
   d2= new AndroidDriver(new URL("http://127.0.0.1:4725/wd/hub"), capabilities2);
  } 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);

  
 }
  
  
 
}
  
  @AfterMethod
  @ AfterTest(alwaysRun= true)
  public void tearDown(){
   driver.quit();
  }
  
  
}

#154

Hi @sabarinathan,
Do you have any error message? Can you provide appium logs?


#155

Hi @rgonalo,@appium

I am getting the below issue in appium grid. could u pls help me with it.

Error in eclipse logcat:

Please provide me the helpful answer


#157

Hi,

pls find the screenshot below for device 1 appium log


#158

Hi,

I have attached an appium log as u mentioned

I have started two appium server simultaneously. both appium servers run as above image.

The first device installs the app and stopped opening. The second device does not install app . and eclipse shows error as session not created exception


#159

Hi rgonalo

I have been waiting for your reply… Is there any solution for this issue.


#160

Hi @suganya and @sabarinathan,
It’s not possible to help you with partial screenshots, you must provide complete appium logs.
And before pasting them, please read them carefully, trying to find out at least the error message. This will help you to find out the problem and to learn more about how Appium works.


#161

Hi,

Has anyone got this to work Appioum grid

I have everything set up however once I run the jar file , it picks up the device but then just hangs on executing the appium and nothing happens with the phone. Any help will do.

Also when importing this into eclipse and trying to run it from the source it throws java.io.IOException: Cannot run program “adb”: error=2, No such file or directory.


#162

I did, not using anymore. You should look into https://github.com/saikrishna321/AppiumTestDistribution


#163

https://appiumforbeginners.wordpress.com/2016/03/24/appium-grid-on-android-devices/


#164

hello,

During start node server it shows a error “Syntax error in node configuration file: Unexpected token P”

srikantas-Mac-mini-3:bin RajShekhar_DiroLabs$ appium --nodeconfig /Users/RajShekhar_DiroLabs/Desktop/node1.json -p 4730
[Appium] Welcome to Appium v1.5.2
[Appium] Non-default server args:
[Appium] port: 4730
[Appium] nodeconfig: ‘/Users/RajShekhar_DiroLabs/Desktop/node1.json’
[Appium] Error: Syntax error in node configuration file: Unexpected token P
at Object.wrappedLogger.errorAndThrow (lib/logger.js:60:13)
at postRequest$ (lib/grid-register.js:42:12)

Can any one please suggest me how to resolve it