Bry*_*Luk 12 mobile-safari coded-ui-tests ios xctest xcode-ui-testing
有没有办法自动化SFSafariViewController?我喜欢Xcode 7 UI测试功能,但它似乎不支持SFSafariViewController自动化.我正在测试的一些UI流程需要一个Web浏览器,因此应用程序使用SFSafariViewController使其比Web视图更安全.
如果它类似于启动扩展(目前无法直接交互),请尝试在您要查找的元素所在的位置点按屏幕:
点击启动扩展的操作表的示例:
func tapElementInActionSheetByPosition(element: XCUIElement!) {
let tableSize = app.tables.elementBoundByIndex(0).frame.size
let elementFrame = element.frame
// get the frame of the cancel button, because it has a real origin point
let CancelY = app.buttons["Cancel"].frame.origin.y
// 8 is the standard apple margin between views
let yCoordinate = CancelY - 8.0 - tableSize.height + elementFrame.midY
// tap the button at its screen position since tapping a button in the extension picker directly is currently broken
app.coordinateWithNormalizedOffset(CGVectorMake(elementFrame.midX / tableSize.width, yCoordinate / app.frame.size.height)).tap()
}
Run Code Online (Sandbox Code Playgroud)
注意:您必须点击 XCUIApplication 查询层。按位置点击元素不起作用。