Skip to content

Instantly share code, notes, and snippets.

@raxxpack
Created February 18, 2020 20:15
Show Gist options
  • Save raxxpack/b342f6c113f8cdaccfc2fdac3d97e6aa to your computer and use it in GitHub Desktop.
Save raxxpack/b342f6c113f8cdaccfc2fdac3d97e6aa to your computer and use it in GitHub Desktop.
XCUIApplication Extension to signOutOfiTunesSandboxAccount
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