-
Notifications
You must be signed in to change notification settings - Fork 0
pw locators, actions and assertions #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,54 @@ | ||
| import { test, expect } from "@playwright/test"; | ||
|
|
||
| export default class RegistrationPage { | ||
| constructor(page) { | ||
| this.page = page; | ||
| this.signupNameInput = '#signupName'; | ||
| this.signupLastNameInput = '#signupLastName'; | ||
| this.signupEmailInput = '#signupEmail'; | ||
| this.signupPasswordInput = '#signupPassword'; | ||
| this.signupRepeatPasswordInput = '#signupRepeatPassword'; | ||
| this.registerButton = 'text=Register'; | ||
|
Comment on lines
+6
to
+11
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. create locators instead of selectors There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. move this fields to a components such as RegistrationPopup |
||
| } | ||
|
|
||
| async fillRegistrationForm(name, lastName, email, password) { | ||
| 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); | ||
|
Comment on lines
+15
to
+19
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| } | ||
|
|
||
| async triggerWarningMessagesForFields() { | ||
| await this.page.click(this.signupNameInput); | ||
| await this.page.click(this.signupLastNameInput); | ||
| await this.page.click(this.signupEmailInput); | ||
| await this.page.click(this.signupPasswordInput); | ||
| await this.page.click(this.signupRepeatPasswordInput); | ||
| await this.page.click(this.signupNameInput); | ||
| } | ||
|
|
||
| async clickRegisterButton() { | ||
| await this.page.click(this.registerButton); | ||
| } | ||
|
|
||
|
|
||
| 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)'); | ||
| } | ||
|
Comment on lines
+36
to
+42
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. page objects are for interacting with page assertions should not be in POM There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this method btw in not universal since you can't check only one field with it |
||
|
|
||
| async validateEmptyFieldsFeedback() { | ||
| await expect(this.page.locator(this.signupNameInput + ' + .invalid-feedback')).toBeVisible(); | ||
| await expect(this.page.locator(this.signupLastNameInput + ' + .invalid-feedback')).toBeVisible(); | ||
| await expect(this.page.locator(this.signupEmailInput + ' + .invalid-feedback')).toBeVisible(); | ||
| await expect(this.page.locator(this.signupPasswordInput + ' + .invalid-feedback')).toBeVisible(); | ||
| await expect(this.page.locator(this.signupRepeatPasswordInput + ' + .invalid-feedback')).toBeVisible(); | ||
| } | ||
| } | ||
|
|
||
| // module.exports = RegistrationPage; | ||
|
|
||
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,219 @@ | ||
| import { test, expect } from "@playwright/test"; | ||
| import { faker } from '@faker-js/faker'; | ||
| import RegistrationPage from "../../pageObjects/RegistrationPage"; | ||
|
|
||
|
|
||
| test.describe('Registration form test', () => { | ||
| let registrationPage; | ||
|
|
||
| test.beforeEach(async ({ page }) => { | ||
| await page.goto('/'); | ||
| await page.locator('.btn-primary').click(); | ||
| await expect(page.locator('.modal-content')).toBeVisible(); | ||
| registrationPage = new RegistrationPage(page); | ||
| }); | ||
|
|
||
| test('Positive', async ({ page }) => { | ||
| const signupName = faker.person.firstName(); | ||
| const signupLastName = faker.person.lastName(); | ||
| const signupEmail = faker.internet.email(); | ||
| const signupPassword = faker.internet.password(); | ||
|
|
||
| await registrationPage.fillRegistrationForm(signupName, signupLastName, signupEmail, signupPassword); | ||
|
|
||
| const name = await page.locator('#signupName').evaluate(element => element.value); | ||
| expect(name).toBe(signupName); | ||
|
Comment on lines
+24
to
+25
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
|
|
||
| const lastName = await page.locator('#signupLastName').evaluate(element => element.value); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. do not use selectors in tests |
||
| expect(lastName).toBe(signupLastName); | ||
|
|
||
| const email = await page.locator('#signupEmail').evaluate(element => element.value); | ||
| expect(email).toBe(signupEmail); | ||
|
|
||
| const passwordValue = await page.locator('#signupPassword').evaluate(element => element.value); | ||
| expect(passwordValue).toBe(signupPassword); | ||
|
|
||
| await registrationPage.clickRegisterButton(); | ||
| await expect(page).toHaveURL('/panel/garage'); | ||
| }); | ||
|
|
||
| test('Empty fields', async ({ page }) => { | ||
| // await registrationPage.clickRegisterButton(); | ||
| await registrationPage.triggerWarningMessagesForFields(); | ||
| await registrationPage.validateEmptyFieldsFeedback(); | ||
| }); | ||
|
|
||
| test('Check red border', async ({ page }) => { | ||
| await registrationPage.triggerWarningMessagesForFields(); | ||
| await registrationPage.validateRedBorder(); | ||
| // await registrationPage.clickRegisterButton(); | ||
| // await registrationPage.validateRedBorder(); | ||
| }); | ||
| }); | ||
|
|
||
| export {}; | ||
|
|
||
|
|
||
| // import { test, expect } from "@playwright/test"; | ||
| // import { faker } from '@faker-js/faker'; | ||
| // import RegistrationPage from "../../pageObjects/RegistrationPage"; // Adjust import path | ||
|
|
||
| // test.describe('Registration form test', () => { | ||
| // let registrationPage; | ||
|
|
||
| // test.beforeEach(async ({ page }) => { // Use 'page' provided as a parameter | ||
| // await page.goto('/'); | ||
| // await page.locator('.btn-primary').click(); | ||
| // await expect(page.locator('.modal-content')).toBeVisible(); | ||
| // registrationPage = new RegistrationPage(page); | ||
| // }); | ||
|
|
||
| // test('Positive', async ({ page }) => { // Use 'page' provided as a parameter | ||
| // const signupName = faker.person.firstName(); | ||
| // const signupLastName = faker.person.lastName(); | ||
| // const signupEmail = faker.internet.email(); | ||
| // const signupPassword = faker.internet.password(); | ||
|
|
||
| // await registrationPage.fillRegistrationForm(signupName, signupLastName, signupEmail, signupPassword); | ||
|
|
||
| // const name = await page.locator('#signupName').evaluate(element => element.value); | ||
| // expect(name).toBe(signupName); | ||
|
|
||
| // const lastName = await page.locator('#signupLastName').evaluate(element => element.value); | ||
| // expect(lastName).toBe(signupLastName); | ||
|
|
||
| // const email = await page.locator('#signupEmail').evaluate(element => element.value); | ||
| // expect(email).toBe(signupEmail); | ||
|
|
||
| // const passwordValue = await page.locator('#signupPassword').evaluate(element => element.value); | ||
| // expect(passwordValue).toBe(signupPassword); | ||
|
|
||
| // await registrationPage.clickRegisterButton(); | ||
| // await expect(page).toHaveURL('/panel/garage'); | ||
| // }); | ||
| // }); | ||
|
|
||
| // import { test, expect } from "@playwright/test"; | ||
| // import { faker } from '@faker-js/faker'; | ||
| // import RegistrationPage from "../../pageObjects/RegistrationPage"; | ||
|
|
||
|
|
||
| // test.describe('Registration form test', () => { | ||
| // let page; | ||
| // let registrationPage; | ||
|
|
||
| // test.beforeEach(async ({ page }) => { | ||
| // await page.goto('/'); | ||
| // await page.locator('.btn-primary').click(); | ||
| // await expect(page.locator('.modal-content')).toBeVisible(); | ||
| // registrationPage = new RegistrationPage(page); | ||
| // }); | ||
|
|
||
| // test('Positive', async () => { | ||
| // const signupName = faker.person.firstName(); | ||
| // const signupLastName = faker.person.lastName(); | ||
| // const signupEmail = faker.internet.email(); | ||
| // const signupPassword = faker.internet.password(); | ||
|
|
||
| // await registrationPage.fillRegistrationForm(signupName, signupLastName, signupEmail, signupPassword); | ||
|
|
||
| // const name = await page.locator('#signupName').evaluate(element => element.value); | ||
| // expect(name).toBe(signupName); | ||
|
|
||
| // const lastName = await page.locator('#signupLastName').evaluate(element => element.value); | ||
| // expect(lastName).toBe(signupLastName); | ||
|
|
||
| // const email = await page.locator('#signupEmail').evaluate(element => element.value); | ||
| // expect(email).toBe(signupEmail); | ||
|
|
||
| // const passwordValue = await page.locator('#signupPassword').evaluate(element => element.value); | ||
| // expect(passwordValue).toBe(signupPassword); | ||
|
|
||
| // await registrationPage.clickRegisterButton(); | ||
| // await expect(page).toHaveURL('/panel/garage'); | ||
| // }); | ||
|
|
||
| // test('Empty fields', async () => { | ||
| // await registrationPage.clickRegisterButton(); | ||
| // await registrationPage.validateEmptyFieldsFeedback(); | ||
| // }); | ||
|
|
||
| // test('Check red border', async () => { | ||
| // await registrationPage.validateRedBorder(); | ||
| // await registrationPage.clickRegisterButton(); | ||
| // await registrationPage.validateRedBorder(); | ||
| // }); | ||
| // }); | ||
|
|
||
|
|
||
| // const signupName = faker.person.firstName(); | ||
| // const signupLastName = faker.person.lastName(); | ||
| // const signupEmail = faker.internet.email(); | ||
| // const signupPassword = faker.internet.password(); | ||
|
|
||
|
|
||
| // test.describe('Registration form test', () => { | ||
|
|
||
| // test.beforeEach(async ({page})=>{ | ||
| // await page.goto("/"); | ||
| // await page.locator(".btn-primary").click(); | ||
| // await expect(page.locator(".modal-content")).toBeVisible(); | ||
| // }) | ||
|
|
||
| // test('Positive', async ({ page }) => { | ||
| // await page.locator("#signupName").fill(signupName); | ||
| // await page.locator("#signupLastName").fill(signupLastName); | ||
| // await page.locator("#signupEmail").fill(signupEmail); | ||
| // await page.locator("#signupPassword").fill(signupPassword); | ||
| // await page.locator("#signupRepeatPassword").fill(signupPassword); | ||
|
|
||
|
|
||
| // const name = await page.locator("#signupName").evaluate(element => element.value); | ||
| // expect(name).toBe(signupName); | ||
|
|
||
| // const lastName = await page.locator("#signupLastName").evaluate(element => element.value); | ||
| // expect(lastName).toBe(signupLastName); | ||
|
|
||
| // const email = await page.locator("#signupEmail").evaluate(element => element.value); | ||
| // expect(email).toBe(signupEmail); | ||
|
|
||
| // const passwordValue = await page.locator("#signupPassword").evaluate(element => element.value); | ||
| // expect(passwordValue).toBe(signupPassword); | ||
|
|
||
| // const passworRepeatdValue = await page.locator("#signupPassword").evaluate(element => element.value); | ||
| // expect(passworRepeatdValue).toBe(signupPassword); | ||
|
|
||
| // await page.getByText("Register").click(); | ||
| // await expect(page).toHaveURL('/' + 'panel/garage') | ||
| // }); | ||
|
|
||
| // test('Empty fields', async ({page})=>{ | ||
| // await page.locator("#signupName").click(); | ||
| // 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(); | ||
| // await page.locator("#signupPassword").click(); | ||
| // await expect(page.locator("#signupEmail + .invalid-feedback")).toBeVisible(); | ||
| // await page.locator("#signupRepeatPassword").click(); | ||
| // await expect(page.locator("#signupPassword + .invalid-feedback")).toBeVisible(); | ||
| // await page.getByText("Registration").click(); | ||
| // await expect(page.locator("#signupRepeatPassword + .invalid-feedback")).toBeVisible(); | ||
| // }) | ||
|
|
||
| // test('Check red border', async ({ page }) => { | ||
| // await page.locator("#signupName").click(); | ||
| // await page.locator("#signupLastName").click(); | ||
| // await expect(page.locator("#signupName")).toHaveCSS('border-color', 'rgb(220, 53, 69)'); | ||
| // await page.locator("#signupEmail").click(); | ||
| // await expect(page.locator("#signupLastName")).toHaveCSS('border-color', 'rgb(220, 53, 69)'); | ||
| // await page.locator("#signupPassword").click(); | ||
| // await expect(page.locator("#signupEmail")).toHaveCSS('border-color', 'rgb(220, 53, 69)'); | ||
| // await page.locator("#signupRepeatPassword").click(); | ||
| // await expect(page.locator("#signupPassword")).toHaveCSS('border-color', 'rgb(220, 53, 69)'); | ||
| // await page.getByText("Registration").click(); | ||
| // await expect(page.locator("#signupRepeatPassword")).toHaveCSS('border-color', 'rgb(220, 53, 69)'); | ||
| // }); | ||
|
|
||
| // }); | ||
|
|
||

There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is no registration page as well as login page
You can call it MainPage or WelcomePage or smth like that
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed