I met the problem when i try to run script on android 7.0. I want to tap on Policy button after closing the dialog. But cannot tap on it and error about "cannot find element" is shown. I tried to some cases on other screen and the same error still displayed.
When run on android 5.x or 6.x, i don't meet this problem
Not enough details are provided. Please fill out the issue reporting form carefully.
I have same problem

Appium server log in attached files
log_30-03-2017.txt
I couldn't find any errors in those logs. Nor can I see anything going wrong in the video you provided. Can you provide more information>
After I close dialog, appium can not load a new screenshot and can not interact with any items before I click on any item myself
I also faced the same issue, with:
Appium 1.6.4
Android 7.0
I open dialog, interact with it and close.
And after it I cannot find any elements on screen.
On e.g. driver.findElement(By.xpath("//*[contains(@text,'First')]")); hangs:
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got command of type ACTION
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got command action: find
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Finding '//*[contains(@text,'First')]' using 'XPATH' with the contextId: '' multiple: false
On driver.getPageSource() it just hangs, and last lines in terminal:
[HTTP] --> GET /wd/hub/session/895d3dd9-09a8-4ee9-ac00-168e300d4fc3/source {}
[debug] [MJSONWP] Calling AppiumDriver.getPageSource() with args: ["895d3dd9-09a8-4ee9-ac00-168e300d4fc3"]
[debug] [AndroidBootstrap] Sending command to android: {"cmd":"action","action":"source","params":{}}
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got data from client: {"cmd":"action","action":"source","params":{}}
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got command of type ACTION
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got command action: source
And only after clicking on screen manually it will find elements.
Some kind of workaround - get coordinates of any element on screen before opening dialog, interact with dialog and just tap by coordinates after closing dialog:
new TouchAction(driver).tap(x, y).perform();
Another workaround until we get this fix : if we put the app in background and resume it after closing the popup/dialog . Appium will start detecting the elements again.
it's happening to me as well with Android: 7.0
Appium 1.6.4 and 1.6.5
Works fine with Android 6.0 and Appium 1.6.4
I am facing same issue. I proceeded with the work around suggested in the thread.
@jlipps - Can you please have a look.
[debug] [MJSONWP] Calling AppiumDriver.implicitWait() with args: [30000,"a8529a06-da98-46ac-a66b-c74bd5fef0c4"]
[debug] [BaseDriver] Set implicit wait to 30000ms
[debug] [MJSONWP] Responding to client with driver.implicitWait() result: null
[HTTP] <-- POST /wd/hub/session/a8529a06-da98-46ac-a66b-c74bd5fef0c4/timeouts/implicit_wait 200 7 ms - 76
[HTTP] --> POST /wd/hub/session/a8529a06-da98-46ac-a66b-c74bd5fef0c4/element {"using":"id","sessionId":"a8529a06-da98-46ac-a66b-c74bd5fef0c4","value":"skip"}
[debug] [MJSONWP] Calling AppiumDriver.findElement() with args: ["id","skip","a8529a06-da98-46ac-a66b-c74bd5fef0c4"]
[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 30000 ms for condition
[debug] [AndroidBootstrap] Sending command to android: {"cmd":"action","action":"find","params":{"strategy":"id","selector":"skip","context":"","multiple":false}}
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got data from client: {"cmd":"action","action":"find","params":{"strategy":"id","selector":"skip","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 'skip' using 'ID' with the contextId: '' multiple: false
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Using: UiSelector[INSTANCE=0, RESOURCE_ID=com.cricbuzz.android:id/skip]
[debug] [AndroidBootstrap] Received command result from bootstrap
[debug] [MJSONWP] Responding to client with driver.findElement() result: {"ELEMENT":"1"}
[HTTP] <-- POST /wd/hub/session/a8529a06-da98-46ac-a66b-c74bd5fef0c4/element 200 34 ms - 87
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Returning result: {"status":0,"value":{"ELEMENT":"1"}}
[HTTP] --> POST /wd/hub/session/a8529a06-da98-46ac-a66b-c74bd5fef0c4/element/1/click {"sessionId":"a8529a06-da98-46ac-a66b-c74bd5fef0c4","id":"1"}
[debug] [MJSONWP] Calling AppiumDriver.click() with args: ["1","a8529a06-da98-46ac-a66b-c74bd5fef0c4"]
[debug] [AndroidBootstrap] Sending command to android: {"cmd":"action","action":"element:click","params":{"elementId":"1"}}
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got data from client: {"cmd":"action","action":"element:click","params":{"elementId":"1"}}
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got command of type ACTION
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got command action: click
[debug] [AndroidBootstrap] Received command result from bootstrap
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Returning result: {"status":0,"value":true}
[debug] [MJSONWP] Responding to client with driver.click() result: true
[HTTP] <-- POST /wd/hub/session/a8529a06-da98-46ac-a66b-c74bd5fef0c4/element/1/click 200 880 ms - 76
[HTTP] --> POST /wd/hub/session/a8529a06-da98-46ac-a66b-c74bd5fef0c4/element {"using":"-android uiautomator","sessionId":"a8529a06-da98-46ac-a66b-c74bd5fef0c4","value":"new UiSelector().textContains(\"Ok\")"}
[debug] [MJSONWP] Calling AppiumDriver.findElement() with args: ["-android uiautomator","new UiSelector().textContains(\"Ok\")","a8529a06-da98-46ac-a66b-c74bd5fef0c4"]
[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 30000 ms for condition
[debug] [AndroidBootstrap] Sending command to android: {"cmd":"action","action":"find","params":{"strategy":"-android uiautomator","selector":"new UiSelector().textContains(\"Ok\")","context":"","multiple":false}}
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got data from client: {"cmd":"action","action":"find","params":{"strategy":"-android uiautomator","selector":"new UiSelector().textContains(\"Ok\")","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 'new UiSelector().textContains("Ok")' using 'ANDROID_UIAUTOMATOR' with the contextId: '' multiple: false
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Parsing selector: new UiSelector().textContains("Ok")
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] UiSelector coerce type: class java.lang.String arg: "Ok"
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Using: UiSelector[CONTAINS_TEXT=Ok]
[debug] [AndroidBootstrap] Received command result from bootstrap
[debug] [MJSONWP] Responding to client with driver.findElement() result: {"ELEMENT":"2"}
[HTTP] <-- POST /wd/hub/session/a8529a06-da98-46ac-a66b-c74bd5fef0c4/element 200 114 ms - 87
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Returning result: {"status":0,"value":{"ELEMENT":"2"}}
[HTTP] --> POST /wd/hub/session/a8529a06-da98-46ac-a66b-c74bd5fef0c4/element/2/click {"sessionId":"a8529a06-da98-46ac-a66b-c74bd5fef0c4","id":"2"}
[debug] [MJSONWP] Calling AppiumDriver.click() with args: ["2","a8529a06-da98-46ac-a66b-c74bd5fef0c4"]
[debug] [AndroidBootstrap] Sending command to android: {"cmd":"action","action":"element:click","params":{"elementId":"2"}}
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got data from client: {"cmd":"action","action":"element:click","params":{"elementId":"2"}}
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got command of type ACTION
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got command action: click
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Returning result: {"status":0,"value":true}
[debug] [AndroidBootstrap] Received command result from bootstrap
[debug] [MJSONWP] Responding to client with driver.click() result: true
[HTTP] <-- POST /wd/hub/session/a8529a06-da98-46ac-a66b-c74bd5fef0c4/element/2/click 200 3164 ms - 76
[HTTP] --> POST /wd/hub/session/a8529a06-da98-46ac-a66b-c74bd5fef0c4/element {"using":"-android uiautomator","sessionId":"a8529a06-da98-46ac-a66b-c74bd5fef0c4","value":"new UiSelector().textContains(\"Featured Video\")"}
[debug] [MJSONWP] Calling AppiumDriver.findElement() with args: ["-android uiautomator","new UiSelector().textContains(\"Featured Video\")","a8529a06-da98-46ac-a66b-c74bd5fef0c4"]
[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 30000 ms for condition
[debug] [AndroidBootstrap] Sending command to android: {"cmd":"action","action":"find","params":{"strategy":"-android uiautomator","selector":"new UiSelector().textContains(\"Featured Video\")","context":"","multiple":false}}
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got data from client: {"cmd":"action","action":"find","params":{"strategy":"-android uiautomator","selector":"new UiSelector().textContains(\"Featured Video\")","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 'new UiSelector().textContains("Featured Video")' using 'ANDROID_UIAUTOMATOR' with the contextId: '' multiple: false
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Parsing selector: new UiSelector().textContains("Featured Video")
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] UiSelector coerce type: class java.lang.String arg: "Featured Video"
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Using: UiSelector[CONTAINS_TEXT=Featured Video]
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Failed to locate element. Clearing Accessibility cache and retrying.
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Finding 'new UiSelector().textContains("Featured Video")' using 'ANDROID_UIAUTOMATOR' with the contextId: '' multiple: false
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Parsing selector: new UiSelector().textContains("Featured Video")
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] UiSelector coerce type: class java.lang.String arg: "Featured Video"
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Using: UiSelector[CONTAINS_TEXT=Featured Video]
[debug] [AndroidBootstrap] Received command result from bootstrap
[debug] [BaseDriver] Waited for 14351 ms so far
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Returning result: {"status":7,"value":"No element found"}
[debug] [AndroidBootstrap] Sending command to android: {"cmd":"action","action":"find","params":{"strategy":"-android uiautomator","selector":"new UiSelector().textContains(\"Featured Video\")","context":"","multiple":false}}
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got data from client: {"cmd":"action","action":"find","params":{"strategy":"-android uiautomator","selector":"new UiSelector().textContains(\"Featured Video\")","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 'new UiSelector().textContains("Featured Video")' using 'ANDROID_UIAUTOMATOR' with the contextId: '' multiple: false
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Parsing selector: new UiSelector().textContains("Featured Video")
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] UiSelector coerce type: class java.lang.String arg: "Featured Video"
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Using: UiSelector[CONTAINS_TEXT=Featured Video]
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Failed to locate element. Clearing Accessibility cache and retrying.
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Finding 'new UiSelector().textContains("Featured Video")' using 'ANDROID_UIAUTOMATOR' with the contextId: '' multiple: false
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Parsing selector: new UiSelector().textContains("Featured Video")
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] UiSelector coerce type: class java.lang.String arg: "Featured Video"
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Using: UiSelector[CONTAINS_TEXT=Featured Video]
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Returning result: {"status":7,"value":"No element found"}
[debug] [AndroidBootstrap] Received command result from bootstrap
[debug] [BaseDriver] Waited for 27941 ms so far
[debug] [AndroidBootstrap] Sending command to android: {"cmd":"action","action":"find","params":{"strategy":"-android uiautomator","selector":"new UiSelector().textContains(\"Featured Video\")","context":"","multiple":false}}
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got data from client: {"cmd":"action","action":"find","params":{"strategy":"-android uiautomator","selector":"new UiSelector().textContains(\"Featured Video\")","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 'new UiSelector().textContains("Featured Video")' using 'ANDROID_UIAUTOMATOR' with the contextId: '' multiple: false
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Parsing selector: new UiSelector().textContains("Featured Video")
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] UiSelector coerce type: class java.lang.String arg: "Featured Video"
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Using: UiSelector[CONTAINS_TEXT=Featured Video]
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Failed to locate element. Clearing Accessibility cache and retrying.
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Finding 'new UiSelector().textContains("Featured Video")' using 'ANDROID_UIAUTOMATOR' with the contextId: '' multiple: false
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Parsing selector: new UiSelector().textContains("Featured Video")
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] UiSelector coerce type: class java.lang.String arg: "Featured Video"
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Using: UiSelector[CONTAINS_TEXT=Featured Video]
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Returning result: {"status":7,"value":"No element found"}
[debug] [AndroidBootstrap] Received command result from bootstrap
[HTTP] <-- POST /wd/hub/session/a8529a06-da98-46ac-a66b-c74bd5fef0c4/element 500 36250 ms - 164
[HTTP] --> POST /wd/hub/session/a8529a06-da98-46ac-a66b-c74bd5fef0c4/appium/app/close {"sessionId":"a8529a06-da98-46ac-a66b-c74bd5fef0c4"}
[debug] [MJSONWP] Calling AppiumDriver.closeApp() with args: ["a8529a06-da98-46ac-a66b-c74bd5fef0c4"]
[debug] [ADB] Getting connected devices...
[debug] [ADB] 1 device(s) connected
[debug] [ADB] Running '/opt/android-sdk-linux/platform-tools/adb' with args: ["-P",5037,"-s","ZY223XP7ZC","shell","am","force-stop","com.cricbuzz.android"]
[debug] [MJSONWP] Responding to client with driver.closeApp() result: null
[HTTP] <-- POST /wd/hub/session/a8529a06-da98-46ac-a66b-c74bd5fef0c4/appium/app/close 200 1033 ms - 76
Please append autoGrantPermissions Capability into your Desired Capabilities to Appium
automatically determine which permissions your app requires and grant them to the app on install.
Sample code:
capabilities.setCapability("autoGrantPermissions", true);
Then, all permissions are granted to your app, the system dialogs won't display at runtime.
In Android 8 there is the same problem!
@shiveshyadav 's advice helped and use android 6 is worked solutuion too.
Using Android 6 is not a solution as you still don't get automated coverage on Android 8 馃槃
I see this same behavior.
Appium 1.6.5
Android 7.0
I have same problem, its a blocker for me, since once logged in it will ask for permission popup and once i tap Ok from appium, i will not be able to find any elements in dashboard screen.
Android 8.0
Appium v1.7.2
Here is the log - https://gist.github.com/arjunbm13/4201d95f4ed743d69c15dd8e01df0af2
Update: After using UiAutomator2 problem got fixed for me. :)
Appium cannot find any elements after close dialog box -Am facing the same issue with below version
capabilities.setCapability("platformName", "Android");
capabilities.setCapability("platformVersion", "7.1.1");
capabilities.setCapability("deviceName", "emulator-5554");
Appium V-1.2.7
Please give me the workaround solution for this issue, i tried tab using x and y axis no use i got below logs in appium console.
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got data from client: {"cmd":"action","action":"find","params":{"strategy":"xpath","selector":"//android.widget.TextView[@text='New Message']","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.widget.TextView[@text='New Message']' using 'XPATH' with the contextId: '' multiple: false
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Failed to locate element. Clearing Accessibility cache and retrying.
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Finding '//android.widget.TextView[@text='New Message']' using 'XPATH' with the contextId: '' multiple: false
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Returning result: {"status":7,"value":"No element found"}
[AndroidBootstrap] Received command result from bootstrap
[BaseDriver] Waited for 10496 ms so far
[AndroidBootstrap] Sending command to android: {"cmd":"action","action":"find","params":{"strategy":"xpath","selector":"//android.widget.TextView[@text='New Message']","context":"","multiple":false}}
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got data from client: {"cmd":"action","action":"find","params":{"strategy":"xpath","selector":"//android.widget.TextView[@text='New Message']","context":"","multiple":false}}
I am having this same issue in a Create React Native App. I have spun up a minimal version of the problem with code living here: https://github.com/BenAychh/android_cnra_modal (all code is in App.js)
You can also see the issue by using the Inspector with these caps:
{
"platformName": "Android",
"platformVersion": "8.1",
"deviceName": "Android Emulator",
"app": "https://exp-shell-app-assets.s3-us-west-1.amazonaws.com/android%2F%40buildit%2Fdialog-test-a3b91d03-e41b-11e7-b3f7-0a580a780605-signed.apk"
}
Click on the 15 minutes button, then click ok and Appium will lose it's connection to the emulated device.
Same issue here.
Running Appium 1.2.7
Android 8.0
Same here. Android emulator running API 27. Appium x64 v1.23.3. Minimizing and maximizing again the app seems to work, might try and find a way to automate the work-around for now.
The same problem affects the UI view too, and the following page seems to suggest that you can fix it by upgrading the UI automator: https://essenceoftesting.blogspot.co.uk/2017/02/how-to-upgrade-appium-uiautomator2.html but I've not had any success with that.
Looks like it should be possible to automate this workaround using driver.runAppInBackground(Duration.ofSeconds(1));. However, in my case (and with any secure production app) the manifest denies third-party apps access to start it's Intent. So, it will minimize the app but fail to maximize it again.
@Fortnox In the recent beta w've added the activateApp endpoint, which tries to activate the app using monkey tool without explicitly starting its activity.
Same issue faced.
Works with: 5.x and 6.x
Doesn't work: 7.x, 8.x
Appiums tried:
Appium CLI 1.7.2, Appium Desktop Version 1.3.2 - Appium Version 1.7.2, Appium Desktop Version 1.2.7 - Appium Version 1.7.1.
The issue is still present in the latest beta as well. Appium Desktop Version 1.3.2
On some devices (those with quick-switch enabled, but it will completely fail on many others) you can work around this by calling the following two methods (with a wait between):
public void minimize() {
driver.pressKeyCode(AndroidKeyCode.HOME);
}
public void maximize() {
driver.pressKeyCode(AndroidKeyCode.KEYCODE_APP_SWITCH);
app.wait(1500);
driver.pressKeyCode(AndroidKeyCode.KEYCODE_APP_SWITCH);
}
This work-around is far from ideal though, and this issue makes using Appium prohibitively awkward for us unfortunately. In particular there is absolutely no workaround that will work across various devices with 99.99% reliability, making DeviceFarm testing impossible.
I also see the same issue. I know solution @Fortnox suggested works but since issue happens at random places hence its hard to automate things.
2018-03-12 13:56:21:859 - [HTTP] <-- POST /wd/hub/session/41d56d9f-e322-44c8-b6cb-2c27d0cd41d6/element/2/click 200 378 ms - 76
2018-03-12 13:56:21:866 - [HTTP] --> POST /wd/hub/session/41d56d9f-e322-44c8-b6cb-2c27d0cd41d6/element {"using":"id","value":"com.android.packageinstaller:id/permission_allow_button"}
2018-03-12 13:56:21:866 - [debug] [MJSONWP] Calling AppiumDriver.findElement() with args: ["id","com.android.packageinstaller:id/permission_allow_button","41d56d9f-e322-44c8-b6cb-2c27d0cd41d6"]
2018-03-12 13:56:21:867 - [debug] [BaseDriver] Valid locator strategies for this request: xpath, id, class name, accessibility id, -android uiautomator
2018-03-12 13:56:21:867 - [debug] [BaseDriver] Valid locator strategies for this request: xpath, id, class name, accessibility id, -android uiautomator
2018-03-12 13:56:21:867 - [debug] [BaseDriver] Waiting up to 0 ms for condition
2018-03-12 13:56:21:868 - [debug] [AndroidBootstrap] Sending command to android: {"cmd":"action","action":"find","params":{"strategy":"id","selector":"com.android.packageinstaller:id/permission_allow_button","context":"","multiple":false}}
2018-03-12 13:56:21:872 - [debug] [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got data from client: {"cmd":"action","action":"find","params":{"strategy":"id","selector":"com.android.packageinstaller:id/permission_allow_button","context":"","multiple":false}}
2018-03-12 13:56:21:872 - [debug] [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got command of type ACTION
2018-03-12 13:56:21:873 - [debug] [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got command action: find
2018-03-12 13:56:21:873 - [debug] [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Finding 'com.android.packageinstaller:id/permission_allow_button' using 'ID' with the contextId: '' multiple: false
2018-03-12 13:56:21:873 - [debug] [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Using: UiSelector[INSTANCE=0, RESOURCE_ID=com.android.packageinstaller:id/permission_allow_button]
2018-03-12 13:56:22:473 - [debug] [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Returning result: {"status":0,"value":{"ELEMENT":"3"}}
2018-03-12 13:56:22:473 - [debug] [AndroidBootstrap] Received command result from bootstrap
2018-03-12 13:56:22:474 - [debug] [MJSONWP] Responding to client with driver.findElement() result: {"ELEMENT":"3"}
2018-03-12 13:56:22:476 - [HTTP] <-- POST /wd/hub/session/41d56d9f-e322-44c8-b6cb-2c27d0cd41d6/element 200 610 ms - 87
2018-03-12 13:56:22:482 - [HTTP] --> POST /wd/hub/session/41d56d9f-e322-44c8-b6cb-2c27d0cd41d6/element/3/click {"id":"3"}
2018-03-12 13:56:22:483 - [debug] [MJSONWP] Calling AppiumDriver.click() with args: ["3","41d56d9f-e322-44c8-b6cb-2c27d0cd41d6"]
2018-03-12 13:56:22:484 - [debug] [AndroidBootstrap] Sending command to android: {"cmd":"action","action":"element:click","params":{"elementId":"3"}}
2018-03-12 13:56:22:489 - [debug] [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got data from client: {"cmd":"action","action":"element:click","params":{"elementId":"3"}}
2018-03-12 13:56:22:490 - [debug] [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got command of type ACTION
2018-03-12 13:56:22:490 - [debug] [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got command action: click
2018-03-12 13:56:25:651 - [debug] [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Returning result: {"status":0,"value":true}
2018-03-12 13:56:25:652 - [debug] [AndroidBootstrap] Received command result from bootstrap
2018-03-12 13:56:25:653 - [debug] [MJSONWP] Responding to client with driver.click() result: true
2018-03-12 13:56:25:654 - [HTTP] <-- POST /wd/hub/session/41d56d9f-e322-44c8-b6cb-2c27d0cd41d6/element/3/click 200 3171 ms - 76
Mar 12, 2018 1:56:25 PM temp.EverythingRelay toggleSwitch
INFO: toggleSwitch() called...
Printing for Test driver.getCapabilities() : Mi A1
2018-03-12 13:56:25:662 - [HTTP] --> POST /wd/hub/session/41d56d9f-e322-44c8-b6cb-2c27d0cd41d6/element {"using":"id","value":"com.ak.test:id/switch_enable_share"}
2018-03-12 13:56:25:662 - [debug] [MJSONWP] Calling AppiumDriver.findElement() with args: ["id","com.ak.test:id/switch_enable_share","41d56d9f-e322-44c8-b6cb-2c27d0cd41d6"]
2018-03-12 13:56:25:663 - [debug] [BaseDriver] Valid locator strategies for this request: xpath, id, class name, accessibility id, -android uiautomator
2018-03-12 13:56:25:663 - [debug] [BaseDriver] Valid locator strategies for this request: xpath, id, class name, accessibility id, -android uiautomator
2018-03-12 13:56:25:664 - [debug] [BaseDriver] Waiting up to 0 ms for condition
2018-03-12 13:56:25:664 - [debug] [AndroidBootstrap] Sending command to android: {"cmd":"action","action":"find","params":{"strategy":"id","selector":"com.ak.test:id/switch_enable_share","context":"","multiple":false}}
2018-03-12 13:56:25:670 - [debug] [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got data from client: {"cmd":"action","action":"find","params":{"strategy":"id","selector":"com.ak.test:id/switch_enable_share","context":"","multiple":false}}
2018-03-12 13:56:25:670 - [debug] [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got command of type ACTION
2018-03-12 13:56:25:671 - [debug] [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got command action: find
2018-03-12 13:56:25:672 - [debug] [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Finding 'com.ak.test:id/switch_enable_share' using 'ID' with the contextId: '' multiple: false
2018-03-12 13:56:25:672 - [debug] [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Using: UiSelector[INSTANCE=0, RESOURCE_ID=com.ak.test:id/switch_enable_share]
2018-03-12 13:56:27:004 - [debug] [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Failed to locate element. Clearing Accessibility cache and retrying.
2018-03-12 13:56:27:007 - [debug] [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Finding 'com.ak.test:id/switch_enable_share' using 'ID' with the contextId: '' multiple: false
2018-03-12 13:56:27:008 - [debug] [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Using: UiSelector[INSTANCE=0, RESOURCE_ID=com.ak.test:id/switch_enable_share]
2018-03-12 13:56:28:523 - [debug] [AndroidBootstrap] Received command result from bootstrap
2018-03-12 13:56:28:531 - [HTTP] <-- POST /wd/hub/session/41d56d9f-e322-44c8-b6cb-2c27d0cd41d6/element 500 2869 ms - 164
2018-03-12 13:56:28:532 - [debug] [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Returning result: {"status":7,"value":"No element found"}
...
2018-03-12 13:56:28:531 - [HTTP] <-- POST /wd/hub/session/41d56d9f-e322-44c8-b6cb-2c27d0cd41d6/element 500 2869 ms - 164
2018-03-12 13:56:28:532 - [debug] [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Returning result: {"status":7,"value":"No element found"}
Exception in thread "main" org.openqa.selenium.NoSuchElementException: An element could not be located on the page using the given search parameters. (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 0 milliseconds
For documentation on this error, please visit: http://seleniumhq.org/exceptions/no_such_element.html
Build info: version: '3.8.1', revision: '6e95a6684b', time: '2017-12-01T19:05:14.666Z'
System info: host: 'Apoorvs-Air-3', ip: 'fe80:0:0:0:4ce:d6b1:d2e5:3b73%en0', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.13.2', java.version: '1.8.0_152'
Driver info: io.appium.java_client.android.AndroidDriver
Capabilities {appActivity: .MainActivity, appPackage: com.ak.test, databaseEnabled: false, desired: {appActivity: .MainActivity, appPackage: com.ak.test, deviceName: Mi A1, dontStopAppOnReset: true, newCommandTimeout: 120000, noReset: true, platformName: android, udid: 00cad4800904}, deviceManufacturer: Xiaomi, deviceModel: Mi A1, deviceName: 00cad4800904, deviceScreenSize: 1080x1920, deviceUDID: 00cad4800904, dontStopAppOnReset: true, javascriptEnabled: true, locationContextEnabled: false, networkConnectionEnabled: true, newCommandTimeout: 120000, noReset: true, platform: LINUX, platformName: LINUX, platformVersion: 7.1.2, takesScreenshot: true, udid: 00cad4800904, warnings: {}, webStorageEnabled: false}
Session ID: 41d56d9f-e322-44c8-b6cb-2c27d0cd41d6
*** Element info: {Using=id, value=com.ak.test:id/switch_enable_share}
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
The issue is still there, the only solution is to use UiAutomator2 or as @Fortnox suggested, unless appium fix this.
Are there any updates?
This is a huge blocker. Does anyone have a workaround apart from the one from Fortnox.
In my case I can't put the app into background, because it then looses its state.
Saving the location of the next element to click is also a very dirty solution.
@Pascal yes, try to use UiAutomator2 as driver instead
When using uiautomator2, I experience this issue on startup #9777
in Python 3,
we can solve this problem just add one line after dialog line
self.driver.background_app(5)
I have the same issue using Appium 1.8.1
I have the same issue ...
There is a solution ? or we still have to use the coordinates ?
Appium 1.7.2, 1.8.1
Android 7.0
Same problem. After loading spinner dialog appears, Appium is not able to find any element.
The Ruby version of khanhdodang's solution: inside env.rb
```def opts
{
caps: {
platformName: 'Android',
deviceName: 'emulator5554',
app: './app/colorNote.apk',
'autoGrantPermissions': true
}
}
end
I am experiencing the same issue.
@Evie-Skinner18 - Although this fix works but in order for this capability to work we need to install app for each test case.
Android 8.1 - Appium 1.6.2
@hoangquochuynh
# try this when you lose control
duration = 0.1 # seconds
driver.background_app(duration)
This doesn't work if the dialog appears after each unpause of the app
This is happening to me [appium 1.6.2 linux, ruby, Android emulator API 26 and Ruby].
The path is:
1.-Appium performs click on a button
2.-App shows a view about "waiting or updating"
3.-Then appears a form to be filled.
The problem:
When I tried to find an element of the form, appium can't find it. get_source is getting the page elements of the "updating" view instead of the form view and NOP, is not a matter about time sync because I tried with sleep and waits and didn't work. The inspector got stuck in the "updating" view as well.
The workaround:
When the app is showing the "updating" view, I send:
_$driver.press_keycode(187) #recent or multitask keycode
sleep 2
$driver.press_keycode(4) #back button keycode
sleep 5_
Then, get_source works and all elements on the form view are available and I can find them. With less time on the sleepers, it doen't work to me.
Hi All,
I am facing the same issue. Once I dismiss the pop up window of 'Forgot Password' from the 'Login' page then I cannot access any element of the Login Page. I always get "Element Not Found" issue.
But if I try to access all the element before I dismiss the pop up, then it's accessible. Problem start once I dismiss any pop up window.
Appium Version: 1.6.3
Android Device: MI A1
Android OS Version: 8.1.0
Workaround for this issue. You have to minimize the app and maximize again. After that Appium will get all the ID's and you can continue the test.
public static void minimizeMaximize() {
try {
driver.runAppInBackground(10);
((AndroidDriver) driver).startActivity("appPackage", "appActivity");
} catch (Exception e) {
e.printStackTrace();
}
}
You have to enter your app package name and activity name to maximize the app.
For Eg:
public static void minimizeMaximize() {
try {
driver.runAppInBackground(10);
((AndroidDriver) driver).startActivity("com.example.test", "com.example.LaunchApp");
} catch (Exception e) {
e.printStackTrace();
}
}
This will definitely work.
Workaround for this issue. You have to minimize the app and maximize again. After that Appium will get all the ID's and you can continue the test.
public static void minimizeMaximize() {
try {
driver.runAppInBackground(10);
((AndroidDriver) driver).startActivity("appPackage", "appActivity");
} catch (Exception e) {
e.printStackTrace();
}
}You have to enter your app package name and activity name to maximize the app.
For Eg:public static void minimizeMaximize() {
try {
driver.runAppInBackground(10);
((AndroidDriver) driver).startActivity("com.example.test", "com.example.LaunchApp");
} catch (Exception e) {
e.printStackTrace();
}
}This will definitely work.
Thanks for this amazing solution! :-)
BTW this code works fine for me without startActivity :-)
fun returnControlForDriver() {
try {
driver.runAppInBackground(Duration.ofSeconds(1))
} catch (e: Exception) {
e.printStackTrace()
}
}
This is the problem of the framework itself. There is not much that can be done on Appium side
Same issue here:
1- pop-up appears
2- runAppInBackground(3)
3- try to find elements in the page.
And what happens is that i get fewer elements. i get 3 when i should be getting more than 40.
People, I resolved this problem here.
I use the uiautomator2 to Android tests now.
I just added de propriety "automationName": "uiautomator2" in the desiredCapabilities of Appium and now work my tests on Android >6.0.
The problem was the Appium could not index the screen after the dialogs.
People, I resolved this problem here.
I use the uiautomator2 to Android tests now.I just added de propriety
"automationName": "uiautomator2"in the desiredCapabilities of Appium and now work my tests on Android >6.0.The problem was the Appium could not index the screen after the dialogs.
Use capabilities.setCapability(MobileCapabilityType.AUTOMATION_NAME, "uiautomator2");
Note: Tried it with Android 8.1.0
I have tried with automationName capability but still getting same problem. Unable to identify the elements.
I have tried runappbackground also my bad didn't work that as well
Switching app twice works for me.
private void switchingAppsTwice() {
// switching apps twice will open the current app again
switchApp();
switchApp();
}
private void switchApp() {
pressAppSwitchKey();
pressAppSwitchKey();
}
private void pressAppSwitchKey() {
CommandExecutionHelper.execute(driver, new SimpleEntry<>(PRESS_KEY_CODE, new KeyEvent(APP_SWITCH).build()));
// make sure that the command is executed
try {
Thread.sleep(1000);
} catch (InterruptedException ex) {
}
}
@j3t
Thanks for the reply, I have tried your code but for me app didn't switch.
Can you please help me in this?
Thanks,
Surekha
You are on android, right? What exactly happens when your app is started and you simply execute:
CommandExecutionHelper.execute(driver, new SimpleEntry<>(PRESS_KEY_CODE, new KeyEvent(APP_SWITCH).build()));
Have you tried to increase the time between two commands?
I had problem when I opend dropdown menu, choosed option and wanted to perform another action on the page. Simple wait for 1 second fixed the problem (probably appium is too fast for itself and needs to wait to catch again all elements on a page)
Appium version 1.17.1-1
Most helpful comment
People, I resolved this problem here.
I use the uiautomator2 to Android tests now.
I just added de propriety
"automationName": "uiautomator2"in the desiredCapabilities of Appium and now work my tests on Android >6.0.The problem was the Appium could not index the screen after the dialogs.