gpt4 book ai didi

ios - XCUI 测试 : How to click Labels populated at run time

转载 作者:可可西里 更新时间:2023-11-01 06:13:11 26 4
gpt4 key购买 nike

我正在尝试单击在运行时填充和缓存的标签。TableViewCell 有一个在运行时决定的 UILabel。所以我无法为其添加辅助功能标识符。但是我已经在 UILabel 中添加了一个标识符,但是当我寻找标签时,这个 View 会重复几次

[tablesQuery.staticTexts[@"Channels"] tap];

我收到一个错误,找到了多个匹配项

我已经在 tableView 的 UILabel 中添加了一个标识符,myIdentifier。

如何访问标签以自动点击?

来自 app.debugDescription

Assertion Failure: Smoke.m:238: No matches found for "Recents" StaticText
Query input was {(
StaticText 0x600000563840: traits: 8589934656, {{40.0, 90.0}, {211.0, 21.0}}, identifier: 'navScreenTitle', label: 'Speaker',
StaticText 0x600000563900: traits: 8589934656, label: 'No Volume Available',
StaticText 0x6000005639c0: traits: 8589934656, {{40.0, 90.0}, {211.0, 21.0}}, identifier: 'navScreenTitle', label: 'Speaker',
StaticText 0x600000563a80: traits: 8589934656, label: 'No Volume Available',
StaticText 0x600000563b40: traits: 8589934656, {{40.0, 90.0}, {211.0, 21.0}}, identifier: 'navScreenTitle', label: 'Speaker',
StaticText 0x600000563c00: traits: 8589934656, label: 'No Volume Available',
StaticText 0x600000563cc0: traits: 8589934656, {{40.0, 90.0}, {211.0, 21.0}}, identifier: 'navScreenTitle', label: 'Speaker',
StaticText 0x600000563d80: traits: 8589934656, label: 'No Volume Available'

更新:我尝试以这种方式访问​​元素:

XCUIElement *speakerStaticText = tablesQuery.staticTexts[@"navScreenTitle"] ;

[speakerStaticText tap];

结果在

   `↳Table 0x6000005681c0: traits: 35192962023424, {{0.0, 77.0}, {330.0, 590.0}}
↳Cell 0x6000005684c0: traits: 8589934592, {{0.0, 79.0}, {330.0, 88.0}}
⋅ ↳StaticText 0x600000568340: traits: 8589934656, {{40.0, 90.0}, {211.0, 21.0}}, identifier: 'navScreenTitle', label: 'Speaker'
↳Cell 0x6000005699c0: traits: 8589934593, {{0.0, 167.0}, {330.0, 44.0}}
⋅ ↳StaticText 0x600000569900: traits: 8589934656, {{40.0, 178.0}, {257.0, 21.0}}, identifier: 'navScreenTitle', label: 'Status'
↳Cell 0x60000056aec0: traits: 8589934593, {{0.0, 213.0}, {330.0, 44.0}}
⋅ ↳StaticText 0x60000056ae00: traits: 8589934656, {{40.0, 224.0}, {257.0, 21.0}}, identifier: 'navScreenTitle', label: 'Recents'
↳Cell 0x60000056c3c0: traits: 8589934593, {{0.0, 257.0}, {330.0, 44.0}}
⋅ ↳StaticText 0x60000056c300: traits: 8589934656, {{40.0, 268.0}, {257.0, 21.0}}, identifier: 'navScreenTitle', label: 'Contacts'
↳Cell 0x60000056d8c0: traits: 8589934593, {{0.0, 301.0}, {330.0, 44.0}}
⋅ ↳StaticText 0x60000056d800: traits: 8589934656, {{40.0, 312.0}, {257.0, 21.0}}, identifier: 'navScreenTitle', label: 'Channels'
↳Cell 0x60000056ec40: traits: 8589934593, {{0.0, 347.0}, {330.0, 44.0}}
↳StaticText 0x60000056eb80: traits: 8589934656, {{40.0, 358.0}, {257.0, 21.0}}, identifier: 'navScreenTitle', label: 'Options'`

我无法隔离并点击特定标签最近请建议我该怎么做。

最佳答案

这适用于 Objective-C

[[[[app staticTexts] matchingIdentifier:@"Recents"]elementBoundByIndex:0]tap];

在 Swift 中:

XCUIApplication().staticTexts.matching(identifier: "Recents").element(boundBy: 0).tap()

关于ios - XCUI 测试 : How to click Labels populated at run time,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45289652/

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