Próbuję replikować ciągnąć do odświeżenia na UITableView
użyciu nowego testowania ramy Xcode UI w Xcode 7 (beta 3)Replikacja pociągnąć, aby odświeżyć w XCTest UI testowania
Moje obecne podejście ciągnie się od stołu do Jakikolwiek element pod stołem mogę znaleźć. Działa to, gdy pod stołem znajduje się stały element, taki jak UIToolbar
lub UITabBar
Wolałbym nie polegać na posiadaniu UITabBar
lub UIToolbar
, ale nie mogę wymyślić sposobu wykonania operacji przeciągania w celu odświeżenia/przeciągnięcia bez użycia tej metody w XCUIElement
.
func pressForDuration(duration: NSTimeInterval, thenDragToElement otherElement: XCUIElement)
Ale to się nie powiedzie, kiedy nie ma paska narzędzi/umieszczenie zakładek i próbują przeciągnąć za pomocą komórki
Jest odpowiednia część mojego kodu:
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()
}
Dodatkowa awaria atte MPTS:
swipeDown()
(wielokrotności czasy również)scrollByDeltaX/deltaY
(OS X tylko)
Dla tych, którzy czytali tak daleko, [moja odpowiedź] (http://stackoverflow.com/a/32694875/384110) działa w Xcode 7 i Xcode 7.1. –