find the xPath with the help of Appium Inspector. But i got Xpath in tree format. (Please find the attached image).
But in inspector tool, i could able to find the element and send key values with this xpath. But via Appium code i could not able to find this element and also send key values.
I used below syntax for xPath. i got error like no such element found.Kindly verify the syntax correct or not.
Kindly let me know, how to fix this error.
I used Appium v1.10.0 (.exe format)
xPath syntax:
driver.findElementByXPath("/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.support.v4.widget.DrawerLayout/android.widget.RelativeLayout/android.widget.RelativeLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.LinearLayout/android.widget.ScrollView/android.widget.LinearLayout/TextInputLayout[1]/android.widget.FrameLayout/android.widget.EditText").sendKeys(“11”);
Appium Log:
[HTTP]
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Returning result: {“status”:0,“value”:true}
[HTTP] --> POST /wd/hub/session/cef36ca5-37ac-488e-a929-a5170c5398e3/element
[HTTP] {“using”:“xpath”,“value”:"/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.support.v4.widget.DrawerLayout/android.widget.RelativeLayout/android.widget.RelativeLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.LinearLayout/android.widget.ScrollView/android.widget.LinearLayout/TextInputLayout[1]/android.widget.FrameLayout/android.widget.EditText"}
[W3C (cef36ca5)] Calling AppiumDriver.findElement() with args: [“xpath”,"/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.support.v4.widget.DrawerLayout/android.widget.RelativeLayout/android.widget.RelativeLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.LinearLayout/android.widget.ScrollView/android.widget.LinearLayout/TextInputLayout[1]/android.widget.FrameLayout/android.widget.EditText",“cef36ca5-37ac-488e-a929-a5170c5398e3”]
[BaseDriver] Valid locator strategies for this request: xpath, id, class name, accessibility id, -android uiautomator
[BaseDriver] Waiting up to 0 ms for condition
[AndroidBootstrap] Sending command to android: {“cmd”:“action”,“action”:“find”,“params”:{“strategy”:“xpath”,“selector”:"/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.support.v4.widget.DrawerLayout/android.widget.RelativeLayout/android.widget.RelativeLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.LinearLayout/android.widget.ScrollView/android.widget.LinearLayout/TextInputLayout[1]/android.widget.FrameLayout/android.widget.EditText",“context”:"",“multiple”:false}}
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got data from client: {“cmd”:“action”,“action”:“find”,“params”:{“strategy”:“xpath”,“selector”:"/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.support.v4.widget.DrawerLayout/android.widget.RelativeLayout/android.widget.RelativeLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.LinearLayout/android.widget.ScrollView/android.widget.LinearLayout/TextInputLayout[1]/android.widget.FrameLayout/android.widget.EditText",“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 ‘/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.support.v4.widget.DrawerLayout/android.widget.RelativeLayout/android.widget.RelativeLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.LinearLayout/android.widget.ScrollView/android.widget.LinearLayout/TextInputLayout[1]/android.widget.FrameLayout/android.widget.EditText’ 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 ‘/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.support.v4.widget.DrawerLayout/android.widget.RelativeLayout/android.widget.RelativeLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.LinearLayout/android.widget.ScrollView/android.widget.LinearLayout/TextInputLayout[1]/android.widget.FrameLayout/android.widget.EditText’ using ‘XPATH’ with the contextId: ‘’ multiple: false
[AndroidBootstrap] Received command result from bootstrap
[MJSONWP] Matched JSONWP error code 7 to NoSuchElementError
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Returning result: {“status”:7,“value”:“No element found”}
[W3C (cef36ca5)] Encountered internal error running command: NoSuchElementError: An element could not be located on the page using the given search parameters.
[W3C (cef36ca5)] at AndroidDriver.helpers.findElOrEls (C:\Program Files (x86)\Appium\resources\app\node_modules\appium-android-driver\lib\commands\find.js:75:11)
[W3C (cef36ca5)] at process._tickCallback (internal/process/next_tick.js:68:7)
[HTTP] <-- POST /wd/hub/session/cef36ca5-37ac-488e-a929-a5170c5398e3/element 404 274 ms - 468