Skip to content

Commit 00f62f0

Browse files
committed
fix: return desiredCapabilities to support jsonwp
1 parent f5f1354 commit 00f62f0

File tree

1 file changed

+13
-10
lines changed

1 file changed

+13
-10
lines changed

packages/webdriver/src/utils.ts

+13-10
Original file line numberDiff line numberDiff line change
@@ -44,15 +44,15 @@ export async function startWebDriverSession (params: RemoteConfig): Promise<{ se
4444
* to check what style the user sent in so we know how to construct the
4545
* object for the other style
4646
*/
47-
const capabilities = params.capabilities && 'alwaysMatch' in params.capabilities
47+
const [w3cCaps, jsonwpCaps] = params.capabilities && 'alwaysMatch' in params.capabilities
4848
/**
4949
* in case W3C compliant capabilities are provided
5050
*/
51-
? params.capabilities
51+
? [params.capabilities, params.capabilities.alwaysMatch]
5252
/**
5353
* otherwise assume they passed in jsonwp-style caps (flat object)
5454
*/
55-
: { alwaysMatch: params.capabilities, firstMatch: [{}] }
55+
: [{ alwaysMatch: params.capabilities, firstMatch: [{}] }, params.capabilities]
5656

5757
/**
5858
* automatically opt-into WebDriver Bidi (@ref https://w3c.github.io/webdriver-bidi/)
@@ -61,28 +61,31 @@ export async function startWebDriverSession (params: RemoteConfig): Promise<{ se
6161
/**
6262
* except, if user does not want to opt-in
6363
*/
64-
!capabilities.alwaysMatch['wdio:enforceWebDriverClassic'] &&
64+
!w3cCaps.alwaysMatch['wdio:enforceWebDriverClassic'] &&
6565
/**
6666
* or user requests a Safari session which does not support Bidi
6767
*/
68-
typeof capabilities.alwaysMatch.browserName === 'string' &&
69-
capabilities.alwaysMatch.browserName.toLowerCase() !== 'safari'
68+
typeof w3cCaps.alwaysMatch.browserName === 'string' &&
69+
w3cCaps.alwaysMatch.browserName.toLowerCase() !== 'safari'
7070
) {
7171
/**
7272
* opt-into WebDriver Bidi
7373
*/
74-
capabilities.alwaysMatch.webSocketUrl = true
74+
w3cCaps.alwaysMatch.webSocketUrl = true
7575
/**
7676
* allow WebdriverIO to handle alerts
7777
*/
78-
capabilities.alwaysMatch.unhandledPromptBehavior = 'ignore'
78+
w3cCaps.alwaysMatch.unhandledPromptBehavior = 'ignore'
7979
}
8080

81-
validateCapabilities(capabilities.alwaysMatch)
81+
validateCapabilities(w3cCaps.alwaysMatch)
8282
const sessionRequest = new environment.value.Request(
8383
'POST',
8484
'/session',
85-
{ capabilities }
85+
{
86+
capabilities: w3cCaps, // W3C compliant
87+
desiredCapabilities: jsonwpCaps // JSONWP compliant
88+
}
8689
)
8790

8891
let response: SessionInitializationResponse

0 commit comments

Comments
 (0)