Hi there, although testing of safari view controllers might not be officially supported by Appium, I managed to create a filthy workaround for Xcode 8 AND Xcode 9 safari view controller.
Let’s say I want to fill in a UITextField in bei safariVC:
Xcode 8 / iOS 10: you can actually retrieve the coordinates of the requested element from the view tree like this (for example by xpath) and send
MobileElement myTextField = (MobileElement)driver.findElementByXpath(“myXpathToElement”);
Point elementPoint = myTextField.getCoordinates().inViewPort();
(new TouchAction(driver)).tap(elementPoint.x + 10, elementPoint.y + 10).perform();
myTextField.sendKeys(“Hello World”);
Xcode 9 / iOS 11: you have no access to the desired UI element in the view tree, therefore you need to have
to hardcode the coordinates of the desired mobile element for every device screen type and send the keys to a XCUIElementTypeOther element, with which interactions are available. It is recommended to try out all XCUIElementOther-candidates in Appium inspector mode in order to find the “correct one”. If it works in inspector, it will work in your step defintion
MobileElement otherElement = (MobileElement) driver.findElementByXpath("//XCUIElementTypeApplication[@name=“MyApplicationName”]/XCUIElementTypeWindow[2]/XCUIElementTypeOther);
(new TouchAction(driver)).tap(200, 250).perform();
otherElement.sendKeys(“Hello World”);
Happy coding!