问题
Basically everything works until a notification is displayed on screen. After i dismiss the alert i, appium is no longer detecting any of my buttons, fields, etc. The only things that works is if i put the app in background and resume it. After resume everything works. (i`m using Appium 1.6.4, with Android 7.0).
Any hint here?
回答1:
It is known issue in appium project.
Workaround that I use:
- get coordinates (x, y) of any element on screen before opening dialog
- interact with dialog (e.g. select elements, close etc.)
- tap by coordinates (x, y) after closing dialog:
new TouchAction(driver).tap(x, y).perform();
Only after clicking on screen by coordinates it will find elements.
回答2:
Another workaround for this problem is - you can put app in background and launch again.
driver.runAppInBackground(5);
回答3:
There is a better solution for this if you don't want to click on the permission pop ups. Before you launch/initialise the appium driver, just give all the required permissions to the respective app through adb command as below so that the ALLOW pop up won't be displayed:
adb -s yourDeviceSerialNumber shell pm grant your.app.packagename android.permission.READ_EXTERNAL_STORAGE
adb -s yourDeviceSerialNumber shell pm grant your.app.packagename android.permission.WRITE_EXTERNAL_STORAGE
adb -s yourDeviceSerialNumber shell pm grant your.app.packagename android.permission.ACCESS_FINE_LOCATION
adb -s yourDeviceSerialNumber shell pm grant your.app.packagename android.permission.CAMERA
adb -s yourDeviceSerialNumber shell pm grant your.app.packagename android.permission.READ_CONTACTS
adb -s yourDeviceSerialNumber shell pm grant your.app.packagename android.permission.WRITE_CONTACTS
来源:https://stackoverflow.com/questions/44412211/after-dismissing-the-alert-appium-is-no-longer-detecting-any-element-on-the-scre