-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathaddtocart.cy.js
34 lines (27 loc) · 1.22 KB
/
addtocart.cy.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import LoginPage from '../helper/pageobject/loginPage'
import ProductPage from "../helper/pageobject/productPage"
describe('Add to Cart Test', () => {
beforeeach(() => {
cy.viewport(Cypress.env('width'), Cypress.env('height'));
})
it('Verify User should be able to login with valid credentials and add items to the cart', () => {
cy.visit(Cypress.config().baseUrl);
LoginPage.setUserName("standard_user").setPassWord("secret_sauce").clickLoginButton()
ProductPage.getPageTitle().then(title => cy.log(title.text()))
ProductPage.getAllProducts().then(item => {
cy.log(item.length)
})
ProductPage.addItemToCart().click()
});
it('Verify User not should be able add items to the cart without succesful login', () => {
cy.visit(Cypress.config().baseUrl);
LoginPage.setUserName("standard_user").setPassWord("secret_sauce").clickLoginButton()
ProductPage.getPageTitle().then(title =>
{
cy.log(title.text())
expect(title.text()).eq("Products")
})
ProductPage.getAllProducts().then(item => cy.log(item.text()))
ProductPage.addItemToCart().click()
});
});