Playwright: [Feature] Ability to skip/or close the page opened by `browser.launch`

Created on 13 Feb 2020  路  4Comments  路  Source: microsoft/playwright

Version: https://github.com/microsoft/playwright/commit/d367a2ed3a2d583e5e82d27ac1f53caddd8aa943 (current master)

When running this script it opens two pages (and I think two contexts)

  • one after chromium.launch
  • the other after context.newPage
const { chromium, devices } = require("playwright");
const iPhone = devices["iPhone 6"];

(async () => {
  const browser = await chromium.launch({ headless: false });
  const context = await browser.newContext({
    viewport: iPhone.viewport,
    userAgent: iPhone.userAgent
  });
  const page = await context.newPage();
})();

I would like to close the page opened by chromium.launch, or skip opening it in the first place. Since it is confusing to have a blank page that is not in use (https://github.com/qawolf/qawolf/issues/395).

example-small

Most helpful comment

Thanks for the report. We are going to get there, but it'll take some time. In order to implement it we need to introduce a new mode in all the browsers that does not open the default profile on browser startup.

All 4 comments

Thanks for the report. We are going to get there, but it'll take some time. In order to implement it we need to introduce a new mode in all the browsers that does not open the default profile on browser startup.

Should be fixed by now in Chromium and WebKit. Still has an extra tab in FF, but that is probably Ok for now.

Yeah, extra tab is less annoying than extra window.
Anyway, when this fixes will be available, in 0.12?

@DavertMik It's merged so you can get it before the next release by installing playwright@next

Was this page helpful?
0 / 5 - 0 ratings