* 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)
| 2011 | * @throws {error.NoSuchCookieError} if there is no such cookie. |
| 2012 | */ |
| 2013 | async getCookie(name) { |
| 2014 | // Validate the cookie name is non-empty and properly trimmed. |
| 2015 | if (!name?.trim()) { |
| 2016 | throw new error.InvalidArgumentError('Cookie name cannot be empty') |
| 2017 | } |
| 2018 | |
| 2019 | try { |
| 2020 | const cookie = await this.driver_.execute(new command.Command(command.Name.GET_COOKIE).setParameter('name', name)) |
| 2021 | return cookie |
| 2022 | } catch (err) { |
| 2023 | if (!(err instanceof error.UnknownCommandError) && !(err instanceof error.UnsupportedOperationError)) { |
| 2024 | throw err |
| 2025 | } |
| 2026 | return null |
| 2027 | } |
| 2028 | } |
| 2029 | |
| 2030 | /** |
| 2031 | * Fetches the timeouts currently configured for the current session. |
no test coverage detected