简体   繁体   English

TypeError:无法读取未定义的属性(读取“add_cookies”)

[英]TypeError: Cannot read properties of undefined (reading 'add_cookies')

I am getting this error:我收到此错误:

TypeError: Cannot read properties of undefined (reading 'add_cookies') TypeError:无法读取未定义的属性(读取“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"]

you can pass through a browser object that give you a context to be sure to be able to add cookie你可以通过一个浏览器对象给你一个上下文来确保能够添加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"];
 }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 类型错误:无法读取未定义的属性(读取“添加”) - TypeError: Cannot read properties of undefined (reading 'add') 类型错误:无法在 vuejs 中读取未定义的属性(读取“添加”) - TypeError: Cannot read properties of undefined (reading 'add') in vuejs Discord.js:TypeError:无法读取未定义的属性(读取“添加”) - Discord.js: TypeError: Cannot read properties of undefined (reading 'add') TypeError:无法读取未定义(读取“_id”)购物车添加的属性 - TypeError: Cannot read properties of undefined (reading '_id') cart add 类型错误:无法读取未定义的属性(读取“和”) - TypeError: Cannot read properties of undefined (reading 'and') × 类型错误:无法读取未定义的属性(读取“名称”) - × TypeError: Cannot read properties of undefined (reading 'name') TypeError:无法读取未定义的属性(读取“名称”); - TypeError: Cannot read properties of undefined (reading 'name'); TypeError:无法读取未定义的属性(读取“v”) - TypeError: Cannot read properties of undefined (reading 'v') 未捕获的类型错误:无法读取未定义的属性(读取“0”) - Uncaught TypeError: Cannot read properties of undefined (reading '0') TypeError:无法读取未定义的属性(读取“总计”) - TypeError: Cannot read properties of undefined (reading 'total')
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM