selenium-webdriver 4.48.0 → 4.50.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.
Files changed (52) hide show
  1. package/CHANGES.md +26 -0
  2. package/bidi/generated/bluetooth.d.ts +199 -37
  3. package/bidi/generated/bluetooth.js +212 -106
  4. package/bidi/generated/browser.d.ts +81 -28
  5. package/bidi/generated/browser.js +97 -69
  6. package/bidi/generated/browsing_context.d.ts +274 -87
  7. package/bidi/generated/browsing_context.js +328 -241
  8. package/bidi/generated/common.d.ts +105 -21
  9. package/bidi/generated/common.js +64 -15
  10. package/bidi/generated/digital_credentials.d.ts +41 -0
  11. package/bidi/generated/digital_credentials.js +54 -0
  12. package/bidi/generated/emulation.d.ts +354 -58
  13. package/bidi/generated/emulation.js +262 -101
  14. package/bidi/generated/input.d.ts +63 -35
  15. package/bidi/generated/input.js +77 -51
  16. package/bidi/generated/log.d.ts +39 -18
  17. package/bidi/generated/log.js +23 -43
  18. package/bidi/generated/network.d.ts +248 -76
  19. package/bidi/generated/network.js +247 -181
  20. package/bidi/generated/permissions.d.ts +22 -4
  21. package/bidi/generated/permissions.js +31 -17
  22. package/bidi/generated/script.d.ts +166 -70
  23. package/bidi/generated/script.js +203 -116
  24. package/bidi/generated/session.d.ts +76 -36
  25. package/bidi/generated/session.js +81 -48
  26. package/bidi/generated/speculation.d.ts +15 -5
  27. package/bidi/generated/speculation.js +20 -16
  28. package/bidi/generated/storage.d.ts +41 -17
  29. package/bidi/generated/storage.js +58 -40
  30. package/bidi/generated/user_agent_client_hints.d.ts +25 -13
  31. package/bidi/generated/user_agent_client_hints.js +29 -18
  32. package/bidi/generated/webextension.d.ts +24 -10
  33. package/bidi/generated/webextension.js +39 -25
  34. package/bidi/serialization/enum.js +6 -3
  35. package/bidi/serialization/record.js +34 -29
  36. package/bin/linux-arm64/selenium-manager +0 -0
  37. package/bin/{linux → linux-x86_64}/selenium-manager +0 -0
  38. package/bin/macos/selenium-manager +0 -0
  39. package/bin/selenium-manager-THIRD-PARTY-NOTICES.txt +327 -51
  40. package/bin/selenium-manager.cdx.json +491 -491
  41. package/bin/windows/selenium-manager.exe +0 -0
  42. package/chromium.js +1 -1
  43. package/common/seleniumManager.js +2 -2
  44. package/eslint.config.js +2 -1
  45. package/example/chrome_mobile_emulation.js +1 -1
  46. package/firefox.js +7 -104
  47. package/index.js +8 -0
  48. package/lib/atoms/find-elements.js +14 -2
  49. package/package.json +10 -10
  50. package/remote/index.js +12 -3
  51. package/remote/util.js +5 -5
  52. package/testing/index.js +84 -1
@@ -17,65 +17,91 @@
17
17
  // under the License.
18
18
  Object.defineProperty(exports, "__esModule", { value: true });
19
19
  exports.Input = void 0;
