@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
- Created a Hub by using
java -jar selenium-server-standalone-2.45.0.jar -role hub - 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 ?