Rayrun
← Back to Discord Forum

Disable Web Security for Webkit Browser

harry_aujlaposted in #help-playwright
Open in Discord
harry_aujla
harry_aujla

Hi team, Is there a way to disable the web security for the Webkit browser?

This is what I'm doing for chromium-browser and it works fine. launchOptions: { args: ['--disable-web-security'], },

Just wondering if there is something similar available for the Webkit browser as well.

Thanks

This thread is trying to answer question "Is there a way to disable the web security for the Webkit browser?"

0 replies

Answer

Sure, you can disable web security for the WebKit browser in Playwright. Here's how you can do it:

First, launch a new instance of the WebKit browser using webkit.launch().

import { webkit } from 'playwright';

async function main() {
  const browser = await webkit.launch();
  //...
}

Next, create a new context using browser.newContext() and pass an array of command-line arguments as options. Include the --disable-web-security flag in these arguments.

async function main() {
  //...
  const context = await browser.newContext({
    // Disable web security
    args: ['--disable-web-security'],
  });
  //...
}

Now, you can use this context to create new pages and perform actions.

async function main() {
  //...
  const page = await context.newPage();
  await page.goto('https://ray.run/');
  //...
  await browser.close();
}

Remember, disabling web security can have potential security implications. So, use it with caution. Always enable web security when running tests or accessing websites that require secure browsing.

For more details or updates, refer to the official Playwright documentation.

Related Discord Threads

TwitterGitHubLinkedIn
AboutQuestionsDiscord ForumBrowser ExtensionTagsQA Jobs

Rayrun is a community for QA engineers. I am constantly looking for new ways to add value to people learning Playwright and other browser automation frameworks. If you have feedback, email luc@ray.run.