@playwright/test#chromium TypeScript Examples

The following examples show how to use @playwright/test#chromium. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: common-hooks.ts    From cucumber-playwright with MIT License 6 votes vote down vote up
BeforeAll(async function () {
  switch (config.browser) {
    case 'firefox':
      browser = await firefox.launch(config.browserOptions);
      break;
    case 'webkit':
      browser = await webkit.launch(config.browserOptions);
      break;
    default:
      browser = await chromium.launch(config.browserOptions);
  }
  await ensureDir(tracesDir);
});
Example #2
Source File: global-setup.ts    From erda-ui with GNU Affero General Public License v3.0 6 votes vote down vote up
// const { chromium } = require('playwright');

async function globalSetup() {
  // const userDataDir = './auto_test/auth';
  // const context = await chromium.launchPersistentContext(userDataDir, { headless: false });
  const browser = await chromium.launch();

  const roles = Object.keys(config.roles) as RoleTypes[];
  const authFiles = fs.readdirSync(path.resolve(__dirname, './auth'));

  const promiseList: Promise<any>[] = [];
  roles.forEach((role) => {
    if (role && !authFiles.includes(`${role}.json`)) {
      promiseList.push(login({ browser, role }));
    }
  });

  await Promise.all(promiseList);
}