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

Repo changes #6

Merged
merged 4 commits into from
Sep 23, 2022
Merged
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
11 changes: 7 additions & 4 deletions .cypress-cucumber-preprocessorrc.json
Original file line number Diff line number Diff line change
@@ -1,19 +1,22 @@
{
"json": {
"enabled": true,
"enabled": false,
"output": "jsonlogs/log.json",
"formatter": "cucumber-json-formatter.exe"
},
"messages": {
"enabled": true,
"enabled": false,
"output": "jsonlogs/messages.ndjson"
},
"html": {
"enabled": true
"enabled": false
},
"stepDefinitions": [
"[filepath]/**/*.{js,ts}",
"[filepath].{js,ts}",
"cypress/e2e/step_definitions/*.{js,ts}"
"cypress/e2e/step_definitions/*.{js,ts}",
"[filepath]\\***.{js,ts}",
"[filepath].{js,ts}",
"cypress\\e2e\\step_definitions\\*.{js,ts}"
]
}
16 changes: 16 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: Cypress Tests

on: [push]

jobs:
cypress-run:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
# Install NPM dependencies, cache them correctly
# and run all Cypress tests
- name: Cypress run
uses: cypress-io/github-action@v4.2.0 # use the explicit version number
with:
command: npm run cypress:execution
16 changes: 5 additions & 11 deletions cypress/e2e/features/login.feature
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,20 @@ Feature: Login page
Feature Login page will work depending on the user credentials.

Background:
Given A user opens a saucelabs website
Given A web browser is at the saucelabs login page
Scenario: Success Login
When A user enters the username "standard_user"
And A user enters the password "secret_sauce"
And A user clicks on the login button
When A user enters the username "standard_user", the password "secret_sauce", and clicks on the login button
Then the url will contains the inventory subdirectory
Scenario: Blocked Login
When A user enters the username "locked_out_user"
And A user enters the password "secret_sauce"
And A user clicks on the login button
When A user enters the username "locked_out_user", the password "secret_sauce", and clicks on the login button
Then The error message "Epic sadface: Sorry, this user has been locked out." is displayed
Scenario: Incorrect Username Login
When A user provides incorrect credentials
When A user provides incorrect credentials, and clicks on the login button
| username | password |
| testName | secret_sauce |
And A user clicks on the login button
Then The error message "Epic sadface: Username and password do not match any user in this service" is displayed
Scenario: Incorrect Password Login
When A user provides incorrect credentials
When A user provides incorrect credentials, and clicks on the login button
| username | password |
| standard_user | testPassword |
And A user clicks on the login button
Then The error message "Epic sadface: Username and password do not match any user in this service" is displayed
16 changes: 6 additions & 10 deletions cypress/e2e/features/tags.feature
Original file line number Diff line number Diff line change
@@ -1,18 +1,14 @@
Feature: Login page with Tags

Feature Login page will work depending on the user credentials.
Feature Login page will work depending on the user credentials with Tags

Background:
Given A user opens a saucelabs website
Given A web browser is at the saucelabs login page - tag demo
@mobile
Scenario: Success Login
When A user enters the username "standard_user"
And A user enters the password "secret_sauce"
And A user clicks on the login button
Then the url will contains the inventory subdirectory
When A user enters the username "standard_user", the password "secret_sauce", and clicks on the login button - tag demo
Then the url will contains the inventory subdirectory - tag demo
@desktop
Scenario: Blocked Login
When A user enters the username "locked_out_user"
And A user enters the password "secret_sauce"
And A user clicks on the login button
Then The error message "Epic sadface: Sorry, this user has been locked out." is displayed
When A user enters the username "locked_out_user", the password "secret_sauce", and clicks on the login button - tag demo
Then The error message "Epic sadface: Sorry, this user has been locked out." is displayed - tag demo
21 changes: 8 additions & 13 deletions cypress/e2e/step_definitions/login.js
Original file line number Diff line number Diff line change
@@ -1,31 +1,26 @@
import {
Given,
When,
And,
Then,
} from "@badeball/cypress-cucumber-preprocessor";
const loginPage = require("../../pages/LoginPage");

Given("A user opens a saucelabs website", () => {
Given("A web browser is at the saucelabs login page", () => {
cy.visit("/");
});
When("A user enters the username {string}", (username) => {
loginPage.typeUsername(username);

When("A user enters the username {string}, the password {string}, and clicks on the login button", (username,password) => {
loginPage.submitLogin(username,password)
});
When("A user provides incorrect credentials", (table) => {

When("A user provides incorrect credentials, and clicks on the login button", (table) => {
table.hashes().forEach((row) => {
cy.log(row.username);
cy.log(row.password);
loginPage.typeUsername(row.username);
loginPage.typePassword(row.password);
loginPage.submitLogin(row.username, row.password)

});
});
And("A user enters the password {string}", (password) => {
loginPage.typePassword(password);
});
And("A user clicks on the login button", () => {
loginPage.clickLogin();
});
Then("the url will contains the inventory subdirectory", () => {
cy.url().should("contains", "/inventory.html");
});
Expand Down
29 changes: 29 additions & 0 deletions cypress/e2e/step_definitions/tags.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import {
Given,
When,
Then,
} from "@badeball/cypress-cucumber-preprocessor";
const loginPage = require("../../pages/LoginPage");

Given("A web browser is at the saucelabs login page - tag demo", () => {
cy.visit("/");
});

When("A user enters the username {string}, the password {string}, and clicks on the login button - tag demo", (username,password) => {
loginPage.submitLogin(username,password)
});

When("A user provides incorrect credentials, and clicks on the login button - tag demo", (table) => {
table.hashes().forEach((row) => {
cy.log(row.username);
cy.log(row.password);
loginPage.submitLogin(row.username, row.password)

});
});
Then("the url will contains the inventory subdirectory - tag demo", () => {
cy.url().should("contains", "/inventory.html");
});
Then("The error message {string} is displayed - tag demo", (errorMessage) => {
loginPage.elements.errorMessage().should("have.text", errorMessage);
});
6 changes: 6 additions & 0 deletions cypress/pages/LoginPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@ class homeSaucePage {
clickLogin() {
this.elements.loginBtn().click();
}

submitLogin(username,password){
this.elements.usernameInput().type(username);
this.elements.passwordInput().type(password);
this.elements.loginBtn().click();
}
}

module.exports = new homeSaucePage();
Loading