OGeek|极客世界-中国程序员成长平台

标题: ios - XCTest : Can not get the last collection cell element after swipeLeft() [打印本页]

作者: 菜鸟教程小白    时间: 2022-12-11 19:14
标题: ios - XCTest : Can not get the last collection cell element after swipeLeft()

我的表格 View 单元格中有一个 Collection View 。我想在向左滑动后点击最后一个单元格以查看最后一个收藏单元格。

例如,这里是我的列表 Collection View 单元格:

          |A  B  C  D| E F

Note: '|' is the bounds of screen and collection cell E, F are not visible yet

     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

经过调试,发现集合向左滑动后,list staticTexts 没有更新。

我认为这家伙和我有同样的问题。 https://forums.developer.apple.com/thread/82366



Best Answer-推荐答案


此问题已解决。我的同事有一个很好的解决方案来解决它。

let cell = XCUIApplication().cells.containing(NSPredicate(format: "label CONTAINS %@", "E")).element

cell.tap()              // Success.

希望这对其他人有帮助。

关于ios - XCTest : Can not get the last collection cell element after swipeLeft(),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47171491/






欢迎光临 OGeek|极客世界-中国程序员成长平台 (http://ogeek.cn/) Powered by Discuz! X3.4