stf-appium-example icon indicating copy to clipboard operation
stf-appium-example copied to clipboard

Appium Java example

Open xchgaur opened this issue 8 years ago • 0 comments

Hi Vishal, Could you please provide a working java example for appium test execution. I am trying to run one from remote machine, but the udid I get after remote connection, does not seem to be accepted by adb commands.I get below error:

Results :

Failed tests: setup(com.vimalselvam.stf.AndroidTest): An unknown server-side error occurred while processing the command. Original error: Error in waiting for device. Original error: 'Error executing adbExec. Original error: 'Command '/Users/gachauha/Library/Android/sdk/platform-tools/adb -P 5037 -s 10.41.17.66:7401 wait-for-device' exited with code 1'; Stderr: 'error: unknown host service'; Code: '1''. Retrying by restarting ADB (WARNING: The server did not provide any stacktrace information)(..)

Tests run: 4, Failures: 1, Errors: 0, Skipped: 3

Complete log:


T E S T S

Running com.vimalselvam.stf.AndroidTest Configuring TestNG with: org.apache.maven.surefire.testng.conf.TestNG652Configurator@4361bd48 [Appium] Welcome to Appium v1.7.1 [Appium] Appium REST http interface listener started on 0.0.0.0:4723 [HTTP] --> GET /wd/hub/status {} [debug] [MJSONWP] Calling AppiumDriver.getStatus() with args: [] [debug] [MJSONWP] Responding to client with driver.getStatus() result: {"build":{"version":"1.7.1","revision":null}} [HTTP] <-- GET /wd/hub/status 200 12 ms - 83 [HTTP] --> POST /wd/hub/session {"desiredCapabilities":{"app":"/Users/gachauha/stf-appium/appium-stf-example/src/test/resources/ApiDemos-debug.apk","platformName":"Android","deviceName":"ANDROID"}} [debug] [MJSONWP] Calling AppiumDriver.createSession() with args: [{"app":"/Users/gachauha/stf-appium/appium-stf-example/src/test/resources/ApiDemos-debug.apk","platformName":"Android","deviceName":"ANDROID"},null,null] [debug] [BaseDriver] Event 'newSessionRequested' logged at 1512644652627 (16:34:12 GMT+0530 (IST)) [Appium] Creating new AndroidDriver (v1.28.1) session [Appium] Capabilities: [Appium] app: '/Users/gachauha/stf-appium/appium-stf-example/src/test/resources/ApiDemos-debug.apk' [Appium] platformName: 'Android' [Appium] deviceName: 'ANDROID' [BaseDriver] Session created with session id: 3fd827a5-6ed5-49f5-860d-98432815b55d [debug] [AndroidDriver] Getting Java version [AndroidDriver] Java version is: 1.8.0_144 [ADB] Checking whether adb is present [ADB] Using adb from /Users/gachauha/Library/Android/sdk/platform-tools/adb [AndroidDriver] Retrieving device list [debug] [ADB] Trying to find a connected android device [debug] [ADB] Getting connected devices... [debug] [ADB] 1 device(s) connected [AndroidDriver] Using device: 10.41.17.66:7401 [ADB] Checking whether adb is present [ADB] Using adb from /Users/gachauha/Library/Android/sdk/platform-tools/adb [debug] [ADB] Setting device id to 10.41.17.66:7401 [BaseDriver] Using local app '/Users/gachauha/stf-appium/appium-stf-example/src/test/resources/ApiDemos-debug.apk' [debug] [AndroidDriver] Checking whether app is actually present [AndroidDriver] Starting Android session [debug] [ADB] Running '/Users/gachauha/Library/Android/sdk/platform-tools/adb' with args: ["-P",5037,"-s","10.41.17.66:7401","wait-for-device"] [debug] [ADB] Running '/Users/gachauha/Library/Android/sdk/platform-tools/adb' with args: ["-P",5037,"-s","10.41.17.66:7401","wait-for-device"] [debug] [ADB] Restarting adb [debug] [ADB] Killing adb server on port 5037 [debug] [ADB] Getting connected devices... [debug] [ADB] 1 device(s) connected [ADB] Error: Error in waiting for device. Original error: 'Error executing adbExec. Original error: 'Command '/Users/gachauha/Library/Android/sdk/platform-tools/adb -P 5037 -s 10.41.17.66:7401 wait-for-device' exited with code 1'; Stderr: 'error: unknown host service'; Code: '1''. Retrying by restarting ADB at Object.wrappedLogger.errorAndThrow (../../lib/logging.js:63:13) at ADB.callee$1$0$ (../../../lib/tools/system-calls.js:733:11) at tryCatch (/usr/local/lib/node_modules/appium/node_modul[dees/babel-runtime/regenerator/runtime.js:67:40) at Genbug] [ADB] Running '/Users/gachauha/LibrareratorFunctionPrototype.invoke [as _invoke] (/usr/local/lib/node_modules/appium/node_my/Android/sdk/platform-tools/adb' with args: ["-Podu",5037les/babel-runtime/regenerator/runtime.js:315:22) at G,"-s"e,"10.41.17.ne66:7401","wairatorFunctionPrototype.prototype.(t-for-device"] anonymous function) [as next] (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:100:21) at GeneratorFunctionPrototype.invoke (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:136:37) at at process._tickCallback (internal/process/next_tick.js:188:7) Error: Error in waiting for device. Original error: 'Error executing adbExec. Original error: 'Command '/Users/gachauha/Library/Android/sdk/platform-tools/adb -P 5037 -s 10.41.17.66:7401 wait-for-device' exited with code 1'; Stderr: 'error: unknown host service'; Code: '1''. Retrying by restarting ADB at Object.wrappedLogger.errorAndThrow (../../lib/logging.js:63:13) at ADB.callee$1$0$ (../../../lib/tools/system-calls.js:733:11) at tryCatch (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:67:40) at GeneratorFunctionPrototype.invoke [as _invoke] (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:315:22) at GeneratorFunctionPrototype.prototype.(anonymous function) [as next] (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:100:21) at GeneratorFunctionPrototype.invoke (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:136:37) at at process._tickCallback (internal/process/next_tick.js:188:7) [debug] [ADB] Running '/Users/gachauha/Library/Android/sdk/platform-tools/adb' with args: ["-P",5037,"-s","10.41.17.66:7401","wait-for-device"] [debug] [ADB] Restarting adb [debug] [ADB] Killing adb server on port 5037 [debug] [ADB] Getting connected devices... [debug] [ADB] 1 device(s) connected [ADB] Error: Error in waiting for device. Original error: 'Error executing adbExec. Original error: 'Command '/Users/gachauha/Library/Android/sdk/platform-to[debug] [ADB] Runningols/ '/Uadb -P 5037 -s 10se.4rs/gacha1.17.6uha/Libr6:7401 wait-for-device' exited wary/Android/sdk/platform-tools/adb' with args: ["-P",5037,"-s","10.41.17.66:7401","wait-for-device"] ith code 1'; Stderr: 'error: unknown host service'; Code: '1''. Retrying by restarting ADB at Object.wrappedLogger.errorAndThrow (../../lib/logging.js:63:13) at ADB.callee$1$0$ (../../../lib/tools/system-calls.js:733:11) at tryCatch (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:67:40) at GeneratorFunctionPrototype.invoke [as _invoke] (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:315:22) at GeneratorFunctionPrototype.prototype.(anonymous function) [as next] (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:100:21) at GeneratorFunctionPrototype.invoke (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:136:37) at at process._tickCallback (internal/process/next_tick.js:188:7) Error: Error in waiting for device. Original error: 'Error executing adbExec. Original error: 'Command '/Users/gachauha/Library/Android/sdk/platform-tools/adb -P 5037 -s 10.41.17.66:7401 wait-for-device' exited with code 1'; Stderr: 'error: unknown host service'; Code: '1''. Retrying by restarting ADB at Object.wrappedLogger.errorAndThrow (../../lib/logging.js:63:13) at ADB.callee$1$0$ (../../../lib/tools/system-calls.js:733:11) at tryCatch (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:67:40) at GeneratorFunctionPrototype.invoke [as _invoke] (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:315:22) at GeneratorFunctionPrototype.prototype.(anonymous function) [as next] (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:100:21) at GeneratorFunctionPrototype.invoke (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:136:37) at at process._tickCallback (internal/process/next_tick.js:188:7) [debug] [ADB] Running '/Users/gachauha/Library/Android/sdk/platform-tools/adb' with args: ["-P",5037,"-s","10.41.17.66:7401","wait-for-device"] [debug] [ADB] Restarting adb [debug] [ADB] Killing adb server on port 5037 [debug] [ADB] Getting connected devices... [debug] [ADB] 1 device(s) connected [ADB] Error: Error in waiting for device. Original error: 'Error executing adbExec. Original error: 'Command '/Users/gachauha/Library/Android/sdk/platform-tools/adb -P 5037 -s 10.41.17.66:7401 wait-for-device' exited with code 1'; Stderr: 'error: unknown host service'; Code: '1''. Retrying by restarting ADB at Object.wrappedLogger.errorAndThrow (../../lib/logging.js:63:13) at ADB.callee[d$1$0$ (ebug] [AndroidDriver../../..] Shutting dow/ln Android drib/toolives/system-calls.js:733:11) at tryCr atch (/usr/local/lib/node_modules/ap[depium/node_modules/babel-runtime/regenebugrato] [Anr/droidDriver] Caruntime.jslled :67:40) at GeneratorFunctiodelnPrototype.ineteSevokession but boot [as _invstroke] (/usr/localap /lib/node_modwaules/appiumsn'/node_modules/bt active abel[debug] [ADB] Ge-runtimetti/regenng connectederat devices..or/runtime.js:315:22) . at GeneratorFunctionPrototype.prototype.(anonymous function) [as next] (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:100:21) at GeneratorFunctionPrototype.invoke (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:136:37) at at process._tickCallback (internal/process/next_tick.js:188:7) Error: Error in waiting for device. Original error: 'Error executing adbExec. Original error: 'Command '/Users/gachauha/Library/Android/sdk/platform-tools/adb -P 5037 -s 10.41.17.66:7401 wait-for-device' exited with code 1'; Stderr: 'error: unknown host service'; Code: '1''. Retrying by restarting ADB at Object.wrappedLogger.errorAndThrow (../../lib/logging.js:63:13) at ADB.callee$1$0$ (../../../lib/tools/system-calls.js:733:11) at tryCatch (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:67:40) at GeneratorFunctionPrototype.invoke [as _invoke] (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:315:22) at GeneratorFunctionPrototype.prototype.(anonymous function) [as next] (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:100:21) at GeneratorFunctionPrototype.invoke (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:136:37) at at process._tickCallback (internal/process/next_tick.js:188:7) [debug] [ADB] 1 device(s) connected [debug] [ADB] Running '/Users/gachauha/Library/Android/sdk/platform-tools/adb' with args: ["-P",5037,"-s","10.41.17.66:7401","shell","am","force-stop","io.appium.unlock"] [debug] [ADB] Running '/Users/gachauha/Library/Android/sdk/platform-tools/adb' with args: ["-P",5037,"-s","10.41.17.66:7401","shell","am","force-stop","io.appium.unlock"] [MJSONWP] Encountered internal error running command: Error: Error in waiting for device. Original error: 'Error executing adbExec. Original error: 'Command '/Users/gachauha/Library/Android/sdk/platform-tools/adb -P 5037 -s 10.41.17.66:7401 wait-for-device' exited with code 1'; Stderr: 'error: unknown host service'; Code: '1''. Retrying by restarting ADB at Object.wrappedLogger.errorAndThrow (../../lib/logging.js:63:13) at ADB.callee$1$0$ (../../../lib/tools/system-calls.js:733:11) at tryCatch (/usr/local/lib/node_modules/appium/n[HTTP] <ode_modules/-- POST /wd/hub/sebabel-runtime/regenession 500 39rator/runtime.js:67:40) 7 ms - 434 at GeneratorFunctionPrototype.invoke [as _invoke] (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:315:22) at GeneratorFunctionPrototype.prototype.(anonymous function) [as next] (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:100:21) at GeneratorFunctionPrototype.invoke (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:136:37) at at process._tickCallback (internal/process/next_tick.js:188:7) Tests run: 4, Failures: 1, Errors: 0, Skipped: 3, Time elapsed: 6.592 sec <<< FAILURE! setup(com.vimalselvam.stf.AndroidTest) Time elapsed: 6.499 sec <<< FAILURE! org.openqa.selenium.WebDriverException: An unknown server-side error occurred while processing the command. Original error: Error in waiting for device. Original error: 'Error executing adbExec. Original error: 'Command '/Users/gachauha/Library/Android/sdk/platform-tools/adb -P 5037 -s 10.41.17.66:7401 wait-for-device' exited with code 1'; Stderr: 'error: unknown host service'; Code: '1''. Retrying by restarting ADB (WARNING: The server did not provide any stacktrace information) Command duration or timeout: 591 milliseconds Build info: version: '2.53.0', revision: '35ae25b1534ae328c771e0856c93e187490ca824', time: '2016-03-15 10:43:46' System info: host: 'gachauha-macOS', ip: '10.41.116.174', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.12.6', java.version: '1.8.0_144' Driver info: io.appium.java_client.android.AndroidDriver 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:423) 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:678) at io.appium.java_client.DefaultGenericMobileDriver.execute(DefaultGenericMobileDriver.java:51) at io.appium.java_client.AppiumDriver.execute(AppiumDriver.java:1) at io.appium.java_client.android.AndroidDriver.execute(AndroidDriver.java:1) at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:249) at org.openqa.selenium.remote.RemoteWebDriver.(RemoteWebDriver.java:131) at org.openqa.selenium.remote.RemoteWebDriver.(RemoteWebDriver.java:144) at io.appium.java_client.DefaultGenericMobileDriver.(DefaultGenericMobileDriver.java:47) at io.appium.java_client.AppiumDriver.(AppiumDriver.java:114) at io.appium.java_client.AppiumDriver.(AppiumDriver.java:132) at io.appium.java_client.android.AndroidDriver.(AndroidDriver.java:97) at com.vimalselvam.stf.AndroidTest.setup(AndroidTest.java:57)

