Я пытаюсь повторить тянуть, чтобы обновить на UITableView
, используя новую систему тестирования Xcode UI в Xcode 7 (бета 3)Replicate тянуть, чтобы обновить в тестировании XCTest UI
Мой текущий подход тащит со стола любой элемент под столом, который я могу найти. Это работает, когда есть фиксированный элемент под таблицей, такой как UIToolbar
или UITabBar
. Я бы предпочел не полагаться на наличие UITabBar
или UIToolbar
, но я не могу понять, как сделать pull для обновления/перетаскивания, не используя метод в XCUIElement
.
func pressForDuration(duration: NSTimeInterval, thenDragToElement otherElement: XCUIElement)
Но он терпит неудачу, когда у меня нет панели инструментов/TabBar и попытаться перетащить с использованием клеток
Это соответствующая часть моего кода:
func testRefresh() {
//For testing cell
for _ in 0...9 {
addCell()
}
refreshTable()
}
func refreshTable(var tbl: XCUIElement? = nil) {
let app = XCUIApplication()
if tbl == nil {
let tables = app.tables
if tables.count > 0 {
tbl = tables.elementAtIndex(0)
}
}
guard let table = tbl else {
XCTFail("Cannot find a table to refresh, you can provide on explicitly if you do have a table")
return
}
var topElement = table
let bottomElement: XCUIElement?
//Try to drag to a tab bar then to a toolbar then to the last cell
if app.tabBars.count > 0 {
bottomElement = app.tabBars.elementAtIndex(0)
}
else if app.toolbars.count > 0 {
bottomElement = app.toolbars.elementAtIndex(0)
}
else {
let cells = app.cells
if cells.count > 0 {
topElement = cells.elementAtIndex(0)
bottomElement = cells.elementAtIndex(cells.count - 1)
}
else {
bottomElement = nil
}
}
if let dragTo = bottomElement {
topElement.pressForDuration(0.1, thenDragToElement: dragTo)
}
}
func addCell() {
let app = XCUIApplication()
app.navigationBars["Master"].buttons["Add"].tap()
}
Дополнительная неисправность atte MPTS:
swipeDown()
(кратные раз, а)scrollByDeltaX/deltaY
(OS X только)
Для тех, кто прочел это, [мой ответ] (http://stackoverflow.com/a/32694875/384110) работает в Xcode 7 и Xcode 7.1. –