Skip to content

Commit 36caf89

Browse files
feat(protocol): WebDriver Bidi Protocol update (#14478)
* feat(protocol): WebDriver Bidi Protocol update * fix build issues * bring back extensible * more tweaks
1 parent 4cfe33e commit 36caf89

File tree

8 files changed

+580
-102
lines changed

8 files changed

+580
-102
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@
9393
"@wdio/eslint": "^0.1.1",
9494
"@wdio/repl": "workspace:*",
9595
"camelcase": "^8.0.0",
96-
"cddl": "^0.8.5",
96+
"cddl": "^0.12.0",
9797
"cddl2ts": "^0.2.2",
9898
"chalk": "^5.3.0",
9999
"cheerio": "1.0.0",

packages/wdio-protocols/src/protocols/webdriverBidi.ts

Lines changed: 114 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ const protocol = {
9090
"returns": {
9191
"type": "Object",
9292
"name": "local.SessionNewResult",
93-
"description": "Command return value with the following interface:\n ```ts\n {\n sessionId: string;\n capabilities: {\n acceptInsecureCerts: boolean;\n browserName: string;\n browserVersion: string;\n platformName: string;\n setWindowRect: boolean;\n userAgent: string;\n proxy?: SessionProxyConfiguration;\n webSocketUrl?: string;\n };\n }\n ```"
93+
"description": "Command return value with the following interface:\n ```ts\n {\n sessionId: string;\n capabilities: {\n acceptInsecureCerts: boolean;\n browserName: string;\n browserVersion: string;\n platformName: string;\n setWindowRect: boolean;\n userAgent: string;\n proxy?: SessionProxyConfiguration;\n unhandledPromptBehavior?: SessionUserPromptHandler;\n webSocketUrl?: string;\n };\n }\n ```"
9494
}
9595
}
9696
},
@@ -118,10 +118,15 @@ const protocol = {
118118
{
119119
"name": "params",
120120
"type": "`remote.SessionSubscriptionRequest`",
121-
"description": "<pre>\\{<br /> events: string[];<br /> contexts?: BrowsingContextBrowsingContext[];<br />\\}</pre>",
121+
"description": "<pre>\\{<br /> events: string[];<br /> contexts?: BrowsingContextBrowsingContext[];<br /> userContexts?: BrowserUserContext[];<br />\\}</pre>",
122122
"required": true
123123
}
124-
]
124+
],
125+
"returns": {
126+
"type": "Object",
127+
"name": "local.SessionSubscribeResult",
128+
"description": "Command return value with the following interface:\n ```ts\n {\n subscription: SessionSubscription;\n }\n ```"
129+
}
125130
}
126131
},
127132
"session.unsubscribe": {
@@ -132,8 +137,8 @@ const protocol = {
132137
"parameters": [
133138
{
134139
"name": "params",
135-
"type": "`remote.SessionSubscriptionRequest`",
136-
"description": "<pre>\\{<br /> events: string[];<br /> contexts?: BrowsingContextBrowsingContext[];<br />\\}</pre>",
140+
"type": "`remote.SessionUnsubscribeParameters`",
141+
"description": "<pre>\\\\}</pre>",
137142
"required": true
138143
}
139144
]
@@ -162,8 +167,8 @@ const protocol = {
162167
"parameters": [
163168
{
164169
"name": "params",
165-
"type": "`remote.EmptyParams`",
166-
"description": "<pre>\\{\\}</pre>",
170+
"type": "`remote.BrowserCreateUserContextParameters`",
171+
"description": "<pre>\\{<br /> acceptInsecureCerts?: boolean;<br />\\}</pre>",
167172
"required": true
168173
}
169174
],
@@ -174,6 +179,26 @@ const protocol = {
174179
}
175180
}
176181
},
182+
"browser.getClientWindows": {
183+
"socket": {
184+
"command": "browserGetClientWindows",
185+
"description": "WebDriver Bidi command to send command method \"browser.getClientWindows\" with parameters.",
186+
"ref": "https://w3c.github.io/webdriver-bidi/#command-browser-getClientWindows",
187+
"parameters": [
188+
{
189+
"name": "params",
190+
"type": "`remote.EmptyParams`",
191+
"description": "<pre>\\{\\}</pre>",
192+
"required": true
193+
}
194+
],
195+
"returns": {
196+
"type": "Object",
197+
"name": "local.BrowserGetClientWindowsResult",
198+
"description": "Command return value with the following interface:\n ```ts\n {\n clientWindows: BrowserClientWindowInfo[];\n }\n ```"
199+
}
200+
}
201+
},
177202
"browser.getUserContexts": {
178203
"socket": {
179204
"command": "browserGetUserContexts",
@@ -209,6 +234,21 @@ const protocol = {
209234
]
210235
}
211236
},
237+
"browser.setClientWindowState": {
238+
"socket": {
239+
"command": "browserSetClientWindowState",
240+
"description": "WebDriver Bidi command to send command method \"browser.setClientWindowState\" with parameters.",
241+
"ref": "https://w3c.github.io/webdriver-bidi/#command-browser-setClientWindowState",
242+
"parameters": [
243+
{
244+
"name": "params",
245+
"type": "`remote.BrowserSetClientWindowStateParameters`",
246+
"description": "<pre>\\{<br /> clientWindow: BrowserClientWindow;<br />\\}</pre>",
247+
"required": true
248+
}
249+
]
250+
}
251+
},
212252
"browsingContext.activate": {
213253
"socket": {
214254
"command": "browsingContextActivate",
@@ -398,7 +438,7 @@ const protocol = {
398438
{
399439
"name": "params",
400440
"type": "`remote.BrowsingContextSetViewportParameters`",
401-
"description": "<pre>\\{<br /> context: BrowsingContextBrowsingContext;<br /> viewport?: BrowsingContextViewport &#124; null;<br /> devicePixelRatio?: number &#124; null;<br />\\}</pre>",
441+
"description": "<pre>\\{<br /> context?: BrowsingContextBrowsingContext;<br /> viewport?: BrowsingContextViewport &#124; null;<br /> devicePixelRatio?: number &#124; null;<br /> userContexts?: BrowserUserContext[];<br />\\}</pre>",
402442
"required": true
403443
}
404444
]
@@ -419,6 +459,21 @@ const protocol = {
419459
]
420460
}
421461
},
462+
"emulation.setGeolocationOverride": {
463+
"socket": {
464+
"command": "emulationSetGeolocationOverride",
465+
"description": "WebDriver Bidi command to send command method \"emulation.setGeolocationOverride\" with parameters.",
466+
"ref": "https://w3c.github.io/webdriver-bidi/#command-emulation-setGeolocationOverride",
467+
"parameters": [
468+
{
469+
"name": "params",
470+
"type": "`remote.EmulationSetGeolocationOverrideParameters`",
471+
"description": "<pre>\\\\}</pre>",
472+
"required": true
473+
}
474+
]
475+
}
476+
},
422477
"network.addIntercept": {
423478
"socket": {
424479
"command": "networkAddIntercept",
@@ -529,6 +584,21 @@ const protocol = {
529584
]
530585
}
531586
},
587+
"network.setCacheBehavior": {
588+
"socket": {
589+
"command": "networkSetCacheBehavior",
590+
"description": "WebDriver Bidi command to send command method \"network.setCacheBehavior\" with parameters.",
591+
"ref": "https://w3c.github.io/webdriver-bidi/#command-network-setCacheBehavior",
592+
"parameters": [
593+
{
594+
"name": "params",
595+
"type": "`remote.NetworkSetCacheBehaviorParameters`",
596+
"description": "<pre>\\{<br /> cacheBehavior: \"default\" &#124; \"bypass\";<br /> contexts?: BrowsingContextBrowsingContext[];<br />\\}</pre>",
597+
"required": true
598+
}
599+
]
600+
}
601+
},
532602
"script.addPreloadScript": {
533603
"socket": {
534604
"command": "scriptAddPreloadScript",
@@ -538,7 +608,7 @@ const protocol = {
538608
{
539609
"name": "params",
540610
"type": "`remote.ScriptAddPreloadScriptParameters`",
541-
"description": "<pre>\\{<br /> functionDeclaration: string;<br /> arguments?: ScriptChannelValue[];<br /> contexts?: BrowsingContextBrowsingContext[];<br /> sandbox?: string;<br />\\}</pre>",
611+
"description": "<pre>\\{<br /> functionDeclaration: string;<br /> arguments?: ScriptChannelValue[];<br /> contexts?: BrowsingContextBrowsingContext[];<br /> userContexts?: BrowserUserContext[];<br /> sandbox?: string;<br />\\}</pre>",
542612
"required": true
543613
}
544614
],
@@ -738,6 +808,41 @@ const protocol = {
738808
}
739809
]
740810
}
811+
},
812+
"webExtension.install": {
813+
"socket": {
814+
"command": "webExtensionInstall",
815+
"description": "WebDriver Bidi command to send command method \"webExtension.install\" with parameters.",
816+
"ref": "https://w3c.github.io/webdriver-bidi/#command-webExtension-install",
817+
"parameters": [
818+
{
819+
"name": "params",
820+
"type": "`remote.WebExtensionInstallParameters`",
821+
"description": "<pre>\\{<br /> extensionData: WebExtensionExtensionData;<br />\\}</pre>",
822+
"required": true
823+
}
824+
],
825+
"returns": {
826+
"type": "Object",
827+
"name": "local.WebExtensionInstallResult",
828+
"description": "Command return value with the following interface:\n ```ts\n {\n extension: WebExtensionExtension;\n }\n ```"
829+
}
830+
}
831+
},
832+
"webExtension.uninstall": {
833+
"socket": {
834+
"command": "webExtensionUninstall",
835+
"description": "WebDriver Bidi command to send command method \"webExtension.uninstall\" with parameters.",
836+
"ref": "https://w3c.github.io/webdriver-bidi/#command-webExtension-uninstall",
837+
"parameters": [
838+
{
839+
"name": "params",
840+
"type": "`remote.WebExtensionUninstallParameters`",
841+
"description": "<pre>\\{<br /> extension: WebExtensionExtension;<br />\\}</pre>",
842+
"required": true
843+
}
844+
]
845+
}
741846
}
742847
} as const
743848
export default protocol

packages/webdriver/src/bidi/core.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import type { ClientOptions, RawData, WebSocket } from 'ws'
33

44
import { environment } from '../environment.js'
55
import type * as remote from './remoteTypes.js'
6+
import type * as local from './localTypes.js'
67
import type { CommandData } from './remoteTypes.js'
78
import type { CommandResponse, ErrorResponse } from './localTypes.js'
89

@@ -162,9 +163,10 @@ export class BidiCore {
162163
})
163164

164165
if (payload.type === 'error' || 'error' in payload) {
165-
failError.message += ` with error: ${payload.error} - ${payload.message}`
166-
if (payload.stacktrace && typeof payload.stacktrace === 'string') {
167-
const driverStack = payload.stacktrace
166+
const error = payload as local.ErrorResponse
167+
failError.message += ` with error: ${payload.error} - ${error.message}`
168+
if (error.stacktrace && typeof error.stacktrace === 'string') {
169+
const driverStack = error.stacktrace
168170
.split('\n')
169171
.filter(Boolean)
170172
.map((line: string) => ` at ${line}`)

0 commit comments

Comments
 (0)