I am getting this error:
TypeError: Cannot read properties of undefined (reading 'add_cookies')
But I am unsure how I can declare it further? What amI doing wrong in the code?
Added the snippet below:
import { test, expect, browser_context, add_cookies} from '@playwright/test';
test('test', async ({ page, }) => {
await page.goto('https://myurl.com/');
await page.waitForTimeout(4000)
browser_context.add_cookies(["cookiename", "myvalue"]
CodePudding user response:
you can pass through a browser object that give you a context to be sure to be able to add cookie
test('test', async ({ page, browser })) => {
await page.goto('https://myurl.com/');
await page.waitForTimeout(4000)
const browserContext = await browser.newContext();
browserContext.add_cookies(["cookiename", "myvalue"];
}