PhoenixTest.Playwright.CookieArgs (PhoenixTestPlaywright v0.7.0)

View Source

Functions to assist with adding cookies to the browser context

A cookie's value must be a binary unless the cookie is signed/encrypted

keytypedescription
:namebinary()
:valuebinary()
:urlbinary()(optional) either url or domain / path are required
:domainbinary()(optional) either url or domain / path are required
:pathbinary()(optional) either url or domain / path are required
:max_agefloat()(optional) The cookie max age, in seconds.
:http_onlyboolean()(optional)
:secureboolean()(optional)
:encryptboolean()(optional)
:signboolean()(optional)
:same_sitebinary()(optional) one of "Strict", "Lax", "None"

Two of the cookie fields mean nothing to Playwright. These are:

  1. :encrypt
  2. :sign

The :max_age cookie field means the same thing as documented in Plug.Conn.put_resp_cookie/4. The :max_age value is used to infer the correct expires value that Playwright requires.

See https://playwright.dev/docs/api/class-browsercontext#browser-context-add-cookies

Summary

Functions

Converts the cookie kw list into a map suitable for posting

Converts the session cookie kw list (with value that is a map) into a map suitable for posting

Types

cookie()

@type cookie() :: [
  domain: binary(),
  encrypt: boolean(),
  http_only: boolean(),
  max_age: integer(),
  name: binary(),
  path: binary(),
  same_site: binary(),
  secure: boolean(),
  sign: boolean(),
  url: binary(),
  value: binary() | map()
]

Functions

from_cookie(cookie)

@spec from_cookie(cookie()) :: playwright_cookie_args()

Converts the cookie kw list into a map suitable for posting

from_session_options(cookie, session_options)

@spec from_session_options(cookie(), Keyword.t()) :: playwright_cookie_args()

Converts the session cookie kw list (with value that is a map) into a map suitable for posting