MCPcopy Create free account
hub / github.com/SeleniumHQ/selenium / setTimeouts

Method setTimeouts

javascript/selenium-webdriver/lib/webdriver.js:2073–2108  ·  view source on GitHub ↗

* Sets the timeout durations associated with the current session. * * The following timeouts are supported (all timeouts are specified in * milliseconds): * * - `implicit` specifies the maximum amount of time to wait for an element * locator to succeed when {@linkplain WebDrive

({ script, pageLoad, implicit } = {})

Source from the content-addressed store, hash-verified

2071 * @see <https://w3c.github.io/webdriver/webdriver-spec.html#dfn-set-timeouts>
2072 */
2073 setTimeouts({ script, pageLoad, implicit } = {}) {
2074 let cmd = new command.Command(command.Name.SET_TIMEOUT)
2075
2076 let valid = false
2077
2078 function setParam(key, value) {
2079 if (value === null || typeof value === 'number') {
2080 valid = true
2081 cmd.setParameter(key, value)
2082 } else if (typeof value !== 'undefined') {
2083 throw TypeError('invalid timeouts configuration:' + ` expected "${key}" to be a number, got ${typeof value}`)
2084 }
2085 }
2086
2087 setParam('implicit', implicit)
2088 setParam('pageLoad', pageLoad)
2089 setParam('script', script)
2090
2091 if (valid) {
2092 return this.driver_.execute(cmd).catch(() => {
2093 // Fallback to the legacy method.
2094 let cmds = []
2095 if (typeof script === 'number') {
2096 cmds.push(legacyTimeout(this.driver_, 'script', script))
2097 }
2098 if (typeof implicit === 'number') {
2099 cmds.push(legacyTimeout(this.driver_, 'implicit', implicit))
2100 }
2101 if (typeof pageLoad === 'number') {
2102 cmds.push(legacyTimeout(this.driver_, 'page load', pageLoad))
2103 }
2104 return Promise.all(cmds)
2105 })
2106 }
2107 throw TypeError('no timeouts specified')
2108 }
2109
2110 /**
2111 * @return {!Logs} The interface for managing driver logs.

Calls 2

legacyTimeoutFunction · 0.85
executeMethod · 0.65

Tested by

no test coverage detected