如何使用 playwright 禁用 Chrome 中的网络安全

问题描述 投票:0回答:1

使用 launchOptions 设置浏览器启动配置并将对象传递给浏览器实例。

var launchOptions = new BrowserTypeLaunchOptions
 {
     Headless = false,
     Args = new[] { "--disable-web-security" }
 };

browser = await browserType.LaunchAsync(launchOptions);
google-chrome configuration playwright disable websecurity
1个回答
0
投票

从 playwright.config.ts 使用以下配置,

const config: PlaywrightTestConfig = {
  projects: [
    {
      name: 'chromium',
      use: {
        launchOptions: {
          args: ['--disable-web-security'],
        }
      },
    }
  ]
}
© www.soinside.com 2019 - 2024. All rights reserved.