* 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)
| 1974 | * @throws {error.NoSuchCookieError} if there is no such cookie. |
| 1975 | */ |
| 1976 | async getCookie(name) { |
| 1977 | // Validate the cookie name is non-empty and properly trimmed. |
| 1978 | if (!name?.trim()) { |
| 1979 | throw new error.InvalidArgumentError('Cookie name cannot be empty') |
| 1980 | } |
| 1981 | |
| 1982 | try { |
| 1983 | const cookie = await this.driver_.execute(new command.Command(command.Name.GET_COOKIE).setParameter('name', name)) |
| 1984 | return cookie |
| 1985 | } catch (err) { |
| 1986 | if (!(err instanceof error.UnknownCommandError) && !(err instanceof error.UnsupportedOperationError)) { |
| 1987 | throw err |
| 1988 | } |
| 1989 | return null |
| 1990 | } |
| 1991 | } |
| 1992 | |
| 1993 | /** |
| 1994 | * Fetches the timeouts currently configured for the current session. |
no test coverage detected