appium-webdriveragent 16.14.2 → 16.15.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,9 @@
1
+ ## [16.15.0](https://github.com/appium/WebDriverAgent/compare/v16.14.2...v16.15.0) (2026-10-12)
2
+
3
+ ### Features
4
+
5
+ * add asAppUnderTest flag to /wda/apps/launch ([#1289](https://github.com/appium/WebDriverAgent/issues/1289)) ([f5c0688](https://github.com/appium/WebDriverAgent/commit/f5c068873ff6dcd1ce444d26246c102cc379d5bf))
6
+
1
7
  ## [16.14.2](https://github.com/appium/WebDriverAgent/compare/v16.14.1...v16.14.2) (2026-10-08)
2
8
 
3
9
  ### Bug Fixes
@@ -131,7 +131,8 @@
131
131
  [request.session launchApplicationWithBundleId:(id)request.arguments[@"bundleId"]
132
132
  shouldWaitForQuiescence:request.arguments[@"shouldWaitForQuiescence"]
133
133
  arguments:request.arguments[@"arguments"]
134
- environment:request.arguments[@"environment"]];
134
+ environment:request.arguments[@"environment"]
135
+ asApplicationUnderTest:[request.arguments[@"asAppUnderTest"] boolValue]];
135
136
  return FBResponseWithOK();
136
137
  }
137
138
 
@@ -15,11 +15,11 @@
15
15
  <key>CFBundlePackageType</key>
16
16
  <string>FMWK</string>
17
17
  <key>CFBundleShortVersionString</key>
18
- <string>16.14.2</string>
18
+ <string>16.15.0</string>
19
19
  <key>CFBundleSignature</key>
20
20
  <string>????</string>
21
21
  <key>CFBundleVersion</key>
22
- <string>16.14.2</string>
22
+ <string>16.15.0</string>
23
23
  <key>NSPrincipalClass</key>
24
24
  <string/>
25
25
  </dict>
@@ -107,6 +107,28 @@ extern NSString* const FBSessionWasKilledNotification;
107
107
  arguments:(nullable NSArray<NSString *> *)arguments
108
108
  environment:(nullable NSDictionary <NSString *, NSString *> *)environment;
109
109
 
