Skip to content

Commit 438ae13

Browse files
authored
Refactor waitAndTap (#19256)
1 parent bb88a17 commit 438ae13

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

WordPress/UITestsFoundation/Globals.swift

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,16 @@ public func pullToRefresh(app: XCUIApplication = XCUIApplication()) {
3131
top.press(forDuration: 0.01, thenDragTo: bottom)
3232
}
3333

34-
public func waitAndTap( _ element: XCUIElement) {
34+
public func waitAndTap( _ element: XCUIElement, maxRetries: Int = 10, timeout: TimeInterval = 10) {
35+
guard element.waitForIsHittable(timeout: timeout) else {
36+
XCTFail("Expected element (\(element)) was not hittable after \(timeout) seconds.")
37+
return
38+
}
39+
3540
var retries = 0
36-
let maxRetries = 10
37-
if element.waitForIsHittable(timeout: 10) {
38-
while element.isHittable && retries < maxRetries {
39-
element.tap()
40-
retries += 1
41-
}
41+
while element.isHittable && retries < maxRetries {
42+
element.tap()
43+
retries += 1
4244
}
4345
}
4446

0 commit comments

Comments
 (0)