## The problem
unknown error: Unsupported locator strategy: -android uiautoma…tor while trying to use findElementsByAndroidUiAutomator Locator.
## Environment
* Appium 1.6.4
* Windows 10
* Android 5.0
* Real device
* Selenium 2.53.1, JDK 1.8, Java Client 4.1.2 chrome for Android 58
## Details
I am automating mobile web application using Appium Server and Selenium. All I want to do is to retrieve the titles of android notification, to achieve this i tried to using the locator: findElementsByAndroidUIAutomator to identify an element using resourceId.
Below is the code written by me:
## Code To Reproduce Issue [ Good To Have ]
package com.roofandfloor.test;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.List;
import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.remote.DesiredCapabilities;
import io.appium.java_client.MobileBy;
import io.appium.java_client.android.AndroidDriver;
public class test02 {
public static void main(String[] args) throws MalformedURLException, InterruptedException {
DesiredCapabilities desc = null;
URL url = null;
desc = new DesiredCapabilities();
desc.setCapability("automationName","Appium");
desc.setCapability("platformName", "Android");
desc.setCapability("platformVersion", "5.0");
desc.setCapability("deviceName", "Lenovo K50a40");
desc.setCapability("browserName", "Chrome");
desc.setCapability("appPackage", "com.android.systemui");
// desc.setCapability("appActivity", "com.google.android.apps.chrome.Main");
url = new URL("http://0.0.0.0:4723/wd/hub");
AndroidDriver driver = new AndroidDriver(url,desc);
driver.openNotifications();
Thread.sleep(5000);
List<WebElement>allNotifications=driver.findElements(MobileBy.AndroidUIAutomator("new UiSelector().resourceId(\"android:id/title\")"));
driver.findElementsByAndroidUIAutomator("new UiSelector().resourceId(\"android:id/title\")");
System.out.println(allNotifications.size());
}
}
## Link to Appium logs
The server is running
Start New SessionStop Server
[Appium] Welcome to Appium v1.6.4
[Appium] Appium REST http interface listener started on 0.0.0.0:4723
[HTTP] --> POST /wd/hub/session {"desiredCapabilities":{"appPackage":"com.android.systemui","platformVersion":"5.0","automationName":"Appium","browserName":"Chrome","platformName":"Android","deviceName":"Lenovo K50a40"}}
[MJSONWP] Calling AppiumDriver.createSession() with args: [{"appPackage":"com.android.systemui","platformVersion":"5.0","automationName":"Appium","browserName":"Chrome","platformName":"Android","deviceName":"Lenovo K50a40"},null,null,null,null]
[BaseDriver] Event 'newSessionRequested' logged at 1494854637730 (18:53:57 GMT+0530 (India Standard Time))
[Appium] Creating new AndroidDriver (v1.17.1) session
[Appium] Capabilities:
[Appium] appPackage: 'com.android.systemui'
[Appium] platformVersion: '5.0'
[Appium] automationName: 'Appium'
[Appium] browserName: 'Chrome'
[Appium] platformName: 'Android'
[Appium] deviceName: 'Lenovo K50a40'
[AndroidDriver] AndroidDriver version: 1.17.1
[BaseDriver] Session created with session id: 2597bc3f-adca-45df-aee7-95ea444b5a10
[AndroidDriver] Getting Java version
[AndroidDriver] Java version is: 1.8.0_131
[AndroidDriver] We're going to run a Chrome-based session
[AndroidDriver] Chrome-type package and activity are com.android.chrome and com.google.android.apps.chrome.Main
[ADB] Checking whether adb is present
[ADB] Using adb.exe from C:\Users\admin\AppData\Local\Android\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] Looking for a device with Android '5.0'
[ADB] Setting device id to IFS8QOZ5O769MNMZ
[ADB] Getting device platform version
[ADB] Getting connected devices...
[ADB] 1 device(s) connected
[ADB] Running 'C:\Users\admin\AppData\Local\Android\android-sdk\platform-tools\adb.exe' with args: ["-P",5037,"-s","IFS8QOZ5O769MNMZ","shell","getprop","ro.build.version.release"]
[AndroidDriver] Using device: IFS8QOZ5O769MNMZ
[ADB] Checking whether adb is present
[ADB] Using adb.exe from C:\Users\admin\AppData\Local\Android\android-sdk\platform-tools\adb.exe
[ADB] Setting device id to IFS8QOZ5O769MNMZ
[AndroidDriver] App file was not listed, instead we're going to run com.android.chrome directly on the device
[AndroidDriver] Checking whether package is present on the device
[ADB] Getting connected devices...
[ADB] 1 device(s) connected
[ADB] Running 'C:\Users\admin\AppData\Local\Android\android-sdk\platform-tools\adb.exe' with args: ["-P",5037,"-s","IFS8QOZ5O769MNMZ","shell","pm","list","packages","com.android.chrome"]
[AndroidDriver] Starting Android session
[ADB] Running 'C:\Users\admin\AppData\Local\Android\android-sdk\platform-tools\adb.exe' with args: ["-P",5037,"-s","IFS8QOZ5O769MNMZ","wait-for-device"]
[ADB] Getting connected devices...
[ADB] 1 device(s) connected
[ADB] Running 'C:\Users\admin\AppData\Local\Android\android-sdk\platform-tools\adb.exe' with args: ["-P",5037,"-s","IFS8QOZ5O769MNMZ","shell","echo","ping"]
[Logcat] Starting logcat capture
[AndroidDriver] Pushing settings apk to device...
[ADB] Getting install status for io.appium.settings
[ADB] Getting connected devices...
[ADB] 1 device(s) connected
[ADB] Running 'C:\Users\admin\AppData\Local\Android\android-sdk\platform-tools\adb.exe' with args: ["-P",5037,"-s","IFS8QOZ5O769MNMZ","shell","pm","list","packages","io.appium.settings"]
[ADB] App is installed
[ADB] Getting package info for io.appium.settings
[ADB] Getting connected devices...
[ADB] 1 device(s) connected
[ADB] Running 'C:\Users\admin\AppData\Local\Android\android-sdk\platform-tools\adb.exe' with args: ["-P",5037,"-s","IFS8QOZ5O769MNMZ","shell","dumpsys","package","io.appium.settings"]
[ADB] Checking whether aapt is present
[ADB] Using aapt.exe from C:\Users\admin\AppData\Local\Android\android-sdk\build-tools\19.1.0\aapt.exe
[ADB] Cannot read version codes of C:\Users\admin\AppData\Local\Programs\appium-desktop\resources\app\node_modules\appium\node_modules\io.appium.settings\app\build\outputs\apk\settings_apk-debug.apk and/or io.appium.settings. Assuming correct app version is already installed
[ADB] Getting connected devices...
[ADB] 1 device(s) connected
[ADB] Running 'C:\Users\admin\AppData\Local\Android\android-sdk\platform-tools\adb.exe' with args: ["-P",5037,"-s","IFS8QOZ5O769MNMZ","shell","getprop","ro.build.version.sdk"]
[ADB] Device API level: 21
[ADB] Getting connected devices...
[ADB] 1 device(s) connected
[ADB] Running 'C:\Users\admin\AppData\Local\Android\android-sdk\platform-tools\adb.exe' with args: ["-P",5037,"-s","IFS8QOZ5O769MNMZ","shell","dumpsys","package","io.appium.settings"]
[AndroidDriver] Pushing unlock helper app to device...
[ADB] Running 'C:\Users\admin\AppData\Local\Android\android-sdk\platform-tools\adb.exe' with args: ["-P",5037,"-s","IFS8QOZ5O769MNMZ","install","C:\\Users\\admin\\AppData\\Local\\Programs\\appium-desktop\\resources\\app\\node_modules\\appium\\node_modules\\appium-unlock\\bin\\unlock_apk-debug.apk"]
[ADB] Device API level: 21
[ADB] Getting connected devices...
[ADB] 1 device(s) connected
[ADB] Running 'C:\Users\admin\AppData\Local\Android\android-sdk\platform-tools\adb.exe' with args: ["-P",5037,"-s","IFS8QOZ5O769MNMZ","shell","settings","put","secure","mock_location","1"]
[ADB] Getting device platform version
[ADB] Getting connected devices...
[ADB] 1 device(s) connected
[ADB] Running 'C:\Users\admin\AppData\Local\Android\android-sdk\platform-tools\adb.exe' with args: ["-P",5037,"-s","IFS8QOZ5O769MNMZ","shell","getprop","ro.build.version.release"]
[ADB] Getting connected devices...
[ADB] 1 device(s) connected
[ADB] Running 'C:\Users\admin\AppData\Local\Android\android-sdk\platform-tools\adb.exe' with args: ["-P",5037,"-s","IFS8QOZ5O769MNMZ","shell","wm","size"]
[ADB] Getting connected devices...
[ADB] 1 device(s) connected
[ADB] Running 'C:\Users\admin\AppData\Local\Android\android-sdk\platform-tools\adb.exe' with args: ["-P",5037,"-s","IFS8QOZ5O769MNMZ","shell","getprop","ro.product.model"]
[ADB] Current device property 'ro.product.model': Lenovo K50a40
[ADB] Getting connected devices...
[ADB] 1 device(s) connected
[ADB] Running 'C:\Users\admin\AppData\Local\Android\android-sdk\platform-tools\adb.exe' with args: ["-P",5037,"-s","IFS8QOZ5O769MNMZ","shell","getprop","ro.product.manufacturer"]
[ADB] Current device property 'ro.product.manufacturer': LENOVO
[AndroidDriver] No app sent in, not parsing package/activity
[AndroidDriver] No app capability. Assuming it is already on the device
[AndroidDriver] Running fast reset (stop and clear)
[ADB] Getting connected devices...
[ADB] 1 device(s) connected
[ADB] Running 'C:\Users\admin\AppData\Local\Android\android-sdk\platform-tools\adb.exe' with args: ["-P",5037,"-s","IFS8QOZ5O769MNMZ","shell","am","force-stop","com.android.chrome"]
[ADB] Getting connected devices...
[ADB] 1 device(s) connected
[ADB] Running 'C:\Users\admin\AppData\Local\Android\android-sdk\platform-tools\adb.exe' with args: ["-P",5037,"-s","IFS8QOZ5O769MNMZ","shell","pm","clear","com.android.chrome"]
[AndroidBootstrap] Watching for bootstrap disconnect
[ADB] Forwarding system: 4724 to device: 4724
[ADB] Running 'C:\Users\admin\AppData\Local\Android\android-sdk\platform-tools\adb.exe' with args: ["-P",5037,"-s","IFS8QOZ5O769MNMZ","forward","tcp:4724","tcp:4724"]
[UiAutomator] Starting UiAutomator
[UiAutomator] Moving to state 'starting'
[UiAutomator] Parsing uiautomator jar
[UiAutomator] Found jar name: 'AppiumBootstrap.jar'
[ADB] Running 'C:\Users\admin\AppData\Local\Android\android-sdk\platform-tools\adb.exe' with args: ["-P",5037,"-s","IFS8QOZ5O769MNMZ","push","C:\\Users\\admin\\AppData\\Local\\Programs\\appium-desktop\\resources\\app\\node_modules\\appium\\node_modules\\appium-android-bootstrap\\bootstrap\\bin\\AppiumBootstrap.jar","/data/local/tmp/"]
[ADB] Attempting to kill all uiautomator processes
[ADB] Getting all processes with uiautomator
[ADB] Getting connected devices...
[ADB] 1 device(s) connected
[ADB] Running 'C:\Users\admin\AppData\Local\Android\android-sdk\platform-tools\adb.exe' with args: ["-P",5037,"-s","IFS8QOZ5O769MNMZ","shell","ps"]
[ADB] No uiautomator process found to kill, continuing...
[UiAutomator] Starting UIAutomator
[ADB] Creating ADB subprocess with args: ["-P",5037,"-s","IFS8QOZ5O769MNMZ","shell","uiautomator","runtest","AppiumBootstrap.jar","-c","io.appium.android.bootstrap.Bootstrap","-e","pkg","com.android.chrome","-e","disableAndroidWatchers",false,"-e","acceptSslCerts",false]
[UiAutomator] Moving to state 'online'
[AndroidBootstrap] Android bootstrap socket is now connected
[ADB] Getting connected devices...
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Registered crash watchers.
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Client connected
[ADB] 1 device(s) connected
[ADB] Running 'C:\Users\admin\AppData\Local\Android\android-sdk\platform-tools\adb.exe' with args: ["-P",5037,"-s","IFS8QOZ5O769MNMZ","shell","dumpsys","window"]
[AndroidDriver] Screen is locked, trying to unlock
[AndroidDriver] Using app unlock, this is going to be deprecated!
[AndroidDriver] Unlocking screen
[ADB] Getting connected devices...
[ADB] 1 device(s) connected
[ADB] Running 'C:\Users\admin\AppData\Local\Android\android-sdk\platform-tools\adb.exe' with args: ["-P",5037,"-s","IFS8QOZ5O769MNMZ","shell","am","force-stop","io.appium.unlock"]
[AndroidBootstrap] Emitting alert message...
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Emitting system alert message
[ADB] Device API level: 21
[ADB] Getting connected devices...
[ADB] 1 device(s) connected
[ADB] Running 'C:\Users\admin\AppData\Local\Android\android-sdk\platform-tools\adb.exe' with args: ["-P",5037,"-s","IFS8QOZ5O769MNMZ","shell","am","start","-W","-n","io.appium.unlock/.Unlock","-a","android.intent.action.MAIN","-c","android.intent.category.LAUNCHER","-f","0x10200000"]
[ADB] Device API level: 21
[ADB] Getting connected devices...
[ADB] 1 device(s) connected
[ADB] Running 'C:\Users\admin\AppData\Local\Android\android-sdk\platform-tools\adb.exe' with args: ["-P",5037,"-s","IFS8QOZ5O769MNMZ","shell","am","start","-W","-n","io.appium.unlock/.Unlock","-a","android.intent.action.MAIN","-c","android.intent.category.LAUNCHER","-f","0x10200000"]
[ADB] Getting connected devices...
[ADB] 1 device(s) connected
[ADB] Running 'C:\Users\admin\AppData\Local\Android\android-sdk\platform-tools\adb.exe' with args: ["-P",5037,"-s","IFS8QOZ5O769MNMZ","shell","dumpsys","window"]
[AndroidDriver] Screen unlocked successfully
[AndroidDriver] Starting a chrome-based browser session
[AndroidDriver] A port was not given, using random port: 8000
[Chromedriver] Changed state to 'starting'
[Chromedriver] Set chromedriver binary as: C:\Users\admin\AppData\Local\Programs\appium-desktop\resources\app\node_modules\appium\node_modules\appium-chromedriver\chromedriver\win\chromedriver.exe
[Chromedriver] Killing any old chromedrivers, running: FOR /F "usebackq tokens=5" %a in (`netstat -nao ^| findstr /R /C:"8000 "`) do (FOR /F "usebackq" %b in (`TASKLIST /FI "PID eq %a" ^| findstr /I chromedriver.exe`) do (IF NOT %b=="" TASKKILL /F /PID %a))
[Chromedriver] No old chromedrivers seemed to exist
[Chromedriver] Spawning chromedriver with: C:\Users\admin\AppData\Local\Programs\appium-desktop\resources\app\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.28.455520 (cc17746adff54984afff480136733114c6b3704b) 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\":\"\",\"status\":0,\"value\":{\"build\":{\"version\":\"alpha\"},\"os\":{\"arch\":\"x86_64\",\"name\":\"Windows NT\",\"version\":\"10.0.14393\"}}}"
[JSONWP Proxy] Proxying [POST /session] to [POST http://127.0.0.1:8000/wd/hub/session] with body: {"desiredCapabilities":{"chromeOptions":{"androidPackage":"com.android.chrome","androidDeviceSerial":"IFS8QOZ5O769MNMZ"}}}
[JSONWP Proxy] Got response with status 200: {"sessionId":"d171c0ab826d95306977ef385f120a7b","status":0,"value":{"acceptSslCerts":true,"applicationCacheEnabled":false,"browserConnectionEnabled":false,"browserName":"chrome","chrome":{"chromedriverVersion":"2.28.455520 (cc17746adff54984afff480136733114c6b3704b)"},"cssSelectorsEnabled":true,"databaseEnabled":false,"handlesAlerts":true,"hasTouchScreen":true,"javascriptEnabled":true,"locationContextEnabled":true,"mobileEmulationEnabled":false,"nativeEvents":true,"pageLoadStrategy":"normal","platform":"ANDROID","rotatable":false,"takesHeapSnapshot":true,"takesScreenshot":true,"unexpectedAlertBehaviour":"","version":"58.0.3029.83","webStorageEnabled":true}}
[Chromedriver] Changed state to 'online'
[Appium] New AndroidDriver session created successfully, session 2597bc3f-adca-45df-aee7-95ea444b5a10 added to master session list
[BaseDriver] Event 'newSessionStarted' logged at 1494854666107 (18:54:26 GMT+0530 (India Standard Time))
[MJSONWP] Responding to client with driver.createSession() result: {"platform":"LINUX","webStorageEnabled":false,"takesScreenshot":true,"javascriptEnabled":true,"databaseEnabled":false,"networkConnectionEnabled":true,"locationContextEnabled":false,"warnings":{},"desired":{"appPackage":"com.android.systemui","platformVersion":"5.0","automationName":"Appium","browserName":"Chrome","platformName":"Android","deviceName":"Lenovo K50a40"},"appPackage":"com.android.systemui","platformVersion":"5.0","automationName":"Appium","browserName":"Chrome","platformName":"Android","deviceName":"IFS8QOZ5O769MNMZ","deviceUDID":"IFS8QOZ5O769MNMZ","deviceScreenSize":"1080x1920","deviceModel":"Lenovo K50a40","deviceManufacturer":"LENOVO"}
[HTTP] <-- POST /wd/hub/session 200 28387 ms - 731
[HTTP] --> POST /wd/hub/session/2597bc3f-adca-45df-aee7-95ea444b5a10/appium/device/open_notifications {}
[MJSONWP] Calling AppiumDriver.openNotifications() with args: ["2597bc3f-adca-45df-aee7-95ea444b5a10"]
[AndroidBootstrap] Sending command to android: {"cmd":"action","action":"openNotification","params":{}}
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got data from client: {"cmd":"action","action":"openNotification","params":{}}
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got command of type ACTION
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got command action: openNotification
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Returning result: {"status":0,"value":true}
[AndroidBootstrap] Received command result from bootstrap
[MJSONWP] Responding to client with driver.openNotifications() result: true
[HTTP] <-- POST /wd/hub/session/2597bc3f-adca-45df-aee7-95ea444b5a10/appium/device/open_notifications 200 260 ms - 76
[AndroidBootstrap] Emitting alert message...
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Emitting system alert message
[HTTP] --> POST /wd/hub/session/2597bc3f-adca-45df-aee7-95ea444b5a10/elements {"using":"-android uiautomator","value":"new UiSelector().resourceId(\"android:id/title\")"}
[MJSONWP] Driver proxy active, passing request on via HTTP proxy
[JSONWP Proxy] Proxying [POST /wd/hub/session/2597bc3f-adca-45df-aee7-95ea444b5a10/elements] to [POST http://127.0.0.1:8000/wd/hub/session/d171c0ab826d95306977ef385f120a7b/elements] with body: {"using":"-android uiautomator","value":"new UiSelector().resourceId(\"android:id/title\")"}
[JSONWP Proxy] Got response with status 200: {"sessionId":"d171c0ab826d95306977ef385f120a7b","status":13,"value":{"message":"unknown error: Unsupported locator strategy: -android uiautomator\n (Session info: chrome=58.0.3029.83)\n (Driver info: chromedriver=2.28.455520 (cc17746adff54984afff480136733114c6b3704b),platform=Windows NT 10.0.14393 x86_64)"}}
[JSONWP Proxy] Replacing sessionId d171c0ab826d95306977ef385f120a7b with 2597bc3f-adca-45df-aee7-95ea444b5a10
[HTTP] <-- POST /wd/hub/session/2597bc3f-adca-45df-aee7-95ea444b5a10/elements 200 1398 ms - 315