Rayrun
← Back to Discord Forum

Headless : false

Can anyone suggest me a way to start playwright js in a regular mode (headless :false),Please do not suggest me the chrome extension way that's working I want another way

This thread is trying to answer question "How can I start playwright js in a regular mode (headless: false) without using the chrome extension?"

1 reply
ungabungabingobongo
ungabungabingobongo

CLI option --headed

Answer

Sure, you can launch Playwright in regular mode without using any Chrome extension methods. Here's how you can do it:

First, import the chromium module from Playwright:

const { chromium } = require('playwright');

Next, launch a new instance of the Chromium browser with headless: false. This will open up a visible browser window:

const browser = await chromium.launch({ headless: false });

Then, create a new context and a new page within that context:

const context = await browser.newContext();
const page = await context.newPage();

You can now perform various actions on this page such as navigating to URLs, clicking elements, filling forms, etc.

Finally, remember to close the browser once you're done with your testing or automation tasks:

await browser.close();

Here's the complete code:

const { chromium } = require('playwright');

async function startPlaywright() {
  const browser = await chromium.launch({ headless: false });
  const context = await browser.newContext();
  const page = await context.newPage();

  // Perform your actions on the page

  await browser.close();
}

startPlaywright();

By following these steps, you can start Playwright in regular mode (non-headless) without relying on any Chrome extension methods.

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 [email protected].