在UITests中执行元素查询时,要获取不同分段控件值的屏幕截图,在使用.buttons["name"]时会引发一个错误,并且名称是英文的,没有按预期翻译。它已经从故事板上翻译出来了。所以我想找一个更简单的解决方案。
我可以使用.selectedSegmentIndex代替UITest中存在翻译错误的按钮名,或者有其他方法解决这个问题吗?
XCUIApplication().scrollViews
.children(matching: .other)
.element
.children(matching: .other)
.element(boundBy: 0)
.children(matching: .other)
.otherElements
.segmentedControls["MySegmentedControl"]
.buttons["name"] // How to add this value to be .selectedSegmentIndex = 1?
.tap()发布于 2020-07-21 11:58:56
可以使用element(boundBy:)在指定索引处访问元素。
为你的案子;
app.scrollViews
.segmentedControls
.buttons
.element(boundBy: 1)
.tap()https://stackoverflow.com/questions/63009901
复制相似问题