-
Notifications
You must be signed in to change notification settings - Fork 319
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
base: main
Are you sure you want to change the base?
Solution #280
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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 | ||
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'); | ||
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. The method |
||
|
||
homeCatalogue.clickOnLink('Cart'); | ||
homeCatalogue.verifyProductinCart('Sony vaio i7'); | ||
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. The method |
||
|
||
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(); | ||
}); | ||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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
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. There seems to be a typo in the method name |
||
} | ||
|
||
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; |
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 a missing semicolon at the end of the import statement for
HomeAndCataloguePageObject
. This might cause issues depending on your project's configuration.