UITableView
Xcode 7 (ベータ 3) の新しい Xcode UI テスト フレームワークを使用して、更新するプルを複製しようとしています。
私の現在のアプローチは、テーブルからテーブルの下にある要素にドラッグすることです。UIToolbar
これは、またはのようなテーブルの下に固定アイテムがある場合に機能しますが、UITabBar
またはUITabBar
のUIToolbar
メソッドを使用せずに引っ張って更新/ドラッグ アクションを実行する方法がわかりませんXCUIElement
。
func pressForDuration(duration: NSTimeInterval, thenDragToElement otherElement: XCUIElement)
しかし、ツールバー/タブバーがなく、セルを使用してドラッグしようとすると失敗します
これは私のコードの関連部分です:
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()
}
その他の失敗した試行:
swipeDown()
(それも複数回)scrollByDeltaX/deltaY
(OS X のみ)