Stabilize flaky UI wizard and settings test flows
This commit is contained in:
@@ -118,25 +118,40 @@ extension XCUIElement {
|
||||
file: StaticString = #filePath,
|
||||
line: UInt = #line
|
||||
) -> XCUIElement {
|
||||
var scrollsRemaining = maxScrolls
|
||||
while !exists || !isHittable {
|
||||
guard scrollsRemaining > 0 else {
|
||||
XCTFail("Could not scroll \(self) into view after \(maxScrolls) scrolls",
|
||||
file: file, line: line)
|
||||
return self
|
||||
if exists && isHittable { return self }
|
||||
|
||||
func attemptScroll(_ scrollDirection: ScrollDirection, attempts: Int) -> Bool {
|
||||
var remaining = attempts
|
||||
while (!exists || !isHittable) && remaining > 0 {
|
||||
switch scrollDirection {
|
||||
case .down:
|
||||
scrollView.swipeUp(velocity: .slow)
|
||||
case .up:
|
||||
scrollView.swipeDown(velocity: .slow)
|
||||
}
|
||||
remaining -= 1
|
||||
}
|
||||
switch direction {
|
||||
case .down:
|
||||
scrollView.swipeUp(velocity: .slow)
|
||||
case .up:
|
||||
scrollView.swipeDown(velocity: .slow)
|
||||
}
|
||||
scrollsRemaining -= 1
|
||||
return exists && isHittable
|
||||
}
|
||||
|
||||
if attemptScroll(direction, attempts: maxScrolls) {
|
||||
return self
|
||||
}
|
||||
|
||||
let reverseDirection: ScrollDirection = direction == .down ? .up : .down
|
||||
if attemptScroll(reverseDirection, attempts: maxScrolls) {
|
||||
return self
|
||||
}
|
||||
|
||||
XCTFail(
|
||||
"Could not scroll \(self) into view after \(maxScrolls) scrolls in either direction",
|
||||
file: file,
|
||||
line: line
|
||||
)
|
||||
return self
|
||||
}
|
||||
}
|
||||
|
||||
enum ScrollDirection {
|
||||
enum ScrollDirection: Equatable {
|
||||
case up, down
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user