After Accepting a popup, Appium can’t find any element in the app

ENV:
Appium latest 1.6.4
Android 7.1.1

I have a problem with appium, I have test that logins on android native app login screen, closes whats new popup and press menu button on next activity. On this activity appium can not get any element. Also it can’t get page source. It tries to perform any action and suspends for infinite time until app or test will be closed. Before this moment all the actions performs fine. I can’t figure out. Is it some problem with my app? Feels like appium can’t see any stuff on activity.

Appium Logs:
[AndroidBootstrap] Sending command to android: {“cmd”:“action”,“action”:“element:click”,“params”:{“elementId”:“6”}}
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got data from client: {“cmd”:“action”,“action”:“element:click”,“params”:{“elementId”:“6”}}
[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}
[AndroidBootstrap] Received command result from bootstrap
[W3C] Responding to client with driver.click() result: true
[HTTP] <-- POST /wd/hub/session/d74e0285-8c9f-48b1-9b86-963572ea80a9/element/6/click 200 3166 ms - 14
[HTTP]
[HTTP] --> POST /wd/hub/session/d74e0285-8c9f-48b1-9b86-963572ea80a9/element
[HTTP] {“using”:“xpath”,“value”:"//android.widget.EditText[contains(@resource-id,‘com.myapp:id/messageEdit’)]"}
[W3C] Calling AppiumDriver.findElement() with args: [“xpath”,"//android.widget.EditText[contains(@resource-id,‘com.myapp:id/messageEdit’)]",“d74e0285-8c9f-48b1-9b86-963572ea80a9”]
[BaseDriver] Valid locator strategies for this request: xpath, id, class name, accessibility id, -android uiautomator
[BaseDriver] Waiting up to 30000 ms for condition
[AndroidBootstrap] Sending command to android: {“cmd”:“action”,“action”:“find”,“params”:{“strategy”:“xpath”,“selector”:"//android.widget.EditText[contains(@resource-id,‘com.myapp:id/messageEdit’)]",“context”:"",“multiple”:false}}
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got data from client: {“cmd”:“action”,“action”:“find”,“params”:{“strategy”:“xpath”,“selector”:"//android.widget.EditText[contains(@resource-id,‘com.myapp:id/messageEdit’)]",“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.EditText[contains(@resource-id,‘com.myapp:id/messageEdit’)]’ using ‘XPATH’ with the contextId: ‘’ multiple: false

I also cannot find by ID. Any information on this would be appreciated.

@AravindBS_09
According to your logs, the automation strategy for new driver( UiAutomator2 driver) is not set in your script.

So ,if you are using android device with OS version 6.0 and above
then add the below capability and re-execute your script again. You will not face the actions suspend for infinite time with this case. You may have to update some locator strategy at some places in the scripts but scripts execution will be faster.

caps.setCapability(MobileCapabilityType.AUTOMATION_NAME, “uiAutomator2”);

Share the Appium logs again if you still face this issue with uiAutomator2

@Peridactite share Appium logs and detail information of the issue ?

1 Like

Hi @harshitj,

Still it is not recognizing the element. I am getting some below error in the logs mentioned below.

I am trying to click Text box and enter some values and need to click send button. But it is not recognizing the textbox only.

Console Logs:
An element could not be located on the page using the given search parameters.
For documentation on this error, please visit: http://seleniumhq.org/exceptions/no_such_element.html
Build info: version: ‘3.13.0’, revision: ‘2f0d292’, time: ‘2018-06-25T15:32:14.902Z’
System info: host: ‘WLE17C0D’, ip: ‘10.1.18.36’, os.name: ‘Windows 10’, os.arch: ‘amd64’, os.version: ‘10.0’, java.version: ‘1.8.0_172’
Driver info: io.appium.java_client.android.AndroidDriver
Capabilities {appActivity: com.myapp.activities.Splas…, appPackage: com.myapp, autoGrantPermissions: true, automationName: uiAutomator2, databaseEnabled: false, desired: {appActivity: com.myapp.activities.Splas…, appPackage: com.myapp, autoGrantPermissions: true, automationName: uiAutomator2, deviceName: Galaxy On5 Pro, noReset: true, platformName: android, platformVersion: 7.1.1, udid: 420016e19aae9479}, deviceApiLevel: 25, deviceManufacturer: samsung, deviceModel: SM-G550FY, deviceName: 420016e19aae9479, deviceScreenDensity: 320, deviceScreenSize: 720x1280, deviceUDID: 420016e19aae9479, javascriptEnabled: true, locationContextEnabled: false, networkConnectionEnabled: true, noReset: true, pixelRatio: 2, platform: LINUX, platformName: LINUX, platformVersion: 7.1.1, statBarHeight: 48, takesScreenshot: true, udid: 420016e19aae9479, viewportRect: {height: 1232, left: 0, top: 48, width: 720}, warnings: {}, webStorageEnabled: false}
Session ID: 6336b08c-a9d9-47c0-a3c0-779ccfb795f8
*** Element info: {Using=xpath, value=//android.widget.EditText[contains(@resource-id,‘com.myapp:id/messageEdit’)]}

Appium Logs:
[W3C] Calling AppiumDriver.findElement() with args: [“xpath”,"//android.widget.EditText[contains(@resource-id,‘com.myapp:id/messageEdit’)]",“6336b08c-a9d9-47c0-a3c0-779ccfb795f8”]
[BaseDriver] Valid locator strategies for this request: xpath, id, class name, accessibility id, -android uiautomator
[BaseDriver] Waiting up to 30000 ms for condition
[JSONWP Proxy] Proxying [POST /element] to [POST http://localhost:8201/wd/hub/session/1387fc1d-eee8-43dc-9c37-c3f0b4eddfa7/element] with body: {“strategy”:“xpath”,“selector”:"//android.widget.EditText[contains(@resource-id,‘com.myapp:id/messageEdit’)]",“context”:"",“multiple”:false}
[W3C] Encountered internal error running command: {“w3cStatus”:400,“jsonwp”:{“sessionId”:“1387fc1d-eee8-43dc-9c37-c3f0b4eddfa7”,“status”:7,“value”:“An element could not be located on the page using the given search parameters.”}} ProxyRequestError: Could not proxy command to remote server. Original error: 500 - {“sessionId”:“1387fc1d-eee8-43dc-9c37-c3f0b4eddfa7”,“status”:7,“value”:“An element could not be located on the page using the given search parameters.”}
[W3C] at JWProxy.proxy$ (C:\Users\104167\AppData\Local\Programs\Appium\resources\app\node_modules\appium\node_modules\appium-base-driver\lib\jsonwp-proxy\proxy.js:152:13)
[W3C] at tryCatch (C:\Users\104167\AppData\Local\Programs\Appium\resources\app\node_modules\appium\node_modules\babel-runtime\regenerator\runtime.js:67:40)
[W3C] at GeneratorFunctionPrototype.invoke [as _invoke] (C:\Users\104167\AppData\Local\Programs\Appium\resources\app\node_modules\appium\node_modules\babel-runtime\regenerator\runtime.js:315:22)
[W3C] at GeneratorFunctionPrototype.prototype.(anonymous function) [as throw] (C:\Users\104167\AppData\Local\Programs\Appium\resources\app\node_modules\appium\node_modules\babel-runtime\regenerator\runtime.js:100:21)
[W3C] at GeneratorFunctionPrototype.invoke (C:\Users\104167\AppData\Local\Programs\Appium\resources\app\node_modules\appium\node_modules\babel-runtime\regenerator\runtime.js:136:37)
[W3C] at
[MJSONWP] Matched JSONWP error code 7 to NoSuchElementError
[HTTP] <-- POST /wd/hub/session/6336b08c-a9d9-47c0-a3c0-779ccfb795f8/element 404 238 ms - 1640

@AravindBS_09
Can you print and share pageSource along with appium log.

print pageSource just before action/findElement is called for the Textbox(com.myapp:id/messageEdit)

Hi @harshitj,

I have attached the appium logs and page source text file. Please check it out
PageSource.txt (10.7 KB)
AppiumLog.txt (8.2 KB)

According to these logs, driver is able to find element and then performed setValue(“Hi”) operation.

I do not see above error this time An element could not be located on the page using the given search parameters.

Also, Which java client version you are using now ?

Logs:
W3C] Calling AppiumDriver.findElement() with args: [“xpath”,"//android.widget.EditText[contains(@resource-id,‘com.myapp:id/messageEdit’)]",“8e40be6e-097b-4a2b-84be-3887b61af06a”]
[BaseDriver] Valid locator strategies for this request: xpath, id, class name, accessibility id, -android uiautomator
[BaseDriver] Waiting up to 0 ms for condition
[JSONWP Proxy] Proxying [POST /element] to [POST http://localhost:8204/wd/hub/session/0ef0f0ac-050e-48d2-bb1c-ad4904b89a80/element] with body: {“strategy”:“xpath”,“selector”:"//android.widget.EditText[contains(@resource-id,‘com.myapp:id/messageEdit’)]",“context”:"",“multiple”:false}
[JSONWP Proxy] Got response with status 200: {“sessionId”:“0ef0f0ac-050e-48d2-bb1c-ad4904b89a80”,“status”:0,“value”:{“ELEMENT”:“26dd1781-9c26-4d51-bdfd-db84dcb7933c”}}
[W3C] Responding to client with driver.findElement() result: {“element-6066-11e4-a52e-4f735466cecf”:“26dd1781-9c26-4d51-bdfd-db84dcb7933c”}
[HTTP] <-- POST /wd/hub/session/8e40be6e-097b-4a2b-84be-3887b61af06a/element 200 79 ms - 88
[HTTP]
[HTTP] --> POST /wd/hub/session/8e40be6e-097b-4a2b-84be-3887b61af06a/element/26dd1781-9c26-4d51-bdfd-db84dcb7933c/value
[HTTP] {“id”:“26dd1781-9c26-4d51-bdfd-db84dcb7933c”,“text”:“Hi”,“value”:[“H”,“i”]}
[W3C] Calling AppiumDriver.setValue() with args: [[“H”,“i”],“26dd1781-9c26-4d51-bdfd-db84dcb7933c”,“8e40be6e-097b-4a2b-84be-3887b61af06a”]
[JSONWP Proxy] Proxying [POST /element/26dd1781-9c26-4d51-bdfd-db84dcb7933c/value] to [POST http://localhost:8204/wd/hub/session/0ef0f0ac-050e-48d2-bb1c-ad4904b89a80/element/26dd1781-9c26-4d51-bdfd-db84dcb7933c/value] with body: {“elementId”:“26dd1781-9c26-4d51-bdfd-db84dcb7933c”,“text”:“Hi”,“replace”:false}
[JSONWP Proxy] Got response with status 200: {“sessionId”:“0ef0f0ac-050e-48d2-bb1c-ad4904b89a80”,“status”:0,“value”:""}

I am using below java version

java version “1.8.0_172”
Java™ SE Runtime Environment (build 1.8.0_172-b11)
Java HotSpot™ 64-Bit Server VM (build 25.172-b11, mixed mode)

Java client and java are the different things…

Read more about here:
Maven central:
https://mvnrepository.com/artifact/io.appium/java-client

Java client Change logs:

Java Client Wiki

Hi @harshitj

I am using java-client 6.0.0 and My issue got resolved. Now Elements are getting identified.

Thank you for your help.

What did you do to resolve the issue?

Mine started to work after I noticed each ID did not have the app package information in front of it like in other apps. Adding this was working for a while, but it has suddenly stopped working again.

@Peridactite I just included below capability settings in my code that’s all, it just started working

caps.setCapability(MobileCapabilityType.AUTOMATION_NAME, “uiAutomator2”);

@harshitj you saved me. It works