appium-webdriveragent 16.1.2 → 16.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -0
- package/WebDriverAgentLib/Categories/XCUIApplication+FBAlert.h +20 -8
- package/WebDriverAgentLib/Categories/XCUIApplication+FBAlert.m +116 -60
- package/WebDriverAgentLib/Categories/XCUIApplication+FBHelpers.h +15 -0
- package/WebDriverAgentLib/Categories/XCUIApplication+FBHelpers.m +16 -0
- package/WebDriverAgentLib/Commands/FBAlertViewCommands.m +10 -36
- package/WebDriverAgentLib/FBAlert.h +43 -30
- package/WebDriverAgentLib/FBAlert.m +257 -91
- package/WebDriverAgentLib/Info.plist +2 -2
- package/WebDriverAgentLib/Routing/FBExceptionHandler.m +8 -1
- package/WebDriverAgentLib/Routing/FBExceptions.h +9 -0
- package/WebDriverAgentLib/Routing/FBExceptions.m +3 -0
- package/WebDriverAgentLib/Routing/FBSession.m +11 -13
- package/WebDriverAgentLib/Utilities/FBAlertsMonitor.m +11 -9
- package/WebDriverAgentLib/Utilities/FBPasteboard.m +8 -4
- package/WebDriverAgentTests/IntegrationTests/FBAlertTests.m +32 -51
- package/WebDriverAgentTests/IntegrationTests/FBIntegrationTestCase.m +9 -1
- package/WebDriverAgentTests/IntegrationTests/FBSafariAlertTests.m +1 -1
- package/package.json +1 -1
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
#import <mach/mach_time.h>
|
|
12
12
|
#import "FBAlert.h"
|
|
13
13
|
#import "FBErrorBuilder.h"
|
|
14
|
+
#import "FBExceptions.h"
|
|
14
15
|
#import "FBMacros.h"
|
|
15
16
|
#import "XCUIApplication+FBHelpers.h"
|
|
16
17
|
#import "XCUIApplication+FBAlert.h"
|
|
@@ -100,10 +101,13 @@
|
|
|
100
101
|
break;
|
|
101
102
|
}
|
|
102
103
|
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
[
|
|
104
|
+
@try {
|
|
105
|
+
[[FBAlert alertWithApplication:XCUIApplication.fb_systemApplication] accept];
|
|
106
|
+
} @catch (NSException *e) {
|
|
107
|
+
if (![e.name isEqualToString:FBAlertNotPresentException]) {
|
|
108
|
+
@throw e;
|
|
109
|
+
}
|
|
110
|
+
// No alert is present on this tick - expected on most iterations of this poll loop
|
|
107
111
|
}
|
|
108
112
|
uint64_t timeElapsed = clock_gettime_nsec_np(CLOCK_MONOTONIC_RAW) - timeStarted;
|
|
109
113
|
if (timeElapsed / NSEC_PER_SEC > timeout) {
|
|
@@ -69,60 +69,54 @@
|
|
|
69
69
|
|
|
70
70
|
- (void)testAlertPresence
|
|
71
71
|
{
|
|
72
|
-
|
|
73
|
-
XCTAssertFalse(alert.isPresent);
|
|
72
|
+
XCTAssertFalse([FBAlert alertWithApplication:self.testedApplication].isPresent);
|
|
74
73
|
[self showApplicationAlert];
|
|
75
|
-
XCTAssertTrue(
|
|
74
|
+
XCTAssertTrue([FBAlert alertWithApplication:self.testedApplication].isPresent);
|
|
76
75
|
}
|
|
77
76
|
|
|
78
77
|
- (void)testAlertText
|
|
79
78
|
{
|
|
80
|
-
|
|
81
|
-
XCTAssertNil(alert.text);
|
|
79
|
+
XCTAssertNil([FBAlert alertWithApplication:self.testedApplication].text);
|
|
82
80
|
[self showApplicationAlert];
|
|
83
|
-
|
|
84
|
-
XCTAssertTrue([
|
|
81
|
+
NSString *text = [FBAlert alertWithApplication:self.testedApplication].text;
|
|
82
|
+
XCTAssertTrue([text containsString:@"Magic"]);
|
|
83
|
+
XCTAssertTrue([text containsString:@"Should read"]);
|
|
85
84
|
}
|
|
86
85
|
|
|
87
86
|
- (void)testAlertLabels
|
|
88
87
|
{
|
|
89
|
-
|
|
90
|
-
XCTAssertNil(alert.buttonLabels);
|
|
88
|
+
XCTAssertNil([FBAlert alertWithApplication:self.testedApplication].buttonLabels);
|
|
91
89
|
[self showApplicationAlert];
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
90
|
+
NSArray *labels = [FBAlert alertWithApplication:self.testedApplication].buttonLabels;
|
|
91
|
+
XCTAssertNotNil(labels);
|
|
92
|
+
XCTAssertEqual(1, labels.count);
|
|
93
|
+
XCTAssertEqualObjects(@"Will do", labels[0]);
|
|
95
94
|
}
|
|
96
95
|
|
|
97
96
|
- (void)testClickAlertButton
|
|
98
97
|
{
|
|
99
|
-
|
|
100
|
-
XCTAssertFalse([alert clickAlertButton:@"Invalid" error:nil]);
|
|
98
|
+
XCTAssertThrows([[FBAlert alertWithApplication:self.testedApplication] clickAlertButton:@"Invalid"]);
|
|
101
99
|
[self showApplicationAlert];
|
|
102
|
-
|
|
103
|
-
FBAssertWaitTillBecomesTrue(
|
|
104
|
-
|
|
105
|
-
FBAssertWaitTillBecomesTrue(!
|
|
100
|
+
XCTAssertThrows([[FBAlert alertWithApplication:self.testedApplication] clickAlertButton:@"Invalid"]);
|
|
101
|
+
FBAssertWaitTillBecomesTrue([FBAlert alertWithApplication:self.testedApplication].isPresent);
|
|
102
|
+
XCTAssertNoThrow([[FBAlert alertWithApplication:self.testedApplication] clickAlertButton:@"Will do"]);
|
|
103
|
+
FBAssertWaitTillBecomesTrue(![FBAlert alertWithApplication:self.testedApplication].isPresent);
|
|
106
104
|
}
|
|
107
105
|
|
|
108
106
|
- (void)testAcceptingAlert
|
|
109
107
|
{
|
|
110
|
-
NSError *error;
|
|
111
108
|
[self showApplicationAlert];
|
|
112
|
-
|
|
109
|
+
XCTAssertNoThrow([[FBAlert alertWithApplication:self.testedApplication] accept]);
|
|
113
110
|
FBAssertWaitTillBecomesTrue(self.testedApplication.alerts.count == 0);
|
|
114
|
-
XCTAssertNil(error);
|
|
115
111
|
}
|
|
116
112
|
|
|
117
113
|
- (void)testAcceptingAlertWithCustomLocator
|
|
118
114
|
{
|
|
119
|
-
NSError *error;
|
|
120
115
|
[self showApplicationAlert];
|
|
121
116
|
[FBConfiguration setAcceptAlertButtonSelector:@"**/XCUIElementTypeButton[-1]"];
|
|
122
117
|
@try {
|
|
123
|
-
|
|
118
|
+
XCTAssertNoThrow([[FBAlert alertWithApplication:self.testedApplication] accept]);
|
|
124
119
|
FBAssertWaitTillBecomesTrue(self.testedApplication.alerts.count == 0);
|
|
125
|
-
XCTAssertNil(error);
|
|
126
120
|
} @finally {
|
|
127
121
|
[FBConfiguration setAcceptAlertButtonSelector:@""];
|
|
128
122
|
}
|
|
@@ -130,65 +124,52 @@
|
|
|
130
124
|
|
|
131
125
|
- (void)testDismissingAlert
|
|
132
126
|
{
|
|
133
|
-
NSError *error;
|
|
134
127
|
[self showApplicationAlert];
|
|
135
|
-
|
|
128
|
+
XCTAssertNoThrow([[FBAlert alertWithApplication:self.testedApplication] dismiss]);
|
|
136
129
|
FBAssertWaitTillBecomesTrue(self.testedApplication.alerts.count == 0);
|
|
137
|
-
XCTAssertNil(error);
|
|
138
130
|
}
|
|
139
131
|
|
|
140
132
|
- (void)testDismissingAlertWithCustomLocator
|
|
141
133
|
{
|
|
142
|
-
NSError *error;
|
|
143
134
|
[self showApplicationAlert];
|
|
144
135
|
[FBConfiguration setDismissAlertButtonSelector:@"**/XCUIElementTypeButton[-1]"];
|
|
145
136
|
@try {
|
|
146
|
-
|
|
137
|
+
XCTAssertNoThrow([[FBAlert alertWithApplication:self.testedApplication] dismiss]);
|
|
147
138
|
FBAssertWaitTillBecomesTrue(self.testedApplication.alerts.count == 0);
|
|
148
|
-
XCTAssertNil(error);
|
|
149
139
|
} @finally {
|
|
150
140
|
[FBConfiguration setDismissAlertButtonSelector:@""];
|
|
151
141
|
}
|
|
152
142
|
}
|
|
153
143
|
|
|
154
|
-
- (void)testAlertElement
|
|
155
|
-
{
|
|
156
|
-
[self showApplicationAlert];
|
|
157
|
-
XCUIElement *alertElement = [FBAlert alertWithApplication:self.testedApplication].alertElement;
|
|
158
|
-
XCTAssertTrue(alertElement.exists);
|
|
159
|
-
XCTAssertTrue(alertElement.elementType == XCUIElementTypeAlert);
|
|
160
|
-
}
|
|
161
|
-
|
|
162
144
|
- (void)testNotificationAlert
|
|
163
145
|
{
|
|
164
|
-
|
|
165
|
-
XCTAssertNil(alert.text);
|
|
146
|
+
XCTAssertNil([FBAlert alertWithApplication:self.testedApplication].text);
|
|
166
147
|
[self.testedApplication.buttons[@"Create Notification Alert"] tap];
|
|
167
|
-
FBAssertWaitTillBecomesTrue(
|
|
148
|
+
FBAssertWaitTillBecomesTrue([FBAlert alertWithApplication:self.testedApplication].isPresent);
|
|
168
149
|
|
|
169
|
-
|
|
170
|
-
XCTAssertTrue([
|
|
150
|
+
NSString *text = [FBAlert alertWithApplication:self.testedApplication].text;
|
|
151
|
+
XCTAssertTrue([text containsString:@"Would Like to Send You Notifications"]);
|
|
152
|
+
XCTAssertTrue([text containsString:@"Notifications may include"]);
|
|
171
153
|
}
|
|
172
154
|
|
|
173
155
|
- (void)testCameraRollAlert
|
|
174
156
|
{
|
|
175
|
-
|
|
176
|
-
XCTAssertNil(alert.text);
|
|
157
|
+
XCTAssertNil([FBAlert alertWithApplication:self.testedApplication].text);
|
|
177
158
|
|
|
178
159
|
[self.testedApplication.buttons[@"Create Camera Roll Alert"] tap];
|
|
179
|
-
FBAssertWaitTillBecomesTrue(
|
|
160
|
+
FBAssertWaitTillBecomesTrue([FBAlert alertWithApplication:self.testedApplication].isPresent);
|
|
180
161
|
}
|
|
181
162
|
|
|
182
163
|
- (void)testGPSAccessAlert
|
|
183
164
|
{
|
|
184
|
-
|
|
185
|
-
XCTAssertNil(alert.text);
|
|
165
|
+
XCTAssertNil([FBAlert alertWithApplication:self.testedApplication].text);
|
|
186
166
|
|
|
187
167
|
[self.testedApplication.buttons[@"Create GPS access Alert"] tap];
|
|
188
|
-
FBAssertWaitTillBecomesTrue(
|
|
168
|
+
FBAssertWaitTillBecomesTrue([FBAlert alertWithApplication:self.testedApplication].isPresent);
|
|
189
169
|
|
|
190
|
-
|
|
191
|
-
XCTAssertTrue([
|
|
170
|
+
NSString *text = [FBAlert alertWithApplication:self.testedApplication].text;
|
|
171
|
+
XCTAssertTrue([text containsString:@"location"]);
|
|
172
|
+
XCTAssertTrue([text containsString:@"Yo Yo"]);
|
|
192
173
|
}
|
|
193
174
|
|
|
194
175
|
@end
|
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
|
|
11
11
|
#import "FBAlert.h"
|
|
12
12
|
#import "FBTestMacros.h"
|
|
13
|
+
#import "FBExceptions.h"
|
|
13
14
|
#import "FBIntegrationTestCase.h"
|
|
14
15
|
#import "FBConfiguration.h"
|
|
15
16
|
#import "FBMacros.h"
|
|
@@ -151,7 +152,14 @@ NSArray<NSString *> *const FBMainViewButtonLabels = @[
|
|
|
151
152
|
- (void)clearAlert
|
|
152
153
|
{
|
|
153
154
|
[self.testedApplication fb_waitUntilStable];
|
|
154
|
-
|
|
155
|
+
@try {
|
|
156
|
+
[[FBAlert alertWithApplication:self.testedApplication] dismiss];
|
|
157
|
+
} @catch (NSException *e) {
|
|
158
|
+
if (![e.name isEqualToString:FBAlertNotPresentException]) {
|
|
159
|
+
@throw e;
|
|
160
|
+
}
|
|
161
|
+
// No alert is present, nothing to clear
|
|
162
|
+
}
|
|
155
163
|
[self.testedApplication fb_waitUntilStable];
|
|
156
164
|
FBAssertWaitTillBecomesTrue(self.testedApplication.alerts.count == 0);
|
|
157
165
|
}
|
|
@@ -67,7 +67,7 @@
|
|
|
67
67
|
XCTAssertEqualObjects(buttonLabels.firstObject, @"Close");
|
|
68
68
|
XCTAssertNotNil([self.safariApp fb_descendantsMatchingXPathQuery:@"//XCUIElementTypeButton[@label='Close']"
|
|
69
69
|
shouldReturnAfterFirstMatch:YES].firstObject);
|
|
70
|
-
|
|
70
|
+
XCTAssertNoThrow([alert accept]);
|
|
71
71
|
}
|
|
72
72
|
|
|
73
73
|
@end
|