Skip to content
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

Solution #280

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
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
36 changes: 32 additions & 4 deletions cypress/e2e/checkout.cy.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,39 @@
/// <reference types='cypress' />
import { faker } from '@faker-js/faker';
import HomeAndCataloguePageObject

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a missing semicolon at the end of the import statement for HomeAndCataloguePageObject. This might cause issues depending on your project's configuration.

from '../support/pages/homeCatalogue.pageObject';

describe('', () => {
before(() => {
const homeCatalogue = new HomeAndCataloguePageObject();
const name = faker.person.firstName();
const country = faker.location.country();
const city = faker.location.city();
const card = faker.finance.creditCardNumber();
const month = faker.date.month();
const year = new Date().getFullYear();

describe('Demoblaze', () => {
before(() => {
homeCatalogue.visit();
});

it('', () => {
it('should add new product in cart', () => {
homeCatalogue.clickOnCategory('Laptops');
homeCatalogue.clickOnProduct('Sony vaio i7');
homeCatalogue.clickOnButton('Add to cart');

homeCatalogue.verifyAddingToCart('Product added');

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The method verifyAddingToCart is being called with the argument 'Product added'. Ensure that this message matches exactly what is expected from the application after adding a product to the cart.


homeCatalogue.clickOnLink('Cart');
homeCatalogue.verifyProductinCart('Sony vaio i7');

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The method verifyProductinCart is being called. Double-check the spelling of the method name and ensure it matches the actual method name in the HomeAndCataloguePageObject class. It should be verifyProductInCart if following camelCase conventions.


homeCatalogue.clickOnButton('Place Order');
homeCatalogue.typeName(name);
homeCatalogue.typeCountry(country);
homeCatalogue.typeCity(city);
homeCatalogue.typeCard(card);
homeCatalogue.typeMonth(month);
homeCatalogue.typeYear(year);
homeCatalogue.clickOnPurchaseBtn();
homeCatalogue.verifyPurchasing(name, card);
homeCatalogue.clickOnOkBtn();
});
});
78 changes: 78 additions & 0 deletions cypress/support/pages/homeCatalogue.pageObject.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,84 @@ class HomeAndCataloguePageObject extends PageObject {
cy.contains('.hrefch', product)
.click();
}

clickOnButton(buttonName) {
cy.contains('.btn', buttonName)
.click();
}

verifyAddingToCart() {
return this.assertAllert('Product added');
Comment on lines +26 to +27

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There seems to be a typo in the method name assertAllert. It should likely be assertAlert if you are trying to assert an alert message.

}

verifyProductinCart(product) {
cy.contains('td', product)
.should('be.visible');
}

get nameField() {
return cy.get('#name');
}

get countryField() {
return cy.get('#country');
}

get cityField() {
return cy.get('#city');
}

get cardField() {
return cy.get('#card');
}

get monthField() {
return cy.get('#month');
}

get yearField() {
return cy.get('#year');
}

typeName(name) {
this.nameField.type(name);
}

typeCountry(country) {
this.countryField.type(country);
}

typeCity(city) {
this.cityField.type(city);
}

typeCard(card) {
this.cardField.type(card);
}

typeMonth(month) {
this.monthField.type(month);
}

typeYear(year) {
this.yearField.type(year);
}

clickOnPurchaseBtn(buttonName) {
cy.contains('.btn', 'Purchase')
.click();
}

verifyPurchasing(name, card) {
cy.get('.sweet-alert').should('be.visible');
cy.get('.lead').should('contain', name);
cy.get('.lead').should('contain', card);
}

clickOnOkBtn() {
cy.contains('.btn', 'OK')
.click();
}
}

export default HomeAndCataloguePageObject;