I am using Appium 1.22.3 and webdriverIO5 for Android mobile automation The DOM for the element I am trying to click on is as below:
<android.widget.EditText content-desc="Victory Capital User ID required , ">
I have used different combinations of locators as below:
el = await $('//android.widget.EditText[@content-desc="Victory Capital User ID required , "]');
//el = await $('//*[contains(@text(),"Victory Capital User ID")]');
//el = await `$('//android.widget.ScrollView/android.view.viewGroup/android.view.viewGroup/android.widget.EditText[@content-desc="Victory Capital User ID required , "]');`
el.waitForDisplayed();
el.setValue('onlineid31');
However none of these xpaths work and I get error as below:
2022-09-04 13:37:24:795 - [HTTP] {"using":"xpath","value":"//android.widget.EditText[@content-desc=\"Victory Capital User ID required , \"]"}
2022-09-04 13:37:24:795 - [debug] [W3C (ce5ed04d)] Calling AppiumDriver.findElement() with args: ["xpath","//android.widget.EditText[@content-desc=\"Victory Capital User ID required , \"]","ce5ed04d-1f2a-4481-86a2-2529bc0e84e1"]
2022-09-04 13:37:24:795 - [debug] [BaseDriver] Valid locator strategies for this request: xpath, id, class name, accessibility id, css selector, -android uiautomator
2022-09-04 13:37:24:795 - [debug] [BaseDriver] Waiting up to 0 ms for condition
2022-09-04 13:37:24:796 - [debug] [WD Proxy] Matched '/element' to command name 'findElement'
2022-09-04 13:37:24:796 - [debug] [WD Proxy] Proxying [POST /element] to [POST http://127.0.0.1:8200/wd/hub/session/039cdf80-efa9-4b8b-a118-209ef3a3163d/element] with body: {"strategy":"xpath","selector":"//android.widget.EditText[@content-desc=\"Victory Capital User ID required , \"]","context":"","multiple":false}
2022-09-04 13:37:24:864 - [WD Proxy] Got response with status 404: {"sessionId":"039cdf80-efa9-4b8b-a118-209ef3a3163d","value":{"error":"no such element","message":"An element could not be located on the page using the given search parameters","stacktrace":"io.appium.uiautomator2.common.exceptions.ElementNotFoundException: An element could not be located on the page using the given search parameters\n\tat io.appium.uiautomator2.handler.FindElement.findElement(FindElement.java:90)\n\tat io.appium.uiautomator2.handler.FindElement.safeHandle(FindElement.java:67)\n\tat io.appium.uiautomator2.handler.request.SafeRequestHandler.handle(SafeRequestHandler.java:59)\n\tat io.appium.uiautomator2.server.AppiumServlet.handleRequest(AppiumServlet.java:266)\n\tat io.appium.uiautomator2.server.AppiumServlet.handleHttpRequest(AppiumServlet.java:260)\n\tat io.appium.uiautomator2.http.ServerHandler.channelRead(ServerHandler.java:68)\n\tat io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:366)\n\tat io.netty.channel.AbstractChannelHandlerCont...
2022-09-04 13:37:24:864 - [debug] [W3C] Matched W3C error code 'no such element' to NoSuchElementError
2022-09-04 13:37:24:865 - [debug] [W3C (ce5ed04d)] Encountered internal error running command: NoSuchElementError: An element could not be located on the page using the given search parameters.
2022-09-04 13:37:24:865 - [debug] [W3C (ce5ed04d)] at AndroidUiautomator2Driver.findElOrEls (/opt/testdroid/appium-1.22.3/node_modules/appium/node_modules/appium-android-driver/lib/commands/find.js:75:11)
2022-09-04 13:37:24:865 - [debug] [W3C (ce5ed04d)] at runMicrotasks (<anonymous>)
2022-09-04 13:37:24:865 - [debug] [W3C (ce5ed04d)] at processTicksAndRejections (internal/process/task_queues.js:93:5)
2022-09-04 13:37:24:865 - [HTTP] <-- POST /wd/hub/session/ce5ed04d-1f2a-4481-86a2-2529bc0e84e1/element 404 70 ms - 510