Results :

Failed tests: setup(com.vimalselvam.stf.AndroidTest): An unknown server-side error occurred while processing the command. Original error: Error in waiting for device. Original error: 'Error executing adbExec. Original error: 'Command '/Users/gachauha/Library/Android/sdk/platform-tools/adb -P 5037 -s 10.41.17.66:7401 wait-for-device' exited with code 1'; Stderr: 'error: unknown host service'; Code: '1''. Retrying by restarting ADB (WARNING: The server did not provide any stacktrace information)(..)

Tests run: 4, Failures: 1, Errors: 0, Skipped: 3

[INFO] ------------------------------------------------------------------------ [INFO] BUILD FAILURE [INFO] ------------------------------------------------------------------------ [INFO] Total time: 9.665 s [INFO] Finished at: 2017-12-07T16:34:13+05:30 [INFO] Final Memory: 21M/351M [INFO] ------------------------------------------------------------------------ [ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.12.4:test (default-test) on project appium-stf-example: There are test failures. [ERROR] [ERROR] Please refer to /Users/gachauha/stf-appium/appium-stf-example/target/surefire-reports for the individual test results. [ERROR] -> [Help 1] [ERROR] [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch. [ERROR] Re-run Maven using the -X switch to enable full debug logging. [ERROR] [ERROR] For more information about the errors and possible solutions, please read the following articles: [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException

xchgaur avatar Dec 07 '17 13:12 xchgaur