microsoft / playwright

Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.
https://playwright.dev
Apache License 2.0
65.98k stars 3.59k forks source link

Allow codegen to use the OS Chrome instead of chromium #20378

Open cwalker-reveille opened 1 year ago

cwalker-reveille commented 1 year ago

We run our tests on a machine using its OS based Chrome instead of chromium

 browser = await playwright.Chromium.LaunchAsync( new BrowserTypeLaunchOptions()
                        {
                            Headless = true,
                            Channel = 'chrome',
                           ...
                        } );

I know that the current options for codegen -b are 'chromium','firefox' and 'webkit'. We would like to add 'chrome' to the list. In many of our cases, testscripts are generated not by a developer but an enduser who probably does not have a version of chromium installed. They would also question why their 'Chrome' icon while in codegen is blue rather than the 'normal' red,green,yellow icon.

atgehrhardt-stripe commented 1 year ago

I wanted to second this. I believe just allowing codegen to utilize the launch_persistent_context() function on the browsers that are specified would work, so that an executable_path can be set.

mxschmitt commented 2 weeks ago

We recommend the 'Record using custom Setup' for that:

const { chromium } = require('@playwright/test');
(async () => {
  const browser = await chromium.launch({ headless: false, channel: 'chrome' });
  const context = await browser.newContext();
  const page = await context.newPage();
  await page.pause();
})();

Calling page.pause() will open Codegen: https://playwright.dev/docs/api/class-page#page-pause