Conversation
sttaran
left a comment
There was a problem hiding this comment.
I would expect more negative scenarios
And make them please as dedicated tests
tests/qauto/homework1.spec.js
Outdated
| test.describe('Registration form test', () => { | ||
|
|
||
| test.beforeEach(async ({page})=>{ | ||
| await page.goto("https://qauto.forstudy.space/"); |
There was a problem hiding this comment.
you baseUrl in you playwright config, use relative path
tests/qauto/homework1.spec.js
Outdated
| await page.locator("#signupName").fill("Justin"); | ||
| await page.locator("#signupLastName").fill("Potter"); | ||
| await page.locator("#signupEmail").fill("dns-jp@test.com"); | ||
| await page.locator("#signupPassword").fill("qwertY@123"); | ||
| await page.locator("#signupRepeatPassword").fill("qwertY@123"); |
There was a problem hiding this comment.
after you have it moved to variables you can get rid of expectedName, expectedLastName etc.
tests/qauto/homework1.spec.js
Outdated
| expect(passworRepeatdValue).toBe(expectedRepeatValue); | ||
|
|
||
| await page.getByText("Register").click(); | ||
| await expect(page).toHaveURL('https://qauto.forstudy.space/panel/garage') |
tests/qauto/homework1.spec.js
Outdated
| await page.locator("#signupPassword").click(); | ||
| await expect(page.getByText("Email required")).toBeVisible(); | ||
| await page.locator("#signupRepeatPassword").click(); | ||
| await expect(page.getByText("Password required")).toBeVisible(); |
There was a problem hiding this comment.
you do not know where this error appears, use more precise locators
tests/qauto/homework1.spec.js
Outdated
| return style.borderColor; | ||
| }); | ||
|
|
||
| expect(computedStyle).toBe('rgb(220, 53, 69)'); |
There was a problem hiding this comment.
tests/qauto/homework1.spec.js
Outdated
|
|
||
| test('Empty fields', async ({page})=>{ | ||
| await page.locator("#signupName").click(); | ||
| await page.locator("#signupLastName").click(); |
There was a problem hiding this comment.
tests/qauto/homework1.spec.js
Outdated
| const expectedValue = "qwertY@123"; | ||
| expect(passwordValue).toBe(expectedValue); | ||
|
|
||
| const passworRepeatdValue = await page.locator("#signupPassword").evaluate(element => element.value); |
There was a problem hiding this comment.
tests/qauto/homework1.spec.js
Outdated
| const expectedValue = "qwertY@123"; | ||
| expect(passwordValue).toBe(expectedValue); | ||
|
|
||
| const passworRepeatdValue = await page.locator("#signupPassword").evaluate(element => element.value); |
tests/qauto/homework1.spec.js
Outdated
|
|
||
| test('Empty fields', async ({page})=>{ | ||
| await page.locator("#signupName").click(); | ||
| await page.locator("#signupLastName").click(); |
tests/qauto/homework1.spec.js
Outdated
| await page.locator("#signupLastName").click(); | ||
| await expect(page.locator("#signupName + .invalid-feedback")).toBeVisible(); | ||
| await page.locator("#signupEmail").click(); | ||
| await expect(page.locator("#signupLastName + .invalid-feedback")).toBeVisible(); |
There was a problem hiding this comment.
save this locator to variable
you have to many duplicated selectors
| this.signupNameInput = '#signupName'; | ||
| this.signupLastNameInput = '#signupLastName'; | ||
| this.signupEmailInput = '#signupEmail'; | ||
| this.signupPasswordInput = '#signupPassword'; | ||
| this.signupRepeatPasswordInput = '#signupRepeatPassword'; | ||
| this.registerButton = 'text=Register'; |
There was a problem hiding this comment.
move this fields to a components such as RegistrationPopup
| await this.page.fill(this.signupNameInput, name); | ||
| await this.page.fill(this.signupLastNameInput, lastName); | ||
| await this.page.fill(this.signupEmailInput, email); | ||
| await this.page.fill(this.signupPasswordInput, password); | ||
| await this.page.fill(this.signupRepeatPasswordInput, password); |
| async validateRedBorder() { | ||
| await expect(this.page.locator(this.signupNameInput)).toHaveCSS('border-color', 'rgb(220, 53, 69)'); | ||
| await expect(this.page.locator(this.signupLastNameInput)).toHaveCSS('border-color', 'rgb(220, 53, 69)'); | ||
| await expect(this.page.locator(this.signupEmailInput)).toHaveCSS('border-color', 'rgb(220, 53, 69)'); | ||
| await expect(this.page.locator(this.signupPasswordInput)).toHaveCSS('border-color', 'rgb(220, 53, 69)'); | ||
| await expect(this.page.locator(this.signupRepeatPasswordInput)).toHaveCSS('border-color', 'rgb(220, 53, 69)'); | ||
| } |
There was a problem hiding this comment.
page objects are for interacting with page
assertions should not be in POM
There was a problem hiding this comment.
this method btw in not universal since you can't check only one field with it
| @@ -0,0 +1,54 @@ | |||
| import { test, expect } from "@playwright/test"; | |||
|
|
|||
| export default class RegistrationPage { | |||
There was a problem hiding this comment.
There is no registration page as well as login page
You can call it MainPage or WelcomePage or smth like that
| const name = await page.locator('#signupName').evaluate(element => element.value); | ||
| expect(name).toBe(signupName); |
There was a problem hiding this comment.
| const name = await page.locator('#signupName').evaluate(element => element.value); | ||
| expect(name).toBe(signupName); | ||
|
|
||
| const lastName = await page.locator('#signupLastName').evaluate(element => element.value); |

No description provided.