* Retrieves the cookie with the given name. Returns null if there is no such * cookie. The cookie will be returned as a JSON object as described by the * WebDriver wire protocol. * * @param {string} name The name of the cookie to retrieve. * @throws {InvalidArgumentError} - If the coo
(name)
| 2100 | * @throws {error.NoSuchCookieError} if there is no such cookie. |
| 2101 | */ |
| 2102 | async getCookie(name) { |
| 2103 | // Validate the cookie name is non-empty and properly trimmed. |
| 2104 | if (!name?.trim()) { |
| 2105 | throw new error.InvalidArgumentError('Cookie name cannot be empty') |
| 2106 | } |
| 2107 | |
| 2108 | try { |
| 2109 | const cookie = await this.driver_.execute(new command.Command(command.Name.GET_COOKIE).setParameter('name', name)) |
| 2110 | return cookie |
| 2111 | } catch (err) { |
| 2112 | if (!(err instanceof error.UnknownCommandError) && !(err instanceof error.UnsupportedOperationError)) { |
| 2113 | throw err |
| 2114 | } |
| 2115 | return null |
| 2116 | } |
| 2117 | } |
| 2118 | |
| 2119 | /** |
| 2120 | * Fetches the timeouts currently configured for the current session. |
no test coverage detected