我面临的一个问题是使用UITesting框架实现苹果在2015年WWDC上推出的xCode。我有一个UITableView,这个表包含很多单元格。另外,我有一个带有单元格标题的NSArray --如果单元格标题包含在NSArray中,那么这个单元格应该被点击。我的问题是,我不能滚动特定单元格的表视图,因为框架不包含处理表视图的方法,只包含滑动手势(向下,向上)。
也许有人知道我怎么能在桌子上点击特定的单元格?或者如何滚动特定单元格的表视图?因为当我为在屏幕上不可见的单元格调用tap()方法时,什么都不会发生。
提前感谢!
发布于 2015-12-17 20:29:36
这对我起了作用:
XCUIElementQuery *tablesQuery = self.app.tables;
XCUIElementQuery *cellQuery = [tablesQuery.cells containingType:XCUIElementTypeStaticText
identifier:@"Work"];
XCUIElementQuery* cell = [cellQuery childrenMatchingType:XCUIElementTypeStaticText];
XCUIElement* cellElement = cell.element;
[cellElement tap];对于滚动表,请使用:
XCUIElementQuery *tablesQuery = self.app.tables;
XCUIElement* table = tablesQuery.element;
[table swipeUp];发布于 2015-09-24 13:56:07
我最近遇到了一个类似的问题。您可以尝试的一个选项是为表中的单元格寻找一个特定的标题,然后点击它,
例如:-
XCUIApplication().tables.staticTexts["identifier"].tap()或
XCUIApplication().tables.cells.staticTexts["identifier"].tap()其中“标识符”是您要点击的单元格的标题。
我希望这能帮到你!
发布于 2016-09-13 18:03:36
@Eugene真雅·戈丁的答案:更新为Swift 4
let tablesQuery = app.tables
let cellQuery = tablesQuery.cells.containing(.staticText, identifier: "MyCell")
let cell = cellQuery.children(matching: .staticText)
let cellElement = cell.element
cellElement.tap()
let tableElement = tablesQuery.element
tableElement.swipeUp()https://stackoverflow.com/questions/32562793
复制相似问题