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
Binary file added .DS_Store
Binary file not shown.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ node_modules/
/playwright/.cache/
/test-result/
/test-results/
.vscode/
cucumber-report.html
assets
features
Expand Down
6 changes: 3 additions & 3 deletions config/cucumber.js → cucumber.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ module.exports = {
snippetInterface: "async-await"
},
paths: [
"src/test/features/"
"src/test/features/**/*.feature"
],
publishQuiet: true,
dryRun: false,
require: [
"src/test/steps/*.ts",
"src/test/steps/**/*.ts",
"src/hooks/hooks.ts"
],
requireModule: [
Expand All @@ -31,7 +31,7 @@ module.exports = {
publishQuiet: true,
dryRun: false,
require: [
"src/test/steps/*.ts",
"src/test/steps/**/*.ts",
"src/hooks/hooks.ts"
],
requireModule: [
Expand Down
2,186 changes: 507 additions & 1,679 deletions package-lock.json

Large diffs are not rendered by default.

12 changes: 7 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,15 @@
"author": "Koushik @LetCode with Koushik",
"license": "ISC",
"devDependencies": {
"@cucumber/cucumber": "^9.0.1",
"@cucumber/cucumber": "^9.6.0",
"@playwright/test": "1.35.0",
"@types/dotenv": "^6.1.1",
"cross-env": "^7.0.3",
"dotenv": "^16.0.3",
"dotenv": "^16.5.0",
"fs-extra": "^11.1.1",
"multiple-cucumber-html-reporter": "^3.3.0",
"ts-node": "^10.9.1",
"winston": "^3.8.2"
"prettier": "^3.5.3",
"ts-node": "^10.9.2",
"winston": "^3.17.0"
}
}
}
11 changes: 11 additions & 0 deletions playwright.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { defineConfig } from '@playwright/test';

export default defineConfig({
testDir: './src/test', // Ruta donde están tus pruebas
timeout: 30000,
retries: 1,
use: {
headless: true,
baseURL: process.env.BASEURL || 'https://automationexercise.com/',
},
});
1 change: 0 additions & 1 deletion src/helper/browsers/browserManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,4 @@ export const invokeBrowser = () => {
default:
throw new Error("Please set the proper browser!")
}

}
2 changes: 1 addition & 1 deletion src/helper/env/.env.prod
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
BASEURL = https://bookcart.azurewebsites.net/
BASEURL = https://automationexercise.com/
BROWSER = chrome
HEAD = true
2 changes: 1 addition & 1 deletion src/helper/env/.env.staging
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
BASEURL = https://staging.bookcart.azurewebsites.net/
BASEURL = https://automationexercise.com/
BROWSER = chrome
HEAD = true
1 change: 0 additions & 1 deletion src/helper/env/env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import * as dotenv from 'dotenv'
export const getEnv = () => {
if (process.env.ENV) {
dotenv.config({
override: true,
path: `src/helper/env/.env.${process.env.ENV}`
})
} else {
Expand Down
16 changes: 14 additions & 2 deletions src/helper/util/test-data/registerUser.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,19 @@
{
"firstName": "Koushik ",
"firstName": "Koushik c",
"lastName": "C ",
"userName": "user",
"password": "Pass123$",
"confirmPassword": "Pass123$"
"confirmPassword": "Pass123$",
"day":"01",
"month":"01",
"year":"2000",
"company": "Test",
"address1": "Test",
"address2": "Test",
"contry": "Test",
"state": "Test",
"city": "Test",
"zip": "123456",
"phone": "1234567890",
"email": "automation2@mailinator.com"
}
50 changes: 45 additions & 5 deletions src/pages/loginPage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,15 @@ export default class LoginPage {
}

private Elements = {
userInput: "Username",
passwordInput: "Password",
loginBtn: "button[color='primary']",
errorMessage: "alert"
signupLogin: "a[href='/login']",
userInput: "input[placeholder='Name']",
emailInput: "//input[@data-qa='signup-email']",
passwordInput: "input[data-qa='signup-email']",
loginBtn: "button[data-qa='signup-button']",
imgHeader: "img[alt='Website for automation practice']",
newUserSignup: "//h2[normalize-space()='New User Signup!']",
errorMessage: "alert",
accountMessage: "//b[normalize-space()='Enter Account Information']"
}

async navigateToLoginPage() {
Expand All @@ -26,8 +31,32 @@ export default class LoginPage {
await this.page.getByLabel(this.Elements.passwordInput).fill(Password);
}

async enterFullName(fullName: string) {
await this.page.click(this.Elements.userInput);
await this.page.locator(this.Elements.userInput).fill(fullName);
}
async enterEmail(email: string) {
await this.page.locator(this.Elements.emailInput).fill(email);
}

async clickLoginButton() {
await this.base.waitAndClick(this.Elements.loginBtn);
await this.page.click(this.Elements.loginBtn);
}

async clickSignupLogin() {
await this.page.click(this.Elements.signupLogin);
}
async getTextImag() {
return this.page.getByAltText(this.Elements.imgHeader).isVisible();
}

async waitForElement(selector: string, timeout: number = 5000): Promise<void> {
await this.page.waitForSelector(selector, { state: "visible", timeout });
}

async getTextUserSignup() {
await this.waitForElement(this.Elements.signupLogin);
return this.page.getByText(this.Elements.newUserSignup).isVisible();
}

getErrorMessage() {
Expand All @@ -40,5 +69,16 @@ export default class LoginPage {
await this.clickLoginButton();
}

async setUser(user: string, email: string) {
await this.enterFullName(user);
await this.enterEmail(email);
}

async validateMenssage(expectedMessage: string) {
this.page.locator(this.Elements.accountMessage).isVisible();
const accountMessage = await this.page.locator(this.Elements.accountMessage).textContent();
expect(accountMessage).toContain(expectedMessage);
}


}
28 changes: 20 additions & 8 deletions src/pages/registerPage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,22 @@ export default class RegisterPage {
}

private Elements = {
fName: "input[formcontrolname='firstname']",
lname: "input[formcontrolname='lastname']",
userName: "input[formcontrolname='username']",
password: "input[formcontrolname='password']",
titleGRadioBtn:"input[value='Mr']",
fName: "input[name='first_name']",
lname: "//input[@name='last_name']",
userName: "input[value='Test3']",
password: "input[name='password']",
confirmPassword: "input[formcontrolname='confirmPassword']",
maleInput: "input[value='Male']",
femaleInput: "input[value='Female']",
maleRadioBtn: "//span[contains(text(),'Male')]",
femaleRadioBtn: "//span[contains(text(),'Female')]",
regBtn: "button[color='primary']"
}
regBtn: "button[color='primary']",
day: "select[name='days']",
month: "select[name='months']",
year: "select[name='years']",
newsletterCkeckBtn: "input[value='1'][name='newsletter']",

async navigateToRegisterPage() {
await this.base.goto("https://bookcart.azurewebsites.net/register")
}


Expand Down Expand Up @@ -58,5 +60,15 @@ export default class RegisterPage {
]);
await response.finished();
}
async enterInputForm() {
await this.page.type(this.Elements.fName, "John");
await this.page.type(this.Elements.lname, "Doe");
await this.page.type(this.Elements.userName, "johndoe123");
await this.page.type(this.Elements.password, "password123");
await this.page.type(this.Elements.confirmPassword, "password123");
await this.page.click(this.Elements.maleRadioBtn);
await this.page.click(this.Elements.regBtn);

}
}

25 changes: 0 additions & 25 deletions src/test/features/addToCart.feature

This file was deleted.

17 changes: 0 additions & 17 deletions src/test/features/login.feature

This file was deleted.

7 changes: 0 additions & 7 deletions src/test/features/registerFeature.feature

This file was deleted.

24 changes: 0 additions & 24 deletions src/test/steps/addToCartSteps.ts

This file was deleted.

44 changes: 0 additions & 44 deletions src/test/steps/loginSteps.ts

This file was deleted.

Loading