简体   繁体   中英

Automation test case is working for appium command line tool but not for desktop client

PLEASE HELP ME!!!. I'm trying to automate an android app. I'm using JAVA. If i start the appium server from the command line and run the test case, it is working fine. But when i start the appium sever using Appium desktop client(Version - 1.13.0), i'm getting an error. Why does the test case keep failing when using Appium desktop client(Version - 1.13.0) whereas the same code works fine when run with the appium command line tool?

I'm using Appium(1.14.0) and Appium Desktop version(1.13.0) with Java 8 and along with the following jar files

  • Selenium Remote Driver-3.14.0
  • Java-client-7.0.0
  • Apache commong language file - 3.7

     public static AndroidDriver<AndroidElement> InstallInvokeAPK() throws MalformedURLException { //Define the source folder File f1 = new File("src"); //Define the destination and name of the APK file File f2 = new File(f1, "New Driver app-excel-debug.apk"); //COnfiguration setting to work with the application DesiredCapabilities cap = new DesiredCapabilities();//Creating an object of Desiredcapabilities class cap.setCapability(MobileCapabilityType.PLATFORM_NAME, MobilePlatform.ANDROID);//Defining the platform cap.setCapability(MobileCapabilityType.DEVICE_NAME, "Moto G (5) Plus");//Defining the Mobile handset name cap.setCapability(MobileCapabilityType.UDID, "ZY223Z68JG"); cap.setCapability("automationName", "UiAutomator2"); cap.setCapability(MobileCapabilityType.NEW_COMMAND_TIMEOUT, 100);//Defining the maximum timeout period to execute command cap.setCapability("autoGrantPermissions", "true"); cap.setCapability(MobileCapabilityType.APP, f2.getAbsolutePath()); //Use the Android Driver to work with Android Platform Elements AndroidDriver<AndroidElement> driver = new AndroidDriver<AndroidElement>(new URL("http://127.0.0.1:4723/wd/hub"),cap); return driver; public class TestApp extends Example2{ public static void main(String[] args) throws InterruptedException, MalformedURLException { AndroidDriver<AndroidElement> driver = InstallInvokeAPK(); //AndroidDriver<AndroidElement> driver = PackageActivity("com.e9ine.android.driver", "com.e9ine.android.driver.module.AuthenticationModule.view.activity.SpalshScreenActivity"); driver.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS); driver.findElement(By.xpath("//android.widget.EditText[@text='Username']")).sendKeys("abc@xyz.com"); driver.findElement(By.id("editText_password")).sendKeys("1234"); driver.navigate().back(); 

    These are the appium logs:

    [Appium] Welcome to Appium v1.13.0 [Appium] Appium REST http interface listener started on 0.0.0.0:4723 [HTTP] --> POST /wd/hub/session [HTTP] {"desiredCapabilities":{"app":"C:\\Users\\e9ine-QA\\Appium\\MobileAutomation\\src\\New Driver app-excel-debug.apk","newCommandTimeout":100,"automationName":"UiAutomator2","autoGrantPermissions":"true","platformName":"Android","udid":"ZY223Z68JG","deviceName":"Moto G (5) Plus"},"capabilities":{"firstMatch":[{"appium:app":"C:\\Users\\e9ine-QA\\Appium\\MobileAutomation\\src\\New Driver app-excel-debug.apk","appium:autoGrantPermissions":"true","appium:automationName":"UiAutomator2","appium:deviceName":"Moto G (5) Plus","appium:newCommandTimeout":100,"platformName":"android","appium:udid":"ZY223Z68JG"}]}} [W3C] Calling AppiumDriver.createSession() with args: [{"app":"C:\\Users\\e9ine-QA\\Appium\\MobileAutomation\\src\\New Driver app-excel-debug.apk","newCommandTimeout":100,"automationName":"UiAutomator2","autoGrantPermissions":"true","platformName":"Android","udid":"Z Y223Z68JG","deviceName":"Moto G (5) Plus"},null,{"firstMatch":[{"appium:app":"C:\\Users\\e9ine-QA\\Appium\\MobileAutomation\\src\\New Driver app-excel-debug.apk","appium:autoGrantPermissions":"true","appium:automationName":"UiAutomator2","appium:deviceName":"Moto G (5) Plus","appium:newCommandTimeout":100,"platformName":"android","appium:udid":"ZY223Z68JG"}]}] [BaseDriver] Event 'newSessionRequested' logged at 1565779809999 (16:20:09 GMT+0530 (India Standard Time)) [Appium] Appium v1.13.0 creating new AndroidUiautomator2Driver (v1.33.1) session [Appium] Capabilities: [Appium] platformName: android [Appium] app: C:\\Users\\e9ine-QA\\Appium\\MobileAutomation\\src\\New Driver app-excel-debug.apk [Appium] autoGrantPermissions: true [Appium] automationName: UiAutomator2 [Appium] deviceName: Moto G (5) Plus [Appium] newCommandTimeout: 100 [Appium] udid: ZY223Z68JG [BaseDriver] W3C capabilities {"alwaysMatch":{"platformNa... and MJSONWP desired capabilities {"app":"C:\\Users\\e9ine-QA... were provided [Bas eDriver] Creating session with W3C capabilities: {"alwaysMatch":{"platformNa... [BaseDriver] Capability 'autoGrantPermissions' changed from string to boolean. This may cause unexpected behavior [BaseDriver] Session created with session id: 384a04e7-e07c-46ce-887e-a4f69f0993f2 [BaseDriver] Using local app 'C:\\Users\\e9ine-QA\\Appium\\MobileAutomation\\src\\New Driver app-excel-debug.apk' [UiAutomator2] Checking whether app is actually present [ADB] Using 'adb.exe' from 'C:\\Users\\e9ine-QA\\AppData\\Local\\Android\\Sdk\\platform-tools\\adb.exe' [AndroidDriver] Retrieving device list [ADB] Trying to find a connected android device [ADB] Getting connected devices... [ADB] 1 device(s) connected [AndroidDriver] Using device: ZY223Z68JG [ADB] Using 'adb.exe' from 'C:\\Users\\e9ine-QA\\AppData\\Local\\Android\\Sdk\\platform-tools\\adb.exe' [ADB] Setting device id to ZY223Z68JG [ADB] Running 'C:\\Users\\e9ine-QA\\AppData\\Local\\Android\\Sdk\\platform-tools\\adb.exe -P 5037 -s ZY223Z68JG shell getprop ro.build.version.sdk' [ADB] Error sending command, reconnecting device and retrying: shell,getprop,ro.build.version.sdk [ADB] Trying to find a connected android device [ADB] Getti ng connected devices... [ADB] 1 device(s) connected [UiAutomator2] Deleting UiAutomator2 session [ADB] Removing forwarded port socket connection: 8200 [ADB] Running 'C:\\Users\\e9ine-QA\\AppData\\Local\\Android\\Sdk\\platform-tools\\adb.exe -P 5037 -s ZY223Z68JG forward --remove tcp:8200' [UiAutomator2] Unable to remove port forward 'Error executing adbExec. Original error: 'Command 'C:\\Users\\e9ine-QA\\AppData\\Local\\Android\\Sdk\\platform-tools\\adb.exe -P 5037 -s ZY223Z68JG forward --remove tcp:8200' exited with code 1'; Stderr: 'error: unknown host service'; Code: '1'' [ADB] Running 'C:\\Users\\e9ine-QA\\AppData\\Local\\Android\\Sdk\\platform-tools\\adb.exe -P 5037 -s ZY223Z68JG shell getprop ro.build.version.sdk' [ADB] Error sending command, reconnecting device and retrying: shell,getprop,ro.build.version.sdk [ADB] Trying to find a connected android device [ADB] Getting connected devices... [ADB] 1 device(s) connected [BaseDriver] Event 'newSessionStarted' logged at 1565779812994 (16:20:12 GMT+0530 (India Standard Time)) [W3C] Encountered internal error running command: Error: Error getting device API level. Original error: Error executing adbExec. Original error: 'Command 'C:\\Users\\e9ine-QA\\AppData\\Local\\Android\\Sdk\\platform-tools\\adb.exe -P 5037 -s ZY223Z68JG shell getprop ro.build.version.sdk' exited with code 1'; Stderr: 'error: device still connecting'; Code: '1' [W3C] at ADB. (C:\\Program Files\\Appium\\resources\\app\\node_modules\\appium\\node_modules\\appium-adb\\lib\\tools\\adb-commands.js:98:13) [W3C] at Generator.throw () [W3C] at asyncGeneratorStep (C:\\Program Files\\Appium\\resources\\app\\node_modules\\appium\\node_modules@babel\\runtime\\helpers\\asyncToGenerator.js:3:24) [W3C] at _throw (C:\\Program Files\\Appium\\resources\\app\\node_modules\\appium\\node_modules@babel\\runtime\\helpers\\asyncToGenerator.js:29:9) [W3C] at run (C:\\Program Files\\Appium\\resources\\app\\node_modules\\appium\\node_modules\\core-js\\modules\\es6.promise.js:75:22) [W3C] at C:\\Program Files\\Appium\\resources\\app\\node_modules\\appium\\node_modules\\core-js\\modules\\es6.promise.js:92:30 [W3C] at flush (C:\\Program Files\\Appium\\resources\\app\\node_modules\\appium\\node_modules\\core-js\\modules_microtask.js:18:9) [W3C] at process._tickCallback (internal/process/next_tick.js:61:11) [HTTP] <-- POST /wd/hub/session 500 3021 ms - 1276 [HTTP]

    Selenium logs:

    Exception in thread "main" org.openqa.selenium.SessionNotCreatedException: Unable to create a new remote session. Please check the server log for more details. Original error: An unknown server-side error occurred while processing the command. Original error: Error getting device API level. Original error: Error executing adbExec. Original error: 'Command 'C:\\Users\\e9ine-QA\\AppData\\Local\\Android\\Sdk\\platform-tools\\adb.exe -P 5037 -s ZY223Z68JG shell getprop ro.build.version.sdk' exited with code 1'; Stderr: 'error: device still connecting'; Code: '1' Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:25:48' System info: host: 'DESKTOP-17I5IMK', ip: '192.168.5.208', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_211' Driver info: driver.version: AndroidDriver remote stacktrace: UnknownError: An unknown server-side error occurred while processing the command. Original error: Error getting device API level. Original error: Error executing adbExec. Original error: 'Command 'C:\\Users\\e9ine-QA\\AppData\\Local\\Android\\Sdk\\platform-tools\\adb.exe -P 5037 -s ZY223Z68JG shell getprop ro.build.version.sdk' exited with code 1'; Stderr: 'error: device still connecting'; Code: '1' at getResponseForW3CError (C:\\Program Files\\Appium\\resources\\app\\node_modules\\appium\\node_modules\\appium-base-driver\\lib\\protocol\\errors.js:826:9) at asyncHandler (C:\\Program Files\\Appium\\resources\\app\\node_modules\\appium\\node_modules\\appium-base-driver\\lib\\protocol\\protocol.js:447:37) at process._tickCallback (internal/process/next_tick.js:68:7) Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:25:48' System info: host: 'DESKTOP-17I5IMK', ip: '192.168.5.208', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_211' Driver info: driver.version: AndroidDriver at io.appium.java_client.remote.AppiumCommandExecutor$1.createSession(AppiumCommandExecutor.java:208) at io.appium.java_client.remote.AppiumCommandExecutor.createSession(AppiumCommandExecutor.java:217) at io.appium.java_client.remote.AppiumCommandExecutor.execute(AppiumCommandExecutor.java:239) at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.j ava:552) at io.appium.java_client.DefaultGenericMobileDriver.execute(DefaultGenericMobileDriver.java:42) 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:213) at org.openqa.selenium.remote.RemoteWebDriver.(RemoteWebDriver.java:131) at io.appium.java_client.DefaultGenericMobileDriver.(DefaultGenericMobileDriver.java:38) at io.appium.java_client.AppiumDriver.(AppiumDriver.java:84) at io.appium.java_client.AppiumDriver.(AppiumDriver.java:94) at io.appium.java_client.android.AndroidDriver.(AndroidDriver.java:95) at Test.Example2.InstallInvokeAPK(Example2.java:38) at Test.TestApp.main(TestApp.java:35) Caused by: java.lang.reflect.InvocationTargetException at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorI mpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at io.appium.java_client.remote.AppiumCommandExecutor$1.createSession(AppiumCommandExecutor.java:186) ... 14 more Caused by: org.openqa.selenium.WebDriverException: An unknown server-side error occurred while processing the command. Original error: Error getting device API level. Original error: Error executing adbExec. Original error: 'Command 'C:\\Users\\e9ine-QA\\AppData\\Local\\Android\\Sdk\\platform-tools\\adb.exe -P 5037 -s ZY223Z68JG shell getprop ro.build.version.sdk' exited with code 1'; Stderr: 'error: device still connecting'; Code: '1' Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:25:48' System info: host: 'DESKTOP-17I5IMK', ip: '192.168.5.208', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_211' Driver info: driver.version: AndroidDriver remote stacktrace: UnknownError: An unknown server-side error occurred while processing the command. Original error: Error getting device API level. Original error: Error executing adbExec. Original error: 'Command 'C:\\Users\\e9ine-QA\\AppData\\Local\\Android\\Sdk\\platform-tools\\adb.exe -P 5037 -s ZY223Z68JG shell getprop ro.build.version.sdk' exited with code 1'; Stderr: 'error: device still connecting'; Code: '1' at getResponseForW3CError (C:\\Program Files\\Appium\\resources\\app\\node_modules\\appium\\node_modules\\appium-base-driver\\lib\\protocol\\errors.js:826:9) at asyncHandler (C:\\Program Files\\Appium\\resources\\app\\node_modules\\appium\\node_modules\\appium-base-driver\\lib\\protocol\\protocol.js:447:37) at process._tickCallback (internal/process/next_tick.js:68:7) 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.W3CHandshakeResponse.lambda$errorHandler$0(W3CHandshakeResponse.java:62) at org.openqa.selenium.remote.HandshakeResponse.lambda$getResponseFunction$0(HandshakeResponse.java:30) at org.openqa.selenium.remote.ProtocolHandshake.lambda$createSession$0(ProtocolHandshake.java:126) at java.util.stream.ReferencePipeline$3$1.accept(Un known Source) at java.util.Spliterators$ArraySpliterator.tryAdvance(Unknown Source) at java.util.stream.ReferencePipeline.forEachWithCancel(Unknown Source) at java.util.stream.AbstractPipeline.copyIntoWithCancel(Unknown Source) at java.util.stream.AbstractPipeline.copyInto(Unknown Source) at java.util.stream.AbstractPipeline.wrapAndCopyInto(Unknown Source) at java.util.stream.FindOps$FindOp.evaluateSequential(Unknown Source) at java.util.stream.AbstractPipeline.evaluate(Unknown Source) at java.util.stream.ReferencePipeline.findFirst(Unknown Source) at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:128) ... 19 more

  1. Remove your Selenium Remote Driver-3.14.0 dependency, Appium Java Client 7.0.0 includes selenium-java, selenium-support and selenium-api versions 3.141.59 as transitive dependencies . If you particularly need Selenium Remote Driver I would suggest to ramp it up to 3.141.59 to avoid any API inconsistencies.
  2. Try resetting your ADB host by running adb kill-server command . Prior to launching your Appium test make sure to execute abd devices command and double check that your phone is in connected state

References:

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM