Created
February 21, 2023 18:55
-
-
Save MarcusFelling/86cccea2419ea4145b08e9dac0e1d6f7 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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