-
Notifications
You must be signed in to change notification settings - Fork 0
/
auth-login.spec.js
52 lines (39 loc) · 2.24 KB
/
auth-login.spec.js
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
const {test, expect} = require('@playwright/test');
test("Login using existing user", async ({page}) => {
// Access the main page
await page.goto('https://magento.softwaretestingboard.com/');
// check if home page has the expected title
await expect(page).toHaveTitle('Home Page');
// Locate and click the sign in button
await page.getByRole('link', { name: 'Sign In' }).click();
// Check if Sign in and Registration is displaying properly
await expect(page.getByText('Registered Customers If you')).toContainText('Email');
// Enter existing user email and password then click sign in
await page.getByLabel('Email', { exact: true }).click();
await page.getByLabel('Email', { exact: true }).fill('Test3@gmail.com');
await page.getByLabel('Password').click();
await page.getByLabel('Password').fill('Test2Test');
await page.getByRole('button', { name: 'Sign In' }).click();
// check if page loads properly after logging in
await expect(page).toHaveURL('https://magento.softwaretestingboard.com/');
});
test("Login using non-existing user", async ({page}) => {
// Access the main page
await page.goto('https://magento.softwaretestingboard.com/');
// check if home page has the expected title
await expect(page).toHaveTitle('Home Page');
// Locate and click the sign in button
await page.getByRole('link', { name: 'Sign In' }).click();
// Check if Sign in and Registration is displaying properly
await expect(page.getByText('Registered Customers If you')).toContainText('Email');
// Enter non-existing user email and password then click sign in
await page.getByLabel('Email', { exact: true }).click();
await page.getByLabel('Email', { exact: true }).fill('Test3@gmail.com');
await page.getByLabel('Password').click();
await page.getByLabel('Password').fill('*****');
await page.getByRole('button', { name: 'Sign In' }).click();
// Check if error message is visible
await expect(page.getByRole('alert').locator('div').first()).toBeVisible();
// check if page loads properly after logging in
// await expect(page).toHaveURL('https://magento.softwaretestingboard.com/');
});