hi,
Is there a way to integrate appium with selenium grid?
i am executing my scripts on android devices.using windows 7 and java.
any inputs would be highly appreciated.
Thanks and regards,
M.Karthik
hi,
Is there a way to integrate appium with selenium grid?
i am executing my scripts on android devices.using windows 7 and java.
any inputs would be highly appreciated.
Thanks and regards,
M.Karthik
I have not used it before, so I am not sure if it would actually work or not , but there is a Serer configuration specifically for that:
ânode-config â> Configuration JSON file to register appium with selenium grid
Give it a try and let me know how it works.
i was able to see that mobile device got registered as node to grid and the same showed up in grid console. But the problem is when i tried to execute the script it failed saying that appium could not be started at 4723. in my code i am launching the appium server and then actions are performed on the device. I think there is a problem as node is already launched at the same port as per the nodeconfig.json.
Hi All,
Any one has any breakthrough on this? Any suggestions?
Thanks and regards,
M.Karthik
Hey, I got to the same point where my node is configured with Appium server and selendroid standalone both are registered to the selenium grid. The problem is like described - both the appium and selendroid are using the same port which eventually returns an error because they are using the same port⌠I am still struggling to figure this out, but I will be happy if any one gots through this issue by now and can commit.
Try to launch Appium in other port with -p option:
node . --nodeconfig appium_node.json -p 4725
You must also change âurlâ and âportâ parameters in the node config file (appium_node.json) with the new port value:
âurlâ:âhttp://host_name_appium_server_or_ip-address_appium_server:4725/wd/hubâ,
âportâ: 4725,
You can see more config parameters in http://appium.io/slate/en/master/?java#selenium-grid
I have configured appium with selenium grid and works fine.
only you have to start new node for each device and register it with grid server.
Start server: java -jar selenium-server-standalone-2.43.0.jar -role hub
Register node: appium -p -U --nodecofig
Even I am stuck on the last step in launching Appium Grid on 2 Android devices that are connected to the same Windows 7 machine. Your inputs will really help in moving forward:
Steps that I have done so far:
Clonned the Appium and started the server on 2 different ports
Created 2 different json files for each port and started Appium server using these files
Now trying to deploy the selendroid test app on both device at same
time.
One one device itâs being added successfully but on other it errorâs out with a message
âuiautomator quit before it successfully launchedâ
Although the Grid console shows both port connected for DefaultRemoteProxy (version : 1.2.0)
id : http://127.0.0.1:4730, OS : ANDROID and the second one id : http://127.0.0.1:4728, OS : ANDROID
node1.json
{
âcapabilitiesâ:
[
{
âbrowserNameâ: âAndroidâ,
âversionâ:â4.4.2â,
âmaxInstancesâ: 1,
âplatformâ:âANDROIDâ
}
],
âconfigurationâ:
{
âcleanUpCycleâ:2000,
âtimeoutâ:30000,
âproxyâ: âorg.openqa.grid.selenium.proxy.DefaultRemoteProxyâ,
âurlâ:âhttp://127.0.0.1:4730/wd/hubâ,
âmaxSessionâ: 1,
âportâ: â4730â,
âhostâ: â127.0.0.1â,
âregisterâ: true,
âregisterCycleâ: 5000,
âhubPortâ: â4444â,
âhubHostâ: â127.0.0.1â
}
}
node2.json
{
âcapabilitiesâ:
[
{
âbrowserNameâ: âAndroidâ,
âversionâ:â4.4.2â,
âmaxInstancesâ: 1,
âplatformâ:âANDROIDâ
}
],
âconfigurationâ:
{
âcleanUpCycleâ:2000,
âtimeoutâ:30000,
âproxyâ: âorg.openqa.grid.selenium.proxy.DefaultRemoteProxyâ,
âurlâ:âhttp://127.0.0.1:4728/wd/hubâ,
âmaxSessionâ: 1,
âportâ: â4728â,
âhostâ: â127.0.0.1â,
âregisterâ: true,
âregisterCycleâ: 5000,
âhubPortâ: â4444â,
âhubHostâ: â127.0.0.1â
}
}
Let me know if I am missing something or any more configuration required?
Thanks in Advance
Hi Team,
Any help in the same as the hub is listening to both Ports and both devices are connected to one machine but while executing the code when I run it serially it gets executed on one device only and when I run the code parallelly then it throws exception for âuiautomator quit before it successfully launchedâ
Thanks
My Json looks like
{
âcapabilitiesâ:
[
{
âbrowserNameâ: âAndroidâ,
âversionâ:â4.4â,
âmaxInstancesâ: 3,
âplatformâ:âANDROIDâ,
âdeviceNameâ:âemulator-5554â
}],
"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
}
}
i used 3 more json file(only node url and device changed ) for more devices and working fine with me
Hi
here is the link that explains about the grid configuration along with the screenshots of the grid setup
Thanks
Sravan
Even i was stuck on same issue for long.
you might creating new driver instance for each node so iitâll will stop existing running session when new session request open with new instance.
thats why you are not able to run session parallel on both devices.
Solution:
!! Happy testing âŚ
Even I am facing the same issue. My node config files are:
file 1
{
âcapabilitiesâ:
[
{
âbrowserNameâ: âAndroidâ,
âversionâ:â4.4.2â,
âmaxInstancesâ: 3,
âplatformâ:âANDROIDâ,
âdeviceNameâ:âemulator-5554â
}
],
â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
}
}
File 2
{
âcapabilitiesâ:
[
{
âbrowserNameâ: âAndroidâ,
âversionâ:â4.4.2â,
âmaxInstancesâ: 3,
âplatformâ:âANDROIDâ,
âdeviceNameâ:âemulator-5556â
}
],
â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
}
}
Code Written:
public static AndroidDriver driver=null;
@Test(dataProvider="getData")
public void searchTest(String b) throws MalformedURLException, InterruptedException{
if(driver==null){
DesiredCapabilities cap = null;
System.out.println(b);
if(b.equals("mobile1")){
cap = new DesiredCapabilities();
cap.setCapability(CapabilityType.BROWSER_NAME, "");
cap.setCapability("deviceName","emulator-5556");
cap.setCapability("platformVersion", "4.4.2");
cap.setCapability("platformName","Android");
cap.setCapability("appPackage",
"com.android.contacts");
cap.setCapability("appActivity",
"com.android.contacts.activities.DialtactsActivity");
}else if(b.equals("mobile2")){
cap = new DesiredCapabilities();
cap.setCapability(CapabilityType.BROWSER_NAME, "");
cap.setCapability("deviceName","emulator-5554");
cap.setCapability("platformVersion", "4.4.2");
cap.setCapability("platformName","Android");
cap.setCapability("appPackage",
"com.android.contacts");
cap.setCapability("appActivity",
"com.android.contacts.activities.DialtactsActivity");
}
driver = new AndroidDriver(new URL("http://localhost:4444/wd/hub"), cap);
driver.manage().timeouts().implicitlyWait(80, TimeUnit.SECONDS);
driver.quit();
}
}
@DataProvider(parallel=true)
public Object[][] getData(){
Object data[][] = new Object[2][1];
data[0][0] = "mobile1";
data[1][0] = "mobile2";
return data;
}
Every time the code is being executed on a single device where as I have connected two real device with same machine and started the hub as well on same machine:
Hub Started with:
java -jar selenium-server-standalone-2.44.0.jar -role hub
Started node 1:
C:\Users\ishita\Desktop\Appium\Appium2\node_modules\appium\bin>node appium --nodeconfig c:/softwares/jars/appiumnode1.json -p 4728
Started node 2:
C:\Users\Selenium\Desktop\Appium\Appium\node_modules\appium\bin>node appium --nodeconfig c:/softwares/jars/appiumnode2.json -p 4730
Please suggest me the fix as I need to submit a POC on the same UGENTLY !!!
Thanks for the help.
Ishita
Config. looks fine. Try to run and pass parameter from xml file and make parallel=tests
like:
suite name=âVK Suiteâ parallel=âtestsâ thread-count=â5â verbose="1
test name=âfirstTest on fiest mobileâ
parameter name=âDeviceIDâ value=âTA9asdsda33071OQâ
classes
class
name=âvKSocialSite.VKTestâ
classes
test
test name="firstTest on second mobile "
parameter name=âDeviceIDâ value=âAN45577â
classes
class
name=âsof_app.SOFTestâ
classes
test
suite
<> </> syntex removed
Hi,
I am trying to run two scripts on different mobile(Nexus and Samsung).
I have 2 nodeconfig.json files each having the config of devices. I am starting 2 appium servers with different node config specified in general settings. When i check the grid console i see that both the devices are appearing as Node.
In testng.xml i have specified different tests. When they are executed sequentially all the scripts are executed on a single mobile even though desired capabilities mentioned in the test script are different.
I am currently using :
appium: 1.2.0.0
OS windows
Android devices: Nexus and Samsung
Device OS: 5.0 and 4.3
Please let me know if i am missing any thing which is making the script to run on same device even though the desired capabilities mentioned are different in each test script.
JSON:
File 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
}
}
File 2:
{
â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
}
}
I have attached the test scripts and testng.xml info.txt (7.3 KB) for reference. Any help would be appriciated.
Thanks and regards,
M.Karthik
Hi All,
Configuration to run test parallel on multiple device:
Prerequisite: 1. Start selenium grid on 127.0.0.1
2. Register multiple appium node on grid with different port
XML file:
suite name=âLogintestsuite:â parallel=âtestsâ thread-count=â5â verbose="1
test name=âfirstTest on fiest mobileâ
parameter name=âDeviceIDâ value=âTA9asdsda33071OQâ
classes
class
name=âpackage.testfilenameâ
classes
test
test name="firstTest on second mobile "
parameter name=âDeviceIDâ value=âAN45577â
classes
class
name=âpackage.testfilenameâ
classes
test
suite
<> </> syntex removed
Test File:
package arvind;
public class LoginTest{
public String appionlicatPath = "//....apk";
public String emulator_device_1 ="emulator-5554";
public String emulator_device_2 ="emulator-5556";
public String MobileDevice_1 ="D1";
public String MobileDevice_2 ="D2";
public static DesiredCapabilities capabilities = new DesiredCapabilities();
@Parameters("DeviceID")
@BeforeTest
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");
}
if(DeviceID.equalsIgnoreCase("first")){
setcapabilities(appionlicatPath, emulator_device_1,"Appium");
}
if(DeviceID.equalsIgnoreCase("second")){
setcapabilities(appionlicatPath, emulator_device_1,"Appium");
}
if(DeviceID.equalsIgnoreCase("chrome")){
setChromeCapabilities(emulator_device_1,"Appium");
}
driver = new AndroidDriver(new URL("http://127.0.0.1:4444/wd/hub"),capabilities);
driver.manage().timeouts().implicitlyWait(80, TimeUnit.SECONDS);
}
@ AfterTest(alwaysRun= true)
public void tearDown(){
driver.quit();
}
@Test()
public void loginTest() throws InterruptedException{
Thread.sleep(10000L);
homepage.loginButton();
registerpage.login("[email protected]", "abcd");
Assert.assertTrue("User not loggedIn", homepage.isTestPresent("Log Out"));
public void setcapabilities(String apppath,String device,String automation){
File app = new File(apppath);
capabilities.setCapability("deviceName", device);
capabilities.setCapability("automationName",automation);
capabilities.setCapability("appium-version", "1.2.2");
capabilities.setCapability("platformName", "Android");
capabilities.setCapability("platformVersion", "4.4.2");
capabilities.setCapability("app", app.getAbsolutePath());
}
hope this is helpful for appium grid setup.
Question welcomed
Hi @Arvind_Patel,
I tried below mentioned steps:
1)Launch grid at localhost:4444
2)Launch appium with nodeConfig.json and start it i.e. appium started at 127.0.0.1:4723
3)Launch appium with nodeConfig1.json and start it i.e. appium started at 127.0.0.1:4728
Prepare testng.xml as shown below:
suite name=âSuiteâ parallel=âtestsâ thread-count=â5â verbose=â1â
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
Have beforemethod parametarized:
@Parameters (âDevice_IDâ)
@BeforeMethod
public void setUp(String device)throws MalformedURLException {
System.out.println(device);
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(âno mob existsâŚâ);
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);
}
@Parameters(âDevice_IDâ)
@BeforeMethod
public void setup(String device)throws Exception
{
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(âno mobâŚexistsâ);
break;
}
driver= new AppiumDriver(new URL(âhttp://127.0.0.1:4723/wd/hubâ), capabilities);
//driver = new AppiumDriver(new URL("http://localhost:4444/wd/hub"), capabilities);
}
When executed, out of 2 tests 1 of them failâŚ
when only Test2 is executed, even though device id is mentioned it is getting executed on another device.
Please suggest what needs to be doneâŚ
Thanks and regards,
M.Karthik
Hi @karthik_holla,
You are launching the second test directly on the first appium server (port 4723):
You must use the hub url:
driver = new AppiumDriver(new URL("http://localhost:4444/wd/hub"), capabilities);
And the hub will redirect your test to the properly appium server depending on âbrowserNameâ, âversionâ and âplatformâ capabilities.
@rgonalo sorryâŚmy mistakeâŚthank you for correcting me⌠will try this and verifyâŚ