单击项目的第一个实例

时间:2017-07-24 22:26:53

标签: objective-c xcode8 xcode-ui-testing

我想点击最近,但实例太多,我不知道怎么做。

Find: Descendants matching type StaticText
  Output: {
    StaticText 0x60800036da40: traits: 8590000192, {{0.0, 77.0}, {330.0, 2.0}}, label: 'Details'
    StaticText 0x60800036df80: traits: 8589934656, {{40.0, 90.0}, {211.0, 21.0}}, identifier: 'navScreenTitle', label: 'Speaker'
    StaticText 0x60800036dd40: traits: 8589934656, label: 'No Volume Available'
    StaticText 0x60800036e040: traits: 8589934656, {{40.0, 90.0}, {211.0, 21.0}}, identifier: 'navScreenTitle', label: 'Speaker'
    StaticText 0x60800036e100: traits: 8589934656, label: 'No Volume Available'
    StaticText 0x60800036e1c0: traits: 8589934656, {{40.0, 90.0}, {211.0, 21.0}}, identifier: 'navScreenTitle', label: 'Speaker'
    StaticText 0x60800036e280: traits: 8589934656, label: 'No Volume Available'
    StaticText 0x60800036e340: traits: 8589934656, {{40.0, 90.0}, {211.0, 21.0}}, identifier: 'navScreenTitle', label: 'Speaker'
    StaticText 0x60800036e400: traits: 8589934656, label: 'No Volume Available'
    StaticText 0x60800036e580: traits: 8589934656, {{40.0, 178.0}, {257.0, 21.0}}, identifier: 'navScreenTitle', label: 'Status'
    StaticText 0x60800036e640: traits: 8589934656, {{177.0, 178.0}, {118.0, 21.0}}, label: 'Available'
    StaticText 0x60800036e700: traits: 8589934656, {{40.0, 178.0}, {257.0, 21.0}}, identifier: 'navScreenTitle', label: 'Status'
    StaticText 0x60800036e7c0: traits: 8589934656, {{177.0, 178.0}, {118.0, 21.0}}, label: 'Available'
    StaticText 0x60800036e880: traits: 8589934656, {{40.0, 178.0}, {257.0, 21.0}}, identifier: 'navScreenTitle', label: 'Status'
    StaticText 0x60800036e940: traits: 8589934656, {{177.0, 178.0}, {118.0, 21.0}}, label: 'Available'
    StaticText 0x60800036ea00: traits: 8589934656, {{40.0, 178.0}, {257.0, 21.0}}, identifier: 'navScreenTitle', label: 'Status'
    StaticText 0x60800036eac0: traits: 8589934656, {{177.0, 178.0}, {118.0, 21.0}}, label: 'Available'
    StaticText 0x60800036ec40: traits: 8590000192, {{0.0, 211.0}, {330.0, 2.0}}, label: 'Conversations'
    StaticText 0x60800036edc0: traits: 8589934656, {{40.0, 224.0}, {257.0, 21.0}}, identifier: 'navScreenTitle', label: 'Recents'
    StaticText 0x60800036ee80: traits: 8589934656, {{40.0, 224.0}, {257.0, 21.0}}, identifier: 'navScreenTitle', label: 'Recents'
    StaticText 0x60800036ef40: traits: 8589934656, {{40.0, 224.0}, {257.0, 21.0}}, identifier: 'navScreenTitle', label: 'Recents'
    StaticText 0x60800036f000: traits: 8589934656, {{40.0, 224.0}, {257.0, 21.0}}, identifier: 'navScreenTitle', label: 'Recents'
    StaticText 0x60800036f180: traits: 8589934656, {{40.0, 268.0}, {257.0, 21.0}}, identifier: 'navScreenTitle', label: 'Contacts'
    StaticText 0x60800036f240: traits: 8589934656, {{40.0, 268.0}, {257.0, 21.0}}, identifier: 'navScreenTitle', label: 'Contacts'
    StaticText 0x60800036f300: traits: 8589934656, {{40.0, 268.0}, {257.0, 21.0}}, identifier: 'navScreenTitle', label: 'Contacts'
    StaticText 0x60800036f3c0: traits: 8589934656, {{40.0, 268.0}, {257.0, 21.0}}, identifier: 'navScreenTitle', label: 'Contacts'
    StaticText 0x60800036f540: traits: 8589934656, {{40.0, 312.0}, {257.0, 21.0}}, identifier: 'navScreenTitle', label: 'Ch'
    StaticText 0x60800036f600: traits: 8589934656, {{40.0, 312.0}, {257.0, 21.0}}, identifier: 'navScreenTitle', label: 'Ch'
    StaticText 0x60800036f6c0: traits: 8589934656, {{40.0, 312.0}, {257.0, 21.0}}, identifier: 'navScreenTitle', label: 'Ch'
    StaticText 0x60800036f780: traits: 8589934656, {{40.0, 312.0}, {257.0, 21.0}}, identifier: 'navScreenTitle', label: 'Ch'
    StaticText 0x60800036f900: traits: 8590000192, {{0.0, 345.0}, {330.0, 2.0}}, label: 'Options'
    StaticText 0x60800036fa80: traits: 8589934656, {{40.0, 358.0}, {257.0, 21.0}}, identifier: 'navScreenTitle', label: 'Options'
    StaticText 0x60800036fb40: traits: 8589934656, {{40.0, 358.0}, {257.0, 21.0}}, identifier: 'navScreenTitle', label: 'Options'
    StaticText 0x60800036fc00: traits: 8589934656, {{40.0, 358.0}, {257.0, 21.0}}, identifier: 'navScreenTitle', label: 'Options'
    StaticText 0x60800036fcc0: traits: 8589934656, {{40.0, 358.0}, {257.0, 21.0}}, identifier: 'navScreenTitle', label: 'Options'
    StaticText 0x6080003708c0: traits: 8589934656, {{379.0, 69.0}, {319.0, 18.0}}, label: 'echo'
    StaticText 0x608000370980: traits: 8589934656, {{398.0, 92.0}, {294.0, 16.0}}, label: 'Talk to me to test your audio'
    StaticText 0x608000370bc0: traits: 8589934656, {{379.0, 122.0}, {319.0, 18.0}}, label: 'Test user'
    StaticText 0x608000370c80: traits: 8589934656, {{398.0, 145.0}, {294.0, 16.0}}, label: 'Standby'
  }

如何点击标签的第一个实例最近 标签正在运行时动态填充,我没有特定的标识符可以点击它。

1 个答案:

答案 0 :(得分:1)

您可以使用element(boundBy: Int)访问某个索引处的元素

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

或在Objective-C

[[[[[XCUIApplication alloc] init] staticTexts] matchingIdentifier:@"Recents"] elementBoundByIndex:0];