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.
@@ -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
- XCUIElement *alertElement = XCUIApplication.fb_systemApplication.fb_alertElement;
104
- if (nil != alertElement) {
105
- FBAlert *alert = [FBAlert alertWithElement:alertElement];
106
- [alert acceptWithError:nil];
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
- FBAlert *alert = [FBAlert alertWithApplication:self.testedApplication];
73
- XCTAssertFalse(alert.isPresent);
72
+ XCTAssertFalse([FBAlert alertWithApplication:self.testedApplication].isPresent);
74
73
  [self showApplicationAlert];
75
- XCTAssertTrue(alert.isPresent);
74
+ XCTAssertTrue([FBAlert alertWithApplication:self.testedApplication].isPresent);
76
75
  }
77
76
 
78
77
  - (void)testAlertText
79
78
  {
80
- FBAlert *alert = [FBAlert alertWithApplication:self.testedApplication];
81
- XCTAssertNil(alert.text);
79
+ XCTAssertNil([FBAlert alertWithApplication:self.testedApplication].text);
82
80
  [self showApplicationAlert];
83
- XCTAssertTrue([alert.text containsString:@"Magic"]);
84
- XCTAssertTrue([alert.text containsString:@"Should read"]);
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
- FBAlert* alert = [FBAlert alertWithApplication:self.testedApplication];
90
- XCTAssertNil(alert.buttonLabels);
88
+ XCTAssertNil([FBAlert alertWithApplication:self.testedApplication].buttonLabels);
91
89
  [self showApplicationAlert];
92
- XCTAssertNotNil(alert.buttonLabels);
93
- XCTAssertEqual(1, alert.buttonLabels.count);
94
- XCTAssertEqualObjects(@"Will do", alert.buttonLabels[0]);
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
- FBAlert* alert = [FBAlert alertWithApplication:self.testedApplication];
100
- XCTAssertFalse([alert clickAlertButton:@"Invalid" error:nil]);
98
+ XCTAssertThrows([[FBAlert alertWithApplication:self.testedApplication] clickAlertButton:@"Invalid"]);
101
99
  [self showApplicationAlert];
102
- XCTAssertFalse([alert clickAlertButton:@"Invalid" error:nil]);
103
- FBAssertWaitTillBecomesTrue(alert.isPresent);
104
- XCTAssertTrue([alert clickAlertButton:@"Will do" error:nil]);
105
- FBAssertWaitTillBecomesTrue(!alert.isPresent);
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
- XCTAssertTrue([[FBAlert alertWithApplication:self.testedApplication] acceptWithError:&error]);
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
- XCTAssertTrue([[FBAlert alertWithApplication:self.testedApplication] acceptWithError:&error]);
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
- XCTAssertTrue([[FBAlert alertWithApplication:self.testedApplication] dismissWithError:&error]);
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
- XCTAssertTrue([[FBAlert alertWithApplication:self.testedApplication] dismissWithError:&error]);
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
- FBAlert *alert = [FBAlert alertWithApplication:self.testedApplication];
165
- XCTAssertNil(alert.text);
146
+ XCTAssertNil([FBAlert alertWithApplication:self.testedApplication].text);
166
147
  [self.testedApplication.buttons[@"Create Notification Alert"] tap];
167
- FBAssertWaitTillBecomesTrue(alert.isPresent);
148
+ FBAssertWaitTillBecomesTrue([FBAlert alertWithApplication:self.testedApplication].isPresent);
168
149
 
169
- XCTAssertTrue([alert.text containsString:@"Would Like to Send You Notifications"]);
170
- XCTAssertTrue([alert.text containsString:@"Notifications may include"]);
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
- FBAlert *alert = [FBAlert alertWithApplication:self.testedApplication];
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(alert.isPresent);
160
+ FBAssertWaitTillBecomesTrue([FBAlert alertWithApplication:self.testedApplication].isPresent);
180
161
  }
181
162
 
182
163
  - (void)testGPSAccessAlert
183
164
  {
184
- FBAlert *alert = [FBAlert alertWithApplication:self.testedApplication];
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(alert.isPresent);
168
+ FBAssertWaitTillBecomesTrue([FBAlert alertWithApplication:self.testedApplication].isPresent);
189
169
 
190
- XCTAssertTrue([alert.text containsString:@"location"]);
191
- XCTAssertTrue([alert.text containsString:@"Yo Yo"]);
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
- [[FBAlert alertWithApplication:self.testedApplication] dismissWithError:nil];
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
- XCTAssertTrue([alert acceptWithError:nil]);
70
+ XCTAssertNoThrow([alert accept]);
71
71
  }
72
72
 
73
73
  @end
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "appium-webdriveragent",
3
- "version": "16.1.2",
3
+ "version": "16.1.3",
4
4
  "description": "Package bundling WebDriverAgent",
5
5
  "keywords": [
6
6
  "Appium",