Tutorial: Appium Android configuration on Eclipse IDE
Appium is an open source test automation framework for use with native and hybrid mobile apps. It drives iOS and Android apps using the WebDriver JSON wire protocol. It’s a great tool for automating mobile apps. Here is a step-by-step tutorial for configuring Appium tool for Android apps automation.
We will use Eclipse and TestNG framework to run Appium automated test on Android device/emulator(If you have not configured TestNG on Eclipse, refer this tutorial). Let’s check out prerequisites of this setup process.
Prerequisites:
-
Android SDK installed in system.
-
Appium (You can get it from official Appium site)
-
.NET Framerork 4.5
-
Eclipse
-
TestNG and Selenium 2 JARs
We will now start setting up Appium Android configuration from scratch. Follow below steps for the same.
- Install Android SDK in your system.
- Set ANDROID_HOME environment variable which points to your SDK directory’s \sdk\ folder.
- Append ‘%ANDROID_HOME%\platform-tools’ value to your PATH environment variable.
- Start your Android emulator or connect your Android device to your system (Make sure you have Android Debugging option enabled in your Android device).
- Open Command Prompt and navigate to your Android SDK’s \platform-tools\ directory (Eg. D:\adt-bundle-windows-x86_64-20130514\sdk\platform-tools).
- Run ‘adb devices’ command. You should see your connected devices listed in Command Prompt window.
- Run ‘adb start-server’ command. It will start ADB server which will be used by Appium to send commands to your Android device.
- Now, navigate to Appium directory in your system and start Appium by clicking Appium.exe file.
- Click Launch button. Your Appium console should be displayed as below.
- Create a Java project in your Eclipse and reference Selenium 2 and TestNG JARs.
- Create a new Java class in your project and enter below code.
1234567891011121314151617181920212223242526272829303132333435363738394041package com.appiumproj.test;import java.net.MalformedURLException;import java.net.URL;import org.openqa.selenium.By;import org.openqa.selenium.WebDriver;import org.openqa.selenium.remote.CapabilityType;import org.openqa.selenium.remote.DesiredCapabilities;import org.openqa.selenium.remote.RemoteWebDriver;import org.testng.annotations.AfterClass;import org.testng.annotations.BeforeClass;import org.testng.annotations.Test;public class Appium {WebDriver driver;@BeforeClasspublic void setUp() throws MalformedURLException{DesiredCapabilities capabilities = new DesiredCapabilities();capabilities.setCapability("device", "Android");capabilities.setCapability(CapabilityType.BROWSER_NAME, ""); //Name of mobile web browser to automate. Should be an empty string if automating an app instead.capabilities.setCapability(CapabilityType.VERSION, "4.4");capabilities.setCapability(CapabilityType.PLATFORM, "Windows");capabilities.setCapability("app-package", "APP PACKAGE"); //Replace with your app's packagecapabilities.setCapability("app-activity", "APP PACKAGE.ANDROID ACTIVITY"); //Replace with app's Activitydriver = new RemoteWebDriver(new URL("http://127.0.0.1:4723/wd/hub"), capabilities);}@Testpublic void Cal(){driver.findElement(By.name("Weather")).click();}@AfterClasspublic void tearDown(){driver.quit();}}
- Run your test using TestNG.
Let us know in the comments how this Appium Android configuration tutorial work for you.
Cheers!
Correct me if I’m wrong but in Appium, if you are trying to test an App (vs testing websites on the mobile browser) you set the BROWSER_NAME capability to an empty string, not to “Android”
Capabilities.setCapability(CapabilityType.BROWSER_NAME, “Android”);
Changes to:
Capabilities.setCapability(CapabilityType.BROWSER_NAME, “”);
Yes, that’s true. Thanks for pointing it out. Updated the code.
Wow!
very nice and it is very detail…
Glad you liked it. 🙂
Thanks for sharing this information.It was very nice blog to learn about Appium .
http://thecreatingexperts.com/appium-training-in-chennai/
Great info! still I’m facing some issue on running the code, can you please help me ?, I’m trying to run the Android app on real device, while running the code I’m getting the following error in eclipse
“FAILED CONFIGURATION: @BeforeMethod setupAppium
org.openqa.selenium.UnsupportedCommandException: That URL did not map to a valid JSONWP resource
Command duration or timeout: 312 milliseconds
Build info: version: ‘2.39.0’, revision: ‘ff23eac’, time: ‘2013-12-16 16:11:15’
System info: host: ‘BPA-CH-L019’, ip: ‘192.168.10.24’, os.name: ‘Windows 7’, os.arch: ‘x86’, os.version: ‘6.1’, java.version: ‘1.7.0_71’
Driver info: org.openqa.selenium.remote.RemoteWebDriver”
It says below in Appium.exe,
> Starting Node Server
> info: Welcome to Appium v1.3.4 (REV c8c79a85fbd6870cd6fc3d66d038a115ebe22efe)
> info: Appium REST http interface listener started on 127.0.0.1:4723
> info: [debug] Non-default server args: {“app”:”C:\\Users\\Pavithra\\Desktop\\adt-bundle-windows-x86-20140702\\sdk\\build-tools\\android-4.4W\\MatrixApp.apk”,”address”:”127.0.0.1″,”logNoColors”:true,”platformName”:”Android”,”platformVersion”:”19″,”automationName”:”Appium”}
> info: Console LogLevel: debug
> info: –> POST /wb/hub/session {“desiredCapabilities”:{“platform”:”Windows”,”browserName”:””,”app-package”:”com.acinfotech.matrix”,”device”:”Android”,”app-activity”:”SplashScreenActivity”,”version”:”4.4″}}
> info: [debug] Responding to client that we did not find a valid resource
> info: <– POST /wb/hub/session 404 15.752 ms – 47
Thanks in advance,
Not sure what may be causing the issue but try changing URL to http://127.0.0.1:4723/wd/hub/status.
Iam getting below error
*********************************************
FAILED CONFIGURATION: @BeforeClass setUp
org.openqa.selenium.remote.UnreachableBrowserException: Could not start a new session. Possible causes are invalid address of the remote server or browser start-up failure.
Build info: version: ‘2.44.0’, revision: ’76d78cf’, time: ‘2014-10-23 20:02:37’
System info: host: ‘B1450F1D’, ip: ‘172.25.22.140’, os.name: ‘Windows 7’, os.arch: ‘amd64’, os.version: ‘6.1’, java.version: ‘1.8.0_25’
Driver info: driver.version: RemoteWebDriver
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:593)
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 PracticeOnline.setUp(PracticeOnline.java:24)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:483)
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.invokeConfigurations(Invoker.java:138)
at org.testng.internal.TestMethodWorker.invokeBeforeClassMethods(TestMethodWorker.java:175)
at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:107)
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)
at org.testng.TestNG.run(TestNG.java:1057)
at org.testng.remote.RemoteTestNG.run(RemoteTestNG.java:111)
at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:204)
at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:175)
Caused by: org.apache.http.conn.HttpHostConnectException: Connect to 127.0.0.1:4723 [/127.0.0.1] failed: Connection refused: connect
at org.apache.http.impl.conn.HttpClientConnectionOperator.connect(HttpClientConnectionOperator.java:140)
at org.apache.http.impl.conn.PoolingHttpClientConnectionManager.connect(PoolingHttpClientConnectionManager.java:318)
at org.apache.http.impl.execchain.MainClientExec.establishRoute(MainClientExec.java:363)
at org.apache.http.impl.execchain.MainClientExec.execute(MainClientExec.java:219)
at org.apache.http.impl.execchain.ProtocolExec.execute(ProtocolExec.java:195)
at org.apache.http.impl.execchain.RetryExec.execute(RetryExec.java:86)
at org.apache.http.impl.execchain.RedirectExec.execute(RedirectExec.java:108)
at org.apache.http.impl.client.InternalHttpClient.doExecute(InternalHttpClient.java:184)
at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:72)
at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:57)
at org.openqa.selenium.remote.HttpCommandExecutor.fallBackExecute(HttpCommandExecutor.java:215)
at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:184)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:572)
… 28 more
Caused by: java.net.ConnectException: Connection refused: connect
at java.net.DualStackPlainSocketImpl.waitForConnect(Native Method)
at java.net.DualStackPlainSocketImpl.socketConnect(DualStackPlainSocketImpl.java:85)
at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:345)
at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206)
at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188)
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:172)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
at java.net.Socket.connect(Socket.java:589)
at org.apache.http.conn.socket.PlainConnectionSocketFactory.connectSocket(PlainConnectionSocketFactory.java:72)
at org.apache.http.impl.conn.HttpClientConnectionOperator.connect(HttpClientConnectionOperator.java:123)
… 40 more
SKIPPED CONFIGURATION: @AfterClass tearDown
SKIPPED: Cal
===============================================
Default test
Tests run: 1, Failures: 0, Skips: 1
Configuration Failures: 1, Skips: 1
===============================================
===============================================
Default suite
Total tests run: 1, Failures: 0, Skips: 1
Configuration Failures: 1, Skips: 1
===============================================
[TestNG] Time taken by org.testng.reporters.JUnitReportReporter@626b2d4a: 15 ms
[TestNG] Time taken by org.testng.reporters.SuiteHTMLReporter@73a8dfcc: 75 ms
[TestNG] Time taken by org.testng.reporters.EmailableReporter2@6f2b958e: 10 ms
[TestNG] Time taken by [FailedReporter passed=0 failed=0 skipped=0]: 6 ms
[TestNG] Time taken by org.testng.reporters.jq.Main@aec6354: 42 ms
[TestNG] Time taken by org.testng.reporters.XMLReporter@c2e1f26: 9 ms
i am getting error timeout while trying to contact RemoteTestNG. Any ideas?
I am looking to set up mock data on IOS device and while opening the app it should have been preset on the setting while opening the app.Do you have idea how do we set this programitcally on Appium
I am getting Error java.lang.VerifyError: org/openqa/selenium/remote/JsonToBeanConverter
at org.openqa.selenium.remote.http.JsonHttpCommandCodec.(JsonHttpCommandCodec.java:48)
at org.openqa.selenium.remote.HttpCommandExecutor.(HttpCommandExecutor.java:93)
at org.openqa.selenium.remote.HttpCommandExecutor.(HttpCommandExecutor.java:81)
at org.openqa.selenium.remote.RemoteWebDriver.(RemoteWebDriver.java:153)
at io.appium.java_client.AppiumDriver.(AppiumDriver.java:109)
at com.example.learningtasks.test.AppiumTest$1.(AppiumTest.java:40)
at com.example.learningtasks.test.AppiumTest.setUp(AppiumTest.java:40)
at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:169)
at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:154)
at android.test.InstrumentationTestRunner.onStart(InstrumentationTestRunner.java:537)
at android.app.Instrumentation$InstrumentationThread.run(Instrumentation.java:1677)
I am having problems with this tutorial as well. I am brand new to Appium so I may need a bit more hand holding here as to what I should change. Here is the error I am getting. I coped and pasted the code above but now see I need to change some things. Not sure what to do with “app package” so any info would be appreciated.
[TestNG] Running:
C:\Users\Janet\AppData\Local\Temp\testng-eclipse-41689240\testng-customsuite.xml
FAILED CONFIGURATION: @BeforeClass setUp
org.openqa.selenium.SessionNotCreatedException: A new session could not be created. (Original error: The following desired capabilities are required, but were not provided: platformName, deviceName) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 625 milliseconds
Build info: version: ‘2.42.2’, revision: ‘6a6995d’, time: ‘2014-06-03 17:42:03’
System info: host: ‘Janet-PC’, ip: ‘192.168.1.2’, os.name: ‘Windows 7’, os.arch: ‘x86’, os.version: ‘6.1’, java.version: ‘1.7.0_75’
Driver info: org.openqa.selenium.remote.RemoteWebDriver
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
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 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 AppiumProject.Appium.setUp(Appium.java:28)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
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.invokeConfigurations(Invoker.java:138)
at org.testng.internal.TestMethodWorker.invokeBeforeClassMethods(TestMethodWorker.java:175)
at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:107)
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)
at org.testng.TestNG.run(TestNG.java:1057)
at org.testng.remote.RemoteTestNG.run(RemoteTestNG.java:111)
at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:204)
at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:175)
SKIPPED CONFIGURATION: @AfterClass tearDown
SKIPPED: Cal
===============================================
Default test
Tests run: 1, Failures: 0, Skips: 1
Configuration Failures: 1, Skips: 1
===============================================
No need to change $ANDROID_HOME variable if you can successfully fire adb command from you command line, and there is SDK path in your $PATH variable…,
besides this you don’t need to specify app package name if you are planning to test whole application… from given apk , beside this I can help you more if you post whole @BeforeClass/@Before method declaration.
Here is my code. Thanks!!!
package AppiumProject;
import java.net.MalformedURLException;
import java.net.URL;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.remote.CapabilityType;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.remote.RemoteWebDriver;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
public class Appium {
WebDriver driver;
@BeforeClass
public void setUp() throws MalformedURLException{
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability(“device”, “Android”);
capabilities.setCapability(CapabilityType.BROWSER_NAME, “Chrome”); //Name of mobile web browser to automate. Should be an empty string if automating an app instead.
capabilities.setCapability(CapabilityType.VERSION, “5.0”);
capabilities.setCapability(CapabilityType.PLATFORM, “Windows”);
// capabilities.setCapability(“app-package”, “APP PACKAGE”); //Replace with your app’s package
// capabilities.setCapability(“app-activity”, “APP PACKAGE.ANDROID ACTIVITY”); //Replace with app’s Activity
driver = new RemoteWebDriver(new URL(“http://127.0.0.1:4723/wd/hub”), capabilities);
}
@Test
public void Cal(){
// driver.findElement(By.name(“Weather”)).click();
driver.navigate().to(“http://www.facebook.com”);
}
@AfterClass
public void tearDown(){
driver.quit();
}
}
package AppiumProject;
import java.net.MalformedURLException;
import java.net.URL;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.remote.CapabilityType;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.remote.RemoteWebDriver;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
public class Appium {
WebDriver driver;
@BeforeClass
public void setUp() throws MalformedURLException{
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability(“device”, “Android”);
capabilities.setCapability(CapabilityType.BROWSER_NAME, “Chrome”); //Name of mobile web browser to automate. Should be an empty string if automating an app instead.
capabilities.setCapability(CapabilityType.VERSION, “5.0”);
capabilities.setCapability(CapabilityType.PLATFORM, “Windows”);
// capabilities.setCapability(“app-package”, “APP PACKAGE”); //Replace with your app’s package
// capabilities.setCapability(“app-activity”, “APP PACKAGE.ANDROID ACTIVITY”); //Replace with app’s Activity
driver = new RemoteWebDriver(new URL(“http://127.0.0.1:4723/wd/hub”), capabilities);
}
@Test
public void Cal(){
// driver.findElement(By.name(“Weather”)).click();
driver.navigate().to(“http://www.facebook.com”);
}
@AfterClass
public void tearDown(){
driver.quit();
}
}
One other thing. How do I change the ANDROID_HOME variable?? Could that be my problem??
Sorry I did not see that the comment with my code had posted before. I am new to changing variables on the computer so how can I check the $PATH variable to be sure that it is correct. Thanks!!
Can I see a screenshot of how to set the Android Settings and the device. I am using a Samsung Galaxy S5
This is what I get when I launch Appium:
> Starting Node Server
> usage: main.js [-h] [-v] [–shell]
> [–localizable-strings-dir LOCALIZABLESTRINGSDIR] [–app APP]
> [–ipa IPA] [-U UDID] [-a ADDRESS] [-p PORT]
> [-ca CALLBACKADDRESS] [-cp CALLBACKPORT] [-bp BOOTSTRAPPORT]
> [-k] [-r BACKENDRETRIES] [–session-override] [–full-reset]
> [–no-reset] [-l] [-lt LAUNCHTIMEOUT] [-g LOG]
> [–log-level {info,info:debug,info:info,info:warn,info:error,warn,warn:debug,warn:info,warn:warn,warn:error,error,error:debug,error:info,error:warn,error:error,debug,debug:debug,debug:info,debug:warn,debug:error}]
> [–log-timestamp] [–local-timezone] [–log-no-colors]
> [-G WEBHOOK] [–native-instruments-lib]
> [–app-pkg ANDROIDPACKAGE] [–app-activity ANDROIDACTIVITY]
> [–app-wait-package ANDROIDWAITPACKAGE]
> [–app-wait-activity ANDROIDWAITACTIVITY]
> [–android-coverage ANDROIDCOVERAGE] [–avd AVD]
>
> [–avd-args AVDARGS]
> [–device-ready-timeout ANDROIDDEVICEREADYTIMEOUT] [–safari]
> [–device-name DEVICENAME] [–platform-name PLATFORMNAME]
> [–platform-version PLATFORMVERSION]
> [–automation-name AUTOMATIONNAME] [–browser-name BROWSERNAME]
> [–default-device] [–force-iphone] [–force-ipad]
> [–language LANGUAGE] [–locale LOCALE]
> [–calendar-format CALENDARFORMAT] [–orientation ORIENTATION]
> [–tracetemplate AUTOMATIONTRACETEMPLATEPATH] [–show-sim-log]
> [–show-ios-log] [–nodeconfig NODECONFIG] [-ra ROBOTADDRESS]
> [-rp ROBOTPORT] [–selendroid-port SELENDROIDPORT]
> [–chromedriver-port CHROMEDRIVERPORT]
> [–chromedriver-executable CHROMEDRIVEREXECUTABLE]
> [–use-keystore] [–keystore-path KEYSTOREPATH]
> [–keystore-password KEYSTOREPASSWORD] [–key-alias KEYALIAS]
> [–key-password KEYPASSWORD] [–show-config] [–no-perms-check]
> [–command-timeout DEFAULTCOMMANDTIMEOUT] [–keep-keychains]
> [–strict-caps] [–isolate-sim-device] [–tmp TMPDIR]
> [–trace-dir TRACEDIR] [–intent-action INTENTACTION]
> [–intent-category INTENTCATEGORY] [–intent-flags INTENTFLAGS]
> [–intent-args OPTIONALINTENTARGUMENTS]
>
>
> Node Server Process Ended
I have appium running for my device and my phone does something. All I want my test to do is open Chrome and go to Yahoo home page. I am attaching my error messages and my code. Thanks!!
[TestNG] Running:
C:\Users\Janet\AppData\Local\Temp\testng-eclipse–1888407039\testng-customsuite.xml
FAILED CONFIGURATION: @BeforeClass setUp
org.openqa.selenium.SessionNotCreatedException: A new session could not be created. (Original error: Did not get session redirect from Chromedriver) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 50.95 seconds
Build info: version: ‘2.42.2’, revision: ‘6a6995d’, time: ‘2014-06-03 17:42:03’
System info: host: ‘Janet-PC’, ip: ‘192.168.1.2’, os.name: ‘Windows 7’, os.arch: ‘x86’, os.version: ‘6.1’, java.version: ‘1.7.0_75’
Driver info: org.openqa.selenium.remote.RemoteWebDriver
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
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 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 AppiumProject.Appium.setUp(Appium.java:30)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
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.invokeConfigurations(Invoker.java:138)
at org.testng.internal.TestMethodWorker.invokeBeforeClassMethods(TestMethodWorker.java:175)
at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:107)
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)
at org.testng.TestNG.run(TestNG.java:1057)
at org.testng.remote.RemoteTestNG.run(RemoteTestNG.java:111)
at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:204)
at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:175)
SKIPPED CONFIGURATION: @AfterClass tearDown
SKIPPED: Cal
===============================================
Default test
Tests run: 1, Failures: 0, Skips: 1
Configuration Failures: 1, Skips: 1
===============================================
===============================================
Default suite
Total tests run: 1, Failures: 0, Skips: 1
Configuration Failures: 1, Skips: 1
===============================================
[TestNG] Time taken by org.testng.reporters.JUnitReportReporter@6d8d73: 12 ms
[TestNG] Time taken by org.testng.reporters.XMLReporter@d4b473: 17 ms
[TestNG] Time taken by [FailedReporter passed=0 failed=0 skipped=0]: 13 ms
[TestNG] Time taken by org.testng.reporters.EmailableReporter2@14943d6: 9 ms
[TestNG] Time taken by org.testng.reporters.SuiteHTMLReporter@fbd45: 44 ms
[TestNG] Time taken by org.testng.reporters.jq.Main@1963273: 54 ms
My code:
package AppiumProject;
import java.net.MalformedURLException;
import java.net.URL;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.remote.CapabilityType;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.remote.RemoteWebDriver;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
public class Appium {
WebDriver driver;
@BeforeClass
public void setUp() throws MalformedURLException{
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability(“device”, “Android”);
capabilities.setCapability(“deviceName”, “Android”);
capabilities.setCapability(“platformName”, “Android”);
capabilities.setCapability(CapabilityType.BROWSER_NAME, “Chrome”); //Name of mobile web browser to automate. Should be an empty string if automating an app instead.
capabilities.setCapability(CapabilityType.VERSION, “5.0”);
capabilities.setCapability(CapabilityType.PLATFORM, “Android”);
// capabilities.setCapability(“app-package”, “APP PACKAGE”); //Replace with your app’s package
// capabilities.setCapability(“app-activity”, “APP PACKAGE.ANDROID ACTIVITY”); //Replace with app’s Activity
driver = new RemoteWebDriver(new URL(“http://127.0.0.1:4723/wd/hub”), capabilities);
}
@Test
public void Cal(){
// driver.findElement(By.name(“Weather”)).click();
driver.navigate().to(“http://www.yahoo.com”);
}
@AfterClass
public void tearDown(){
driver.quit();
}
}
Hey make sure you started appium server in terminal…
Hi All, i am new to mobile automation and i would like to learn Appium as well as i need some job support on it. Please help me on this i will pay you for training and job support.
HI all,
How we get the package and activity name from the .apk file….
Himashu – To get package and activity name, you need to install APkINFo app. with the help of APKINFO app you can find the package name and activity name of required app.
Use apk info, download from google play store and select specific app from list to get info
HI
Please help getting the below error
[TestNG] Running:
C:\Users\pratik\AppData\Local\Temp\testng-eclipse–53361981\testng-customsuite.xml
FAILED CONFIGURATION: @BeforeClass setUp
org.openqa.selenium.SessionNotCreatedException: A new session could not be created. (Original error: Requested a new session but one was in progress) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 539 milliseconds
Build info: version: ‘2.47.1’, revision: ‘411b314’, time: ‘2015-07-30 02:56:46’
System info: host: ‘pratik-PC’, ip: ‘192.168.147.1’, os.name: ‘Windows 7’, os.arch: ‘amd64’, os.version: ‘6.1’, java.version: ‘1.8.0_45’
Driver info: org.openqa.selenium.remote.RemoteWebDriver
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:422)
at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:206)
at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:158)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:595)
at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:242)
at org.openqa.selenium.remote.RemoteWebDriver.(RemoteWebDriver.java:128)
at org.openqa.selenium.remote.RemoteWebDriver.(RemoteWebDriver.java:155)
at new_project.NewTest.setUp(NewTest.java:71)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:85)
at org.testng.internal.Invoker.invokeConfigurationMethod(Invoker.java:515)
at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:213)
at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:140)
at org.testng.internal.TestMethodWorker.invokeBeforeClassMethods(TestMethodWorker.java:170)
at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:104)
at org.testng.TestRunner.privateRun(TestRunner.java:771)
at org.testng.TestRunner.run(TestRunner.java:621)
at org.testng.SuiteRunner.runTest(SuiteRunner.java:357)
at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:352)
at org.testng.SuiteRunner.privateRun(SuiteRunner.java:310)
at org.testng.SuiteRunner.run(SuiteRunner.java:259)
at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)
at org.testng.TestNG.runSuitesSequentially(TestNG.java:1176)
at org.testng.TestNG.runSuitesLocally(TestNG.java:1101)
at org.testng.TestNG.run(TestNG.java:1009)
at org.testng.remote.RemoteTestNG.run(RemoteTestNG.java:111)
at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:204)
at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:175)
SKIPPED CONFIGURATION: @AfterClass teardown
SKIPPED: festivals_list
SKIPPED: Daily_Panchang
SKIPPED: Daily_Muhurat
===============================================
Default test
Tests run: 3, Failures: 0, Skips: 3
Configuration Failures: 1, Skips: 1
===============================================
===============================================
Default suite
Total tests run: 3, Failures: 0, Skips: 3
Configuration Failures: 1, Skips: 1
===============================================
[TestNG] Time taken by org.testng.reporters.XMLReporter@6073f712: 176 ms
[TestNG] Time taken by org.testng.reporters.SuiteHTMLReporter@61064425: 250 ms
[TestNG] Time taken by org.testng.reporters.jq.Main@6bc168e5: 382 ms
[TestNG] Time taken by org.testng.reporters.EmailableReporter2@3abfe836: 29 ms
[TestNG] Time taken by [FailedReporter passed=0 failed=0 skipped=0]: 8 ms
[TestNG] Time taken by org.testng.reporters.JUnitReportReporter@532760d8: 20 ms
HI My test gives the following log:
The following desired capabilities are required, but were not provided: platformName, deviceName
My code is exactly as given above. Do i have to add those capabilities to make it work?
I’m having the exact same error while running a Nexus 5 emulator. I’m not sure what the platformName and deviceName should be for the desired capabilities object.
This is what mine looks like:
caps.setCapability(“platformName”, “Android”);
caps.setCapability(“deviceName”, “Nexus 5”);
Remove the “CapabilityType” and just leave platformName and deviceName…
UnreachableBrowserException cannot start a new Session
Someone know what’s the problem?
Hi,
I tried to run the code. I was able to launch the application in the real time device(i.e @BeforeClass got executed ) but after that I was not able to execute the other methods(i.e @Test). It does not give any error. appium waits for some time and then it closes the app saying that “no further instructions were recieved so closing Appium”. Can you please help me.