Skip to content

Commit 821bdf8

Browse files
Merge pull request #57 from appium/master
Fork Sync: Update from parent repository
2 parents 25c8978 + ed06d2f commit 821bdf8

File tree

5 files changed

+67
-16
lines changed

5 files changed

+67
-16
lines changed

CHANGELOG.md

+7
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
## [6.1.0](https://github.com/appium/WebDriverAgent/compare/v6.0.0...v6.1.0) (2024-02-10)
2+
3+
4+
### Features
5+
6+
* Add a possibility of starting a test with a deep link ([#845](https://github.com/appium/WebDriverAgent/issues/845)) ([aa25e49](https://github.com/appium/WebDriverAgent/commit/aa25e49fa9821960b08e9f4f3ea5891ebdf7d48d))
7+
18
## [6.0.0](https://github.com/appium/WebDriverAgent/compare/v5.15.8...v6.0.0) (2024-01-31)
29

310

WebDriverAgentLib/Commands/FBSessionCommands.m

+37-2
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,9 @@ + (NSArray *)routes
136136
}
137137

138138
NSString *bundleID = capabilities[FB_CAP_BUNDLE_ID];
139+
NSString *initialUrl = capabilities[FB_CAP_INITIAL_URL];
139140
XCUIApplication *app = nil;
141+
BOOL didOpenInitialUrl = NO;
140142
if (bundleID != nil) {
141143
app = [[XCUIApplication alloc] initWithBundleIdentifier:bundleID];
142144
BOOL forceAppLaunch = YES;
@@ -150,14 +152,47 @@ + (NSArray *)routes
150152
|| [capabilities[FB_CAP_SHOULD_WAIT_FOR_QUIESCENCE] boolValue];
151153
app.launchArguments = (NSArray<NSString *> *)capabilities[FB_CAP_ARGUMENTS] ?: @[];
152154
app.launchEnvironment = (NSDictionary <NSString *, NSString *> *)capabilities[FB_CAP_ENVIRNOMENT] ?: @{};
153-
[app launch];
155+
if (nil != initialUrl) {
156+
NSError *openError;
157+
didOpenInitialUrl = [XCUIDevice.sharedDevice fb_openUrl:initialUrl
158+
withApplication:bundleID
159+
error:&openError];
160+
if (!didOpenInitialUrl) {
161+
NSString *errorMsg = [NSString stringWithFormat:@"Cannot open the URL %@ in %@ application. Original error: %@",
162+
initialUrl, bundleID, openError.description];
163+
return FBResponseWithStatus([FBCommandStatus sessionNotCreatedError:errorMsg traceback:nil]);
164+
}
165+
} else {
166+
[app launch];
167+
}
154168
if (![app running]) {
155169
NSString *errorMsg = [NSString stringWithFormat:@"Cannot launch %@ application. Make sure the correct bundle identifier has been provided in capabilities and check the device log for possible crash report occurrences", bundleID];
156170
return FBResponseWithStatus([FBCommandStatus sessionNotCreatedError:errorMsg
157171
traceback:nil]);
158172
}
159173
} else if (appState == XCUIApplicationStateRunningBackground && !forceAppLaunch) {
160-
[app activate];
174+
if (nil != initialUrl) {
175+
NSError *openError;
176+
didOpenInitialUrl = [XCUIDevice.sharedDevice fb_openUrl:initialUrl
177+
withApplication:bundleID
178+
error:&openError];
179+
if (!didOpenInitialUrl) {
180+
NSString *errorMsg = [NSString stringWithFormat:@"Cannot open the URL %@ in %@ application. Original error: %@",
181+
initialUrl, bundleID, openError.description];
182+
return FBResponseWithStatus([FBCommandStatus sessionNotCreatedError:errorMsg traceback:nil]);
183+
}
184+
} else {
185+
[app activate];
186+
}
187+
}
188+
}
189+
190+
if (nil != initialUrl && nil == bundleID) {
191+
NSError *openError;
192+
if (![XCUIDevice.sharedDevice fb_openUrl:initialUrl error:&openError]) {
193+
NSString *errorMsg = [NSString stringWithFormat:@"Cannot open the URL %@. Original error: %@",
194+
initialUrl, openError.description];
195+
return FBResponseWithStatus([FBCommandStatus sessionNotCreatedError:errorMsg traceback:nil]);
161196
}
162197
}
163198

WebDriverAgentLib/Utilities/FBCapabilities.h

+20
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,36 @@
99

1010
#import <Foundation/Foundation.h>
1111

