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

Method setTimeouts

javascript/selenium-webdriver/lib/webdriver.js:2036–2071  ·  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

2034 * @see <https://w3c.github.io/webdriver/webdriver-spec.html#dfn-set-timeouts>
2035 */
2036 setTimeouts({ script, pageLoad, implicit } = {}) {
2037 let cmd = new command.Command(command.Name.SET_TIMEOUT)
2038
2039 let valid = false
2040
2041 function setParam(key, value) {
2042 if (value === null || typeof value === 'number') {
2043 valid = true
2044 cmd.setParameter(key, value)
2045 } else if (typeof value !== 'undefined') {
2046 throw TypeError('invalid timeouts configuration:' + ` expected "${key}" to be a number, got ${typeof value}`)
2047 }
2048 }
2049
2050 setParam('implicit', implicit)
2051 setParam('pageLoad', pageLoad)
2052 setParam('script', script)
2053
2054 if (valid) {
2055 return this.driver_.execute(cmd).catch(() => {
2056 // Fallback to the legacy method.
2057 let cmds = []
2058 if (typeof script === 'number') {
2059 cmds.push(legacyTimeout(this.driver_, 'script', script))
2060 }
2061 if (typeof implicit === 'number') {
2062 cmds.push(legacyTimeout(this.driver_, 'implicit', implicit))
2063 }
2064 if (typeof pageLoad === 'number') {
2065 cmds.push(legacyTimeout(this.driver_, 'page load', pageLoad))
2066 }
2067 return Promise.all(cmds)
2068 })
2069 }
2070 throw TypeError('no timeouts specified')
2071 }
2072
2073 /**
2074 * @return {!Logs} The interface for managing driver logs.

Calls 2

legacyTimeoutFunction · 0.85
executeMethod · 0.65

Tested by

no test coverage detected