20
- exports.getInputInstance = getInputInstance;
21
- // --- Additional Types ---
22
- /** @deprecated Use {@link Input.create} instead — will be removed in a future major version. */
23
- async function getInputInstance(driver) {
24
- return Input.create(driver);
25
- }
20
+ require("./browser.js");
21
+ require("./browsing_context.js");
22
+ require("./common.js");
23
+ require("./script.js");
24
+ const record_js_1 = require("../serialization/record.js");
25
+ const enum_js_1 = require("../serialization/enum.js");
26
+ const union_js_1 = require("../serialization/union.js");
27
+ const domain_js_1 = require("../domain.js");
28
+ const InputElementOrigin = (0, record_js_1.defineRecord)('input.ElementOrigin', [{ "name": "type", "wire": "type", "required": true, "type": { "const": "element" } }, { "name": "element", "wire": "element", "required": true, "type": { "ref": "script.SharedReference" } }]);
29
+ const InputPerformActions = (0, record_js_1.defineRecord)('input.PerformActions', [{ "name": "method", "wire": "method", "required": true, "type": { "const": "input.performActions" } }, { "name": "params", "wire": "params", "required": true, "type": { "ref": "input.PerformActionsParameters" } }]);
30
+ const InputPerformActionsParameters = (0, record_js_1.defineRecord)('input.PerformActionsParameters', [{ "name": "context", "wire": "context", "required": true, "type": { "ref": "browsingContext.BrowsingContext" } }, { "name": "actions", "wire": "actions", "required": true, "type": { "list": { "ref": "input.SourceActions" } } }]);
31
+ const InputSourceActionsUnion = (0, union_js_1.defineUnion)('input.SourceActions', { "by": "type", "variants": [{ "value": "none", "ref": "input.NoneSourceActions" }, { "value": "key", "ref": "input.KeySourceActions" }, { "value": "pointer", "ref": "input.PointerSourceActions" }, { "value": "wheel", "ref": "input.WheelSourceActions" }] }, { "objectOnly": true });
32
+ const InputNoneSourceActions = (0, record_js_1.defineRecord)('input.NoneSourceActions', [{ "name": "type", "wire": "type", "required": true, "type": { "const": "none" } }, { "name": "id", "wire": "id", "required": true, "type": { "primitive": "string" } }, { "name": "actions", "wire": "actions", "required": true, "type": { "list": { "ref": "input.NoneSourceAction" } } }]);
33
+ (0, record_js_1.defineAlias)('input.NoneSourceAction', { "ref": "input.PauseAction" });
34
+ const InputKeySourceActions = (0, record_js_1.defineRecord)('input.KeySourceActions', [{ "name": "type", "wire": "type", "required": true, "type": { "const": "key" } }, { "name": "id", "wire": "id", "required": true, "type": { "primitive": "string" } }, { "name": "actions", "wire": "actions", "required": true, "type": { "list": { "ref": "input.KeySourceAction" } } }]);
35
+ const InputKeySourceActionUnion = (0, union_js_1.defineUnion)('input.KeySourceAction', { "by": "type", "variants": [{ "value": "pause", "ref": "input.PauseAction" }, { "value": "keyDown", "ref": "input.KeyDownAction" }, { "value": "keyUp", "ref": "input.KeyUpAction" }] }, { "objectOnly": true });
36
+ const InputPointerSourceActions = (0, record_js_1.defineRecord)('input.PointerSourceActions', [{ "name": "type", "wire": "type", "required": true, "type": { "const": "pointer" } }, { "name": "id", "wire": "id", "required": true, "type": { "primitive": "string" } }, { "name": "parameters", "wire": "parameters", "required": false, "type": { "ref": "input.PointerParameters" } }, { "name": "actions", "wire": "actions", "required": true, "type": { "list": { "ref": "input.PointerSourceAction" } } }]);
37
+ const InputPointerTypeEnum = (0, enum_js_1.defineEnum)('input.PointerType', ["mouse", "pen", "touch"]);
38
+ const InputPointerParameters = (0, record_js_1.defineRecord)('input.PointerParameters', [{ "name": "pointerType", "wire": "pointerType", "required": false, "type": { "ref": "input.PointerType" } }]);
39
+ const InputPointerSourceActionUnion = (0, union_js_1.defineUnion)('input.PointerSourceAction', { "by": "type", "variants": [{ "value": "pause", "ref": "input.PauseAction" }, { "value": "pointerDown", "ref": "input.PointerDownAction" }, { "value": "pointerUp", "ref": "input.PointerUpAction" }, { "value": "pointerMove", "ref": "input.PointerMoveAction" }] }, { "objectOnly": true });
40
+ const InputWheelSourceActions = (0, record_js_1.defineRecord)('input.WheelSourceActions', [{ "name": "type", "wire": "type", "required": true, "type": { "const": "wheel" } }, { "name": "id", "wire": "id", "required": true, "type": { "primitive": "string" } }, { "name": "actions", "wire": "actions", "required": true, "type": { "list": { "ref": "input.WheelSourceAction" } } }]);
41
+ const InputWheelSourceActionUnion = (0, union_js_1.defineUnion)('input.WheelSourceAction', { "by": "type", "variants": [{ "value": "pause", "ref": "input.PauseAction" }, { "value": "scroll", "ref": "input.WheelScrollAction" }] }, { "objectOnly": true });
42
+ const InputPauseAction = (0, record_js_1.defineRecord)('input.PauseAction', [{ "name": "type", "wire": "type", "required": true, "type": { "const": "pause" } }, { "name": "duration", "wire": "duration", "required": false, "type": { "ref": "js-uint" } }]);
43
+ const InputKeyDownAction = (0, record_js_1.defineRecord)('input.KeyDownAction', [{ "name": "type", "wire": "type", "required": true, "type": { "const": "keyDown" } }, { "name": "value", "wire": "value", "required": true, "type": { "primitive": "string" } }]);
44
+ const InputKeyUpAction = (0, record_js_1.defineRecord)('input.KeyUpAction', [{ "name": "type", "wire": "type", "required": true, "type": { "const": "keyUp" } }, { "name": "value", "wire": "value", "required": true, "type": { "primitive": "string" } }]);
45
+ const InputPointerUpAction = (0, record_js_1.defineRecord)('input.PointerUpAction', [{ "name": "type", "wire": "type", "required": true, "type": { "const": "pointerUp" } }, { "name": "button", "wire": "button", "required": true, "type": { "ref": "js-uint" } }]);
46
+ const InputPointerDownAction = (0, record_js_1.defineRecord)('input.PointerDownAction', [{ "name": "type", "wire": "type", "required": true, "type": { "const": "pointerDown" } }, { "name": "button", "wire": "button", "required": true, "type": { "ref": "js-uint" } }, { "name": "width", "wire": "width", "required": false, "type": { "ref": "js-uint" } }, { "name": "height", "wire": "height", "required": false, "type": { "ref": "js-uint" } }, { "name": "pressure", "wire": "pressure", "required": false, "type": { "primitive": "number" } }, { "name": "tangentialPressure", "wire": "tangentialPressure", "required": false, "type": { "primitive": "number" } }, { "name": "twist", "wire": "twist", "required": false, "type": { "primitive": "integer" } }, { "name": "altitudeAngle", "wire": "altitudeAngle", "required": false, "type": { "primitive": "number" } }, { "name": "azimuthAngle", "wire": "azimuthAngle", "required": false, "type": { "primitive": "number" } }]);
47
+ const InputPointerMoveAction = (0, record_js_1.defineRecord)('input.PointerMoveAction', [{ "name": "type", "wire": "type", "required": true, "type": { "const": "pointerMove" } }, { "name": "x", "wire": "x", "required": true, "type": { "primitive": "number" } }, { "name": "y", "wire": "y", "required": true, "type": { "primitive": "number" } }, { "name": "duration", "wire": "duration", "required": false, "type": { "ref": "js-uint" } }, { "name": "origin", "wire": "origin", "required": false, "type": { "ref": "input.Origin" } }, { "name": "width", "wire": "width", "required": false, "type": { "ref": "js-uint" } }, { "name": "height", "wire": "height", "required": false, "type": { "ref": "js-uint" } }, { "name": "pressure", "wire": "pressure", "required": false, "type": { "primitive": "number" } }, { "name": "tangentialPressure", "wire": "tangentialPressure", "required": false, "type": { "primitive": "number" } }, { "name": "twist", "wire": "twist", "required": false, "type": { "primitive": "integer" } }, { "name": "altitudeAngle", "wire": "altitudeAngle", "required": false, "type": { "primitive": "number" } }, { "name": "azimuthAngle", "wire": "azimuthAngle", "required": false, "type": { "primitive": "number" } }]);
48
+ const InputWheelScrollAction = (0, record_js_1.defineRecord)('input.WheelScrollAction', [{ "name": "type", "wire": "type", "required": true, "type": { "const": "scroll" } }, { "name": "x", "wire": "x", "required": true, "type": { "ref": "js-int" } }, { "name": "y", "wire": "y", "required": true, "type": { "ref": "js-int" } }, { "name": "deltaX", "wire": "deltaX", "required": true, "type": { "ref": "js-int" } }, { "name": "deltaY", "wire": "deltaY", "required": true, "type": { "ref": "js-int" } }, { "name": "duration", "wire": "duration", "required": false, "type": { "ref": "js-uint" } }, { "name": "origin", "wire": "origin", "required": false, "type": { "ref": "input.Origin" } }]);
49
+ const InputPointerCommonProperties = (0, record_js_1.defineRecord)('input.PointerCommonProperties', [{ "name": "width", "wire": "width", "required": false, "type": { "ref": "js-uint" } }, { "name": "height", "wire": "height", "required": false, "type": { "ref": "js-uint" } }, { "name": "pressure", "wire": "pressure", "required": false, "type": { "primitive": "number" } }, { "name": "tangentialPressure", "wire": "tangentialPressure", "required": false, "type": { "primitive": "number" } }, { "name": "twist", "wire": "twist", "required": false, "type": { "primitive": "integer" } }, { "name": "altitudeAngle", "wire": "altitudeAngle", "required": false, "type": { "primitive": "number" } }, { "name": "azimuthAngle", "wire": "azimuthAngle", "required": false, "type": { "primitive": "number" } }]);
50
+ (0, record_js_1.defineAlias)('input.Origin', { "union": [{ "const": "viewport" }, { "const": "pointer" }, { "ref": "input.ElementOrigin" }], "scalar": "string", "scalarValues": ["viewport", "pointer"] });
51
+ (0, record_js_1.defineAlias)('input.PerformActionsResult', { "ref": "EmptyResult" });
52
+ const InputReleaseActions = (0, record_js_1.defineRecord)('input.ReleaseActions', [{ "name": "method", "wire": "method", "required": true, "type": { "const": "input.releaseActions" } }, { "name": "params", "wire": "params", "required": true, "type": { "ref": "input.ReleaseActionsParameters" } }]);
53
+ const InputReleaseActionsParameters = (0, record_js_1.defineRecord)('input.ReleaseActionsParameters', [{ "name": "context", "wire": "context", "required": true, "type": { "ref": "browsingContext.BrowsingContext" } }]);
54
+ (0, record_js_1.defineAlias)('input.ReleaseActionsResult', { "ref": "EmptyResult" });
55
+ const InputSetFiles = (0, record_js_1.defineRecord)('input.SetFiles', [{ "name": "method", "wire": "method", "required": true, "type": { "const": "input.setFiles" } }, { "name": "params", "wire": "params", "required": true, "type": { "ref": "input.SetFilesParameters" } }]);
56
+ const InputSetFilesParameters = (0, record_js_1.defineRecord)('input.SetFilesParameters', [{ "name": "context", "wire": "context", "required": true, "type": { "ref": "browsingContext.BrowsingContext" } }, { "name": "element", "wire": "element", "required": true, "type": { "ref": "script.SharedReference" } }, { "name": "files", "wire": "files", "required": true, "type": { "list": { "primitive": "string" } } }]);
57
+ (0, record_js_1.defineAlias)('input.SetFilesResult', { "ref": "EmptyResult" });
58
+ const InputFileDialogOpened = (0, record_js_1.defineRecord)('input.FileDialogOpened', [{ "name": "method", "wire": "method", "required": true, "type": { "const": "input.fileDialogOpened" } }, { "name": "params", "wire": "params", "required": true, "type": { "ref": "input.FileDialogInfo" } }]);
59
+ const InputFileDialogInfo = (0, record_js_1.defineRecord)('input.FileDialogInfo', [{ "name": "context", "wire": "context", "required": true, "type": { "ref": "browsingContext.BrowsingContext" } }, { "name": "userContext", "wire": "userContext", "required": false, "type": { "ref": "browser.UserContext" } }, { "name": "element", "wire": "element", "required": false, "type": { "ref": "script.SharedReference" } }, { "name": "multiple", "wire": "multiple", "required": true, "type": { "primitive": "boolean" } }]);
26
60
  // --- Implementation ---