12+
/** Whether to use alternative elements visivility detection method */
1213
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) */
1315
extern NSString* const FB_CAP_MAX_TYPING_FREQUENCY;
16+
/** this setting was needed for some legacy stuff */
1417
extern NSString* const FB_CAP_USE_SINGLETON_TEST_MANAGER;
18+
/** Whether to disable screneshots that XCTest automaticallly creates after each step */
1519
extern NSString* const FB_CAP_DISABLE_AUTOMATIC_SCREENSHOTS;
20+
/** Whether to terminate the application under test after the session ends */
1621
extern NSString* const FB_CAP_SHOULD_TERMINATE_APP;
22+
/** The maximum amount of seconds to wait for the event loop to become idle */
1723
extern NSString* const FB_CAP_EVENT_LOOP_IDLE_DELAY_SEC;
24+
/** Bundle identifier of the application to run the test for */
1825
extern NSString* const FB_CAP_BUNDLE_ID;
26+
/**
27+
Usually an URL used as initial link to run Mobile Safari, but could be any other deep link.
28+
This might also work together with `FB_CAP_BUNLDE_ID`, which tells XCTest to open
29+
the given deep link in the particular app.
30+
Only works since iOS 16.4
31+
*/
32+
extern NSString* const FB_CAP_INITIAL_URL;
33+
/** Whether to enforrce (re)start of the application under test on session startup */
1934
extern NSString* const FB_CAP_FORCE_APP_LAUNCH;
35+
/** Whether to wait for quiescence before starting interaction with apps laucnhes in scope of the test session */
2036
extern NSString* const FB_CAP_SHOULD_WAIT_FOR_QUIESCENCE;
37+
/** Array of command line arguments to be passed to the application under test */
2138
extern NSString* const FB_CAP_ARGUMENTS;
39+
/** Dictionary of environment variables to be passed to the application under test */
2240
extern NSString* const FB_CAP_ENVIRNOMENT;
41+
/** Whether to use native XCTest caching strategy */
2342
extern NSString* const FB_CAP_USE_NATIVE_CACHING_STRATEGY;
43+
/** Whether to enforce software keyboard presence on simulator */
2444
extern NSString* const FB_CAP_FORCE_SIMULATOR_SOFTWARE_KEYBOARD_PRESENCE;

WebDriverAgentLib/Utilities/FBCapabilities.m

+1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
NSString* const FB_CAP_SHOULD_TERMINATE_APP = @"shouldTerminateApp";
1717
NSString* const FB_CAP_EVENT_LOOP_IDLE_DELAY_SEC = @"eventloopIdleDelaySec";
1818
NSString* const FB_CAP_BUNDLE_ID = @"bundleId";
19+
NSString* const FB_CAP_INITIAL_URL = @"initialUrl";
1920
NSString* const FB_CAP_FORCE_APP_LAUNCH = @"forceAppLaunch";
2021
NSString* const FB_CAP_SHOULD_WAIT_FOR_QUIESCENCE = @"shouldWaitForQuiescence";
2122
NSString* const FB_CAP_ARGUMENTS = @"arguments";

package.json

+2-14
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,15 @@
11
{
22
"name": "appium-webdriveragent",
3-
"version": "6.0.0",
3+
"version": "6.1.0",
44
"description": "Package bundling WebDriverAgent",
55
"main": "./build/index.js",
66
"scripts": {
77
"build": "tsc -b",
88
"dev": "npm run build -- --watch",
99
"clean": "npm run build -- --clean",
1010
"lint": "eslint .",
11+
"format": "prettier -w ./lib",
1112
"lint:fix": "npm run lint -- --fix",
12-
"precommit-msg": "echo 'Pre-commit checks...' && exit 0",
13-
"precommit-lint": "lint-staged",
1413
"prepare": "npm run build",
1514
"test": "mocha --exit --timeout 1m \"./test/unit/**/*-specs.js\"",
1615
"e2e-test": "mocha --exit --timeout 10m \"./test/functional/**/*-specs.js\"",
@@ -23,20 +22,11 @@
2322
"node": ">=14",
2423
"npm": ">=8"
2524
},
26-
"lint-staged": {
27-
"*.js": [
28-
"eslint --fix"
29-
]
30-
},
3125
"prettier": {
3226
"bracketSpacing": false,
3327
"printWidth": 100,
3428
"singleQuote": true
3529
},
36-
"pre-commit": [
37-
"precommit-msg",
38-
"precommit-lint"
39-
],
4030
"repository": {
4131
"type": "git",
4232
"url": "git+https://github.com/appium/WebDriverAgent.git"
@@ -83,9 +73,7 @@
8373
"eslint-plugin-import": "^2.28.0",
8474
"eslint-plugin-mocha": "^10.1.0",
8575
"eslint-plugin-promise": "^6.1.1",
86-
"lint-staged": "^15.0.2",
8776
"mocha": "^10.0.0",
88-
"pre-commit": "^1.2.2",
8977
"prettier": "^3.0.0",
9078
"semantic-release": "^23.0.0",
9179
"sinon": "^17.0.0",

0 commit comments

Comments
 (0)