forked from attentive-mobile/attentive-ios-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Vladimir Espinola
committed
May 23, 2024
1 parent
0fe263f
commit f0efbb3
Showing
4 changed files
with
60 additions
and
11 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,18 +22,22 @@ @implementation CreativeUITest { | |
|
||
|
||
- (void)setUp { | ||
[super setUp]; | ||
// In UI tests it is usually best to stop immediately when a failure occurs. | ||
self.continueAfterFailure = NO; | ||
|
||
[[self class] clearCookies]; | ||
|
||
app = [[XCUIApplication alloc] init]; | ||
} | ||
|
||
+ (void)tearDown { | ||
- (void)tearDown { | ||
// reset cookies & user defaults after all tests have run | ||
[self clearCookies]; | ||
[self resetUserDefaults]; | ||
|
||
[app terminate]; | ||
[self deleteApp]; | ||
|
||
[super tearDown]; | ||
} | ||
|
||
|
||
|
@@ -60,7 +64,7 @@ - (void)testLoadCreative_fillOutFormAndSubmit_launchesSmsAppWithPrePopulatedText | |
// Fill in the email | ||
XCUIElement *emailField = app.webViews.textFields[@"Email Address"]; | ||
[emailField tapOnElement]; | ||
[emailField typeText:@"[email protected]"]; | ||
[emailField fillTextField:@"[email protected]"]; | ||
|
||
// Tap something else on the creative to dismiss the keyboard | ||
[app.staticTexts[@"10% OFF"] tapOnElement]; | ||
|
@@ -137,7 +141,7 @@ - (void)testLoadCreative_clickProductPage_closesCreative { | |
} | ||
|
||
|
||
+ (void)clearCookies { | ||
- (void)clearCookies { | ||
NSLog(@"Clearing cookies!"); | ||
NSSet *websiteDataTypes = [NSSet setWithArray:@[ WKWebsiteDataTypeCookies ]]; | ||
NSDate *dateFrom = [NSDate dateWithTimeIntervalSince1970:0]; | ||
|
@@ -149,7 +153,7 @@ + (void)clearCookies { | |
} | ||
|
||
|
||
+ (void)resetUserDefaults { | ||
- (void)resetUserDefaults { | ||
// Reset user defaults for example app, not the test runner | ||
[[NSUserDefaults standardUserDefaults] removePersistentDomainForName:@"com.attentive.ExampleTest"]; | ||
} | ||
|
24 changes: 24 additions & 0 deletions
24
Example/CreativeUITest/Extensions/XCTestCase+Extension.swift
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
// | ||
// XCTestCase+Extension.swift | ||
// CreativeUITest | ||
// | ||
// Created by Vladimir - Work on 2024-05-23. | ||
// | ||
|
||
import XCTest | ||
|
||
extension XCTestCase { | ||
@objc func deleteApp() { | ||
let springboard = XCUIApplication(bundleIdentifier: "com.apple.springboard") | ||
|
||
let icon = springboard.icons["Example - Local"] | ||
|
||
guard icon.exists else { return } | ||
|
||
icon.press(forDuration: 1) | ||
|
||
springboard.buttons["Remove App"].tapOnElement() | ||
springboard.buttons["Delete App"].tapOnElement() | ||
springboard.buttons["Delete"].tapOnElement() | ||
} | ||
} |
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
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