mirror of
https://github.com/microsoft/playwright.git
synced 2025-06-26 21:40:17 +00:00
parent
1dfc4c769d
commit
a81ce3f13d
@ -55,6 +55,14 @@ setup('authenticate', async ({ page }) => {
|
||||
await page.getByLabel('Username or email address').fill('username');
|
||||
await page.getByLabel('Password').fill('password');
|
||||
await page.getByRole('button', { name: 'Sign in' }).click();
|
||||
// Wait until the page receives the cookies.
|
||||
//
|
||||
// Sometimes login flow sets cookies in the process of several redirects.
|
||||
// Wait for the final URL to ensure that the cookies are actually set.
|
||||
await page.waitForURL('https://github.com/');
|
||||
// Alternatively, you can wait until the page reaches a state where all cookies are set.
|
||||
await expect(page.getByRole('button', { name: 'View profile and more' })).toBeVisible();
|
||||
|
||||
// End of authentication steps.
|
||||
|
||||
await page.context().storageState({ path: authFile });
|
||||
@ -161,6 +169,14 @@ export const test = baseTest.extend<{}, { workerStorageState: string }>({
|
||||
await page.getByLabel('Username or email address').fill(account.username);
|
||||
await page.getByLabel('Password').fill(account.password);
|
||||
await page.getByRole('button', { name: 'Sign in' }).click();
|
||||
// Wait until the page receives the cookies.
|
||||
//
|
||||
// Sometimes login flow sets cookies in the process of several redirects.
|
||||
// Wait for the final URL to ensure that the cookies are actually set.
|
||||
await page.waitForURL('https://github.com/');
|
||||
// Alternatively, you can wait until the page reaches a state where all cookies are set.
|
||||
await expect(page.getByRole('button', { name: 'View profile and more' })).toBeVisible();
|
||||
|
||||
// End of authentication steps.
|
||||
|
||||
await page.context().storageState({ path: fileName });
|
||||
@ -393,6 +409,14 @@ setup('authenticate as admin', async ({ page }) => {
|
||||
await page.getByLabel('Username or email address').fill('admin');
|
||||
await page.getByLabel('Password').fill('password');
|
||||
await page.getByRole('button', { name: 'Sign in' }).click();
|
||||
// Wait until the page receives the cookies.
|
||||
//
|
||||
// Sometimes login flow sets cookies in the process of several redirects.
|
||||
// Wait for the final URL to ensure that the cookies are actually set.
|
||||
await page.waitForURL('https://github.com/');
|
||||
// Alternatively, you can wait until the page reaches a state where all cookies are set.
|
||||
await expect(page.getByRole('button', { name: 'View profile and more' })).toBeVisible();
|
||||
|
||||
// End of authentication steps.
|
||||
|
||||
await page.context().storageState({ path: adminFile });
|
||||
@ -406,6 +430,14 @@ setup('authenticate as user', async ({ page }) => {
|
||||
await page.getByLabel('Username or email address').fill('user');
|
||||
await page.getByLabel('Password').fill('password');
|
||||
await page.getByRole('button', { name: 'Sign in' }).click();
|
||||
// Wait until the page receives the cookies.
|
||||
//
|
||||
// Sometimes login flow sets cookies in the process of several redirects.
|
||||
// Wait for the final URL to ensure that the cookies are actually set.
|
||||
await page.waitForURL('https://github.com/');
|
||||
// Alternatively, you can wait until the page reaches a state where all cookies are set.
|
||||
await expect(page.getByRole('button', { name: 'View profile and more' })).toBeVisible();
|
||||
|
||||
// End of authentication steps.
|
||||
|
||||
await page.context().storageState({ path: userFile });
|
||||
|
Loading…
x
Reference in New Issue
Block a user