简体   繁体   English

XCUITest在页面上找不到元素

[英]XCUITest doesn't find element on page

Certain elements are not "visible" in XCUITest, can't assert for them, their never found. 某些元素在XCUITest中不是“可见的”,不能为它们断言,它们从未被发现。 Even when I print XCUIApplication() from debugging the elements won't show. 即使我从调试中打印XCUIApplication() ,元素也不会显示。

I found out that if you set the 我发现如果你设置了

isAccessbilityElement = true

property (which I did to support voice over) then all of the marked view's subviews will be hidden in XCUITest world. 属性(我支持配音)然后所有标记视图的子视图将隐藏在XCUITest世界中。 My solution was to check if I'm running UITests, if so then set false to this flag if not, then true . 我的解决方案是检查我是否正在运行UITests,如果是,那么如果没有,则将false设置为此标志,然后为true

let application = XCUIApplication()
application.launchArguments = ["UITest"]
application.launch()

public var isRunningUITests: Bool {
    return arguments.contains("UITest")
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM