辅助功能标识符停止查找用于 UI 测试的元素
Accessibility identifiers stopped finding elements used for UI testing
我已经在故事板中设置了辅助功能标识符。这些正在工作。但是,我在更多视图上启用了辅助功能,现在 none 的元素可以使用辅助功能标识符找到。
但是,我仍然可以使用记录函数生成的代码找到元素。
以下是我查找元素的方式:
XCUIApplication().buttons["loginButton"] //loginButton is the accessibility identifier
以下是使用记录器找到相同按钮的方式:
XCUIApplication().children(matching: .window).element(boundBy: 0).children(matching:
.other).element.children(matching: .other).element.children(matching:
.other).element.children(matching: .other).element.tap()
我得到的错误是:
No matches found for *typeOfElement*
到目前为止我还没有在网上找到适用的解决方案。
我的问题简而言之: 为什么我不能使用可访问性标识符获取对元素的引用。
提前致谢。
答案是,当您使视图可访问时,您也会使其所有子视图不可访问。因此,因为我使我正在访问的视图的父视图可访问,所以我无法再访问这些子视图。这意味着要使子视图再次可访问,我必须禁用超级视图的可访问性 属性。
我已经在故事板中设置了辅助功能标识符。这些正在工作。但是,我在更多视图上启用了辅助功能,现在 none 的元素可以使用辅助功能标识符找到。
但是,我仍然可以使用记录函数生成的代码找到元素。
以下是我查找元素的方式:
XCUIApplication().buttons["loginButton"] //loginButton is the accessibility identifier
以下是使用记录器找到相同按钮的方式:
XCUIApplication().children(matching: .window).element(boundBy: 0).children(matching:
.other).element.children(matching: .other).element.children(matching:
.other).element.children(matching: .other).element.tap()
我得到的错误是:
No matches found for *typeOfElement*
到目前为止我还没有在网上找到适用的解决方案。
我的问题简而言之: 为什么我不能使用可访问性标识符获取对元素的引用。
提前致谢。
答案是,当您使视图可访问时,您也会使其所有子视图不可访问。因此,因为我使我正在访问的视图的父视图可访问,所以我无法再访问这些子视图。这意味着要使子视图再次可访问,我必须禁用超级视图的可访问性 属性。