Android N hangs when appium trying to find element by Xpath or execute pageSource command
https://gist.github.com/korenevichev/3a3607bc085135725864e576df092df2
@triager please label: Android,Bug
Facing same issue...
I've faced with the same problem but in new version of Appium:
Environment
Appium version (or git revision) that exhibits the issue: 1.6.0
Desktop OS/version used to run Appium: MacOSX El Capitan
Node.js version (unless using Appium.app|exe): 6.9.0
Mobile platform/version under test: Android 7.0
Real device or emulator/simulator: Nexus 9(Real device)
Appium logs:
2016-10-21 16:54:13:206 - [HTTP] --> GET /wd/hub/session/b52e2ea0-e142-4c15-945b-81b0f4598e65/source {}
2016-10-21 16:54:13:206 - [MJSONWP] Calling AppiumDriver.getPageSource() with args: ["b52e2ea0-e142-4c15-945b-81b0f4598e65"]
2016-10-21 16:54:13:211 - [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got data from client: {"cmd":"action","action":"source","params":{}}
2016-10-21 16:54:13:215 - [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got command of type ACTION
2016-10-21 16:54:13:216 - [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got command action: source
2016-10-21 17:33:40:324 - [Logcat] Logcat terminated with code 0, signal null
2016-10-21 17:34:09:639 - [HTTP] <-- GET /wd/hub/session/b52e2ea0-e142-4c15-945b-81b0f4598e65/source - - ms - -
Process hangs about 40 min.
Can you make sure you have the latest dependencies.
npm uninstall -g appium && npm install -g appium --no-shrinkwrap
Yes, I've already done it.
@SergeVKom
Can you provide the full logs, as a gist? I just ran a test on Android Nougat and it all worked, so I need more information to go on.
Here is a full log:
https://gist.github.com/SergeVKom/39d3f82b27b74635a3dae0f049bd979e
the problem start from 2016-10-24 09:01:51:444
Any update on this issue. Even I am also facing the same issue.
Hi Team,
We have upgraded Appium to version 1.6.3. We are trying to execute test on Android N. Every thing works well until we try to find an element which is not present irrespective of locator.
The appium hangs for infinite amount of time. But when we minimize the app manually, appium comes out of its stall state and starts identifying elements again.
@Prasant-Sutaria Does this happen immediately? If you start a session, and try to get a non-existent element does it hang?
@imurchie Hi Isaac, Yes after after starting the session if we try to identify an element which doesn't exist.
@Prasant-Sutaria I know it's not an answer, but have you tried the new UiAutomator2 backend? Does it have the same problem?
Hi @jlipps, I tried the new UiAutomator2 backend on Appium 1.6.3 but I am getting socket timeout error. I tried the solutions provided in appium community like installing appium-uiautomator2-driver @0.0.8 but it didn't helped.
Please can someone look into this, I'm having the same issues as above.
Having the similar issues like the ones posted here. 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?
I am also facing Same issue, i.e. after starting the script it runs for some time and then it will stop on particular step i.e while finding element "MobileElement helloText = (MobileElement) androidDriver.findElementByXPath("//*[@index='1'][@text='BILLING'][@resource-id='com.mytwc.common.resource:id/title_text']");" . I am using appium 1.6.4 beta 2 and Nexus 6 with 7.0.
Same code works fine for 6.0 devices, but when try to runon Nexus 6 with 7.0, it hangs in this particular step.
Can some one help on the same?
I am also facing the same issue i.e. after starting the script it runs for some time and then it will stop on particular step
Environment
Android-7.0
Java client 5.0.0Beta6.jar
I installed Appium from CLI ( Appium v1.6.4-beta.2)
can someone please help me why this is happening?
I have a couple of problems as well with Android 7.0 and Appium 1.6.3. The same java test scripts working on Android 6.0.1 with Aapium 1.5.3 started NOT working with Android 7.0 and Appium 1.6.3 while the scripr is sending keys to search box and clicking a file on a file list view under a folder. For the search box issue, the search box is closed and a totally unrelated paged on the test app is opened as soon as keeys are sent to it. For the file clicking, it just doesn't respond at all after clicking without appium error. What should I do?
I would first upgrade your uninstall Appium 1.6.3 and install the latest 1.6.4. Then try again. Are you using the older UIAutomator or the new UIAutomator2 support. I found that entering text into text fields was better in Appium 1.6.4. And then when I converted my automation to use UIAutomator2, it got even faster and more reliable then UIAutomator (old).
Thank you so much for your quick response! I will try the Appium 1.6.4. Will need to consider migrating to uiAutomator3 as well.
I have tried my test script with Appium 1.6.3 and 1.6.4 targeting Android 6.0.1 and 7.0 devices which needs to locate and click on mobile elements on a native app. I use Appium, TestNG and Java. The same test script locates all the elements on Android 6.0.1 and below, while it fails to locate them no matter how try to locate them as shown below. I also tried resource-ids from both regular uiautomator dump and compressed version of the same uiautomator screenshot via uiautomatorviewer. Is this an Appium bug?
@AndroidFindAll({
@AndroidFindBy(uiAutomator = "new UiSelector().resourceId(\"com.directv.dvrscheduler:id/radioOnPhone\")"),
@AndroidFindBy(uiAutomator = "new UiSelector().resourceId(\"com.directv.dvrscheduler:id/llRadioOnPhone\")"),
@AndroidFindBy(uiAutomator = "new UiSelector().text(\"Watch on Phone\").className(\"android.widget.RadioButton\")")
})
private MobileElement watchOnPhoneButton;
Or is there any developer options setting to allow appium locate mobile elements on Android 7.0?
Are you using UIAutomator2? I had to start using it in order to get Android 7.x to work for me...
desiredCapabilities.setCapability("automationName", "uiautomator2");
Thank you! I installed uiautomator2 using "npm install appium-uiautomator2-driver" and then added the "desiredCapabilities.setCapability("automationName", "uiautomator2");" to use the uiautomator2, however I get session creation exception as shown below. Is there something else I should do?
org.openqa.selenium.SessionNotCreatedException: Unable to create new remote session. desired capabilities = Capabilities [{appPackage=com.directv.dvrscheduler, appActivity=.activity.core.Setup, noReset=true, newCommandTimeout=600, automationName=uiautomator2, platformName=Android, deviceName=Android Device}], required capabilities = Capabilities [{}]
Build info: version: '3.0.1', revision: '1969d75', time: '2016-10-18 09:48:19 -0700'
System info: host: 'localhost.localdomain', ip: '127.0.0.1', os.name: 'Linux', os.arch: 'amd64', os.version: '3.10.0-327.36.1.el7.x86_64', java.version: '1.8.0_77'
Driver info: driver.version: AndroidDriver
at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:91)
at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:141)
at io.appium.java_client.remote.AppiumCommandExecutor.execute(AppiumCommandExecutor.java:69)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:601)
at io.appium.java_client.DefaultGenericMobileDriver.execute(DefaultGenericMobileDriver.java:40)
at io.appium.java_client.AppiumDriver.execute(AppiumDriver.java:1)
at io.appium.java_client.android.AndroidDriver.execute(AndroidDriver.java:1)
at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:241)
at org.openqa.selenium.remote.RemoteWebDriver.
at org.openqa.selenium.remote.RemoteWebDriver.
at io.appium.java_client.DefaultGenericMobileDriver.
at io.appium.java_client.AppiumDriver.
at io.appium.java_client.AppiumDriver.
at io.appium.java_client.android.AndroidDriver.
I create a driver in Java like this,
driver = new AndroidDriver
Does it need to be changed to something for uiautomator2?
@Zenerax just use a recent versino of appium and set the desired capabilities; that's all.
I might also need to include uiautomator2 library to the build path. I will give it a shot. Thank you!
@Zenerax You should not have to do any extra library setups for uiautomator2. Just do a clean install of Appium 1.6.4, and make sure all your Android libraries are up-to-date by also installing 'appium-doctor' to verify.
@Zenerax I was also facing the same issue, I tried so many things but finally, the below solution works for me.
I had deleted Appium Settings and Unlock apps from the phone and run tests again so that they reinstalled. That worked for me.
and keep this desiredCapabilities.setCapability("automationName", "uiautomator2");
Regards,
Sanjay
Thank you all! I am trying it out now. I have installed clean install of appium 1.6.4, appium-uiautomator2-driver 0.3.1, appium-android-driver 1.17.2. I added the capability and created the driver as usual . While running the test, I see an error stating that JAVA_HOME is not set, even though echo $JAVA_HOME shows its value. I will need to look into it and hopefully it may be the last hurdle. : )
echo $JAVA_HOME
/usr/java/jdk1.8.0_77
Any update on this? Same issue observed on Android > 7.0 devices. Please let us know if any fix available?
@sridharreddy123 ...as suggested earlier in the thread,
1) use latest appium 1.6.4
2) use uiautomator2 (setCapability accordingly)
3) if point1 and 2 still fails then remove server , settings and unlock apks from device
I have been able to resolve this issue 100% of time with this.
@AmitVerma4HP - I am still unable to automate Android N using the steps you outlined. I am still getting the same error as @Zenerax, i.e. JAVA_HOME is not set...even though it is.
I still have the same problem unresolved. I have filed a separate thread for the JAVA_HOME issue at https://github.com/appium/java-client/issues/633#issuecomment-301067087
@AmitVerma4HP I don't see how that will fix the JAVA_HOME issue?
@Zenerax This sounds like an Appium server config/startup problem. Please make sure that the user starting the appium server process has the same profile config as the user running appium-doctor.
Also, it would help us more if you provide Appium server logs. Please follow the rules provided for logs...
Create a GIST which is a paste of your _full_ Appium logs, and link them here.
Do _NOT_ paste your full Appium logs here, as it will make this issue very long and hard to read!
If you are reporting a bug, _always_ include Appium logs!
As far as we can tell, Android 7.0 support is now mostly stable. Any other issues will be handled in their own specific github issue.
im using 1.6.4 and add the uiautomator2, but i get the following error.
2017-05-25 14:47:25:202 - [MJSONWP] Encountered internal error running command: TypeError: this.grantPermissions is not a function
.....
org.openqa.selenium.WebDriverException: An unknown server-side error occurred while processing the command. Original error: this.grantPermissions is not a function (WARNING: The server did not provide any stacktrace information) Command duration or timeout: 2.59 seconds
....
2017-05-25 14:47:25:272 - [MJSONWP] Encountered internal error running command: Error: Could not proxy. Proxy error: Could not proxy command to remote server. Original error: 404 - undefined
appreciate any help.
@Steve-Liu This has been fixed in 1.6.5.
I am facing issue in Android 7. My scripts are working fine until I accept permission.
I am accepting one for location permission android:id/button1 and
com.android.packageinstaller:id/permission_allow_button to accept . After accepting these permission app is not able to recognise any another element even they are present on screen.
From where I can download latest appium 1.6.4? if i run npm install -g appium command it stuck

