-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Ganesh Hubale <ganeshhubale03@gmail.com>
- Loading branch information
1 parent
464a30a
commit b1485a5
Showing
17 changed files
with
2,750 additions
and
1,420 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
const { defineConfig } = require('cypress'); | ||
|
||
module.exports = defineConfig({ | ||
e2e: { | ||
chromeWebSecurity: false, | ||
pageLoadTimeout: 60000, | ||
baseUrl: 'https://www.saucedemo.com', | ||
specPattern: 'cypress/e2e/**/*.cy.js', | ||
supportFile: 'cypress/support/e2e.js', | ||
setupNodeEvents(on, config) { | ||
// implement node event listeners here | ||
}, | ||
}, | ||
env: { | ||
username: "standard_user", | ||
password: "secret_sauce", | ||
}, | ||
viewportWidth: 1280, | ||
viewportHeight: 720, | ||
}); |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
|
||
const username = Cypress.env('username'); | ||
const password = Cypress.env('password'); | ||
|
||
describe('Authentication scenarios', () => { | ||
beforeEach(() => { | ||
cy.visit('/'); | ||
}); | ||
|
||
it('Login to Swag Labs application', () => { | ||
cy.get("input[id=user-name]").clear().type(username) | ||
cy.get("input[id=password]").click().focused().clear().type(password) | ||
|
||
cy.get("input[id=login-button]").click() | ||
|
||
// Assert successful login | ||
cy.url().should('include', '/inventory'); | ||
cy.get("div > a[data-test=shopping-cart-link]").should("be.visible") | ||
|
||
}) | ||
|
||
it('should retain session after page reload', () => { | ||
cy.get("input[id=user-name]").clear().type(username) | ||
cy.get("input[id=password]").click().focused().clear().type(password) | ||
|
||
cy.get("input[id=login-button]").click() | ||
|
||
// Assert login | ||
cy.url().should('include', '/inventory'); | ||
|
||
// Reload application page | ||
cy.reload() | ||
|
||
// Assert user still login | ||
cy.url().should('include', '/inventory'); | ||
cy.get("div > a[data-test=shopping-cart-link]").should("be.visible") | ||
}) | ||
|
||
it('should show error message on empty fields', () => { | ||
|
||
// Click on login button and verify error message for username field | ||
cy.get("input[id=login-button]").click() | ||
|
||
cy.get("h3[data-test=error]").should("contain", "Epic sadface: Username is required") | ||
|
||
// Insert username and click on login button. Verify error message for password field | ||
cy.get("input[id=user-name]").clear().type(username) | ||
cy.get("input[id=login-button]").click() | ||
cy.get("h3[data-test=error]").should("contain", "Epic sadface: Password is required") | ||
}) | ||
|
||
it('should show error message on wrong username and password values', () => { | ||
|
||
// Assert input fields are empty initially | ||
// cy.get(usernameField).should('be.empty'); | ||
// cy.get(passwordField).should('be.empty'); | ||
|
||
// Enter invalid credentials | ||
cy.get("input[id=user-name]").clear().type("wrongUser") | ||
cy.get("input[id=password]").clear().type("wrongPassword") | ||
cy.get("input[id=login-button]").click() | ||
|
||
|
||
const expectedError = "Epic sadface: Username and password do not match any user in this service" | ||
cy.get("h3[data-test=error]").should("contain", expectedError) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
|
||
const username = Cypress.env('username'); | ||
const password = Cypress.env('password'); | ||
|
||
describe('Authentication scenarios', () => { | ||
beforeEach(() => { | ||
cy.visit('/'); | ||
|
||
}); | ||
|
||
it('Logout from Swag Labs application', () => { | ||
cy.get("input[id=user-name]").clear().type(username) | ||
cy.get("input[id=password]").click().focused().clear().type(password) | ||
|
||
cy.get("input[id=login-button]").click() | ||
|
||
// logout from application | ||
cy.get("button[id=react-burger-menu-btn]").click() | ||
cy.get("a[id=logout_sidebar_link]").click() | ||
|
||
// Assert successful logout | ||
cy.get("input[id=login-button]").should("be.visible") | ||
}) | ||
|
||
it('should logout after session expires', () => { | ||
cy.get("input[id=user-name]").clear().type(username) | ||
cy.get("input[id=password]").click().focused().clear().type(password) | ||
|
||
cy.get("input[id=login-button]").click() | ||
|
||
// Assert login | ||
cy.url().should('include', '/inventory'); | ||
|
||
// clear cookies | ||
cy.clearAllCookies() | ||
|
||
// Load the page | ||
cy.reload({force: true}) | ||
|
||
// Assert successful logout on session expiry | ||
cy.get("input[id=login-button]").should("be.visible") | ||
}) | ||
}) |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.