From 07214c45a3d29a39ac7e0b0db207e4c1240bac9b Mon Sep 17 00:00:00 2001 From: Pedro Hyvo Date: Mon, 13 Dec 2021 07:42:15 -0500 Subject: [PATCH 1/2] Add checkout test case --- .../checkout/shopping-cart.spec.js | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 cypress-studio/cypress/integration/checkout/shopping-cart.spec.js diff --git a/cypress-studio/cypress/integration/checkout/shopping-cart.spec.js b/cypress-studio/cypress/integration/checkout/shopping-cart.spec.js new file mode 100644 index 0000000..3f442a8 --- /dev/null +++ b/cypress-studio/cypress/integration/checkout/shopping-cart.spec.js @@ -0,0 +1,36 @@ +// shopping-cart.spec.js created with Cypress +// +// Start writing your Cypress tests below! +// If you're unfamiliar with how Cypress works, +// check out the link below and learn how to write your first test: +// https://on.cypress.io/writing-first-test +/* ==== Test Created with Cypress Studio ==== */ +it('can add a product into cart', function() { + /* ==== Generated with Cypress Studio ==== */ + cy.visit('https://www.saucedemo.com/'); + cy.get('[data-test="username"]').clear(); + cy.get('[data-test="username"]').type('standard_user'); + cy.get('[data-test="password"]').clear(); + cy.get('[data-test="password"]').type('secret_sauce'); + cy.get('[data-test="login-button"]').click(); + cy.get('.title').should('be.visible'); + cy.get('[data-test="add-to-cart-sauce-labs-backpack"]').click(); + cy.get('.shopping_cart_link').click(); + cy.get('.inventory_item_name').should('have.text', 'Sauce Labs Backpack'); + cy.get('.cart_quantity').should('have.text', '1'); + cy.get('.inventory_item_price').should('have.text', '$29.99'); + cy.get('[data-test="checkout"]').click(); + cy.get('[data-test="firstName"]').clear(); + cy.get('[data-test="firstName"]').type('John'); + cy.get('[data-test="lastName"]').clear(); + cy.get('[data-test="lastName"]').type('Smith'); + cy.get('[data-test="postalCode"]').clear(); + cy.get('[data-test="postalCode"]').type('90001'); + cy.get('[data-test="continue"]').click(); + cy.get('[data-test="finish"]').click(); + cy.get('.complete-header').should('be.visible'); + cy.get('.complete-header').should('have.text', 'THANK YOU FOR YOUR ORDER'); + cy.get('.complete-text').should('have.text', 'Your order has been dispatched, and will arrive just as fast as the pony can get there!'); + cy.get('.pony_express').should('be.visible'); + /* ==== End Cypress Studio ==== */ +}); From 36a121ab76aa8232d92dda4668f3f546d5801c04 Mon Sep 17 00:00:00 2001 From: Pedro Hyvo Date: Mon, 13 Dec 2021 16:26:46 -0500 Subject: [PATCH 2/2] Fix requested change --- .../cypress/integration/checkout/shopping-cart.spec.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cypress-studio/cypress/integration/checkout/shopping-cart.spec.js b/cypress-studio/cypress/integration/checkout/shopping-cart.spec.js index 3f442a8..c44bc61 100644 --- a/cypress-studio/cypress/integration/checkout/shopping-cart.spec.js +++ b/cypress-studio/cypress/integration/checkout/shopping-cart.spec.js @@ -18,7 +18,7 @@ it('can add a product into cart', function() { cy.get('.shopping_cart_link').click(); cy.get('.inventory_item_name').should('have.text', 'Sauce Labs Backpack'); cy.get('.cart_quantity').should('have.text', '1'); - cy.get('.inventory_item_price').should('have.text', '$29.99'); + cy.get('.inventory_item_price').should('be.visible'); cy.get('[data-test="checkout"]').click(); cy.get('[data-test="firstName"]').clear(); cy.get('[data-test="firstName"]').type('John');