Skip to content

Commit 901b783

Browse files
authored
[UI Tests] testAddRemoveFeaturedImage: Fix album selection (#19221)
* Move waitAndTap to Globals * Use waitAndTap to select the album
1 parent f8a196d commit 901b783

3 files changed

Lines changed: 12 additions & 12 deletions

File tree

WordPress/UITestsFoundation/Globals.swift

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

34+
public func waitAndTap( _ element: XCUIElement) {
35+
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+
}
42+
}
43+
}
44+
3445
extension ScreenObject {
3546

3647
// TODO: This was implemented on the original `BaseScreen` and is here just as a copy-paste for the transition.

WordPress/UITestsFoundation/Screens/Media/MediaPickerAlbumListScreen.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public class MediaPickerAlbumListScreen: ScreenObject {
1818
public func selectAlbum(atIndex index: Int) throws -> MediaPickerAlbumScreen {
1919
let selectedAlbum = albumListGetter(app).cells.element(boundBy: index)
2020
XCTAssertTrue(selectedAlbum.waitForExistence(timeout: 5), "Selected album did not load")
21-
selectedAlbum.tap()
21+
waitAndTap(selectedAlbum)
2222

2323
return try MediaPickerAlbumScreen()
2424
}

WordPress/WordPressUITests/Utils/XCTest+Extensions.swift

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -93,17 +93,6 @@ extension XCTestCase {
9393
}
9494
}
9595

96-
public func waitAndTap( _ element: XCUIElement) {
97-
var retries = 0
98-
let maxRetries = 10
99-
if element.waitForIsHittable(timeout: 10) {
100-
while element.isHittable && retries < maxRetries {
101-
element.tap()
102-
retries += 1
103-
}
104-
}
105-
}
106-
10796
private enum Constants {
10897
static let homeApp = XCUIApplication(bundleIdentifier: "com.apple.springboard")
10998
}

0 commit comments

Comments
 (0)