MCPcopy Index your code
hub / github.com/SeleniumHQ/selenium / Input

Class Input

javascript/selenium-webdriver/bidi/input.js:27–104  ·  view source on GitHub ↗

* Represents commands and events related to the Input module (simulated user input). * Described in https://w3c.github.io/webdriver-bidi/#module-input.

Source from the content-addressed store, hash-verified

25 * Described in https://w3c.github.io/webdriver-bidi/#module-input.
26 */
27class Input {
28 constructor(driver) {
29 this._driver = driver
30 }
31
32 async init() {
33 if (!(await this._driver.getCapabilities()).get('webSocketUrl')) {
34 throw Error('WebDriver instance must support BiDi protocol')
35 }
36
37 this.bidi = await this._driver.getBidi()
38 }
39
40 /**
41 * Performs the specified actions on the given browsing context.
42 *
43 * @param {string} browsingContextId - The ID of the browsing context.
44 * @param {Array} actions - The actions to be performed.
45 * @returns {Promise} A promise that resolves with the response from the server.
46 */
47 async perform(browsingContextId, actions) {
48 const _actions = await updateActions(actions)
49
50 const command = {
51 method: 'input.performActions',
52 params: {
53 context: browsingContextId,
54 actions: _actions,
55 },
56 }
57
58 return await this.bidi.send(command)
59 }
60
61 /**
62 * Resets the input state in the specified browsing context.
63 *
64 * @param {string} browsingContextId - The ID of the browsing context.
65 * @returns {Promise} A promise that resolves when the release actions are sent.
66 */
67 async release(browsingContextId) {
68 const command = {
69 method: 'input.releaseActions',
70 params: {
71 context: browsingContextId,
72 },
73 }
74 return await this.bidi.send(command)
75 }
76
77 /**
78 * Sets the files property of a given input element.
79 *
80 * @param {string} browsingContextId - The ID of the browsing context.
81 * @param {string | ReferenceValue} element - The ID of the element or a ReferenceValue object representing the element.
82 * @param {string | string[]} files - The file path or an array of file paths to be set.
83 * @throws {Error} If the element is not a string or a ReferenceValue.
84 * @returns {Promise<void>} A promise that resolves when the files are set.

Callers 3

inputMethod · 0.90
input_test.jsFile · 0.50

Calls

no outgoing calls

Tested by

no test coverage detected