110
+ /**
111
+ Launch an application with given bundle identifier in scope of current session
112
+ and optionally make it the application under test of this session.
113
+
114
+ @param bundleIdentifier Valid bundle identifier of the application to be launched
115
+ @param shouldWaitForQuiescence whether to wait for quiescence on application startup.
116
+ If not provided then the setting of the current application under test is inherited.
117
+ If there is no application under test yet then quiescence is only awaited if asApplicationUnderTest is YES
118
+ @param arguments The optional array of application command line arguments. The arguments are going to be applied if the application was not running before.
119
+ @param environment The optional dictionary of environment variables for the application, which is going to be executed. The environment variables are going to be applied if the application was not running before.
120
+ @param asApplicationUnderTest If YES then the launched application replaces the current application under test
121
+ of the session (if any), the same way as if it was launched on session startup: other applications launched later
122
+ inherit its quiescence setting, system alerts over it are respected, its unexpected termination is reported as a crash
123
+ and it gets terminated on session deletion if shouldTerminateApp is enabled
124
+ @return The application instance
125
+ */
126
+ - (XCUIApplication *)launchApplicationWithBundleId:(NSString *)bundleIdentifier
127
+ shouldWaitForQuiescence:(nullable NSNumber *)shouldWaitForQuiescence
128
+ arguments:(nullable NSArray<NSString *> *)arguments
129
+ environment:(nullable NSDictionary <NSString *, NSString *> *)environment
130
+ asApplicationUnderTest:(BOOL)asApplicationUnderTest;
131
+
110
132
  /**
111
133
  Activate an application with given bundle identifier in scope of current session.
112
134
  !This method is only available since Xcode9 SDK
@@ -43,7 +43,8 @@ static const NSTimeInterval FB_KILL_WAIT_TIMEOUT_SEC = 35.;
43
43
  NSString *const FBSessionWasKilledNotification = @"FBSessionWasKilledNotification";
44
44
 
45
45
  @interface FBSession ()
46
- @property (nullable, nonatomic) XCUIApplication *testedApplication;
46
+ // Atomic, since /wda/apps/launch may replace it while a concurrent DELETE /session reads it in -kill
47
+ @property (nullable, atomic) XCUIApplication *testedApplication;
47
48
  @property (nonatomic) BOOL isTestedApplicationExpectedToRun;
48
49
  @property (nonatomic) BOOL shouldAppsWaitForQuiescence;
49
50
  @property (nonatomic, nullable) FBAlertsMonitor *alertsMonitor;
@@ -386,11 +387,27 @@ static NSUInteger _committedTerminationCount = 0;
386
387
  shouldWaitForQuiescence:(nullable NSNumber *)shouldWaitForQuiescence
387
388
  arguments:(nullable NSArray<NSString *> *)arguments
388
389
  environment:(nullable NSDictionary <NSString *, NSString *> *)environment
390
+ {
391
+ return [self launchApplicationWithBundleId:bundleIdentifier
392
+ shouldWaitForQuiescence:shouldWaitForQuiescence
393
+ arguments:arguments
394
+ environment:environment
395
+ asApplicationUnderTest:NO];
396
+ }
397
+
398
+ - (XCUIApplication *)launchApplicationWithBundleId:(NSString *)bundleIdentifier
399
+ shouldWaitForQuiescence:(nullable NSNumber *)shouldWaitForQuiescence
400
+ arguments:(nullable NSArray<NSString *> *)arguments
401
+ environment:(nullable NSDictionary <NSString *, NSString *> *)environment
402
+ asApplicationUnderTest:(BOOL)asApplicationUnderTest
389
403
  {
390
404
  XCUIApplication *app = [self makeApplicationWithBundleId:bundleIdentifier];
391
405
  if (nil == shouldWaitForQuiescence) {
392
- // Iherit the quiescence check setting from the main app under test by default
393
- app.fb_shouldWaitForQuiescence = nil != self.testedApplication && self.shouldAppsWaitForQuiescence;
406
+ // Iherit the quiescence check setting from the main app under test by default.
407
+ // The first app under test of the session waits for quiescence, as it would on session startup
408
+ app.fb_shouldWaitForQuiescence = nil == self.testedApplication
409
+ ? asApplicationUnderTest
410
+ : self.shouldAppsWaitForQuiescence;
394
411
  } else {
395
412
  app.fb_shouldWaitForQuiescence = [shouldWaitForQuiescence boolValue];
396
413
  }
@@ -401,6 +418,11 @@ static NSUInteger _committedTerminationCount = 0;
401
418
  } else {
402
419
  [app activate];
403
420
  }
421
+ if (asApplicationUnderTest) {
422
+ [FBLogger logFmt:@"The application '%@' is set as the application under test", bundleIdentifier];
423
+ self.testedApplication = app;
424
+ self.shouldAppsWaitForQuiescence = app.fb_shouldWaitForQuiescence;
425
+ }
404
426
  if ([app fb_isSameAppAs:self.testedApplication]) {
405
427
  self.isTestedApplicationExpectedToRun = YES;
406
428
  }
@@ -16,6 +16,7 @@
16
16
  #import "FBTestMacros.h"
17
17
  #import "FBUnattachedAppLauncher.h"
18
18
  #import "XCUIApplication+FBHelpers.h"
19
+ #import "XCUIApplication+FBQuiescence.h"
19
20
  #import "XCUIApplication.h"
20
21
 
21
22
  @interface FBSession (Tests)
@@ -101,6 +102,76 @@ static NSString *const SETTINGS_BUNDLE_ID = @"com.apple.Preferences";
101
102
  FBAssertWaitTillBecomesTrue([self.session.activeApplication.bundleID isEqualToString:testedApp.bundleID]);
102
103
  }
103
104
 
105
+ - (NSString *)startSessionWithoutApplicationUnderTest
106
+ {
107
+ NSString *bundleId = (NSString *)self.testedApplication.bundleID;
108
+ [self.testedApplication terminate];
109
+ FBAssertWaitTillBecomesTrue(self.testedApplication.state == XCUIApplicationStateNotRunning);
110
+ self.session = [FBSession initWithApplication:nil];
111
+ return bundleId;
112
+ }
113
+
114
+ - (void)testApplicationCanBeLaunchedAsApplicationUnderTest
115
+ {
116
+ NSString *bundleId = [self startSessionWithoutApplicationUnderTest];
117
+ XCUIApplication *app = [self.session launchApplicationWithBundleId:bundleId
118
+ shouldWaitForQuiescence:nil
119
+ arguments:nil
120
+ environment:nil
121
+ asApplicationUnderTest:YES];
122
+ FBAssertWaitTillBecomesTrue([self.session.activeApplication.bundleID isEqualToString:bundleId]);
123
+ XCTAssertEqual(app, self.session.activeApplication);
124
+ XCTAssertTrue(app.fb_shouldWaitForQuiescence);
125
+
126
+ XCUIApplication *settingsApp = [self.session launchApplicationWithBundleId:SETTINGS_BUNDLE_ID
127
+ shouldWaitForQuiescence:nil
128
+ arguments:nil
129
+ environment:nil];
130
+ FBAssertWaitTillBecomesTrue([self.session.activeApplication.bundleID isEqualToString:SETTINGS_BUNDLE_ID]);
131
+ XCTAssertTrue(settingsApp.fb_shouldWaitForQuiescence);
132
+ }
133
+
134
+ - (void)testApplicationLaunchedAsApplicationUnderTestRespectsQuiescenceArgument
135
+ {
136
+ NSString *bundleId = [self startSessionWithoutApplicationUnderTest];
137
+ XCUIApplication *app = [self.session launchApplicationWithBundleId:bundleId
138
+ shouldWaitForQuiescence:@NO
139
+ arguments:nil
140
+ environment:nil
141
+ asApplicationUnderTest:YES];
142
+ FBAssertWaitTillBecomesTrue([self.session.activeApplication.bundleID isEqualToString:bundleId]);
143
+ XCTAssertEqual(app, self.session.activeApplication);
144
+ XCTAssertFalse(app.fb_shouldWaitForQuiescence);
145
+ }
146
+
147
+ - (void)testCrashOfApplicationLaunchedAsApplicationUnderTestIsDetected
148
+ {
149
+ NSString *bundleId = [self startSessionWithoutApplicationUnderTest];
150
+ XCUIApplication *app = [self.session launchApplicationWithBundleId:bundleId
151
+ shouldWaitForQuiescence:nil
152
+ arguments:nil
153
+ environment:nil
154
+ asApplicationUnderTest:YES];
155
+ FBAssertWaitTillBecomesTrue([self.session.activeApplication.bundleID isEqualToString:bundleId]);
156
+ [app terminate];
157
+ FBAssertWaitTillBecomesTrue(app.state == XCUIApplicationStateNotRunning);
158
+ XCTAssertThrowsSpecificNamed(self.session.activeApplication, NSException, FBApplicationCrashedException);
159
+ }
160
+
161
+ - (void)testApplicationIsNotLaunchedAsApplicationUnderTestByDefault
162
+ {
163
+ NSString *bundleId = [self startSessionWithoutApplicationUnderTest];
164
+ XCUIApplication *app = [self.session launchApplicationWithBundleId:bundleId
165
+ shouldWaitForQuiescence:nil
166
+ arguments:nil
167
+ environment:nil];
168
+ FBAssertWaitTillBecomesTrue([self.session.activeApplication.bundleID isEqualToString:bundleId]);
169
+ XCTAssertFalse(app.fb_shouldWaitForQuiescence);
170
+ [app terminate];
171
+ FBAssertWaitTillBecomesTrue(app.state == XCUIApplicationStateNotRunning);
172
+ XCTAssertNoThrow(self.session.activeApplication);
173
+ }
174
+
104
175
  - (void)testLaunchUnattachedApp
105
176
  {
106
177
  [FBUnattachedAppLauncher launchAppWithBundleId:SETTINGS_BUNDLE_ID];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "appium-webdriveragent",
3
- "version": "16.14.2",
3
+ "version": "16.15.0",
4
4
  "description": "Package bundling WebDriverAgent",
5
5
  "keywords": [
6
6
  "Appium",