appium / appium

Cross-platform automation framework for all kinds of apps, built on top of the W3C WebDriver protocol
http://appium.io/
Apache License 2.0
18.95k stars 6.07k forks source link

Unable find element at Android 7.0 and Appium 1.5.3 #7128

Closed tomliuxin closed 7 years ago

tomliuxin commented 8 years ago

Appium:1.5.3 (using npm install -g appium@1.5.3 to upgrade the appium to 1.5.3 version) Android version: 7.0 emulator node version: 4.6.0

using the below code can initialize the driver:

        DesiredCapabilities capabilities = new DesiredCapabilities();
            capabilities.SetCapability("device", "Android");
            capabilities.SetCapability(CapabilityType.Platform, "Windows");
            capabilities.SetCapability("deviceName", deviceName);
            capabilities.SetCapability("platformName", "Android");
            capabilities.SetCapability("platformVersion", "7.0");
            capabilities.SetCapability("automationName", "Appium");
            capabilities.SetCapability("unicodeKeyboard", "True");
            capabilities.SetCapability("resetKeyboard", "True");
            capabilities.SetCapability("appPackage", appPackage);
            capabilities.SetCapability("appActivity", appActivity);

        Uri uri = new Uri(uriString);
        TimeSpan timeSpan = TimeSpan.FromMinutes(20);
        myDriver = new AndroidDriver<AppiumWebElement>(uri, capabilities, timeSpan);

but using the By.className can't find element (any classname can't find element even the classname is correct)

AndroidDriverUtility.FindElementsByClassName("android.widget.ImageView");

does anybody met this issue? how to resolve it? Thanks.

mykola-mokhnach commented 8 years ago

Have you tried Appium 1.6.0?

rafalf commented 8 years ago

think I have encountered it too. had to use IDs and ACCESSIBILITY ID I am on 1.6.0, Android 5.1.1 and automating a native app.

tomliuxin commented 8 years ago

@mykola-mokhnach, Thanks. Yes, I have tried at Appium 1.6.0 and Appium 1.5.2. all met the same as issue. Issue: can initialize the Android driver, but run cases very slowly, andCANNOT find the element.

and also, I have tried at appium Version: 1.3.7,Version: 1.4.13, Version: 1.4.16 issue:can’t initialize the Android driver.

the issue is not repro at the android version 6.0, only repro at android version 7.0

tomliuxin commented 8 years ago

@rafalf , Thanks your suggestion. but our app, some of UI element are not have Ids or Accessbility Id. did you run cases at android 7.0?

mykola-mokhnach commented 8 years ago

Probably, it's a good time now to start using UIAutomation2 framework.

imurchie commented 8 years ago

Android 7 is not supported in Appium 1.5.3. You can upgrade, and then post the logs for the test run as a gist. Getting the source might be useful, as well.

tomliuxin commented 8 years ago

@mykola-mokhnach, Thanks. could you help to let me know how to use the UIAutomation2 framework.? Thanks.

tomliuxin commented 8 years ago

