Created
March 8, 2023 16:39
-
-
Save MarcusFelling/9a513fe824a3aec9f875db3a41fff6c9 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 { test as setup } from '@playwright/test'; | |
const authFile = '.auth/user.json'; | |
setup('authenticate', async ({ browser }) => { | |
const page = await browser.newPage(); | |
await page.goto(''); | |
// Sign in using creds from env variables | |
const dialogPromise = page.waitForEvent('popup'); | |
await page.getByText('LOGIN').click(); | |
const dialog = await dialogPromise; | |
await dialog.getByPlaceholder('Email, phone, or Skype').fill(process.env.AADUSERNAME!); | |
await dialog.getByRole('button', { name: 'Next' }).click(); | |
await dialog.getByPlaceholder('Password').fill(process.env.AADPASSWORD!); | |
await dialog.getByRole('button', { name: 'Sign in' }).click(); | |
// Do not stay signed in | |
await dialog.getByRole('button', { name: 'No' }).click(); | |
await page.context().storageState({ path: authFile }); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment