2017-07-24 138 views
4

我試圖單擊在運行時填充並緩存的標籤。 TableViewCell有一個在運行時決定的UILabel。所以我不能添加一個輔助功能標識符。但我已經添加了一個標識到的UILabel,但這一觀點被重複幾次,並且當我看一個標籤XCUI測試:如何點擊運行時填充的標籤

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

我得到一個錯誤,多次找到匹配

我添加了一個標識符到UILabel在tableView,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' 

更新: 我試圖訪問該元素是這樣的:在

`↳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'` 

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

[speakerStaticText tap]; 

結果我不能分離te並點擊特定標籤最近收件人 請建議我如何做到這一點。

回答

0

這適用於目標C

[[[[應用staticTexts] matchingIdentifier:@ 「最近通話」] elementBoundByIndex:0] TAP];

而在夫特:

XCUIApplication()staticTexts.matching(標識符: 「最近通話」)。元素(boundBy:0).tap()