Created
February 18, 2020 20:15
-
-
Save raxxpack/b342f6c113f8cdaccfc2fdac3d97e6aa to your computer and use it in GitHub Desktop.
XCUIApplication Extension to signOutOfiTunesSandboxAccount
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extension XCUIApplication { | |
/// Signs out the Sandbox account on the device if signed in. | |
/// Assumes user is in the Settings app. | |
func signOutOfiTunesSandboxAccount() { | |
#if !targetEnvironment(simulator) | |
// If running UI tests on simulator, don't go anything. | |
tables.element(boundBy: 0).waitForIt().cells.staticTexts["iTunes & App Store"].tap() | |
let detailsTable = oniPad ? tables.element(boundBy: 1).waitForIt() : tables.element(boundBy: 0).waitForIt() | |
detailsTable.swipeUp() | |
if !detailsTable.otherElements["SANDBOX ACCOUNT"].waitForExistence(timeout: 30) { | |
return | |
} | |
let sandboxBtn = detailsTable.cells.element(boundBy: detailsTable.cells.count - 1) | |
if sandboxBtn.label == "Sign In" { | |
return | |
} | |
sandboxBtn.tap() | |
alerts["Apple ID"].waitForIt().buttons["Sign Out"].waitForIt().waitToBeHittable().tap() | |
#endif | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment