* 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 } = {})
| 2160 | * @see <https://w3c.github.io/webdriver/webdriver-spec.html#dfn-set-timeouts> |
| 2161 | */ |
| 2162 | setTimeouts({ script, pageLoad, implicit } = {}) { |
| 2163 | let cmd = new command.Command(command.Name.SET_TIMEOUT) |
| 2164 | |
| 2165 | let valid = false |
| 2166 | |
| 2167 | function setParam(key, value) { |
| 2168 | if (value === null || typeof value === 'number') { |
| 2169 | valid = true |
| 2170 | cmd.setParameter(key, value) |
| 2171 | } else if (typeof value !== 'undefined') { |
| 2172 | throw TypeError('invalid timeouts configuration:' + ` expected "${key}" to be a number, got ${typeof value}`) |
| 2173 | } |
| 2174 | } |
| 2175 | |
| 2176 | setParam('implicit', implicit) |
| 2177 | setParam('pageLoad', pageLoad) |
| 2178 | setParam('script', script) |
| 2179 | |
| 2180 | if (valid) { |
| 2181 | return this.driver_.execute(cmd).catch(() => { |
| 2182 | // Fallback to the legacy method. |
| 2183 | let cmds = [] |
| 2184 | if (typeof script === 'number') { |
| 2185 | cmds.push(legacyTimeout(this.driver_, 'script', script)) |
| 2186 | } |
| 2187 | if (typeof implicit === 'number') { |
| 2188 | cmds.push(legacyTimeout(this.driver_, 'implicit', implicit)) |
| 2189 | } |
| 2190 | if (typeof pageLoad === 'number') { |
| 2191 | cmds.push(legacyTimeout(this.driver_, 'page load', pageLoad)) |
| 2192 | } |
| 2193 | return Promise.all(cmds) |
| 2194 | }) |
| 2195 | } |
| 2196 | throw TypeError('no timeouts specified') |
| 2197 | } |
| 2198 | |
| 2199 | /** |
| 2200 | * @return {!Logs} The interface for managing driver logs. |
no test coverage detected