Sto cercando di replicare un tiro per aggiornare su un UITableView
utilizzando il nuovo framework di test Xcode interfaccia utente in Xcode 7 (beta 3)Replica tirare per aggiornare in XCTest UI test
mio approccio attuale sta trascinando dalla tabella per qualunque elemento sotto il tavolo riesca a trovare. Funziona quando c'è un elemento fisso sotto la tabella come un UIToolbar
o UITabBar
Preferisco non contare su un UITabBar
o UIToolbar
ma non riesco a capire un modo per eseguire il pull per aggiornare/trascinare l'azione senza utilizzare il metodo in XCUIElement
.
func pressForDuration(duration: NSTimeInterval, thenDragToElement otherElement: XCUIElement)
ma fallisce quando non ho una barra degli strumenti/barra delle linguette e tenta di trascinare utilizzando le cellule
Questa è la quota di competenza del mio codice:
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()
}
ulteriore fallito MPTS:
swipeDown()
(multipli volte così)scrollByDeltaX/deltaY
(OS X)
Per coloro che hanno letto fino a qui, [la mia risposta] (http://stackoverflow.com/a/32694875/384110) funziona con Xcode 7 e Xcode 7.1. –