@@ -44,15 +44,15 @@ export async function startWebDriverSession (params: RemoteConfig): Promise<{ se
44
44
* to check what style the user sent in so we know how to construct the
45
45
* object for the other style
46
46
*/
47
- const capabilities = params . capabilities && 'alwaysMatch' in params . capabilities
47
+ const [ w3cCaps , jsonwpCaps ] = params . capabilities && 'alwaysMatch' in params . capabilities
48
48
/**
49
49
* in case W3C compliant capabilities are provided
50
50
*/
51
- ? params . capabilities
51
+ ? [ params . capabilities , params . capabilities . alwaysMatch ]
52
52
/**
53
53
* otherwise assume they passed in jsonwp-style caps (flat object)
54
54
*/
55
- : { alwaysMatch : params . capabilities , firstMatch : [ { } ] }
55
+ : [ { alwaysMatch : params . capabilities , firstMatch : [ { } ] } , params . capabilities ]
56
56
57
57
/**
58
58
* automatically opt-into WebDriver Bidi (@ref https://w3c.github.io/webdriver-bidi/)
@@ -61,28 +61,31 @@ export async function startWebDriverSession (params: RemoteConfig): Promise<{ se
61
61
/**
62
62
* except, if user does not want to opt-in
63
63
*/
64
- ! capabilities . alwaysMatch [ 'wdio:enforceWebDriverClassic' ] &&
64
+ ! w3cCaps . alwaysMatch [ 'wdio:enforceWebDriverClassic' ] &&
65
65
/**
66
66
* or user requests a Safari session which does not support Bidi
67
67
*/
68
- typeof capabilities . alwaysMatch . browserName === 'string' &&
69
- capabilities . alwaysMatch . browserName . toLowerCase ( ) !== 'safari'
68
+ typeof w3cCaps . alwaysMatch . browserName === 'string' &&
69
+ w3cCaps . alwaysMatch . browserName . toLowerCase ( ) !== 'safari'
70
70
) {
71
71
/**
72
72
* opt-into WebDriver Bidi
73
73
*/
74
- capabilities . alwaysMatch . webSocketUrl = true
74
+ w3cCaps . alwaysMatch . webSocketUrl = true
75
75
/**
76
76
* allow WebdriverIO to handle alerts
77
77
*/
78
- capabilities . alwaysMatch . unhandledPromptBehavior = 'ignore'
78
+ w3cCaps . alwaysMatch . unhandledPromptBehavior = 'ignore'
79
79
}
80
80
81
- validateCapabilities ( capabilities . alwaysMatch )
81
+ validateCapabilities ( w3cCaps . alwaysMatch )
82
82
const sessionRequest = new environment . value . Request (
83
83
'POST' ,
84
84
'/session' ,
85
- { capabilities }
85
+ {
86
+ capabilities : w3cCaps , // W3C compliant
87
+ desiredCapabilities : jsonwpCaps // JSONWP compliant
88
+ }
86
89
)
87
90
88
91
let response : SessionInitializationResponse
0 commit comments