Skip to content

Commit

Permalink
fix: improved logger
Browse files Browse the repository at this point in the history
  • Loading branch information
beemi committed Jan 6, 2024
1 parent 640f243 commit 5d5a7da
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 15 deletions.
4 changes: 2 additions & 2 deletions pages/home-page.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { expect, type Locator, type Page } from '@playwright/test';


const logger = require('../test-utils/logger')('home-page.ts');
const logger = require('../test-utils/logger')('home-page');


export class HomePage {
Expand All @@ -24,7 +24,7 @@ export class HomePage {
await this.page.hover('.icon.fas.fa-user');
await this.page.click('text=Login');
expect(await this.page.title()).toContain('Account Login');
console.log('Login button clicked');
logger.info('Login button is clicked');
}

async clickOnRegisterButton() {
Expand Down
11 changes: 8 additions & 3 deletions pages/login-page.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { expect, type Locator, type Page } from '@playwright/test';

const logger = require('../test-utils/logger')('login-page');

export class LoginPage {
private page: Page;

Expand All @@ -9,19 +11,22 @@ export class LoginPage {

async enterEmail(email: string) {
await this.page.fill('#input-email', email);
logger.info('Email is entered');
}

async enterPassword(password: string) {
await this.page.fill('#input-password', password);
logger.info('Password is entered');
}

async clickOnContinueButton() {
await this.page.click('text=Continue');
console.log('Continue button clicked');
logger.info('Continue button is clicked');
}

async clickOnLoginButton() {
await this.page.click('input[value=Login]');
logger.info('Login button is clicked');
}

async clickOnRegisterButton() {
Expand All @@ -30,12 +35,12 @@ export class LoginPage {

async clickOnLogoutButton() {
await this.page.click("//a[contains(text(),'Logout')]");
console.log('Logout button clicked');
logger.info('Logout button is clicked');
await this.page.waitForSelector('#common-success');
expect(await this.page.isVisible('#common-success')).toBeTruthy();
const successMessage = await this.page.textContent('#common-success');
expect(successMessage).toContain('You have been logged off your account. It is now safe to leave the computer.');
console.log('Logout success message is: ' + successMessage);
logger.info('User is logged out');
}

async clickOnBillingLineButton() {
Expand Down
22 changes: 12 additions & 10 deletions pages/register-page.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { expect, type Locator, type Page } from '@playwright/test';

const logger = require('../test-utils/logger')('register-page');

export class RegisterPage {

private page: Page;
Expand All @@ -10,52 +12,52 @@ export class RegisterPage {

async navigateToRegisterPage(url: string) {
await this.page.goto(url);
console.log('Register page opened');
logger.info('Navigated to register page');
}

async enterFirstName(firstName: string) {
await this.page.fill('#input-firstname', firstName);
console.log('First name entered');
logger.info('First name entered');
}

async enterLastName(lastName: string) {
await this.page.fill('#input-lastname', lastName);
console.log('Last name entered');
logger.info('Last name entered');
}

async enterEmail(email: string) {
await this.page.fill('#input-email', email);
console.log('Email entered as: ' + email);
logger.info('Email entered');
}

async enterTelephone(telephone: string) {
await this.page.fill('#input-telephone', telephone);
console.log('Telephone entered');
logger.info('Telephone entered');
}

async enterPassword(password: string) {
await this.page.fill('#input-password', password);
console.log('Password entered as: ' + password);
logger.info('Password entered');
}

async enterConfirmPassword(confirmPassword: string) {
await this.page.fill('#input-confirm', confirmPassword);
console.log('Confirm password entered as: ' + confirmPassword);
logger.info('Confirm password entered');
}

async clickOnSubscribeRadioButton() {
await this.page.click('text=Yes');
console.log('Subscribe radio button clicked');
logger.info('Subscribe radio button clicked');
}

async clickOnPrivacyPolicyCheckbox() {
await this.page.click('label[for=input-agree]');
console.log('Privacy Policy checkbox clicked');
logger.info('Privacy policy checkbox clicked');
}

async clickOnContinueButton() {
await this.page.click('text=Continue');
console.log('Continue button clicked');
logger.info('Continue button clicked');
}

async clickOnRegisterButton() {
Expand Down

0 comments on commit 5d5a7da

Please sign in to comment.