27
- class Input {
28
- constructor(bidi) {
29
- this.bidi = bidi;
30
- }
61
+ /**
62
+ * This is an unsupported API. No compatibility guarantees are provided.
63
+ * It tracks the W3C WebDriver BiDi specification directly. As the specification
64
+ * evolves, this API will change or be removed without prior notice.
65
+ */
66
+ class Input extends domain_js_1.Domain {
31
67
  static async create(driver) {
32
- const caps = await driver.getCapabilities();
33
- if (!caps.get('webSocketUrl')) {
34
- throw new Error('WebDriver instance must support BiDi protocol');
35
- }
36
- const bidi = await driver.getBidi();
37
- return new Input(bidi);
68
+ return new Input(await domain_js_1.Domain.connect(driver), domain_js_1.DOMAIN_TOKEN);
38
69
  }
70
+ /**
71
+ * @param {InputPerformActionsParameters} params
72
+ * @param {BrowsingContextBrowsingContext} params.context
73
+ * @param {Array<InputSourceActions>} params.actions
74
+ * @returns {Promise<void>}
75
+ * @see https://w3c.github.io/webdriver-bidi/#command-input-performActions
76
+ */
39
77
  async performActions(params) {
40
- const response = await this.bidi.send({
41
- method: 'input.performActions',
42
- params: params,
43
- });
44
- if (response['type'] === 'error') {
45
- throw new Error(`${response['error']}: ${response['message']}`);
46
- }
78
+ const validatedParams = new InputPerformActionsParameters(params);
79
+ await this.send('input.performActions', validatedParams);
47
80
  }
81
+ /**
82
+ * @param {InputReleaseActionsParameters} params
83
+ * @param {BrowsingContextBrowsingContext} params.context
84
+ * @returns {Promise<void>}
85
+ * @see https://w3c.github.io/webdriver-bidi/#command-input-releaseActions
86
+ */
48
87
  async releaseActions(params) {
49
- const response = await this.bidi.send({
50
- method: 'input.releaseActions',
51
- params: params,
52
- });
53
- if (response['type'] === 'error') {
54
- throw new Error(`${response['error']}: ${response['message']}`);
55
- }
88
+ const validatedParams = new InputReleaseActionsParameters(params);
89
+ await this.send('input.releaseActions', validatedParams);
56
90
  }
91
+ /**
92
+ * @param {InputSetFilesParameters} params
93
+ * @param {BrowsingContextBrowsingContext} params.context
94
+ * @param {ScriptSharedReference} params.element
95
+ * @param {Array<string>} params.files
96
+ * @returns {Promise<void>}
97
+ * @see https://w3c.github.io/webdriver-bidi/#command-input-setFiles
98
+ */
57
99
  async setFiles(params) {
58
- const response = await this.bidi.send({
59
- method: 'input.setFiles',
60
- params: params,
61
- });
62
- if (response['type'] === 'error') {
63
- throw new Error(`${response['error']}: ${response['message']}`);
64
- }
65
- }
66
- async onFileDialogOpened(callback) {
67
- await this.bidi.subscribe('input.fileDialogOpened');
68
- this.bidi.on('input.fileDialogOpened', (params) => {
69
- callback(params);
70
- });
71
- }
72
- /** @deprecated Use {@link performActions} instead — will be removed in a future major version. */
73
- async perform(browsingContextId, actions) {
74
- await this.performActions({ context: browsingContextId, actions });
75
- }
76
- /** @deprecated Use {@link releaseActions} instead — will be removed in a future major version. */
77
- async release(browsingContextId) {
78
- await this.releaseActions({ context: browsingContextId });
100
+ const validatedParams = new InputSetFilesParameters(params);
101
+ await this.send('input.setFiles', validatedParams);
79
102
  }
80
103
  }
81
104
  exports.Input = Input;
105
+ /** @see https://w3c.github.io/webdriver-bidi/#event-input-fileDialogOpened */
106
+ Input.FILE_DIALOG_OPENED = (0, domain_js_1.event)('input.fileDialogOpened', InputFileDialogInfo);
107
+ Input.PointerType = Object.freeze({ MOUSE: "mouse", PEN: "pen", TOUCH: "touch" });
@@ -1,6 +1,8 @@
1
1
  import type { JsUint } from './common.js';
2
+ import './common.js';
2
3
  import type { ScriptRemoteValue, ScriptSource, ScriptStackTrace } from './script.js';
3
- export type LogEvent = LogEntryAdded;
4
+ import './script.js';
5
+ import { Domain, type EventDescriptor } from '../domain.js';
4
6
  export type LogLevel = "debug" | "info" | "warn" | "error";
5
7
  export type LogEntry = LogGenericLogEntry | LogConsoleLogEntry | LogJavascriptLogEntry;
6
8
  export interface LogBaseLogEntry {
@@ -10,30 +12,49 @@ export interface LogBaseLogEntry {
10
12
  timestamp: JsUint;
11
13
  stackTrace?: ScriptStackTrace;
12
14
  }
13
- export type LogGenericLogEntry = LogBaseLogEntry & {
15
+ export interface LogGenericLogEntry {
16
+ level: LogLevel;
17
+ source: ScriptSource;
18
+ text: string | null;
19
+ timestamp: JsUint;
20
+ stackTrace?: ScriptStackTrace;
14
21
  type: string;
15
- };
16
- export type LogConsoleLogEntry = LogBaseLogEntry & {
22
+ }
23
+ export interface LogConsoleLogEntry {
24
+ level: LogLevel;
25
+ source: ScriptSource;
26
+ text: string | null;
27
+ timestamp: JsUint;
28
+ stackTrace?: ScriptStackTrace;
17
29
  type: "console";
18
30
  method: string;
19
- args: ScriptRemoteValue[];
20
- };
21
- export type LogJavascriptLogEntry = LogBaseLogEntry & {
31
+ args: Array<ScriptRemoteValue>;
32
+ }
33
+ export interface LogJavascriptLogEntry {
34
+ level: LogLevel;
35
+ source: ScriptSource;
36
+ text: string | null;
37
+ timestamp: JsUint;
38
+ stackTrace?: ScriptStackTrace;
22
39
  type: "javascript";
23
- };
40
+ }
24
41
  export interface LogEntryAdded {
25
42
  method: "log.entryAdded";
26
43
  params: LogEntry;
27
44
  }
28
- /** @deprecated Use {@link Log.create} instead — will be removed in a future major version. */
29
- export declare function getLogInspectorInstance(driver: unknown): Promise<Log>;
30
- export declare class Log {
31
- private readonly bidi;
32
- private constructor();
45
+ /**
46
+ * This is an unsupported API. No compatibility guarantees are provided.
47
+ * It tracks the W3C WebDriver BiDi specification directly. As the specification
48
+ * evolves, this API will change or be removed without prior notice.
49
+ */
50
+ export declare class Log extends Domain {
51
+ /** @see https://w3c.github.io/webdriver-bidi/#event-log-entryAdded */
52
+ static readonly ENTRY_ADDED: EventDescriptor<LogEntry>;
53
+ static readonly Level: Readonly<{
54
+ readonly DEBUG: "debug";
55
+ readonly INFO: "info";
56
+ readonly WARN: "warn";
57
+ readonly ERROR: "error";
58
+ }>;
33
59
  static create(driver: unknown): Promise<Log>;
34
- onEntryAdded(callback: (params: LogEntry) => void): Promise<void>;
35
- onConsoleEntry(callback: (params: LogEntry) => void): Promise<void>;
36
- onJavascriptLog(callback: (params: LogEntry) => void): Promise<void>;
37
- onJavascriptException(callback: (params: LogEntry) => void): Promise<void>;
38
- onLog(callback: (params: LogEntry) => void): Promise<void>;
39
60
  }
@@ -17,51 +17,31 @@
17
17
  // under the License.
18
18
  Object.defineProperty(exports, "__esModule", { value: true });
19
19
  exports.Log = void 0;
20
- exports.getLogInspectorInstance = getLogInspectorInstance;
21
- // --- Additional Types ---
22
- /** @deprecated Use {@link Log.create} instead — will be removed in a future major version. */
23
- async function getLogInspectorInstance(driver) {
24
- return Log.create(driver);
25
- }
20
+ require("./common.js");
21
+ require("./script.js");
22
+ const record_js_1 = require("../serialization/record.js");
23
+ const enum_js_1 = require("../serialization/enum.js");
24
+ const union_js_1 = require("../serialization/union.js");
25
+ const domain_js_1 = require("../domain.js");
26
+ const LogLevelEnum = (0, enum_js_1.defineEnum)('log.Level', ["debug", "info", "warn", "error"]);
27
+ const LogEntryUnion = (0, union_js_1.defineUnion)('log.Entry', { "by": "type", "variants": [{ "value": "console", "ref": "log.ConsoleLogEntry" }, { "value": "javascript", "ref": "log.JavascriptLogEntry" }], "default": "log.GenericLogEntry" }, { "objectOnly": true });
28
+ const LogBaseLogEntry = (0, record_js_1.defineRecord)('log.BaseLogEntry', [{ "name": "level", "wire": "level", "required": true, "type": { "ref": "log.Level" } }, { "name": "source", "wire": "source", "required": true, "type": { "ref": "script.Source" } }, { "name": "text", "wire": "text", "required": true, "type": { "primitive": "string", "nullable": true } }, { "name": "timestamp", "wire": "timestamp", "required": true, "type": { "ref": "js-uint" } }, { "name": "stackTrace", "wire": "stackTrace", "required": false, "type": { "ref": "script.StackTrace" } }]);
29
+ const LogGenericLogEntry = (0, record_js_1.defineRecord)('log.GenericLogEntry', [{ "name": "level", "wire": "level", "required": true, "type": { "ref": "log.Level" } }, { "name": "source", "wire": "source", "required": true, "type": { "ref": "script.Source" } }, { "name": "text", "wire": "text", "required": true, "type": { "primitive": "string", "nullable": true } }, { "name": "timestamp", "wire": "timestamp", "required": true, "type": { "ref": "js-uint" } }, { "name": "stackTrace", "wire": "stackTrace", "required": false, "type": { "ref": "script.StackTrace" } }, { "name": "type", "wire": "type", "required": true, "type": { "primitive": "string" } }]);
30
+ const LogConsoleLogEntry = (0, record_js_1.defineRecord)('log.ConsoleLogEntry', [{ "name": "level", "wire": "level", "required": true, "type": { "ref": "log.Level" } }, { "name": "source", "wire": "source", "required": true, "type": { "ref": "script.Source" } }, { "name": "text", "wire": "text", "required": true, "type": { "primitive": "string", "nullable": true } }, { "name": "timestamp", "wire": "timestamp", "required": true, "type": { "ref": "js-uint" } }, { "name": "stackTrace", "wire": "stackTrace", "required": false, "type": { "ref": "script.StackTrace" } }, { "name": "type", "wire": "type", "required": true, "type": { "const": "console" } }, { "name": "method", "wire": "method", "required": true, "type": { "primitive": "string" } }, { "name": "args", "wire": "args", "required": true, "type": { "list": { "ref": "script.RemoteValue" } } }]);
31
+ const LogJavascriptLogEntry = (0, record_js_1.defineRecord)('log.JavascriptLogEntry', [{ "name": "level", "wire": "level", "required": true, "type": { "ref": "log.Level" } }, { "name": "source", "wire": "source", "required": true, "type": { "ref": "script.Source" } }, { "name": "text", "wire": "text", "required": true, "type": { "primitive": "string", "nullable": true } }, { "name": "timestamp", "wire": "timestamp", "required": true, "type": { "ref": "js-uint" } }, { "name": "stackTrace", "wire": "stackTrace", "required": false, "type": { "ref": "script.StackTrace" } }, { "name": "type", "wire": "type", "required": true, "type": { "const": "javascript" } }]);
32
+ const LogEntryAdded = (0, record_js_1.defineRecord)('log.EntryAdded', [{ "name": "method", "wire": "method", "required": true, "type": { "const": "log.entryAdded" } }, { "name": "params", "wire": "params", "required": true, "type": { "ref": "log.Entry" } }]);
26
33
  // --- Implementation ---
27
- class Log {
28
- constructor(bidi) {
29
- this.bidi = bidi;
30
- }
34
+ /**
35
+ * This is an unsupported API. No compatibility guarantees are provided.
36
+ * It tracks the W3C WebDriver BiDi specification directly. As the specification
37
+ * evolves, this API will change or be removed without prior notice.
38
+ */
39
+ class Log extends domain_js_1.Domain {
31
40
  static async create(driver) {
32
- const caps = await driver.getCapabilities();
33
- if (!caps.get('webSocketUrl')) {
34
- throw new Error('WebDriver instance must support BiDi protocol');
35
- }
36
- const bidi = await driver.getBidi();
37
- return new Log(bidi);
38
- }
39
- async onEntryAdded(callback) {
40
- await this.bidi.subscribe('log.entryAdded');
41
- this.bidi.on('log.entryAdded', (params) => {
42
- callback(params);
43
- });
44
- }
45
- async onConsoleEntry(callback) {
46
- await this.onEntryAdded((entry) => {
47
- if (entry.type === 'console')
48
- callback(entry);
49
- });
50
- }
51
- async onJavascriptLog(callback) {
52
- await this.onEntryAdded((entry) => {
53
- if (entry.type === 'javascript')
54
- callback(entry);
55
- });
56
- }
57
- async onJavascriptException(callback) {
58
- await this.onEntryAdded((entry) => {
59
- if (entry.type === 'javascript' && entry.level === 'error')
60
- callback(entry);
61
- });
62
- }
63
- async onLog(callback) {
64
- await this.onEntryAdded(callback);
41
+ return new Log(await domain_js_1.Domain.connect(driver), domain_js_1.DOMAIN_TOKEN);
65
42
  }
66
43
  }
67
44
  exports.Log = Log;
45
+ /** @see https://w3c.github.io/webdriver-bidi/#event-log-entryAdded */
46
+ Log.ENTRY_ADDED = (0, domain_js_1.event)('log.entryAdded', LogEntryUnion);
47
+ Log.Level = Object.freeze({ DEBUG: "debug", INFO: "info", WARN: "warn", ERROR: "error" });