Interact with webview IOS

Hello.

In the app I’m currently writing UI tests for there is a few links that leads me to a webview, in my test I want to click on these links then assert that the link is directed to the correct URL. I’ve got the the correct accessibility for the “address field” but I can’t seem to find it or interact with it.

So my question is, HOW do I deal with webviews when writing UI tests for IOS? I’ve written the same kind of test for the android version and I can just simply assert the address field without and problem.

My conclusion is I have to switch to the webview somehow but how I just can’t grasp. Ive read multiple threads on this forum and everything is something among the lines of switch context view to webview but I’ve never managed to make this switch, no matter what I do I always seem to be stuck in the NATIVE_APP view.

Would appreciate help with this issue loads, aka being able to switch to webview so I can interact with the address field aka url field.

Using appium 1.6.4, Java, iOS Simulator and all code written in java.

Regards

System.out.println(driver.getContext()); //displays all the views available in app.
driver.context(“WEBVIEW_NAME”); // replace the WEBVIEW_NAME with the webview of the app
//Now interact with your webview

1 Like

Thanks for help!

This made me realize the app doesn’t go into a webview, it stays in the NATIVE_APP view all time. What solved my problem was just setting a Thread sleep for 2 seconds until the new page reloaded then I could interact with it.