gpt4 book ai didi

ios - 如何在 XCUIElementQuery 中获取 XCUIElement 的索引?

转载 作者:搜寻专家 更新时间:2023-10-30 22:31:01 25 4
gpt4 key购买 nike

这是我的简单 UITest (自定义 tabbarcontroller 中的选项卡顺序):

func testIsOrderOfTabsSaved() {

let app = XCUIApplication()
let tabBarsQuery = app.tabBars
tabBarsQuery.buttons["More"].tap()
app.navigationBars["More"].buttons["Edit"].tap()
tabBarsQuery.buttons["Takeaway"].swipeLeft()
tabBarsQuery.buttons["In Restaurant"].swipeLeft()

//here, how to get position of moved button with text "In Restaurant"?

注意:

可以通过索引从XCUIElementQuery 获取XCUIElement。我可以用另一种方式来做吗?

最佳答案

似乎查询会根据屏幕上的位置自动按顺序返回。

for i in 0...tabsQuery.buttons.count {
let ele = tabsQuery.buttons.elementBoundByIndex(i)
}

其中索引 i 表示按钮在选项卡栏中的位置,0 是最左边的选项卡,i == tabsQuery.buttons.count 是最右边的。

关于ios - 如何在 XCUIElementQuery 中获取 XCUIElement 的索引?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32164956/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com