Ich versuche, einen Pull zu replizieren auf einem UITableView
mit dem neuen Xcode UI-Test-Framework in Xcode 7 (Beta 3)Replizieren ziehen in XCTest UI-Tests aktualisieren
Mein aktuellen Ansatz aktualisieren wird aus der Tabelle ziehen zu welches Element unter dem Tisch ich finden kann. Dies funktioniert, wenn es ein festes Element unterhalb der Tabelle wie eine UIToolbar
oder UITabBar
Ich würde lieber nicht auf UITabBar
oder UIToolbar
verlassen, aber ich kann nicht eine Möglichkeit, die Pull zu aktualisieren/ziehen Aktion ohne die Methode in XCUIElement
.
func pressForDuration(duration: NSTimeInterval, thenDragToElement otherElement: XCUIElement)
aber es funktioniert nicht, wenn ich um die Zellen zu ziehen nicht eine Symbolleiste/Tabbar haben und versuchen Sie es mit
Dies ist der relevante Teil meines Codes:
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()
}
Zusätzliche fehlgeschlagene attest MPTS:
swipeDown()
(Multiples mal auch)scrollByDeltaX/deltaY
(OS X nur)
Für diejenigen, die so weit gelesen haben, funktioniert [meine Antwort] (http://stackoverflow.com/a/32694875/384110) in Xcode 7 und Xcode 7.1. –