Skip to content

Commit

Permalink
The new Sign In Widget keeps the static text hidden behind the scenes…
Browse files Browse the repository at this point in the history
…, so we have to wait for it to be visible
  • Loading branch information
mikenachbaur-okta committed Nov 23, 2023
1 parent 4cdc43d commit b6b0e5d
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
10 changes: 9 additions & 1 deletion Samples/Shared/Common/Testing/Screen+Extensions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,16 @@ extension WebLogin where Self: Screen {
}
}

func wait(for staticText: String, timeout: TimeInterval = .standard) -> Bool {
guard app.staticTexts[staticText].waitForExistence(timeout: timeout) else { return false }
if !app.staticTexts[staticText].isHittable {
return app.staticTexts[staticText].waitToBeHittable(timeout: timeout)
}
return true
}

func send(password: String? = nil) {
if app.webViews.staticTexts["Select from the following options"].waitForExistence(timeout: 1) {
if app.webViews.staticTexts["Select from the following options"].waitToBeHittable(timeout: .standard) {
select(authenticator: "Password")
}

Expand Down
12 changes: 12 additions & 0 deletions Samples/Shared/Common/Testing/XCTest+Extensions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,18 @@ extension XCUIElement {

return false
}

func waitToBeHittable(timeout: TimeInterval) -> Bool {
let timeStart = Date().timeIntervalSince1970

while Date().timeIntervalSince1970 <= (timeStart + timeout) {
if !exists {
return true
}
}

return false
}
}

extension XCUIElementQuery {
Expand Down

0 comments on commit b6b0e5d

Please sign in to comment.