Skip to content

Document k6 browserContext.addCookies  #1128

@mdcruz

Description

@mdcruz

As part of xk6-browser v0.9.0 release, we have introduced a new feature to add cookies.

See more info below:

Websites require cookies to help store session details which will be used by the backend to retrieve the state. For example, when a user logins into a website then the backend will store login session details in a cookie, which can be used in future actions performed on the website. For the given example, to speed up the test run, instead of having to first go through the login flow, it would be quicker to set a known valid cookie so that the user can easily test a different feature of the website. With this new feature cookies can be added to a browserContext and all new pages created from this browserContext will have the cookie assigned to them. Thanks @zucchinho for implementing the feature!

const context = browser.newContext()
context.addCookies([{name: 'myCookie', value: 'hello world', url: 'https://test.k6.io'}])
const page = context.newPage()

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions