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 { | |
/// Confirms buying of a subscription purchase and retries once if the user is not authorized. | |
private func confirmBuyingOfSubscription(signInRequired: Bool = true, | |
account: AppStoreConnectService.AppStoreSandboxUser, | |
retryCount: Int, | |
_ block: () -> ()) { | |
block() | |
if signInRequired { |
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
// Recognize alert | |
let springboardApp = XCUIApplication("com.apple.springboard") | |
let privacyAlert = springboardApp.alerts["App Store & Privacy"] | |
if privacyAlert.waitForExistence(timeout: 30) { ... } |
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() |
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 { | |
/// Launches the Settings app and verifies that the initial screen exists. | |
static func launchSettingsApp() -> XCUIApplication { | |
let app = XCUIApplication(bundleIdentifier: "com.apple.Preferences") | |
// Launch, terminate and again launch the Settings app to ensure we are in a clean state. | |
app.launch() | |
app.terminate() | |
app.launch() | |
app.navigationBars["Settings"].waitForIt() | |
return app |
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 XCUIElement { | |
/// Asserts that the element exists within the time interval. | |
@discardableResult | |
func waitForIt(timeout: TimeInterval = 30) -> XCUIElement { | |
XCTAssertTrue(waitForExistence(timeout: timeout)) | |
return self | |
} | |
/// Asserts that the element is hittable within the time interval. |