ios - XCTest : Can not get the last collection cell element after swipeLeft()
<p><p>我的表格 View 单元格中有一个 Collection View 。我想在向左滑动后点击最后一个单元格以查看最后一个收藏单元格。</p>
<p>例如,这里是我的列表 Collection View 单元格:</p>
<blockquote>
<pre><code> |ABCD| E F
</code></pre>
<p>Note: '|' is the bounds of screen and collection cell E, F are not visible yet</p>
</blockquote>
<pre><code> let tableCell = app.tables["TableView"].cells.element(boundBy: 1)
// Test to get the label of collection cell inside tableCell
let collectionCell_A = tableCell.staticTexts["A"]
XCTAssert(collectionCell_A.exists) // Okay
// Swipe left to see the collection cell E
tableCell.swipeLeft()
// Test to get collection cell D success
let sevenElevenCell = tableCell.staticTexts["D"]
// But with the collection cell E always failed.
let collectionCell_E = tableCell.staticTexts["E"]
waitUntilElementExists(collectionCell_E) // My helper func to wait element exits for 10 seconds
collectionCell_E.tap() // Failed here
</code></pre>
<p>经过调试,发现集合向左滑动后,list staticTexts 没有更新。 </p>
<p>我认为这家伙和我有同样的问题。 <a href="https://forums.developer.apple.com/thread/82366" rel="noreferrer noopener nofollow">https://forums.developer.apple.com/thread/82366</a> </p></p>
<br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
<p><p>此问题已解决。我的同事有一个很好的解决方案来解决它。</p>
<pre><code>let cell = XCUIApplication().cells.containing(NSPredicate(format: "label CONTAINS %@", "E")).element
cell.tap() // Success.
</code></pre>
<p>希望这对其他人有帮助。</p></p>
<p style="font-size: 20px;">关于ios - XCTest : Can not get the last collection cell element after swipeLeft(),我们在Stack Overflow上找到一个类似的问题:
<a href="https://stackoverflow.com/questions/47171491/" rel="noreferrer noopener nofollow" style="color: red;">
https://stackoverflow.com/questions/47171491/
</a>
</p>
页:
[1]