@imurchie , Thanks. Yes, I have upgrade the appium to 1.6.0 (npm -g install appium@1.6.0), met the same as issue. The driver can initialize, and the API presskeyCode(), Swipe(), worked fine. but when execute the method: FindElement By className, NO found element. The log error: [MJSONWP] Calling AppiumDriver.findElement() with args: ["class name","android.webk... [debug] [BaseDriver] Valid locator strategies for this request: xpath, id, class name, accessibility id, -android uiautomator [debug] [BaseDriver] Valid locator strategies for this request: xpath, id, class name, accessibility id, -android uiautomator [debug] [BaseDriver] Waiting up to 0 ms for condition [debug] [AndroidBootstrap] Sending command to android: {"cmd":"action","action":"find","params":{"strategy":"class name","selector":"android.webkit.WebView","context":"","multiple":false}} [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got data from client: {"cmd":"action","action":"find","params":{"strategy":"class name","selector":"android.webkit.WebView","context":"","multiple":false}} [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got command of type ACTION [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got command action: find [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Finding 'android.webkit.WebView' using 'CLASS_NAME' with the contextId: '' multiple: false [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Using: UiSelector[CLASS=android.webkit.WebView, INSTANCE=0] [debug] [AndroidBootstrap] Received command result from bootstrap [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Returning result: {"status":0,"value":{"ELEMENT":"45"}} [MJSONWP] Responding to client with driver.findElement() result: {"ELEMENT":"45"} [HTTP] <-- POST /wd/hub/session/41f42d1c-39ed-4c3f-b9c4-cf5891ad15e3/element 200 35 ms - 88 [HTTP] --> POST /wd/hub/session/41f42d1c-39ed-4c3f-b9c4-cf5891ad15e3/element/45/elements {"using":"class name","value":"android.widget.EditText"} [MJSONWP] Calling AppiumDriver.findElementsFromElement() with args: ["class name","android.widg... [debug] [BaseDriver] Valid locator strategies for this request: xpath, id, class name, accessibility id, -android uiautomator [debug] [BaseDriver] Valid locator strategies for this request: xpath, id, class name, accessibility id, -android uiautomator [debug] [BaseDriver] Waiting up to 0 ms for condition [debug] [AndroidBootstrap] Sending command to android: {"cmd":"action","action":"find","params":{"strategy":"class name","selector":"android.widget.EditText","context":"45","multiple":true}} [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got data from client: {"cmd":"action","action":"find","params":{"strategy":"class name","selector":"android.widget.EditText","context":"45","multiple":true}} [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got command of type ACTION [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got command action: find [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Finding 'android.widget.EditText' using 'CLASS_NAME' with the contextId: '45' multiple: true [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Using: UiSelector[CLASS=android.widget.EditText] [AndroidBootstrap] [BOOTSTRAP LOG] [debug] getElements selector:UiSelector[CLASS=android.widget.EditText] [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Element[45] is 45, counter: 0 [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Failed to locate element. Clearing Accessibility cache and retrying. [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Finding 'android.widget.EditText' using 'CLASS_NAME' with the contextId: '45' multiple: true [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Using: UiSelector[CLASS=android.widget.EditText] [AndroidBootstrap] [BOOTSTRAP LOG] [debug] getElements selector:UiSelector[CLASS=android.widget.EditText] [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Element[45] is 45, counter: 0 [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Returning result: {"status":0,"value":[]} [debug] [AndroidBootstrap] Received command result from bootstrap [MJSONWP] Responding to client with driver.findElementsFromElement() result: [] [HTTP] <-- POST /wd/hub/session/41f42d1c-39ed-4c3f-b9c4-cf5891ad15e3/element/45/elements 200 35 ms - 74

NO element find.

tomliuxin commented 8 years ago

@mykola-mokhnach, I changed the initialize driver code as below: DesiredCapabilities capabilities = new DesiredCapabilities(); capabilities.SetCapability("device", "Android"); capabilities.SetCapability(CapabilityType.Platform, "Windows"); capabilities.SetCapability("deviceName", deviceName); capabilities.SetCapability("platformName", "Android"); capabilities.SetCapability("platformVersion", "7.0"); capabilities.SetCapability("automationName", "uiautomator2"); capabilities.SetCapability("unicodeKeyboard", "True"); capabilities.SetCapability("resetKeyboard", "True"); capabilities.SetCapability("appPackage", appPackage); capabilities.SetCapability("appActivity", appActivity);

(automationName changed to: uiautomator2), not sure is it right or not.

but met one issue: Error while killing uiAutomator: Error: Unable to kill io.appium.uiautomator2.server processes. Original error: Unable to get pids for tomator2.server

Encountered internal error running command: ProxyRequestError: Could not proxy command to remote server. Original error: Error: read ECONNRESET

Full log as below: [Appium] Welcome to Appium v1.6.0 [Appium] Non-default server args: [Appium] address: '127.0.0.1' [Appium] Appium REST http interface listener started on 127.0.0.1:4723 [HTTP] --> POST /wd/hub/session {"desiredCapabilities":{"device":"Android","platform":"Windows","deviceName":"emulator-5554","platformName":"Android","platformVersion":"7.0","automationName":"uiautomator2","unicodeKeyboard":"True","resetKeyboard":"True","appPackage":"com.microsoft.flow.nightly","appActivity":"com.microsoft.flow.nightly.MainActivity"}} [MJSONWP] Calling AppiumDriver.createSession() with args: [{"device":"Android","platf... [Appium] Creating new AndroidUiautomator2Driver session [Appium] Capabilities: [Appium] device: 'Android' [Appium] platform: 'Windows' [Appium] deviceName: 'emulator-5554' [Appium] platformName: 'Android' [Appium] platformVersion: '7.0' [Appium] automationName: 'uiautomator2' [Appium] unicodeKeyboard: 'True' [Appium] resetKeyboard: 'True' [Appium] appPackage: 'com.microsoft.flow.nightly' [Appium] appActivity: 'com.microsoft.flow.nightly.MainActivity' [BaseDriver] Capability 'unicodeKeyboard' changed from string to boolean. This may cause unexpected behavior [BaseDriver] Capability 'resetKeyboard' changed from string to boolean. This may cause unexpected behavior [BaseDriver] The following capabilities were provided, but are not recognized by appium: device, platform. [BaseDriver] Session created with session id: deb1562f-5a89-49a2-a7cd-e4c6724d1449 [debug] [AndroidDriver] Getting Java version [AndroidDriver] Java version is: 1.8.0_101 [ADB] Checking whether adb is present [ADB] Using adb.exe from E:\Android\sdk\platform-tools\adb.exe [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] Looking for a device with Android '7.0' [debug] [ADB] Setting device id to emulator-5554 [ADB] Getting device platform version [debug] [ADB] Getting connected devices... [debug] [ADB] 1 device(s) connected [debug] [ADB] Running 'E:\Android\sdk\platform-tools\adb.exe' with args: ["-P",5037,"-s","emulator-5554","shell","getprop","ro.build.version.release"] [AndroidDriver] Using device: emulator-5554 [ADB] Checking whether adb is present [ADB] Using adb.exe from E:\Android\sdk\platform-tools\adb.exe [debug] [ADB] Setting device id to emulator-5554 [AndroidDriver] No app sent in, not parsing package/activity [ADB] Getting device platform version [debug] [ADB] Getting connected devices... [debug] [ADB] 1 device(s) connected [debug] [ADB] Running 'E:\Android\sdk\platform-tools\adb.exe' with args: ["-P",5037,"-s","emulator-5554","shell","getprop","ro.build.version.release"] [debug] [ADB] Attempting to kill all io.appium.uiautomator2.server processes [debug] [ADB] Getting all processes with io.appium.uiautomator2.server [debug] [ADB] Getting connected devices... [ADB] Error: Unable to get pids for tomator2.server. Orginial error: this.shell(...).trim is not a function at Object.wrappedLogger.errorAndThrow (lib/logger.js:60:13) at ADB.callee$0$0$ (lib/tools/adb-commands.js:441:9) at tryCatch (C:\Users\sqlcl02\AppData\Roaming\npm\node_modules\appium\node_modules\babel-runtime\regenerator\runtime.js:67:40) at GeneratorFunctionPrototype.invoke as _invoke at GeneratorFunctionPrototype.prototype.(anonymous function) as next at invoke (C:\Users\sqlcl02\AppData\Roaming\npm\node_modules\appium\node_modules\babel-runtime\regenerator\runtime.js:136:37) at enqueueResult (C:\Users\sqlcl02\AppData\Roaming\npm\node_modules\appium\node_modules\babel-runtime\regenerator\runtime.js:185:17) at new Promise (C:\Users\sqlcl02\AppData\Roaming\npm\node_modules\appium\node_modules\core-js\library\modules\es6.promise.js:201:7) at AsyncIterator.enqueue (C:\Users\sqlcl02\AppData\Roaming\npm\node_modules\appium\node_modules\babel-runtime\regenerator\runtime.js:184:12) at AsyncIterator.prototype.(anonymous function) as next at Object.runtime.async (C:\Users\sqlcl02\AppData\Roaming\npm\node_modules\appium\node_modules\babel-runtime\regenerator\runtime.js:209:12) at ADB.callee$0$0 as getPIDsByName at ADB.callee$0$0$ (lib/tools/adb-commands.js:448:27) at tryCatch (C:\Users\sqlcl02\AppData\Roaming\npm\node_modules\appium\node_modules\babel-runtime\regenerator\runtime.js:67:40) at GeneratorFunctionPrototype.invoke as _invoke at GeneratorFunctionPrototype.prototype.(anonymous function) as next at invoke (C:\Users\sqlcl02\AppData\Roaming\npm\node_modules\appium\node_modules\babel-runtime\regenerator\runtime.js:136:37) at enqueueResult (C:\Users\sqlcl02\AppData\Roaming\npm\node_modules\appium\node_modules\babel-runtime\regenerator\runtime.js:185:17) at new Promise (C:\Users\sqlcl02\AppData\Roaming\npm\node_modules\appium\node_modules\core-js\library\modules\es6.promise.js:201:7) at AsyncIterator.enqueue (C:\Users\sqlcl02\AppData\Roaming\npm\node_modules\appium\node_modules\babel-runtime\regenerator\runtime.js:184:12) at AsyncIterator.prototype.(anonymous function) as next at Object.runtime.async (C:\Users\sqlcl02\AppData\Roaming\npm\node_modules\appium\node_modules\babel-runtime\regenerator\runtime.js:209:12) at ADB.callee$0$0 as killProcessesByName at UiAutomator2Server.killUiAutomatorOnDevice$ (lib\uiautomator2.js:151:22) at tryCatch (C:\Users\sqlcl02\AppData\Roaming\npm\node_modules\appium\node_modules\babel-runtime\regenerator\runtime.js:67:40) at GeneratorFunctionPrototype.invoke as _invoke at GeneratorFunctionPrototype.prototype.(anonymous function) as next at invoke (C:\Users\sqlcl02\AppData\Roaming\npm\node_modules\appium\node_modules\babel-runtime\regenerator\runtime.js:136:37) at enqueueResult (C:\Users\sqlcl02\AppData\Roaming\npm\node_modules\appium\node_modules\babel-runtime\regenerator\runtime.js:185:17) at new Promise (C:\Users\sqlcl02\AppData\Roaming\npm\node_modules\appium\node_modules\core-js\library\modules\es6.promise.js:201:7) at AsyncIterator.enqueue (C:\Users\sqlcl02\AppData\Roaming\npm\node_modules\appium\node_modules\babel-runtime\regenerator\runtime.js:184:12) at AsyncIterator.prototype.(anonymous function) as next at Object.runtime.async (C:\Users\sqlcl02\AppData\Roaming\npm\node_modules\appium\node_modules\babel-runtime\regenerator\runtime.js:209:12) at UiAutomator2Server.killUiAutomatorOnDevice (lib\uiautomator2.js:149:33) at AndroidUiautomator2Driver.startUiAutomator2Session$ (lib\driver.js:196:29) at tryCatch (C:\Users\sqlcl02\AppData\Roaming\npm\node_modules\appium\node_modules\babel-runtime\regenerator\runtime.js:67:40) at GeneratorFunctionPrototype.invoke as _invoke at GeneratorFunctionPrototype.prototype.(anonymous function) as next at GeneratorFunctionPrototype.invoke (C:\Users\sqlcl02\AppData\Roaming\npm\node_modules\appium\node_modules\babel-runtime\regenerator\runtime.js:136:37) at run (C:\Users\sqlcl02\AppData\Roaming\npm\node_modules\appium\node_modules\core-js\library\modules\es6.promise.js:108:47) at C:\Users\sqlcl02\AppData\Roaming\npm\node_modules\appium\node_modules\core-js\library\modules\es6.promise.js:119:28 at flush (C:\Users\sqlcl02\AppData\Roaming\npm\node_modules\appium\node_modules\core-js\library\modules\$.microtask.js:19:5) at nextTickCallbackWith0Args (node.js:420:9) at process._tickCallback (node.js:349:13) [Error: Unable to get pids for tomator2.server. Orginial error: this.shell(...).trim is not a function] [ADB] Error: Unable to kill io.appium.uiautomator2.server processes. Original error: Unable to get pids for tomator2.server. Orginial error: this.shell(...).trim is not a function at Object.wrappedLogger.errorAndThrow (lib/logger.js:60:13) at ADB.callee$0$0$ (lib/tools/adb-commands.js:457:9) at tryCatch (C:\Users\sqlcl02\AppData\Roaming\npm\node_modules\appium\node_modules\babel-runtime\regenerator\runtime.js:67:40) at GeneratorFunctionPrototype.invoke as _invoke at GeneratorFunctionPrototype.prototype.(anonymous function) as throw at GeneratorFunctionPrototype.invoke (C:\Users\sqlcl02\AppData\Roaming\npm\node_modules\appium\node_modules\babel-runtime\regenerator\runtime.js:136:37) at run (C:\Users\sqlcl02\AppData\Roaming\npm\node_modules\appium\node_modules\core-js\library\modules\es6.promise.js:108:47) at C:\Users\sqlcl02\AppData\Roaming\npm\node_modules\appium\node_modules\core-js\library\modules\es6.promise.js:119:28 at flush (C:\Users\sqlcl02\AppData\Roaming\npm\node_modules\appium\node_modules\core-js\library\modules\$.microtask.js:19:5) at nextTickCallbackWith0Args (node.js:420:9) at process._tickCallback (node.js:349:13) [Error: Unable to kill io.appium.uiautomator2.server processes. Original error: Unable to get pids for tomator2.server. Orginial error: this.shell(...).trim is not a function] [UiAutomator2] Error while killing uiAutomator: Error: Unable to kill io.appium.uiautomator2.server processes. Original error: Unable to get pids for tomator2.server. Orginial error: this.shell(...).trim is not a function [debug] [ADB] Running 'E:\Android\sdk\platform-tools\adb.exe' with args: ["-P",5037,"-s","emulator-5554","wait-for-device"] [debug] [ADB] 1 device(s) connected [debug] [ADB] Running 'E:\Android\sdk\platform-tools\adb.exe' with args: ["-P",5037,"-s","emulator-5554","shell","ps"] [debug] [ADB] Getting connected devices... [debug] [ADB] 1 device(s) connected [debug] [ADB] Running 'E:\Android\sdk\platform-tools\adb.exe' with args: ["-P",5037,"-s","emulator-5554","shell","echo","ping"] [debug] [Logcat] Starting logcat capture [debug] [AndroidDriver] Enabling Unicode keyboard support [debug] [AndroidDriver] Pushing unicode ime to device... [debug] [ADB] Running 'E:\Android\sdk\platform-tools\adb.exe' with args: ["-P",5037,"-s","emulator-5554","install","C:\Users\sqlcl02\AppData\Roaming\npm\node_modules\appium\node_modules\appium-android-ime\bin\UnicodeIME-debug.apk"] [debug] [ADB] Getting connected devices... [debug] [ADB] 1 device(s) connected [debug] [ADB] Running 'E:\Android\sdk\platform-tools\adb.exe' with args: ["-P",5037,"-s","emulator-5554","shell","settings","get","secure","default_input_method"] [debug] [AndroidDriver] Unsetting previous IME io.appium.android.ime/.UnicodeIME [debug] [AndroidDriver] Setting IME to 'io.appium.android.ime/.UnicodeIME' [debug] [ADB] Getting connected devices... [debug] [ADB] 1 device(s) connected [debug] [ADB] Running 'E:\Android\sdk\platform-tools\adb.exe' with args: ["-P",5037,"-s","emulator-5554","shell","ime","enable","io.appium.android.ime/.UnicodeIME"] [debug] [ADB] Getting connected devices... [debug] [ADB] 1 device(s) connected [debug] [ADB] Running 'E:\Android\sdk\platform-tools\adb.exe' with args: ["-P",5037,"-s","emulator-5554","shell","ime","set","io.appium.android.ime/.UnicodeIME"] [debug] [AndroidDriver] Pushing settings apk to device... [debug] [ADB] Running 'E:\Android\sdk\platform-tools\adb.exe' with args: ["-P",5037,"-s","emulator-5554","install","C:\Users\sqlcl02\AppData\Roaming\npm\node_modules\appium\node_modules\io.appium.settings\bin\settings_apk-debug.apk"] [debug] [AndroidDriver] Pushing unlock helper app to device... [debug] [ADB] Running 'E:\Android\sdk\platform-tools\adb.exe' with args: ["-P",5037,"-s","emulator-5554","install","C:\Users\sqlcl02\AppData\Roaming\npm\node_modules\appium\node_modules\appium-unlock\bin\unlock_apk-debug.apk"] [debug] [ADB] Forwarding system: 8200 to device: 6790 [debug] [ADB] Running 'E:\Android\sdk\platform-tools\adb.exe' with args: ["-P",5037,"-s","emulator-5554","forward","tcp:8200","tcp:6790"] [debug] [ADB] Getting connected devices... [debug] [ADB] 1 device(s) connected [debug] [ADB] Running 'E:\Android\sdk\platform-tools\adb.exe' with args: ["-P",5037,"-s","emulator-5554","shell","dumpsys","window"] [AndroidDriver] Screen already unlocked, doing nothing [debug] [AndroidDriver] Extracting strings from apk null null C:\Users\sqlcl02\AppData\Local\Temp\com.microsoft.flow.nightly [debug] [ADB] Extracting strings for language: default [debug] [ADB] Getting connected devices... [debug] [ADB] 1 device(s) connected [debug] [ADB] Running 'E:\Android\sdk\platform-tools\adb.exe' with args: ["-P",5037,"-s","emulator-5554","shell","getprop","ro.build.version.sdk"] [debug] [ADB] Device API level: 24 [debug] [ADB] Getting connected devices... [debug] [ADB] 1 device(s) connected [debug] [ADB] Running 'E:\Android\sdk\platform-tools\adb.exe' with args: ["-P",5037,"-s","emulator-5554","shell","getprop","persist.sys.locale"] [debug] [ADB] Current device property 'persist.sys.locale': [debug] [ADB] Getting connected devices... [debug] [ADB] 1 device(s) connected [debug] [ADB] Running 'E:\Android\sdk\platform-tools\adb.exe' with args: ["-P",5037,"-s","emulator-5554","shell","getprop","ro.product.locale"] [debug] [ADB] Current device property 'ro.product.locale': en-US [debug] [ADB] No strings.xml for language 'en', getting default strings.xml [debug] [ADB] Getting connected devices... [debug] [ADB] 1 device(s) connected [debug] [ADB] Running 'E:\Android\sdk\platform-tools\adb.exe' with args: ["-P",5037,"-s","emulator-5554","shell","rm","-rf","/data/local/tmp/strings.json"] [debug] [UiAutomator2] No app capability. Assuming it is already on the device [debug] [AndroidDriver] Running fast reset (stop and clear) [debug] [ADB] Getting connected devices... [debug] [ADB] 1 device(s) connected [debug] [ADB] Running 'E:\Android\sdk\platform-tools\adb.exe' with args: ["-P",5037,"-s","emulator-5554","shell","am","force-stop","com.microsoft.flow.nightly"] [debug] [ADB] Getting connected devices... [debug] [ADB] 1 device(s) connected [debug] [ADB] Running 'E:\Android\sdk\platform-tools\adb.exe' with args: ["-P",5037,"-s","emulator-5554","shell","pm","clear","com.microsoft.flow.nightly"] [debug] [ADB] Attempting to kill all io.appium.uiautomator2.server processes [debug] [ADB] Getting all processes with io.appium.uiautomator2.server [debug] [ADB] Getting connected devices... [ADB] Error: Unable to get pids for tomator2.server. Orginial error: this.shell(...).trim is not a function at Object.wrappedLogger.errorAndThrow (lib/logger.js:60:13) at ADB.callee$0$0$ (lib/tools/adb-commands.js:441:9) at tryCatch (C:\Users\sqlcl02\AppData\Roaming\npm\node_modules\appium\node_modules\babel-runtime\regenerator\runtime.js:67:40) at GeneratorFunctionPrototype.invoke as _invoke at GeneratorFunctionPrototype.prototype.(anonymous function) as next at invoke (C:\Users\sqlcl02\AppData\Roaming\npm\node_modules\appium\node_modules\babel-runtime\regenerator\runtime.js:136:37) at enqueueResult (C:\Users\sqlcl02\AppData\Roaming\npm\node_modules\appium\node_modules\babel-runtime\regenerator\runtime.js:185:17) at new Promise (C:\Users\sqlcl02\AppData\Roaming\npm\node_modules\appium\node_modules\core-js\library\modules\es6.promise.js:201:7) at AsyncIterator.enqueue (C:\Users\sqlcl02\AppData\Roaming\npm\node_modules\appium\node_modules\babel-runtime\regenerator\runtime.js:184:12) at AsyncIterator.prototype.(anonymous function) as next at Object.runtime.async (C:\Users\sqlcl02\AppData\Roaming\npm\node_modules\appium\node_modules\babel-runtime\regenerator\runtime.js:209:12) at ADB.callee$0$0 as getPIDsByName at ADB.callee$0$0$ (lib/tools/adb-commands.js:448:27) at tryCatch (C:\Users\sqlcl02\AppData\Roaming\npm\node_modules\appium\node_modules\babel-runtime\regenerator\runtime.js:67:40) at GeneratorFunctionPrototype.invoke as _invoke at GeneratorFunctionPrototype.prototype.(anonymous function) as next at invoke (C:\Users\sqlcl02\AppData\Roaming\npm\node_modules\appium\node_modules\babel-runtime\regenerator\runtime.js:136:37) at enqueueResult (C:\Users\sqlcl02\AppData\Roaming\npm\node_modules\appium\node_modules\babel-runtime\regenerator\runtime.js:185:17) at new Promise (C:\Users\sqlcl02\AppData\Roaming\npm\node_modules\appium\node_modules\core-js\library\modules\es6.promise.js:201:7) at AsyncIterator.enqueue (C:\Users\sqlcl02\AppData\Roaming\npm\node_modules\appium\node_modules\babel-runtime\regenerator\runtime.js:184:12) at AsyncIterator.prototype.(anonymous function) as next at Object.runtime.async (C:\Users\sqlcl02\AppData\Roaming\npm\node_modules\appium\node_modules\babel-runtime\regenerator\runtime.js:209:12) at ADB.callee$0$0 as killProcessesByName at UiAutomator2Server.killUiAutomatorOnDevice$ (lib\uiautomator2.js:151:22) at tryCatch (C:\Users\sqlcl02\AppData\Roaming\npm\node_modules\appium\node_modules\babel-runtime\regenerator\runtime.js:67:40) at GeneratorFunctionPrototype.invoke as _invoke at GeneratorFunctionPrototype.prototype.(anonymous function) as next at invoke (C:\Users\sqlcl02\AppData\Roaming\npm\node_modules\appium\node_modules\babel-runtime\regenerator\runtime.js:136:37) at enqueueResult (C:\Users\sqlcl02\AppData\Roaming\npm\node_modules\appium\node_modules\babel-runtime\regenerator\runtime.js:185:17) at new Promise (C:\Users\sqlcl02\AppData\Roaming\npm\node_modules\appium\node_modules\core-js\library\modules\es6.promise.js:201:7) at AsyncIterator.enqueue (C:\Users\sqlcl02\AppData\Roaming\npm\node_modules\appium\node_modules\babel-runtime\regenerator\runtime.js:184:12) at AsyncIterator.prototype.(anonymous function) as next at Object.runtime.async (C:\Users\sqlcl02\AppData\Roaming\npm\node_modules\appium\node_modules\babel-runtime\regenerator\runtime.js:209:12) at UiAutomator2Server.killUiAutomatorOnDevice (lib\uiautomator2.js:149:33) at UiAutomator2Server.startSession$ (lib\uiautomator2.js:107:16) at tryCatch (C:\Users\sqlcl02\AppData\Roaming\npm\node_modules\appium\node_modules\babel-runtime\regenerator\runtime.js:67:40) at GeneratorFunctionPrototype.invoke as _invoke at GeneratorFunctionPrototype.prototype.(anonymous function) as next at invoke (C:\Users\sqlcl02\AppData\Roaming\npm\node_modules\appium\node_modules\babel-runtime\regenerator\runtime.js:136:37) at enqueueResult (C:\Users\sqlcl02\AppData\Roaming\npm\node_modules\appium\node_modules\babel-runtime\regenerator\runtime.js:185:17) at new Promise (C:\Users\sqlcl02\AppData\Roaming\npm\node_modules\appium\node_modules\core-js\library\modules\es6.promise.js:201:7) at AsyncIterator.enqueue (C:\Users\sqlcl02\AppData\Roaming\npm\node_modules\appium\node_modules\babel-runtime\regenerator\runtime.js:184:12) at AsyncIterator.prototype.(anonymous function) as next at Object.runtime.async (C:\Users\sqlcl02\AppData\Roaming\npm\node_modules\appium\node_modules\babel-runtime\regenerator\runtime.js:209:12) at UiAutomator2Server.startSession (lib\uiautomator2.js:103:12) at AndroidUiautomator2Driver.startUiAutomator2Session$ (lib\driver.js:217:29) at tryCatch (C:\Users\sqlcl02\AppData\Roaming\npm\node_modules\appium\node_modules\babel-runtime\regenerator\runtime.js:67:40) at GeneratorFunctionPrototype.invoke as _invoke at GeneratorFunctionPrototype.prototype.(anonymous function) as next at GeneratorFunctionPrototype.invoke (C:\Users\sqlcl02\AppData\Roaming\npm\node_modules\appium\node_modules\babel-runtime\regenerator\runtime.js:136:37) at run (C:\Users\sqlcl02\AppData\Roaming\npm\node_modules\appium\node_modules\core-js\library\modules\es6.promise.js:108:47) at C:\Users\sqlcl02\AppData\Roaming\npm\node_modules\appium\node_modules\core-js\library\modules\es6.promise.js:119:28 at flush (C:\Users\sqlcl02\AppData\Roaming\npm\node_modules\appium\node_modules\core-js\library\modules\$.microtask.js:19:5) at nextTickCallbackWith0Args (node.js:420:9) at process._tickCallback (node.js:349:13) [Error: Unable to get pids for tomator2.server. Orginial error: this.shell(...).trim is not a function] [ADB] Error: Unable to kill io.appium.uiautomator2.server processes. Original error: Unable to get pids for tomator2.server. Orginial error: this.shell(...).trim is not a function at Object.wrappedLogger.errorAndThrow (lib/logger.js:60:13) at ADB.callee$0$0$ (lib/tools/adb-commands.js:457:9) at tryCatch (C:\Users\sqlcl02\AppData\Roaming\npm\node_modules\appium\node_modules\babel-runtime\regenerator\runtime.js:67:40) at GeneratorFunctionPrototype.invoke as _invoke at GeneratorFunctionPrototype.prototype.(anonymous function) as throw at GeneratorFunctionPrototype.invoke (C:\Users\sqlcl02\AppData\Roaming\npm\node_modules\appium\node_modules\babel-runtime\regenerator\runtime.js:136:37) at run (C:\Users\sqlcl02\AppData\Roaming\npm\node_modules\appium\node_modules\core-js\library\modules\es6.promise.js:108:47) at C:\Users\sqlcl02\AppData\Roaming\npm\node_modules\appium\node_modules\core-js\library\modules\es6.promise.js:119:28 at flush (C:\Users\sqlcl02\AppData\Roaming\npm\node_modules\appium\node_modules\core-js\library\modules\$.microtask.js:19:5) at nextTickCallbackWith0Args (node.js:420:9) at process._tickCallback (node.js:349:13) [Error: Unable to kill io.appium.uiautomator2.server processes. Original error: Unable to get pids for tomator2.server. Orginial error: this.shell(...).trim is not a function] [UiAutomator2] Error while killing uiAutomator: Error: Unable to kill io.appium.uiautomator2.server processes. Original error: Unable to get pids for tomator2.server. Orginial error: this.shell(...).trim is not a function [UiAutomator2] Starting uiautomator2 server with cmd: am,instrument,-w,io.appium.uiautomator2.server.test/android.support.test.runner.AndroidJUnitRunner [UiAutomator2] Waiting for UiAutomator2 to be online... [JSONWP Proxy] Proxying [GET /status] to [GET http://localhost:8200/wd/hub/status] with no body [debug] [ADB] 1 device(s) connected [debug] [ADB] Running 'E:\Android\sdk\platform-tools\adb.exe' with args: ["-P",5037,"-s","emulator-5554","shell","ps"] [UiAutomator2] running command... adb shell am instrument -w io.appium.uiautomator2.server.test/android.support.test.runner.AndroidJUnitRunner... [JSONWP Proxy] Proxying [GET /status] to [GET http://localhost:8200/wd/hub/status] with no body [JSONWP Proxy] Proxying [GET /status] to [GET http://localhost:8200/wd/hub/status] with no body [JSONWP Proxy] Proxying [GET /status] to [GET http://localhost:8200/wd/hub/status] with no body [JSONWP Proxy] Proxying [GET /status] to [GET http://localhost:8200/wd/hub/status] with no body [JSONWP Proxy] Proxying [GET /status] to [GET http://localhost:8200/wd/hub/status] with no body [JSONWP Proxy] Proxying [GET /status] to [GET http://localhost:8200/wd/hub/status] with no body [JSONWP Proxy] Proxying [GET /status] to [GET http://localhost:8200/wd/hub/status] with no body [JSONWP Proxy] Proxying [GET /status] to [GET http://localhost:8200/wd/hub/status] with no body [JSONWP Proxy] Proxying [GET /status] to [GET http://localhost:8200/wd/hub/status] with no body [JSONWP Proxy] Proxying [GET /status] to [GET http://localhost:8200/wd/hub/status] with no body [JSONWP Proxy] Proxying [GET /status] to [GET http://localhost:8200/wd/hub/status] with no body [JSONWP Proxy] Proxying [GET /status] to [GET http://localhost:8200/wd/hub/status] with no body [JSONWP Proxy] Proxying [GET /status] to [GET http://localhost:8200/wd/hub/status] with no body [JSONWP Proxy] Proxying [GET /status] to [GET http://localhost:8200/wd/hub/status] with no body [JSONWP Proxy] Proxying [GET /status] to [GET http://localhost:8200/wd/hub/status] with no body [JSONWP Proxy] Proxying [GET /status] to [GET http://localhost:8200/wd/hub/status] with no body [JSONWP Proxy] Proxying [GET /status] to [GET http://localhost:8200/wd/hub/status] with no body [JSONWP Proxy] Proxying [GET /status] to [GET http://localhost:8200/wd/hub/status] with no body [JSONWP Proxy] Proxying [GET /status] to [GET http://localhost:8200/wd/hub/status] with no body [debug] [UiAutomator2] Deleting UiAutomator2 session [debug] [UiAutomator2] Deleting UiAutomator2 server session [UiAutomator2] Did not get confirmation UiAutomator2 deleteSession worked; Error was: Error: Trying to proxy a session command without session id [debug] [ADB] Getting connected devices... [debug] [ADB] 1 device(s) connected [debug] [ADB] Running 'E:\Android\sdk\platform-tools\adb.exe' with args: ["-P",5037,"-s","emulator-5554","shell","am","force-stop","com.microsoft.flow.nightly"] [debug] [Logcat] Stopping logcat capture [MJSONWP] Encountered internal error running command: ProxyRequestError: Could not proxy command to remote server. Original error: Error: read ECONNRESET at JWProxy.proxy$ (lib/jsonwp-proxy/proxy.js:122:13) at tryCatch (C:\Users\sqlcl02\AppData\Roaming\npm\node_modules\appium\node_modules\babel-runtime\regenerator\runtime.js:67:40) at GeneratorFunctionPrototype.invoke as _invoke at GeneratorFunctionPrototype.prototype.(anonymous function) as throw at GeneratorFunctionPrototype.invoke (C:\Users\sqlcl02\AppData\Roaming\npm\node_modules\appium\node_modules\babel-runtime\regenerator\runtime.js:136:37) at run (C:\Users\sqlcl02\AppData\Roaming\npm\node_modules\appium\node_modules\core-js\library\modules\es6.promise.js:108:47) at C:\Users\sqlcl02\AppData\Roaming\npm\node_modules\appium\node_modules\core-js\library\modules\es6.promise.js:119:28 at flush (C:\Users\sqlcl02\AppData\Roaming\npm\node_modules\appium\node_modules\core-js\library\modules\$.microtask.js:19:5) at nextTickCallbackWith0Args (node.js:420:9) at process._tickCallback (node.js:349:13) [HTTP] <-- POST /wd/hub/session 500 28029 ms - 217

sravanmedarapu commented 8 years ago

Can you try by updating appium-uiautomator2-driver to 0.0.7 ?

tomliuxin commented 8 years ago

@sravanmedarapu, Thanks. how to update it? Thanks.

sravanmedarapu commented 8 years ago

npm update appium-uiautomator2-driver

tomliuxin commented 8 years ago

@sravanmedarapu, Thanks.

after executed the CMD: still met the issue: [ADB] Error: Unable to kill io.appium.uiautomator2.server processes. Original error: Unable to get pids for tomator2.server. Orginial error: this.shell(...).trim is not a function

imurchie commented 8 years ago

What is the source at the point that you do the searches for elements? The first one works, the second, searching within the first, does not. It would be interesting to see what the source is.

sravanmedarapu commented 8 years ago

it seems update was not successful. Can you uninstall 'npm uninstall appium-uiautomator2-driver' and reinstall with 'npm install appium-uiautomator2-driver@0.0.7'

Adding logs in gist would be more helpful.

tomliuxin commented 8 years ago

@imurchie: Find element code: public static AppiumWebElement WebView { get { return AndroidDriverUtility.FindElementByClassName("android.webkit.WebView"); } }

public static ReadOnlyCollection EditTexts { get { return WebView.FindElementsByClassName("android.widget.EditText"); } }

sravanmedarapu commented 8 years ago

For finding the elements in the webview you need to switch to webview context before finding element, refer this example

and for finding the element properties in webview refer https://developers.google.com/web/tools/chrome-devtools/remote-debugging/

sravanmedarapu commented 8 years ago

Not able to replicate the issue. Can you share adb logs(command adb logcat) in a separate file in gist. Please clear the logs before executing the test(adb logcat -c).

Coming to your findElement issue, Have you tried by switching the context to webview in old driver at least(with out UIAutomator2 in capabilities).

tomliuxin commented 8 years ago

@sravanmedarapu , @imurchie Thanks for your help. The issue has been resolved. maybe I missed something at last times.

now, upgrade the appium to 1.6.0, npm install -g appium --no-shrinkwrap upgrade the uiautomator2 to 0.0.7 npm install appium-uiautomator2-driver@0.0.7

changed the android initialize code as below: capabilities.SetCapability("platformVersion", "7.0"); capabilities.SetCapability("automationName", "uiautomator2");

start the appium: "C:\Users\v-tomliu\AppData\Roaming\npm\appium.cmd" -a 127.0.0.1 -p 4723

and then run cases, successfully.

Thanks.

tomliuxin commented 8 years ago

@sravanmedarapu

it is very strange, it can find element for webView, but it can't find element for Button:

Find element code:

private static AppiumWebElement WebView (can find) { get { return AndroidDriverUtility.FindElementByClassName("android.webkit.WebView"); } }

public static AppiumWebElement Skip (can't find) { get { return WebView.FindElementsByClassName("android.widget.Button")[0]; } }

Appium log:

[HTTP] --> POST /wd/hub/session/bac401e3-945b-4905-9ce6-c93a799ed242/element {"using":"class name","value":"android.webkit.WebView"} [MJSONWP] Calling AppiumDriver.findElement() with args: ["class name","android.webkit.WebView","bac401e3-945b-4905-9ce6-c93a799ed242"] [debug] [BaseDriver] Valid locator strategies for this request: xpath, id, class name, accessibility id, -android uiautomator [debug] [BaseDriver] Valid locator strategies for this request: xpath, id, class name, accessibility id, -android uiautomator [debug] [BaseDriver] Waiting up to 0 ms for condition [JSONWP Proxy] Proxying [POST /element] to [POST http://localhost:8200/wd/hub/session/1bd9691c-1623-44d8-8332-7589fefb3c75/element] with body: {"strategy":"class name","selector":"android.webkit.WebView","context":"","multiple":false} [JSONWP Proxy] Got response with status 200: {"sessionId":"1bd9691c-1623-44d8-8332-7589fefb3c75","status":0,"value":{"ELEMENT":"0ae31a9a-1cdd-4f53-a4cf-f97eb135e8bc"}} [MJSONWP] Responding to client with driver.findElement() result: {"ELEMENT":"0ae31a9a-1cdd-4f53-a4cf-f97eb135e8bc"} [HTTP] <-- POST /wd/hub/session/bac401e3-945b-4905-9ce6-c93a799ed242/element 200 52 ms - 122 [HTTP] --> POST /wd/hub/session/bac401e3-945b-4905-9ce6-c93a799ed242/element {"using":"class name","value":"android.webkit.WebView"} [MJSONWP] Calling AppiumDriver.findElement() with args: ["class name","android.webkit.WebView","bac401e3-945b-4905-9ce6-c93a799ed242"] [debug] [BaseDriver] Valid locator strategies for this request: xpath, id, class name, accessibility id, -android uiautomator [debug] [BaseDriver] Valid locator strategies for this request: xpath, id, class name, accessibility id, -android uiautomator [debug] [BaseDriver] Waiting up to 0 ms for condition [JSONWP Proxy] Proxying [POST /element] to [POST http://localhost:8200/wd/hub/session/1bd9691c-1623-44d8-8332-7589fefb3c75/element] with body: {"strategy":"class name","selector":"android.webkit.WebView","context":"","multiple":false} [JSONWP Proxy] Got response with status 200: {"sessionId":"1bd9691c-1623-44d8-8332-7589fefb3c75","status":0,"value":{"ELEMENT":"88ffaf99-6afc-4e4f-8c8f-8b65c72e8b29"}} [MJSONWP] Responding to client with driver.findElement() result: {"ELEMENT":"88ffaf99-6afc-4e4f-8c8f-8b65c72e8b29"} [HTTP] <-- POST /wd/hub/session/bac401e3-945b-4905-9ce6-c93a799ed242/element 200 21 ms - 122 [HTTP] --> POST /wd/hub/session/bac401e3-945b-4905-9ce6-c93a799ed242/element/0ae31a9a-1cdd-4f53-a4cf-f97eb135e8bc/elements {"using":"class name","value":"android.widget.Button"} [MJSONWP] Calling AppiumDriver.findElementsFromElement() with args: ["class name","android.widget.Button","0ae31a9a-1cdd-4f53-a4cf-f97eb135e8bc","bac401e3-945b-4905-9ce6-c93a799ed242"] [debug] [BaseDriver] Valid locator strategies for this request: xpath, id, class name, accessibility id, -android uiautomator [debug] [BaseDriver] Valid locator strategies for this request: xpath, id, class name, accessibility id, -android uiautomator [debug] [BaseDriver] Waiting up to 0 ms for condition [JSONWP Proxy] Proxying [POST /elements] to [POST http://localhost:8200/wd/hub/session/1bd9691c-1623-44d8-8332-7589fefb3c75/elements] with body: {"strategy":"class name","selector":"android.widget.Button","context":"0ae31a9a-1cdd-4f53-a4cf-f97eb135e8bc","multiple":true} [JSONWP Proxy] Got response with status 200: {"sessionId":"1bd9691c-1623-44d8-8332-7589fefb3c75","status":0,"value":[]} [MJSONWP] Responding to client with driver.findElementsFromElement() result: [] [HTTP] <-- POST /wd/hub/session/bac401e3-945b-4905-9ce6-c93a799ed242/element/0ae31a9a-1cdd-4f53-a4cf-f97eb135e8bc/elements 200 19 ms - 74

adb logcat: 11-02 17:40:56.447 2764 2854 I appium : Find element command 11-02 17:40:56.447 2764 2854 D appium : payload: {"strategy":"class name","selector":"android.webkit.WebView","context":"","multiple":false} 11-02 17:40:56.448 2764 2854 I appium : find element command using 'class name' with selector 'android.webkit.WebView'. 11-02 17:40:56.459 2764 2854 I appium : AppiumResponse: {"sessionId":"1bd9691c-1623-44d8-8332-7589fefb3c75","status":0,"value":{"ELEMENT":"0ae31a9a-1cdd-4f53-a4cf-f97eb135e8bc"}} 11-02 17:40:59.205 2764 2855 I appium : channel read invoked! 11-02 17:40:59.205 2764 2855 I appium : channel read: POST /wd/hub/session/1bd9691c-1623-44d8-8332-7589fefb3c75/element 11-02 17:40:59.205 2764 2855 I appium : Find element command 11-02 17:40:59.205 2764 2855 D appium : payload: {"strategy":"class name","selector":"android.webkit.WebView","context":"","multiple":false} 11-02 17:40:59.205 2764 2855 I appium : find element command using 'class name' with selector 'android.webkit.WebView'. 11-02 17:40:59.209 2764 2855 I appium : AppiumResponse: {"sessionId":"1bd9691c-1623-44d8-8332-7589fefb3c75","status":0,"value":{"ELEMENT":"88ffaf99-6afc-4e4f-8c8f-8b65c72e8b29"}} 11-02 17:41:05.157 2764 2783 I appium : channel read invoked! 11-02 17:41:05.157 2764 2783 I appium : channel read: POST /wd/hub/session/1bd9691c-1623-44d8-8332-7589fefb3c75/elements 11-02 17:41:05.157 2764 2783 I appium : Find elements command 11-02 17:41:05.157 2764 2783 D appium : payload: {"strategy":"class name","selector":"android.widget.Button","context":"0ae31a9a-1cdd-4f53-a4cf-f97eb135e8bc","multiple":true} 11-02 17:41:05.157 2764 2783 I appium : find element command using 'class name' with selector 'android.widget.Button'. 11-02 17:41:05.159 2764 2783 I appium : AppiumResponse: {"sessionId":"1bd9691c-1623-44d8-8332-7589fefb3c75","status":0,"value":[]} 11-02 17:41:22.432 1483 1497 I ActivityManager: Killing 2355:com.google.process.gapps/u0a41 (adj 906): empty #17 11-02 17:41:22.737 2107 2930 I GAv4-SVC: Google Analytics 9.6.83 is starting up. 11-02 17:41:23.543 1981 2934 I PhenotypeFlagCommitter: Experiment Configs successfully retrieved for com.google.android.gms.playlog.uploader

rafalf commented 8 years ago

@tomliuxin - Dont take me wrong. Dude, can you start using gist please. https://gist.github.com/ for logs. I am also interested in this issue. This might be worth reading too markup

tomliuxin commented 8 years ago

@rafalf , thanks.

created one gist: https://gist.github.com/tomliuxin/40841232433d119f3442f749b515ca43

tomliuxin commented 8 years ago

@rafalf , sorry, this is public: https://gist.github.com/tomliuxin/cc9e3b2e2e894de997b30dec918bcd19

sravanmedarapu commented 8 years ago

For finding elements under webview you need to switch to webview context.

        Set<String> contextNames = driver.getContextHandles();
        for (String contextName : contextNames) {
            if (contextName.contains("WEBVIEW")) {
                driver.context(contextName);
            }
        }

Element properties under webview will not contain native attributes(as webviews built on HTML), to get the element properties under webview you can use chrome remote debugging - https://developers.google.com/web/tools/chrome-devtools/remote-debugging/

tomliuxin commented 8 years ago

@sravanmedarapu Thanks.

after I used the code to switch the context.: ReadOnlyCollection contexts = myDriver.Contexts; for (int i = 0; i < contexts.Count; i++) { if (contexts[i].Contains("WEBVIEW")) { myDriver.Context = contexts[i]; break; } } met one issue: [Chromedriver] Error: unknown error: Chrome version must be >= 53.0.2785.0 (Driver info: chromedriver=2.25.426923 (0390b88869384d6eb0d5d09729679f934aab9eed),platform=Windows NT 10.0.14393 x86_64)

and how to upgrade the Chrome browser for emulator, my emulator chrome version is 51.0.2704.90, I want to uninstall it and re-install the latest version, but met one issue. the chrome can't delete due to this is installed when emulator created.

C:\Users\v-tomliu>adb uninstall com.android.chrome Failure [DELETE_FAILED_INTERNAL_ERROR]

tomliuxin commented 8 years ago

and run cases at android 7.1.1 and chrome version is:53.0.2785.134, met the same as issue: [Chromedriver] Error: unknown error: Chrome version must be >= 53.0.2785.0 (Driver info: chromedriver=2.25.426923 (0390b88869384d6eb0d5d09729679f934aab9eed),platform=Windows NT 10.0.14393 x86_64)

SrinivasanTarget commented 8 years ago

Latest version of chromedriver works fine with the latest chrome browser. Please update your chrome browser to 54.x.x and give a try.

rafalf commented 8 years ago

There's a link where chrome apks are: http://testprojects.co/automation/2016/10/20/appium-installation-python-chrome.html

tomliuxin commented 8 years ago

@rafalf , thanks for sharing this.

tomliuxin commented 8 years ago

@SrinivasanTarget why I still met this issue, after I upgrade the Chrome browser to 54.0.2840.85

appium 1.6.0 android emulator 7.0 uiautomator2, version 0.0.7 chrome browser 54.x.x chrome driver 2.25.426923

[MJSONWP] Encountered internal error running command: Error: unknown error: Chrome version must be >= 53.0.2785.0 (Driver info: chromedriver=2.25.426923 (0390b88869384d6eb0d5d09729679f934aab9eed),platform=Windows NT 10.0.14393 x86_64)

tomliuxin commented 8 years ago

and the below code initialize the driver DesiredCapabilities capabilities = new DesiredCapabilities(); capabilities.SetCapability("device", "Android"); capabilities.SetCapability(CapabilityType.Platform, "Windows"); capabilities.SetCapability("deviceName", deviceName); capabilities.SetCapability("platformName", "Android"); capabilities.SetCapability("platformVersion", "7.0"); capabilities.SetCapability("automationName", "uiautomator2"); capabilities.SetCapability("unicodeKeyboard", "True"); capabilities.SetCapability("resetKeyboard", "True"); capabilities.SetCapability("appPackage", appPackage); capabilities.SetCapability("appActivity", appActivity); capabilities.SetCapability("newCommandTimeout", "30000");

        Uri uri = new Uri(uriString);
        TimeSpan timeSpan = TimeSpan.FromMinutes(20);
        myDriver = new AndroidDriver<AppiumWebElement>(uri, capabilities, timeSpan);

        ReadOnlyCollection<string> contexts = myDriver.Contexts;

        for (int i = 0; i < contexts.Count; i++)
        {
            if (contexts[i].Contains("WEBVIEW"))
            {
                myDriver.Context = contexts[i];
                break;
            }
        }
rafalf commented 8 years ago

Kill that emulator and start from scratch. Once created install the apk.

tomliuxin commented 8 years ago

@rafalf , could you help to provide more details about this? Thanks.

I created one new emulator 7.0 and there is NO chrome browser at this emulator, then I install the 54.0.2840.85 version chrome to that emulator: adb install ***.apk checked the chrome browser installed successfully.

but I run the cases still met the issue. MJSONWP] Encountered internal error running command: Error: unknown error: Chrome version must be >= 53.0.2785.0

not sure why? Thanks.

rafalf commented 8 years ago

@ try another apk. maybe this one: http://www.apkmirror.com/apk/google-inc/chrome/chrome-54-0-2840-68-release/chrome-54-0-2840-68-3-android-apk-download/download/ I think i ran into this issue before and tried out another apk and it worked, cannot remember.

tomliuxin commented 8 years ago

Thanks rafalf.

I don't know why, I kill the emulator and created again and again, and try at: chrome browser: 54.0.2840.85 and 54.0.2840.68, still met that issue........

tomliuxin commented 8 years ago

using the below switch the context:
myDriver.Context = contexts[i]; met the issue: Error: unknown error: Chrome version must be >= 53.0.2785.0

using the below code switch the context: myDriver.SwitchTo().Window(contexts[i]); met the issue: Encountered internal error running command: Error: Could not proxy. Proxy error: Could not proxy command to remote server. Original error: 404 - undefined

rafalf commented 8 years ago

@tomliuxin How come you are on chromedriver=2.25.426923 ? I am on appium 1.6 as well and on .21 and its working like a charm with on API LEVEL 24 (7.0) :

com.android.chrome_47.0.2526.83-252608310_minAPI16(x86)(nodpi).apk

[Chromedriver] Spawning chromedriver with: C:\Users\rafal\AppData\Roaming\npm\node_modules\appium\node_modules\appium-chromedriver\chromedriver\win\chromedriver.exe --url-base=wd/hub --port=8000 --adb-port=5037
[Chromedriver] [STDOUT] Starting ChromeDriver 2.21.371459 (36d3d07f660ff2bc1bf28a75d1cdabed0983e7c4) on port 8000
Only local connections are allowed.
rafalf commented 8 years ago

@tomliuxin -- Ok you must have the appium 1.6.1 beta it's all working well for me with -- com.android.chrome_54.0.2840.68-284006811_minAPI21(x86)(nodpi)_apkmirror.com.apk and beta

tomliuxin commented 8 years ago

@rafalf, Thanks.

after uninstall the chromedriver(2.25.) and install the chromedriver(2.21.1) Yes, the android driver can initialize and the context can change to WEBVIEW_**

but when execute the below code: Driver.PressKeyCode(AndroidKeyCode.Keycode_ENTER);

met one issue: [MJSONWP] Encountered internal error running command: TypeError: Cannot read property 'sendAction' of undefined

Log:

[Chromedriver] No old chromedrivers seemed to exist [Chromedriver] Spawning chromedriver with: C:\Users\v-tomliu\AppData\Roaming\npm\node_modules\appium\node_modules\appium-chromedriver\chromedriver\win\chromedriver.exe --url-base=wd/hub --port=8000 --adb-port=5037 [Chromedriver] [STDOUT] Starting ChromeDriver 2.21.371459 (36d3d07f660ff2bc1bf28a75d1cdabed0983e7c4) on port 8000 Only local connections are allowed. [JSONWP Proxy] Proxying [GET /status] to [GET http://127.0.0.1:8000/wd/hub/status] with no body [JSONWP Proxy] Got response with status 200: "{\"sessionId\":\"\",\"stat... [JSONWP Proxy] Proxying [POST /session] to [POST http://127.0.0.1:8000/wd/hub/session] with body: {"desiredCapabilities":{"ch... [JSONWP Proxy] Got response with status 200: {"sessionId":"77ed1c115f3f6... [debug] [Chromedriver] Changed state to 'online' [MJSONWP] Responding to client with driver.setContext() result: null [HTTP] <-- POST /wd/hub/session/19d5054e-93fc-4eb2-a44e-25ceedeaa57f/context 200 2107 ms - 76 [HTTP] --> POST /wd/hub/session/19d5054e-93fc-4eb2-a44e-25ceedeaa57f/appium/device/press_keycode {"keycode":66} [MJSONWP] Calling AppiumDriver.pressKeyCode() with args: [66,null,null,null,"19d5054... [MJSONWP] Encountered internal error running command: TypeError: Cannot read property 'sendAction' of undefined at AndroidUiautomator2Driver.callee$0$0$ (lib/commands/actions.js:22:30) at tryCatch (C:\Users\v-tomliu\AppData\Roaming\npm\node_modules\appium\node_modules\babel-runtime\regenerator\runtime.js:67:40) at GeneratorFunctionPrototype.invoke as _invoke at GeneratorFunctionPrototype.prototype.(anonymous function) as next at invoke (C:\Users\v-tomliu\AppData\Roaming\npm\node_modules\appium\node_modules\babel-runtime\regenerator\runtime.js:136:37) at enqueueResult (C:\Users\v-tomliu\AppData\Roaming\npm\node_modules\appium\node_modules\babel-runtime\regenerator\runtime.js:185:17) at Promise.F (C:\Users\v-tomliu\AppData\Roaming\npm\node_modules\appium\node_modules\core-js\library\modules\$.export.js:30:36) at AsyncIterator.enqueue (C:\Users\v-tomliu\AppData\Roaming\npm\node_modules\appium\node_modules\babel-runtime\regenerator\runtime.js:184:12) at AsyncIterator.prototype.(anonymous function) as next at Object.runtime.async (C:\Users\v-tomliu\AppData\Roaming\npm\node_modules\appium\node_modules\babel-runtime\regenerator\runtime.js:209:12) at AndroidUiautomator2Driver.callee$0$0 as pressKeyCode at lib/basedriver/driver.js:174:24 at tryCatcher (C:\Users\v-tomliu\AppData\Roaming\npm\node_modules\appium\node_modules\bluebird\js\main\util.js:26:23) at Promise._settlePromiseFromHandler (C:\Users\v-tomliu\AppData\Roaming\npm\node_modules\appium\node_modules\bluebird\js\main\promise.js:510:31) at Promise._settlePromiseAt (C:\Users\v-tomliu\AppData\Roaming\npm\node_modules\appium\node_modules\bluebird\js\main\promise.js:584:18) at Promise._settlePromiseAtPostResolution (C:\Users\v-tomliu\AppData\Roaming\npm\node_modules\appium\node_modules\bluebird\js\main\promise.js:248:10) at Async._drainQueue (C:\Users\v-tomliu\AppData\Roaming\npm\node_modules\appium\node_modules\bluebird\js\main\async.js:128:12) at Async._drainQueues (C:\Users\v-tomliu\AppData\Roaming\npm\node_modules\appium\node_modules\bluebird\js\main\async.js:133:10) at Immediate.Async.drainQueues (C:\Users\v-tomliu\AppData\Roaming\npm\node_modules\appium\node_modules\bluebird\js\main\async.js:15:14) at runCallback (timers.js:637:20) at tryOnImmediate (timers.js:610:5) at processImmediate as _immediateCallback [HTTP] <-- POST /wd/hub/session/19d5054e-93fc-4eb2-a44e-25ceedeaa57f/appium/device/press_keycode 500 22 ms - 217

tomliuxin commented 8 years ago

@rafalf

which version for appium-uiautomator-driver at your machine? 0.0.7? did you use the C# code?

tomliuxin commented 8 years ago

when execute the below code to get the driver width, met the issue:

Driver.Manage().Window.Size.Width

Error: unknown error: operation is unsupported on Android\n (Session info: chrome=51.0.2704.91)

rafalf commented 8 years ago

Python. Idont know much about webdriver C# but i think you might be doing it wrong maybe Maybe New Size() ? http://yizeng.me/2014/02/23/how-to-get-window-size-resize-or-maximize-window-using-selenium-webdriver/#c-sharp-example

lock[bot] commented 5 years ago

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.