Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
BASE_URL=https://qauto.forstudy.space
HTTP_CREDENTIALS_USERNAME=guest
HTTP_CREDENTIALS_PASSWORD=welcome2qauto
15 changes: 15 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,8 @@
"devDependencies": {
"@playwright/test": "^1.51.1",
"@types/node": "^22.14.0"
},
"dependencies": {
"dotenv": "^16.5.0"
}
}
33 changes: 33 additions & 0 deletions pages/base.page.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
export class BasePage {
constructor(page) {
this.page = page;
}

async navigate(url) {
await this.page.goto(url);
}

async click(locator) {
await locator.click();
}

async fill(locator, text) {
await locator.fill(text);
}

async type(locator, text) {
await locator.type(text);
}

async getText(locator) {
return await locator.innerText();
}

async isVisible(locator) {
return await locator.isVisible();
}

async isEnabled(locator) {
return await locator.isEnabled();
}
}
70 changes: 70 additions & 0 deletions pages/registration.page.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
import { BasePage } from './base.page';
import { expect } from '@playwright/test';

class RegistrationPage extends BasePage {
constructor(page) {
super(page);

// Локатори
this.signUpButton = page.locator('button:has-text("Sign up")');
this.nameInput = page.locator('#signupName');
this.lastNameInput = page.locator('#signupLastName');
this.emailInput = page.locator('#signupEmail');
this.passwordInput = page.locator('#signupPassword');
this.repeatPasswordInput = page.locator('#signupRepeatPassword');
this.registerButton = page.locator('button:text("Register")');

// Помилки валідації
this.nameError = page.locator('#signupName + .invalid-feedback');
this.lastNameError = page.locator('#signupLastName + .invalid-feedback');
this.emailError = page.locator('#signupEmail + .invalid-feedback');
this.passwordError = page.locator('#signupPassword + .invalid-feedback');
this.repeatPasswordError = page.locator('#signupRepeatPassword + .invalid-feedback');
}

async navigateToRegistration() {
await this.navigate(`https://${process.env.HTTP_CREDENTIALS_USERNAME}:${process.env.HTTP_CREDENTIALS_PASSWORD}@${process.env.BASE_URL}`);
await this.click(this.signUpButton);
}

async fillRegistrationForm(name, lastName, email, password, repeatPassword) {
await this.fill(this.nameInput, name);
await this.fill(this.lastNameInput, lastName);
await this.fill(this.emailInput, email);
await this.fill(this.passwordInput, password);
await this.fill(this.repeatPasswordInput, repeatPassword);
}

async submitRegistration() {
await this.click(this.registerButton);
}

async expectSuccessfulRegistration() {
await expect(this.page).toHaveURL(/panel\/garage/);
}

async expectNameError(message) {
await expect(this.nameError).toHaveText(message);
await expect(this.nameInput).toHaveCSS('border-color', 'rgb(220, 53, 69)');
}

async expectEmailError(message) {
await expect(this.emailError).toHaveText(message);
await expect(this.emailInput).toHaveCSS('border-color', 'rgb(220, 53, 69)');
}

async expectPasswordError(message) {
await expect(this.passwordError).toHaveText(message);
await expect(this.passwordInput).toHaveCSS('border-color', 'rgb(220, 53, 69)');
}

async expectRepeatPasswordError(message) {
await expect(this.repeatPasswordError).toHaveText(message);
await expect(this.repeatPasswordInput).toHaveCSS('border-color', 'rgb(220, 53, 69)');
}

async expectRegisterButtonDisabled() {
await expect(this.registerButton).toBeDisabled();
}
}
export {RegistrationPage};
25 changes: 15 additions & 10 deletions playwright.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,11 @@ export default defineConfig({
/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
use: {
/* Base URL to use in actions like `await page.goto('/')`. */
// baseURL: 'http://127.0.0.1:3000',
baseURL: process.env.BASE_URL,
httpCredentials: {
username: process.env.HTTP_CREDENTIALS_USERNAME,
password: process.env.HTTP_CREDENTIALS_PASSWORD,
},

/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
trace: 'on-first-retry',
Expand All @@ -38,17 +42,18 @@ export default defineConfig({
{
name: 'chromium',
use: { ...devices['Desktop Chrome'] },
},
}
//,

{
name: 'firefox',
use: { ...devices['Desktop Firefox'] },
},
// {
// name: 'firefox',
// use: { ...devices['Desktop Firefox'] },
// },

{
name: 'webkit',
use: { ...devices['Desktop Safari'] },
},
// {
// name: 'webkit',
// use: { ...devices['Desktop Safari'] },
// },

/* Test against mobile viewports. */
// {
Expand Down
Loading
Loading