TestProject Forum
Powered by leading experts in the test automation community

Locating and interacting with WebView elements on iOS

Hello to all,
I just started using platform and got into the problem. Im not able to execute test on the page which is actually WebView inside of the native app.
When I try locating element it is there, even if I hover a mouse it will allow me to inspect the element and even recognise that it is a text field. However, when I run the test it just fails.

I would appreciate help if someone could tell me what to do in such case.
Thanks

Hi Jovan. Thanks for reaching out

Can you please elaborate a bit about what exact action you’re trying to perform to this element?
Is this element contains some text, or it’s the element where user should type the text?
When test fails, what error report for this step do you see?

If you’re trying to click on, can you also please try to use Tap action instead of click and see if it makes difference?
If this element contain some constant text, you can use the Element Locator and try to find this element using this XPath sample
//*[contains(@text,‘part of the text’)]

Hey Vladyslav,
Thanks for the swift reply. The problem was with the locator definately since I was able to reach to the element (both tap, click and later to fill the test) if I use xpath like this //*/XCUIElementTypeTextField[1]​

Im not happy with this kind of locator but it works. The app that Im testing is native iOS app but uses Oauth login implemented with WebView. I have tried with tap and click with the xpath offered by the recorder tool and I tried editing it a bit but it didnt work.

Is there any documentation on how to locate elements when it comes to the iOS native app that uses WebView?
Thanks.
Jovan