2017-07-24 68 views
0

我试图点击最近,但有这么多的实例,我不知道该怎么做。点击项目的第一个实例

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

您可以使用element(boundBy: Int)在一定的指数

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

或访问一个元素的Objective-C

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

我试图做同样的Objective-C和我不这样做它。我如何在Objective-C中完成同样的任务? – Vinayaka

+0

指向正确的方向@Titouan de Bailleul This works:[[[[app staticTexts] matchingIdentifier:@“Recents”] elementBoundByIndex:0] tap]; – Vinayaka

相关问题