EDIT: Managed to find the issue, see my edit at the bottom
Hello there, I have a hybrid app, when I access the webview I can see in UIAutomator inspector the element with the following hierarchy:
/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.RelativeLayout/android.webkit.WebView/android.webkit.WebView/android.view.View/android.view.View/android.view.View/android.view.View/android.widget.ListView/android.widget.Button
I can click it just fine via UIAutomator inspector, but haven’t had any success at all doing it via the script (python) even by using the same xpath that supposedly UIAutomator used to click it. I also tried changing the driver context to webview with chromedriver but it seems in there half of the locators don’t work: Message: invalid argument: invalid locator
The element is clickable and has the following attributes:
|index|0|
|class|android.widget.Button|
|text|getmoreapps|
|bounds|[49,377][1393,503]
However any attempts to search by xpath, class name or text result in: An element could not be located on the page
ie.
getmoreapps = driver.find_element_by_xpath(‘//android.widget.ListView/android.widget.Button’)
getmoreapps.click()
This has blocked me for hours and I don’t really want to do it via coordinates, as that won’t work for other screen sizes. I also tried using find element by android uiautomator, to no avail
Any ideas? I also have full access to the webview and the bundle, in case there is a way to create unique identifiers for these buttons, but I don’t know how to do that.
Thank you very much
EDIT: I have found a workaround that works, I noticed on the UI inspector that if I opened it with the webview already on the phone it won’t let me select individual elements, just the whole WebView class, but if I navigated back to the native app and then opened the WebView with UI inspector it will actually show all elements in there so I have applied this to the script (going back to native and then opening webview) and it works. But it’s still not an ideal fix, any ideas what causes this?