Skip to content

Instantly share code, notes, and snippets.

@MarcusFelling
Created February 21, 2023 18:55
Show Gist options
  • Save MarcusFelling/86cccea2419ea4145b08e9dac0e1d6f7 to your computer and use it in GitHub Desktop.
Save MarcusFelling/86cccea2419ea4145b08e9dac0e1d6f7 to your computer and use it in GitHub Desktop.
import { chromium, FullConfig } from '@playwright/test';
async function globalSetup(config: FullConfig) {
const browser = await chromium.launch();
const page = await browser.newPage();
await page.goto(process.env.BASEURL);
// Sign in using creds from env variables
await page.getByTitle('Sign In').click();
await page.getByPlaceholder("Email\\, phone\\, or Skype").fill(process.env.AADUSERNAME);
await page.getByPlaceholder("Email\\, phone\\, or Skype").press('Enter');
await page.getByPlaceholder("Password").fill(process.env.AADPASSWORD);
await page.locator('input:has-text("Sign in")').click();
// Save signed-in state to 'storageState.json'.
await page.context().storageState({ path: 'storageState.json' });
await browser.close();
}
export default globalSetup;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment