-
Notifications
You must be signed in to change notification settings - Fork 50
/
example.spec.ts
36 lines (32 loc) · 1.37 KB
/
example.spec.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import { test, expect } from '@playwright/test';
test.beforeEach(async ({ page }) => {
await page.goto('');
});
test.describe('Oauth tests', () => {
test('Should be able to login with Facebook', async ({ page }) => {
await page.locator('a.button.facebook').click();
await page.locator('[placeholder="Email or phone number"]').fill(process.env.OUTLOOK_USER);
await page.locator('[placeholder="Email or phone number"]').press('Tab');
await page.locator('[placeholder="Password"]').fill(process.env.PW_PWD);
await page.locator('button:has-text("Log In")').click();
});
test('Should be able to login with Google', async ({ page }) => {
await page.locator('a.button.google').click();
await page.locator('[aria-label="Email or phone"]').fill(process.env.GMAIL_USER);
await page.locator('button:has-text("Next")').click();
await page.locator('[aria-label="Enter your password"]').fill(process.env.PW_PWD);
await page.locator('button:has-text("Next") >> nth=0').click();
});
});
test.afterEach(async ({ page }) => {
// URL should be changed to collections page after login
await expect(page).toHaveURL(/.*collections/);
// Check menu items after login
const menuItems = page.locator('ul.dropdown__menu li.dropdown__menu-item');
await expect(menuItems).toHaveText([
'My Account',
'My Dashboard',
'Support',
'Sign Out',
]);
});