appium-webdriveragent 8.1.0 → 8.2.0

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 CHANGED
@@ -1,3 +1,10 @@
1
+ ## [8.2.0](https://github.com/appium/WebDriverAgent/compare/v8.1.0...v8.2.0) (2024-03-28)
2
+
3
+
4
+ ### Features
5
+
6
+ * Add a capability to customize the default state change timeout on app startup ([#877](https://github.com/appium/WebDriverAgent/issues/877)) ([98351c3](https://github.com/appium/WebDriverAgent/commit/98351c358367e67e63701612fd3702d53437e12e))
7
+
1
8
  ## [8.1.0](https://github.com/appium/WebDriverAgent/compare/v8.0.2...v8.1.0) (2024-03-26)
2
9
 
3
10
 
@@ -156,19 +156,25 @@
156
156
  if (app.running) {
157
157
  [app terminate];
158
158
  }
159
- NSError *openError;
160
- if (![XCUIDevice.sharedDevice fb_openUrl:initialUrl
161
- withApplication:bundleID
162
- error:&openError]) {
163
- NSString *errorMsg = [NSString stringWithFormat:@"Cannot open the URL %@ with the %@ application. Original error: %@",
164
- initialUrl, bundleID, openError.localizedDescription];
165
- return FBResponseWithStatus([FBCommandStatus sessionNotCreatedError:errorMsg traceback:nil]);
159
+ id<FBResponsePayload> errorResponse = [self openDeepLink:initialUrl
160
+ withApplication:bundleID
161
+ timeout:capabilities[FB_CAP_APP_LAUNCH_STATE_TIMEOUT_SEC]];
162
+ if (nil != errorResponse) {
163
+ return errorResponse;
166
164
  }
167
165
  } else {
166
+ NSTimeInterval defaultTimeout = _XCTApplicationStateTimeout();
167
+ if (nil != capabilities[FB_CAP_APP_LAUNCH_STATE_TIMEOUT_SEC]) {
168
+ _XCTSetApplicationStateTimeout([capabilities[FB_CAP_APP_LAUNCH_STATE_TIMEOUT_SEC] doubleValue]);
169
+ }
168
170
  @try {
169
171
  [app launch];
170
172
  } @catch (NSException *e) {
171
173
  return FBResponseWithStatus([FBCommandStatus sessionNotCreatedError:e.reason traceback:nil]);
174
+ } @finally {
175
+ if (nil != capabilities[FB_CAP_APP_LAUNCH_STATE_TIMEOUT_SEC]) {
176
+ _XCTSetApplicationStateTimeout(defaultTimeout);
177
+ }
172
178
  }
173
179
  }
174
180
  if (!app.running) {
@@ -178,13 +184,11 @@
178
184
  }
179
185
  } else if (appState == XCUIApplicationStateRunningBackground && !forceAppLaunch) {
180
186
  if (nil != initialUrl) {
181
- NSError *openError;
182
- if (![XCUIDevice.sharedDevice fb_openUrl:initialUrl
183
- withApplication:bundleID
184
- error:&openError]) {
185
- NSString *errorMsg = [NSString stringWithFormat:@"Cannot open the URL %@ with the %@ application. Original error: %@",
186
- initialUrl, bundleID, openError.localizedDescription];
187
- return FBResponseWithStatus([FBCommandStatus sessionNotCreatedError:errorMsg traceback:nil]);
187
+ id<FBResponsePayload> errorResponse = [self openDeepLink:initialUrl
188
+ withApplication:bundleID
189
+ timeout:nil];
190
+ if (nil != errorResponse) {
191
+ return errorResponse;
188
192
  }
189
193
  } else {
190
194
  [app activate];
@@ -193,11 +197,11 @@
193
197
  }
194
198
 
195
199
  if (nil != initialUrl && nil == bundleID) {
196
- NSError *openError;
197
- if (![XCUIDevice.sharedDevice fb_openUrl:initialUrl error:&openError]) {
198
- NSString *errorMsg = [NSString stringWithFormat:@"Cannot open the URL %@. Original error: %@",
199
- initialUrl, openError.localizedDescription];
200
- return FBResponseWithStatus([FBCommandStatus sessionNotCreatedError:errorMsg traceback:nil]);
200
+ id<FBResponsePayload> errorResponse = [self openDeepLink:initialUrl
201
+ withApplication:nil
202
+ timeout:capabilities[FB_CAP_APP_LAUNCH_STATE_TIMEOUT_SEC]];
203
+ if (nil != errorResponse) {
204
+ return errorResponse;
201
205
  }
202
206
  }
203
207
 
@@ -492,4 +496,33 @@
492
496
  };
493
497
  }
494
498
 
499
+ +(nullable id<FBResponsePayload>)openDeepLink:(NSString *)initialUrl
500
+ withApplication:(nullable NSString *)bundleID
501
+ timeout:(nullable NSNumber *)timeout
502
+ {
503
+ NSError *openError;
504
+ NSTimeInterval defaultTimeout = _XCTApplicationStateTimeout();
505
+ if (nil != timeout) {
506
+ _XCTSetApplicationStateTimeout([timeout doubleValue]);
507
+ }
508
+ @try {
509
+ BOOL result = nil == bundleID
510
+ ? [XCUIDevice.sharedDevice fb_openUrl:initialUrl
511
+ error:&openError]
512
+ : [XCUIDevice.sharedDevice fb_openUrl:initialUrl
513
+ withApplication:(id)bundleID
514
+ error:&openError];
515
+ if (result) {
516
+ return nil;
517
+ }
518
+ NSString *errorMsg = [NSString stringWithFormat:@"Cannot open the URL %@ with the %@ application. Original error: %@",
519
+ initialUrl, bundleID ?: @"default", openError.localizedDescription];
520
+ return FBResponseWithStatus([FBCommandStatus sessionNotCreatedError:errorMsg traceback:nil]);
521
+ } @finally {
522
+ if (nil != timeout) {
523
+ _XCTSetApplicationStateTimeout(defaultTimeout);
524
+ }
525
+ }
526
+ }
527
+
495
528
  @end
@@ -11,7 +11,7 @@
11
11
 
12
12
  /** Whether to use alternative elements visivility detection method */
13
13
  extern NSString* const FB_CAP_USE_TEST_MANAGER_FOR_VISIBLITY_DETECTION;
14
- /** Set the maximum amount of charatcers that could be typed within a minute (60 by default) */
14
+ /** Set the maximum amount of characters that could be typed within a minute (60 by default) */
15
15
  extern NSString* const FB_CAP_MAX_TYPING_FREQUENCY;
16
16
  /** this setting was needed for some legacy stuff */
17
17
  extern NSString* const FB_CAP_USE_SINGLETON_TEST_MANAGER;
@@ -42,3 +42,5 @@ extern NSString* const FB_CAP_ENVIRNOMENT;
42
42
  extern NSString* const FB_CAP_USE_NATIVE_CACHING_STRATEGY;
43
43
  /** Whether to enforce software keyboard presence on simulator */
44
44
  extern NSString* const FB_CAP_FORCE_SIMULATOR_SOFTWARE_KEYBOARD_PRESENCE;
45
+ /** Sets the application state change timeout for the initial app startup */
46
+ extern NSString* const FB_CAP_APP_LAUNCH_STATE_TIMEOUT_SEC;
@@ -23,3 +23,4 @@ NSString* const FB_CAP_ARGUMENTS = @"arguments";
23
23
  NSString* const FB_CAP_ENVIRNOMENT = @"environment";
24
24
  NSString* const FB_CAP_USE_NATIVE_CACHING_STRATEGY = @"useNativeCachingStrategy";
25
25
  NSString* const FB_CAP_FORCE_SIMULATOR_SOFTWARE_KEYBOARD_PRESENCE = @"forceSimulatorSoftwareKeyboardPresence";
26
+ NSString* const FB_CAP_APP_LAUNCH_STATE_TIMEOUT_SEC = @"appLaunchStateTimeoutSec";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "appium-webdriveragent",
3
- "version": "8.1.0",
3
+ "version": "8.2.0",
4
4
  "description": "Package bundling WebDriverAgent",
5
5
  "main": "./build/index.js",
6
6
  "scripts": {