I need help :(
@imurchie from where I can download appium 1.6.5?
I installed appium 1.6.5 but still it is giving api 23 not 25.
Im using Appium 1.6.5. has anyone seen a scenario when a spinner dropdown is dismissed then appium cant find any element? and it hangs there till timeout? it works fine on OS 5.1.1 and OS 6.0.1 android but not on the OS 7.0+
https://gist.github.com/Steve-Liu/495a8e9207bab6f5abbd1e6da244d56b
I am seeing the similar issues with Nougat on Appium 1.6.5. Some elements cannot be detected and Appium is just hanging there and no longer responding. I have to manually kill a test to end it. The same tests are running fine with Lollipop.
https://gist.github.com/xshuRoadie/5c15a6a0bb63236403a8a16602fbbd89
Any Updates??? I am also facing same issue, Appium is not responding when some elements not detected.
@xshuRoadie @Kavitha14manoj it'll be nice to create new issues with all the details per issue template. The issue you're facing can have different root causes.
@vikramvi Sure thing. Just opened #8722
I am also seeing the issue on Android 7 with Appium v1.6.5-beta.
@VenkateshPS try to use latest appium and uiautomator2 capability; works pretty ok on android 7/8
any update on this issue, i am facing this issue with AppiumV1.6.5 (appium-desktop-Setup-1.2.0-beta.1)
@RavindraSHirandagi as @vjmaiky mentioned use uiautomator2 capability, works fine for me.
Hello,
I have followed what @vjmaiky and @AmitVerma4HP said. But still I'm facing some issues with Appium 1.6.5 and Android 7 versions.
appium log
[appium-server-logs.txt](https://github.com/appium/appium/files/1236570/appium-server-logs.txt)
My Code
[mycode.zip](https://github.com/appium/appium/files/1236571/mycode.zip)
Please consider my query with urgent priority. I need to submit my tasks to one of my interview tomorrow EoD.
Thanks in advance.
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.
Most helpful comment
Are you using UIAutomator2? I had to start using it in order to get Android 7.x to work for me...
desiredCapabilities.setCapability("automationName", "uiautomator2");