28 lines
1.2 KiB
TypeScript
28 lines
1.2 KiB
TypeScript
|
|
import { test as setup, expect } from '@playwright/test';
|
||
|
|
import path from 'path';
|
||
|
|
|
||
|
|
const authFile = path.join(__dirname, '../playwright/.auth/user.json');
|
||
|
|
|
||
|
|
setup('authenticate', async ({ page }) => {
|
||
|
|
// Perform authentication steps.
|
||
|
|
await page.goto('https://demo.verua.org');
|
||
|
|
|
||
|
|
await page.locator('input[name="name"]').click();
|
||
|
|
await page.locator('input[name="name"]').fill('demo');
|
||
|
|
await page.locator('input[name="pwd"]').click();
|
||
|
|
await page.locator('input[name="pwd"]').fill('demo');
|
||
|
|
await page.getByRole('button', { name: 'Jetzt anmelden' }).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://demo.verua.org/start.php?first=1&id_owner=1');
|
||
|
|
// 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();
|
||
|
|
await expect(page.getByRole('link', { name: 'ABMELDEN (demo)' })).toHaveText("ABMELDEN (demo)")
|
||
|
|
|
||
|
|
// End of authentication steps.
|
||
|
|
|
||
|
|
await page.context().storageState({ path: authFile });
|
||
|
|
});
|