Xcode 7'de yeni Xcode UI test çerçevesini kullanarak bir UITableView
üzerine yenilemek için bir çekme çoğaltmak için çalışıyorum içinde yenilemek için çekin Benim şu anki yaklaşımı tablodan sürükleyerek edilir (beta 3)Çoğalt XCTest UI testi
masanın altındaki herhangi bir element bulabilirim. Bu tablo, bir veya UITabBar
gibi bir sabit öğe olduğunda çalışır, UITabBar
veya UIToolbar
sahip olmak istemiyorum, ancak bu yöntemi kullanmadan işlemi yenilemek/sürüklemek için çekme işlemini yapmanın bir yolunu anlayamıyorum XCUIElement
.
func pressForDuration(duration: NSTimeInterval, thenDragToElement otherElement: XCUIElement)
Ama araç çubuğu/tabbar sahip ve hücreleri
Bu benim kod ilgili kısmıdır kullanarak sürüklemek kalkmayın zaman başarısız:
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()
}
Ek başarısız atte MPTS:
swipeDown()
(yanı katları kez)scrollByDeltaX/deltaY
(yalnızca OS X)
Şimdiye kadar okuyanlar için, [yanıtım] (http://stackoverflow.com/a/32694875/384110) Xcode 7 ve Xcode 7.1'de çalışır. –