├── cypress
├── fixtures
│ ├── userData-qa.json
│ ├── userData-prod.json
│ ├── userData-staging.json
│ └── userData.xlsx
├── e2e
│ ├── features
│ │ ├── output.xlsx
│ │ ├── duckduck1.feature
│ │ ├── duckduck.feature
│ │ └── duckduck.steps.js
│ ├── indexFetch.html
│ ├── dropdown-examples
│ │ ├── dropdown-selectionValue-test.spec.js
│ │ ├── dropdown-selectionText-test.spec.js
│ │ └── dropdown-selectionIndex-test.spec.js
│ ├── alias-example
│ │ └── alias.spec.js
│ ├── file-read-examples
│ │ └── file-read.spec.js
│ ├── index-fetch
│ │ └── indexFetch.spec.js
│ ├── shadow-dom
│ │ └── shadowDom.test.spec.js
│ ├── softAssertion
│ │ └── softAssertion.spec.js
│ ├── data-read-examples
│ │ └── excel-read.spec.js
│ ├── testDataReaderBasedOnEnvi.spec.js
│ ├── test.js
│ ├── console-errorLogger-examples
│ │ └── consoleError.spec.js
│ ├── intercept-examples
│ │ └── interceptCheck.spec.js
│ ├── test copy.js
│ ├── sinon
│ │ └── sinon.spec.js
│ ├── session-cache
│ │ └── login.spec.js
│ ├── regex-example
│ │ └── regex-contains.spec.js
│ ├── calendar-selector
│ │ └── calendar-picker.spec.js
│ ├── accessibility-examples
│ │ └── ax.spec.js
│ ├── iframe
│ │ └── iframe-test.spec.js
│ ├── microsoft-sso
│ │ └── sso.spec.js
│ ├── json-schema-validator
│ │ └── schemaCheck.spec.js
│ ├── queries-example
│ │ └── query-example.spec.js
│ ├── scroll
│ │ └── scrollBar.test.spec.js
│ ├── request-examples
│ │ └── upload-file.spec.js
│ ├── sso
│ │ └── sso.spec.js
│ ├── geo-location
│ │ └── geolocation.spec.js
│ ├── table
│ │ └── table-data.spec.js
│ └── lodash-examples
│ │ └── lodash.spec.js
├── plugins
│ └── index.js
├── parallel-weights.json
├── style.css
├── tsconfig.json
├── index.html
├── support
│ ├── e2e.ts
│ └── commands.ts
├── src
│ └── index.js
├── table.html
└── horizontalScroll.html
├── .gitignore
├── jsonFormatter
└── cucumber-json-formatter
├── multi-reporter-config.json
├── runner-results
├── cypress_e2e_dropdown-examples_dropdown-selectionIndex-test.spec.js.json
├── cypress_e2e_dropdown-examples_dropdown-selectionText-test.spec.js.json
└── cypress_e2e_dropdown-examples_dropdown-selectionValue-test.spec.js.json
├── README.md
├── reporter.js
├── target
└── npmlist.json
├── .github
└── workflows
│ ├── main.yml
│ ├── dependency.yml
│ └── ci.yml
├── cypress.config.ts
└── package.json
/cypress/fixtures/userData-qa.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "qaUser"
3 | }
4 |
--------------------------------------------------------------------------------
/cypress/fixtures/userData-prod.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "prodUser"
3 | }
4 |
--------------------------------------------------------------------------------
/cypress/fixtures/userData-staging.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "stagingUser"
3 | }
4 |
--------------------------------------------------------------------------------
/cypress/e2e/features/output.xlsx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gurudattgd04/cypress-example/HEAD/cypress/e2e/features/output.xlsx
--------------------------------------------------------------------------------
/cypress/fixtures/userData.xlsx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gurudattgd04/cypress-example/HEAD/cypress/fixtures/userData.xlsx
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | /node_modules
2 | /cypress/videos
3 | /*.txt
4 | /cucumber-report
5 | /json-logs
6 | /results
7 | /*.ndjson
8 | /*.log
9 |
--------------------------------------------------------------------------------
/jsonFormatter/cucumber-json-formatter:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gurudattgd04/cypress-example/HEAD/jsonFormatter/cucumber-json-formatter
--------------------------------------------------------------------------------
/multi-reporter-config.json:
--------------------------------------------------------------------------------
1 | {
2 | "reporterEnabled": "cypress-parallel/json-stream.reporter.js, cypress-parallel/simple-spec.reporter.js"
3 | }
--------------------------------------------------------------------------------
/cypress/e2e/indexFetch.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | - foo
5 | - bar
6 | - baz
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/cypress/e2e/dropdown-examples/dropdown-selectionValue-test.spec.js:
--------------------------------------------------------------------------------
1 | it("Validate the dropdown option selection by it's value", () => {
2 | cy.visit("https://www.bstackdemo.com/");
3 | cy.get("select")
4 | .select("lowestprice")
5 | .invoke("val")
6 | .should("eq", "lowestprice");
7 | });
8 |
--------------------------------------------------------------------------------
/cypress/plugins/index.js:
--------------------------------------------------------------------------------
1 | module.exports = (on, config) => {
2 | on("task", {
3 | log(message) {
4 | console.log(message);
5 |
6 | return null;
7 | },
8 | table(message) {
9 | console.table(message);
10 |
11 | return null;
12 | },
13 | });
14 | };
15 |
--------------------------------------------------------------------------------
/cypress/e2e/alias-example/alias.spec.js:
--------------------------------------------------------------------------------
1 | it.only("Dynamic table", () => {
2 | cy.visit("./../../../cypress/table.html");
3 | cy.get("#CompanyData tr")
4 | .not(".tableRow")
5 | .its("length")
6 | .as("tableLength", { type: "static" });
7 | // cy.get("@tableLength").should("eq", 7);
8 | });
9 |
--------------------------------------------------------------------------------
/cypress/parallel-weights.json:
--------------------------------------------------------------------------------
1 | {"cypress/e2e/dropdown-examples/dropdown-selectionIndex-test.spec.js":{"time":10165,"weight":9},"cypress/e2e/dropdown-examples/dropdown-selectionText-test.spec.js":{"time":10879,"weight":10},"cypress/e2e/dropdown-examples/dropdown-selectionValue-test.spec.js":{"time":9777,"weight":9}}
--------------------------------------------------------------------------------
/cypress/e2e/file-read-examples/file-read.spec.js:
--------------------------------------------------------------------------------
1 | it("test file loading using fixture", () => {
2 | cy.fixture("/userData-prod").then((data) => {
3 | cy.log("test", data);
4 | });
5 | });
6 |
7 | cy.readFile("cypress/fixtures/userData-prod.json").then((data) => {
8 | cy.log("data", data);
9 | });
10 |
--------------------------------------------------------------------------------
/cypress/e2e/index-fetch/indexFetch.spec.js:
--------------------------------------------------------------------------------
1 | ///
2 |
3 | describe("Index test", () => {
4 | it("Fetch index", () => {
5 | cy.visit("../cypress/e2e/indexFetch.html");
6 | cy.get("ul li.active").then(($el) => {
7 | cy.log($el.index());
8 | });
9 | });
10 | });
11 |
--------------------------------------------------------------------------------
/cypress/style.css:
--------------------------------------------------------------------------------
1 | #ddlCars {
2 | min-height:190px;
3 | overflow-y :auto;
4 | overflow-x:hidden;
5 | position:absolute;
6 | width:300px;
7 | display: contents;
8 | }
9 |
10 | .dropdown-menu {
11 | max-height:100px;/* you can change as you need it */
12 | overflow:auto;/* to get scroll */
13 | }
--------------------------------------------------------------------------------
/cypress/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "baseUrl": "./",
4 | "target": "es5",
5 | "lib": ["es5", "dom"],
6 | "types": ["cypress","node", "cypress-real-events", "cypress-file-upload","@testing-library/cypress"]
7 | },
8 | "include": ["./**/*.ts", "e2e/dropdown-examples/dropdown-test.spec.ts"],
9 | }
--------------------------------------------------------------------------------
/runner-results/cypress_e2e_dropdown-examples_dropdown-selectionIndex-test.spec.js.json:
--------------------------------------------------------------------------------
1 | {
2 | "suites": 1,
3 | "tests": 2,
4 | "passes": 2,
5 | "pending": 0,
6 | "failures": 0,
7 | "start": "2023-02-05T15:21:42.618Z",
8 | "duration": 9209,
9 | "file": "cypress/e2e/dropdown-examples/dropdown-selectionIndex-test.spec.js"
10 | }
--------------------------------------------------------------------------------
/runner-results/cypress_e2e_dropdown-examples_dropdown-selectionText-test.spec.js.json:
--------------------------------------------------------------------------------
1 | {
2 | "suites": 0,
3 | "tests": 1,
4 | "passes": 0,
5 | "pending": 0,
6 | "failures": 1,
7 | "start": "2023-02-05T15:21:43.870Z",
8 | "duration": 12167,
9 | "file": "cypress/e2e/dropdown-examples/dropdown-selectionText-test.spec.js"
10 | }
--------------------------------------------------------------------------------
/runner-results/cypress_e2e_dropdown-examples_dropdown-selectionValue-test.spec.js.json:
--------------------------------------------------------------------------------
1 | {
2 | "suites": 0,
3 | "tests": 1,
4 | "passes": 1,
5 | "pending": 0,
6 | "failures": 0,
7 | "start": "2023-02-05T15:21:54.622Z",
8 | "duration": 6202,
9 | "file": "cypress/e2e/dropdown-examples/dropdown-selectionValue-test.spec.js"
10 | }
--------------------------------------------------------------------------------
/cypress/e2e/dropdown-examples/dropdown-selectionText-test.spec.js:
--------------------------------------------------------------------------------
1 | it("Validate the dropdown option selection by it's text and assert the selection", () => {
2 | cy.visit("https://www.bstackdemo.com/");
3 | cy.get("select").select("Highest to lowest");
4 | cy.get("select option:selected")
5 | .invoke("text")
6 | .should("eq", "Highet to lowest");
7 | });
8 |
--------------------------------------------------------------------------------
/cypress/e2e/features/duckduck1.feature:
--------------------------------------------------------------------------------
1 | Feature: My feature 1
2 |
3 | Background: Background name
4 |
5 | @p1 @sbx
6 | Scenario: visiting the frontpage 1
7 | When I visit duckduckgo.com
8 | Then I should see a search bar
9 |
10 | @p2
11 | Scenario: visiting the title page 1
12 | When I visit duckduckgo.com
13 | Then I should see DocukDuckGo title
--------------------------------------------------------------------------------
/cypress/e2e/shadow-dom/shadowDom.test.spec.js:
--------------------------------------------------------------------------------
1 | ///
2 | describe("Shadow dom test", () => {
3 | it("shadow dom test", () => {
4 | cy.visit("https://selectorshub.com/xpath-practice-page/");
5 | cy.get("#pact").then(($el) => {
6 | const body = $el.contents();
7 | cy.wrap(body).find("#snacktime").shadow().find("#tea").type("Chai");
8 | });
9 | });
10 | });
11 |
--------------------------------------------------------------------------------
/cypress/e2e/softAssertion/softAssertion.spec.js:
--------------------------------------------------------------------------------
1 | const _ = require("lodash");
2 | const jsonAssertion = require("soft-assert/index");
3 |
4 | it("Let's test soft assertion", () => {
5 | jsonAssertion.softAssert("test", "tst", "assertion error for softAssert 1");
6 | jsonAssertion.softAssert("sbx", "sbx");
7 | jsonAssertion.softAssert(1, 2, "Number mismatch");
8 | jsonAssertion.softAssertAll();
9 | });
10 |
--------------------------------------------------------------------------------
/cypress/e2e/data-read-examples/excel-read.spec.js:
--------------------------------------------------------------------------------
1 | it("Lets read xls file", () => {
2 | cy.fixture("userData.xlsx").then((data) => {
3 | cy.log(data);
4 | });
5 | cy.readFile("cypress/fixtures/userData.xlsx").then((data) => {
6 | cy.log(data);
7 | });
8 | });
9 |
10 | it.only("Excel file import using excelJs", async () => {
11 | cy.task("readXlsxData").then((data) => {
12 | cy.log(data);
13 | });
14 | });
15 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # cypress-example
2 |
3 | This repo is a quick starter and provides examples which helps beginners to understand Cypress
4 |
5 | To start
6 | > Fork this repo
7 |
8 | > Ensure you have node js installed - https://nodejs.org/en/
9 |
10 | > Open the folder path in terminal
11 |
12 | > Execute **npm install** to install all dependencies
13 |
14 | > Execute **npm run cypress:open** to open the cypress test runner for running tests
15 |
--------------------------------------------------------------------------------
/cypress/e2e/testDataReaderBasedOnEnvi.spec.js:
--------------------------------------------------------------------------------
1 | ///
2 | describe("Envi test", () => {
3 | it("let's test fixture data read based on envi set", () => {
4 | cy.visit("https://bistromd-staging.myshopify.com/");
5 | cy.get('input[type="password"]').type("notyet");
6 | cy.get('input[type="submit"]').click();
7 | cy.wait(8000); // waiting for overlay to appear
8 | cy.root();
9 | Cypress.onSpecWindow;
10 | });
11 | });
12 |
--------------------------------------------------------------------------------
/cypress/e2e/features/duckduck.feature:
--------------------------------------------------------------------------------
1 | Feature: My feature 3
2 |
3 | @p12
4 | Scenario: visiting the frontpage
5 | When I visit duckduckgo.com
6 | Then I should see a search bar
7 |
8 | @p22
9 | Scenario: visiting the title page
10 | When I visit duckduckgo.com
11 | Then I should see DocukDuckGo title
12 |
13 | Scenario Outline: visiting the title page outline
14 | When I visit duckduckgo.com
15 | Then I should see DocukDuckGo title
--------------------------------------------------------------------------------
/cypress/e2e/test.js:
--------------------------------------------------------------------------------
1 | const ExcelJS = require("exceljs");
2 |
3 | (async function () {
4 | const workbook = await new ExcelJS.Workbook();
5 | return await workbook.xlsx
6 | .readFile("cypress/fixtures/userData.xlsx")
7 | .then(function () {
8 | console.log(
9 | "test",
10 | workbook.getWorksheet("Sheet1").eachRow((row) => {
11 | console.log(row.eachCel);
12 | })
13 | );
14 | return workbook.getWorksheet("Sheet1");
15 | });
16 | })();
17 |
--------------------------------------------------------------------------------
/cypress/e2e/console-errorLogger-examples/consoleError.spec.js:
--------------------------------------------------------------------------------
1 | it("console error logger", () => {
2 | cy.visit("https://bstackdemo.com/", {
3 | onBeforeLoad(win) {
4 | cy.spy(win.console, "log").as("consoleLog");
5 | },
6 | });
7 |
8 | cy.get("@consoleLog")
9 | .invoke("getCalls")
10 | .then((data) => {
11 | console.table(data);
12 | });
13 | });
14 |
15 | Cypress.on("uncaught:exception", (msg) => {
16 | console.log("uncaught exception msg :", msg);
17 | return false;
18 | });
19 |
--------------------------------------------------------------------------------
/cypress/e2e/features/duckduck.steps.js:
--------------------------------------------------------------------------------
1 | import { When, Then } from "@badeball/cypress-cucumber-preprocessor";
2 |
3 | When("I visit duckduckgo.com", () => {
4 | cy.visit("https://www.duckduckgo.com");
5 | });
6 |
7 | Then("I should see a search bar", () => {
8 | cy.get("#searchbox_input").should(
9 | "have.attr",
10 | "placeholder",
11 | "Search without being tracked"
12 | );
13 | });
14 |
15 | Then("I should see DocukDuckGo title", () => {
16 | cy.get(".header_headerContent__hDivV a").eq(1).should("be.visible");
17 | });
18 |
--------------------------------------------------------------------------------
/cypress/e2e/intercept-examples/interceptCheck.spec.js:
--------------------------------------------------------------------------------
1 | it("Intercept test", () => {
2 | cy.intercept(
3 | {
4 | url: "https://www.bstackdemo.com/api/products",
5 | method: "GET",
6 | },
7 | (req) => {
8 | if (req.headers.host === "www.bstackdemo.com") {
9 | // req.alias = "waitForProduct";
10 | }
11 | }
12 | ).as("waitForProduct");
13 | cy.visit("/");
14 | cy.wait("@waitForProduct", { timeout: 3000 });
15 | cy.get("@waitForProduct.all").then((data) => {
16 | cy.log(data);
17 | });
18 | });
19 |
--------------------------------------------------------------------------------
/cypress/e2e/dropdown-examples/dropdown-selectionIndex-test.spec.js:
--------------------------------------------------------------------------------
1 | describe("Dropdown validations", () => {
2 | it("Validate the dropdown option selection by it's index", () => {
3 | cy.visit("https://www.bstackdemo.com/");
4 | cy.get("select").select(1).invoke("val").should("eq", "lowestprice");
5 | });
6 |
7 | it("Validate the dropdown option selection by it's text", () => {
8 | cy.visit("https://www.bstackdemo.com/");
9 | cy.get("select")
10 | .select("Highest to lowest")
11 | .invoke("val")
12 | .should("eq", "highestprice");
13 | });
14 | });
15 |
--------------------------------------------------------------------------------
/cypress/e2e/test copy.js:
--------------------------------------------------------------------------------
1 | const fs = require("fs");
2 |
3 | (async function () {
4 | const data = fs.readFileSync(
5 | "/Users/gurudattsa/development-repo/PersonalRepo/cypress-dropdown-example/cypress-example/ImportTemplate.csv"
6 | );
7 |
8 | const fileBytes = [];
9 | console.log(data);
10 | const array = new Uint8Array(data);
11 | array.map((b) => fileBytes.push(b));
12 | console.log(fileBytes);
13 | fs.writeFileSync(
14 | "/Users/gurudattsa/development-repo/PersonalRepo/cypress-dropdown-example/cypress-example/ImportTemplate.txt",
15 | fileBytes.toLocaleString()
16 | );
17 | })();
18 |
--------------------------------------------------------------------------------
/reporter.js:
--------------------------------------------------------------------------------
1 | const report = require("multiple-cucumber-html-reporter");
2 | const fs = require("fs");
3 |
4 | report.generate({
5 | jsonDir: "json-logs/",
6 | reportPath: "./cucumber-report/",
7 | metadata: {
8 | browser: {
9 | name: "chrome",
10 | version: 1.0,
11 | },
12 | device: "Local test machine",
13 | platform: {
14 | name: "macos",
15 | },
16 | },
17 | reportName: "GD Report",
18 | customData: {
19 | title: "Run info",
20 | data: [
21 | { label: "Project", value: "GD-Cypress-Cucumber" },
22 | { label: "Environment", value: "Local" },
23 | ],
24 | },
25 | });
26 |
--------------------------------------------------------------------------------
/cypress/e2e/sinon/sinon.spec.js:
--------------------------------------------------------------------------------
1 | describe("sinon tests", () => {
2 | const obj = {};
3 | before(() => {
4 | obj.foo = function foo(a, b) {
5 | return a;
6 | };
7 | });
8 | it("sinon js tests stub", () => {
9 | const stub = cy.stub(obj, "foo");
10 | obj.foo.callThrough();
11 | // obj.foo("foo", "bar");
12 | // stub.onFirstCall().returns("a");
13 | expect(obj.foo("foo", "bar")).to.eq("foo");
14 | expect(stub).to.be.called;
15 | stub.withArgs("a", "b").callsFake(function foo(a, b) {
16 | return "blah";
17 | });
18 |
19 | expect(obj.foo("foo", "bar")).to.eq("foo");
20 | expect(obj.foo("a", "b")).to.eq("blah");
21 | });
22 | });
23 |
--------------------------------------------------------------------------------
/cypress/e2e/session-cache/login.spec.js:
--------------------------------------------------------------------------------
1 | ///
2 |
3 | describe("Session tests", () => {
4 | it("Session test", () => {
5 | cy.visit("https://www.bstackdemo.com/signin");
6 | cy.get(
7 | "#username > .css-yk16xz-control > .css-1hwfws3 > .css-1wa3eu0-placeholder"
8 | ).type("existing_orders_user");
9 | cy.contains("#react-select-2-option-0-2", "existing_orders_user").click();
10 | cy.get("#password > .css-yk16xz-control > .css-1hwfws3").type(
11 | "testingisfun99"
12 | );
13 | cy.contains("#react-select-3-option-0-0", "testingisfun99").click();
14 | cy.get("#login-btn").click();
15 | cy.get(".username").invoke("text").should("eq", "existing_orders_user");
16 | });
17 | });
18 |
--------------------------------------------------------------------------------
/cypress/e2e/regex-example/regex-contains.spec.js:
--------------------------------------------------------------------------------
1 | it("Let's test regex contains", () => {
2 | cy.visit("https://www.bstackdemo.com/");
3 | cy.get("select").select("highestprice");
4 | cy.wait(2000);
5 | cy.contains("Galaxy S20").invoke("text").should("eq", "Galaxy S20 Ultra");
6 | const s20 = new RegExp(`${"Galaxy S20"}[^&]*`, "gm");
7 | cy.contains(s20)
8 | .invoke("text")
9 | .then((data) => {
10 | cy.log(data);
11 | });
12 | const matcher = new RegExp("^Galaxy S20\\+$", "gm");
13 | cy.contains(matcher)
14 | .invoke("text")
15 | .then((data) => {
16 | cy.log(data);
17 | });
18 | });
19 |
20 | it.only("regex", () => {
21 | cy.visit("../../../cypress/index.html");
22 | cy.contains(/^Da\w+/);
23 | cy.contains(new RegExp("^Date: $", "g"));
24 | });
25 |
--------------------------------------------------------------------------------
/cypress/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | jQuery UI Datepicker - Default functionality
6 |
10 |
11 |
12 |
13 |
18 |
19 |
20 | Date:
21 |
22 |
23 |
--------------------------------------------------------------------------------
/cypress/support/e2e.ts:
--------------------------------------------------------------------------------
1 | // ***********************************************************
2 | // This example support/e2e.ts is processed and
3 | // loaded automatically before your test files.
4 | //
5 | // This is a great place to put global configuration and
6 | // behavior that modifies Cypress.
7 | //
8 | // You can change the location of this file or turn off
9 | // automatically serving support files with the
10 | // 'supportFile' configuration option.
11 | //
12 | // You can read more here:
13 | // https://on.cypress.io/configuration
14 | // ***********************************************************
15 |
16 | // Import commands.js using ES2015 syntax:
17 | import "./commands";
18 | import "cypress-mochawesome-reporter/register";
19 | import "cypress-plugin-api";
20 | import "cypress-axe";
21 | chai.use(require("chai-json-schema"));
22 | // Alternatively you can use CommonJS syntax:
23 | // require('./commands')
24 |
--------------------------------------------------------------------------------
/cypress/e2e/calendar-selector/calendar-picker.spec.js:
--------------------------------------------------------------------------------
1 | ///
2 | import { recurse } from "cypress-recurse";
3 | describe("Calendar Validations", () => {
4 | it("select a date", () => {
5 | cy.visit("../../../cypress/index.html");
6 | cy.get("#datepicker").click();
7 | cy.contains("[data-handler='selectDay'] a", "25").click();
8 | });
9 |
10 | it("Select date based on month", () => {
11 | cy.visit("../../../cypress/index.html");
12 | cy.get("#datepicker").click();
13 | recurse(
14 | () => cy.get(".ui-datepicker-month").invoke("text"),
15 | (n) => {
16 | if (!n.includes("December")) {
17 | cy.get("[title='Next']").click();
18 | return false;
19 | }
20 | cy.contains("[data-handler='selectDay'] a", "24").click();
21 | return true;
22 | },
23 | {
24 | limit: 12,
25 | }
26 | );
27 | });
28 | });
29 |
--------------------------------------------------------------------------------
/cypress/e2e/accessibility-examples/ax.spec.js:
--------------------------------------------------------------------------------
1 | function terminalLog(violations) {
2 | cy.task(
3 | "log",
4 | `${violations.length} accessibility violation${
5 | violations.length === 1 ? "" : "s"
6 | } ${violations.length === 1 ? "was" : "were"} detected`
7 | );
8 | // pluck specific keys to keep the table readable
9 | const violationData = violations.map(
10 | ({ id, impact, description, nodes }) => ({
11 | id,
12 | impact,
13 | description,
14 | nodes: nodes.length,
15 | })
16 | );
17 |
18 | cy.task("table", violationData);
19 | }
20 |
21 | it(["axe"], "Lets test accessibility", () => {
22 | cy.visit("https://tenant2.tst.e-bate.net/login");
23 | cy.injectAxe();
24 | cy.configureAxe({
25 | branding: {
26 | brand: "Swag Labs",
27 | application: "Swag Labs Demo App",
28 | },
29 | reporter: "v2",
30 | iframes: true,
31 | });
32 | cy.checkA11y(null, null, terminalLog);
33 | });
34 |
--------------------------------------------------------------------------------
/cypress/e2e/iframe/iframe-test.spec.js:
--------------------------------------------------------------------------------
1 | ///
2 |
3 | describe("IFrame test", () => {
4 | it("Let's select some dates from calendar", () => {
5 | cy.visit("../../../cypress/index.html");
6 | cy.wait(20000);
7 | cy.get("iframe.aut-iframe").then((iframe) => {
8 | const body = iframe.contents().find("body");
9 | return cy.wrap(body);
10 | });
11 | cy.getIframe(".aut-iframe").find("#datepicker").click();
12 | cy.getIframe(".aut-iframe")
13 | .find(".ui-datepicker-month")
14 | .then(($element) => {
15 | cy.log($element.text());
16 | if (!$element.text().includes("September")) {
17 | cy.wrap($element).find("[title='Next']").click();
18 | }
19 | });
20 | cy.intercept("url", (req) => {
21 | req.destroy();
22 | });
23 | //cy.get("#datepicker").click();
24 | });
25 | });
26 |
27 | Cypress.Commands.add("getIframe", (selector) => {
28 | return cy.get(selector).then((iframe) => {
29 | const body = iframe.contents().find("body");
30 | return cy.wrap(body);
31 | });
32 | });
33 |
--------------------------------------------------------------------------------
/cypress/e2e/microsoft-sso/sso.spec.js:
--------------------------------------------------------------------------------
1 | const { url } = require("inspector");
2 |
3 | describe("Authenticate", () => {
4 | beforeEach(() => {
5 | cy.visit("https://etexaustralia.e-bate.net");
6 | cy.intercept({ url: "/api/SSO/SSOSilentLogin", method: "POST" }).as(
7 | "SSOSilentLogin"
8 | );
9 | cy.origin("https://login.microsoftonline.com", () => {
10 | cy.get('[name="loginfmt"]').type(`helpdesk@e-bate.net`);
11 | cy.get("[data-report-value='Submit']").click();
12 | cy.get('[name="passwd"]').type(`TaFV6Dqu6f5U2o`);
13 | cy.get("[data-report-value='Submit']").click();
14 |
15 | cy.get("#idBtn_Back").click();
16 | cy.wait("@SSOSilentLogin")
17 | .its("response")
18 | .then((response) => {
19 | cy.log("response is: ", response.body);
20 | expect(response.statusCode).to.be.equal(200);
21 | });
22 | });
23 |
24 | // cy.get('[name="passwd"]').type(`${Cypress.env("password")}{enter}`);
25 | // cy.get('[type="submit"]').type("{enter}");
26 | });
27 |
28 | it("Show homepage once logged in", () => {});
29 | });
30 |
--------------------------------------------------------------------------------
/cypress/e2e/json-schema-validator/schemaCheck.spec.js:
--------------------------------------------------------------------------------
1 | it("JSON schema validator", () => {
2 | const schema = {
3 | title: "Test Schema v1",
4 | type: "object",
5 | required: ["postId", "id", "name", "email"],
6 | properties: {
7 | postId: {
8 | type: "number",
9 | minimum: 1,
10 | },
11 | id: {
12 | type: "number",
13 | minimum: 1,
14 | },
15 | name: {
16 | type: "string",
17 | },
18 | email: {
19 | type: "string",
20 | },
21 | body: {
22 | type: "string",
23 | },
24 | },
25 | };
26 | const expectedValue = [
27 | {
28 | id: 1,
29 | name: "id labore ex et quam laborum",
30 | email: "Eliseo@gardner.biz",
31 | body: "laudantium",
32 | },
33 | {
34 | postId: 1,
35 | id: 2,
36 | name: "quo vero reiciendis velit similique earum",
37 | email: "Jayne_Kuhic@sydney.com",
38 | body: "est natus",
39 | },
40 | ];
41 |
42 | console.log(expectedValue.length);
43 | expect(expectedValue[0]).to.be.jsonSchema(schema);
44 | });
45 |
--------------------------------------------------------------------------------
/target/npmlist.json:
--------------------------------------------------------------------------------
1 | {"version":"1.0.0","name":"src","dependencies":{"@badeball/cypress-cucumber-preprocessor":{"version":"15.0.0"},"@cypress-audit/lighthouse":{"version":"1.2.0"},"@types/handlebars":{"version":"4.1.0"},"@types/node":{"version":"17.0.45"},"chai-json-schema":{"version":"1.5.1"},"chai":{"version":"4.3.6"},"cypress-cucumber-attach-screenshots-to-failed-steps":{"version":"1.0.0"},"cypress-iframe":{"version":"1.0.1"},"cypress-multi-reporters":{"version":"1.6.1"},"cypress-parallel":{"version":"0.12.0"},"cypress-plugin-api":{"version":"2.5.0"},"cypress-tags":{"version":"1.1.2"},"cypress":{"version":"12.5.0"},"handlebars":{"version":"4.7.7"},"import-cwd":{"version":"3.0.0"},"jasmine":{"version":"3.99.0"},"jquery-csv":{"version":"1.0.21"},"jrm":{"version":"1.0.1"},"junit-report-merger":{"version":"3.0.6"},"junit-xml-to-html":{"version":"1.0.4"},"lighthouse":{"version":"9.4.0"},"lodash":{"version":"4.17.21"},"mocha":{"version":"8.4.0"},"mochawesome-merge":{"version":"4.2.1"},"mochawesome-report-generator":{"version":"5.2.0"},"mochawesome":{"version":"6.3.1"},"multiple-cucumber-html-reporter":{"version":"1.21.6"},"soft-assert":{"version":"0.2.6"},"tsify":{"version":"5.0.4"},"typescript":{"version":"4.8.2"}}}
--------------------------------------------------------------------------------
/cypress/e2e/queries-example/query-example.spec.js:
--------------------------------------------------------------------------------
1 | it("Let's validate get query command", () => {
2 | cy.visit("https://ecommerce-playground.lambdatest.io/");
3 | cy.get("span.title:contains(' Mega Menu')").trigger("mouseover");
4 | });
5 |
6 | it("Lets test contains", () => {
7 | cy.visit("https://ecommerce-playground.lambdatest.io/");
8 | cy.contains("span.title", " Mega Menu").trigger("mouseover");
9 | });
10 |
11 | it("Lets validate find query command", () => {
12 | cy.visit("https://ecommerce-playground.lambdatest.io/");
13 | cy.get("#widget-navbar-217834 ul.horizontal li:contains(' Blog')")
14 | .invoke("text")
15 | .should("to.include", "Blog");
16 | /* .then((el) => {
17 | expect(el.text()).to.include("Blog");
18 | }) */
19 | cy.getTextFromSelector(
20 | "#widget-navbar-217834 ul.horizontal li:contains(' Blog')"
21 | ).should("have.text".replace(" ", ""), "Blog");
22 | });
23 |
24 | Cypress.Commands.addQuery(
25 | "getTextFromSelector",
26 | function getTextFromSelector(selector) {
27 | const getFn = cy.now("get", selector, {});
28 |
29 | return () => {
30 | console.log("The subject we received was:");
31 |
32 | const btn = cy.now("get", selector, {});
33 |
34 | console.log(".get returned this element:", btn().text());
35 |
36 | return btn();
37 | };
38 | }
39 | );
40 |
--------------------------------------------------------------------------------
/cypress/support/commands.ts:
--------------------------------------------------------------------------------
1 | ///
2 | // ***********************************************
3 | // This example commands.ts shows you how to
4 | // create various custom commands and overwrite
5 | // existing commands.
6 | //
7 | // For more comprehensive examples of custom
8 | // commands please read more here:
9 | // https://on.cypress.io/custom-commands
10 | // ***********************************************
11 | //
12 | //
13 | // -- This is a parent command --
14 | // Cypress.Commands.add('login', (email, password) => { ... })
15 | //
16 | //
17 | // -- This is a child command --
18 | // Cypress.Commands.add('drag', { prevSubject: 'element'}, (subject, options) => { ... })
19 | //
20 | //
21 | // -- This is a dual command --
22 | // Cypress.Commands.add('dismiss', { prevSubject: 'optional'}, (subject, options) => { ... })
23 | //
24 | //
25 | // -- This will overwrite an existing command --
26 | // Cypress.Commands.overwrite('visit', (originalFn, url, options) => { ... })
27 | //
28 | // declare global {
29 | // namespace Cypress {
30 | // interface Chainable {
31 | // login(email: string, password: string): Chainable
32 | // drag(subject: string, options?: Partial): Chainable
33 | // dismiss(subject: string, options?: Partial): Chainable
34 | // visit(originalFn: CommandOriginalFn, url: string, options: Partial): Chainable
35 | // }
36 | // }
37 | // }
38 | import "@testing-library/cypress/add-commands";
39 |
--------------------------------------------------------------------------------
/.github/workflows/main.yml:
--------------------------------------------------------------------------------
1 | name: ci
2 | on: push
3 | jobs:
4 | # example splitting all tests across GitHub machines
5 | prepare:
6 | runs-on: ubuntu-20.04
7 | # explicitly set the output of this job
8 | # so that other jobs can use it
9 | outputs:
10 | matrix: ${{ steps.prepare.outputs.matrix }}
11 | steps:
12 | # generate the list using a bash script
13 | - name: Create matrix ⊹
14 | id: prepare
15 | # for reusable workflow, must use the full action reference
16 | uses: bahmutov/gh-build-matrix@main
17 | with:
18 | n: 3 # number of containers to output
19 |
20 | - name: Print result 🖨
21 | run: echo '${{ steps.prepare.outputs.matrix }}'
22 |
23 | test-split:
24 | needs: prepare
25 | runs-on: ubuntu-20.04
26 | strategy:
27 | fail-fast: false
28 | matrix: ${{ fromJSON(needs.prepare.outputs.matrix) }}
29 | steps:
30 | - name: Checkout 🛎
31 | uses: actions/checkout@v3
32 |
33 | - name: Print GitHub variables 🖨
34 | run: npx @bahmutov/print-env GITHUB
35 |
36 | - name: Print GitHub strategy context 🖨
37 | run: echo '${{ toJSON(strategy) }}'
38 |
39 | - name: Run split Cypress tests 🧪
40 | # https://github.com/cypress-io/github-action
41 | uses: cypress-io/github-action@v5
42 | # using operating system process environment variables
43 | env:
44 | SPLIT: ${{ strategy.job-total }}
45 | SPLIT_INDEX: ${{ strategy.job-index }}
46 |
--------------------------------------------------------------------------------
/cypress/e2e/scroll/scrollBar.test.spec.js:
--------------------------------------------------------------------------------
1 | ///
2 |
3 | describe("Scrollbar test", () => {
4 | it("Lets test horizontal scroll bar using position", () => {
5 | cy.visit("cypress/horizontalScroll.html");
6 | cy.contains("a", "Work").should("not.be.visible");
7 | cy.get(".scrollmenu").scrollTo("topRight");
8 | cy.contains("a", "Work").should("be.visible");
9 | });
10 |
11 | it.only("Lets test horizontal scroll bar using co-ordinates", () => {
12 | cy.visit("cypress/horizontalScroll.html");
13 | cy.contains("a", "Work").should("not.be.visible");
14 | // x, y co-ordinates
15 | cy.get(".scrollmenu").scrollTo("100%", 0);
16 | cy.contains("a", "Work").should("be.visible");
17 | });
18 |
19 | it.only("Lets test element is scrollable", () => {
20 | cy.visit("cypress/horizontalScroll.html");
21 | cy.contains("a", "Work").should("not.be.visible");
22 | // x, y co-ordinates. x co-ordinate is for scrolling width and y is for scrolling height
23 | cy.get(".scrollmenu").scrollTo("100%", 0, { ensureScrollable: true });
24 | cy.contains("a", "Work").should("be.visible");
25 | });
26 |
27 | it.only("Lets test horizontal scroll bar using scrollIntoView", () => {
28 | cy.visit("cypress/horizontalScroll.html");
29 | cy.contains("a", "Work").should("not.be.visible");
30 | cy.contains("a", "Work").scrollIntoView().should("be.visible");
31 | });
32 |
33 | it.only("Lets test window scroll", () => {
34 | cy.visit("cypress/horizontalScroll.html");
35 | //cy.contains("button", "Click here").should("not.be.visible");
36 | cy.scrollTo("bottom");
37 | cy.contains("button", "Click here").should("be.visible");
38 | });
39 | });
40 |
--------------------------------------------------------------------------------
/cypress/e2e/request-examples/upload-file.spec.js:
--------------------------------------------------------------------------------
1 | ///
2 |
3 | const fs = require("fs");
4 |
5 | it("upload file", () => {
6 | const data = new FormData();
7 |
8 | data.append("hasHeader", "true");
9 | data.append("name", "tst");
10 | cy.request({
11 | url: "https://api.upload.io/v1/files/form_data",
12 | method: "POST",
13 | headers: {
14 | "Content-Type":
15 | "multipart/form-data; boundary=--------------------------015933885729886267988025",
16 |
17 | "Accept-Encoding": "gzip, deflate, br",
18 | Accept: "*/*",
19 | Authorization: "Bearer free",
20 | },
21 | })
22 | .window()
23 | .then((res) => {
24 | cy.log(res);
25 | });
26 |
27 | cy.request({
28 | method: "POST",
29 | url: "https://api.upload.io/v1/files/form_data",
30 | headers: {
31 | "Content-Type":
32 | "multipart/form-data; boundary=--------------------------015933885729886267988025",
33 |
34 | "Accept-Encoding": "gzip, deflate, br",
35 | Accept: "*/*",
36 | Authorization: "Bearer free",
37 | },
38 | })
39 | .as("fileUpload")
40 | .window()
41 | .then((win) => {
42 | cy.readFile("selenium.png", "binary")
43 | .then((binary) => Cypress.Blob.binaryStringToBlob(binary))
44 | .then((blob) => {
45 | const xhr = new win.XMLHttpRequest();
46 |
47 | data.set("user-file", blob, "selenium.png");
48 |
49 | xhr.open("POST", "https://api.upload.io/v1/files/form_data");
50 |
51 | xhr.setRequestHeader("Authorization", `Bearer free`);
52 |
53 | xhr.send(data);
54 | });
55 | });
56 | cy.wait("@fileUpload").then((res) => {
57 | cy.log(res);
58 | });
59 | });
60 |
--------------------------------------------------------------------------------
/cypress/e2e/sso/sso.spec.js:
--------------------------------------------------------------------------------
1 | describe("SSO scenarios", () => {
2 | it("SSO test", () => {
3 | cy.visit("https://onedrive.live.com/about/en-gb/signin/");
4 | cy.get(".SignIn").then((iframe) => {
5 | const body = iframe.contents().find("body");
6 | cy.wrap(body)
7 | .as("iframe")
8 | .find("[type='email']")
9 | .type("blah@gmail.com", { force: true });
10 | cy.get("@iframe").find("[value='Next']").click();
11 | cy.origin("https://www.microsoft.com/", () => {
12 | cy.visit("/");
13 | cy.get("[name='passwd']").type("blah", { force: true });
14 | cy.get("#idSIButton9").click();
15 | });
16 | });
17 |
18 | // cy.get("[type='email']").type("aryandutt04@gmail.com", { force: true });
19 | // cy.get("[value='Next']").click();
20 | });
21 | it.only("sso test 1", () => {
22 | cy.origin("https://login.microsoftonline.com", () => {
23 | cy.visit("/");
24 | cy.get(".SignIn").then((iframe) => {
25 | const body = iframe.contents().find("body");
26 | cy.wrap(body)
27 | .as("iframe")
28 | .find("[type='email']")
29 | .type("aryandutt04@gmail.com", { force: true });
30 | cy.get("@iframe").find("[value='Next']").click();
31 |
32 | cy.get("[name='passwd']").type("gurudatt@26", { force: true });
33 | cy.get("#idSIButton9").click();
34 | });
35 | });
36 | });
37 |
38 | it("lamdaTest SSO", () => {
39 | cy.visit("https://www.lambdatest.com/");
40 | cy.get("[href='https://accounts.lambdatest.com/login']").click();
41 | cy.get("[href='/login/github/v1?disableSignup=1']").click();
42 | cy.origin("https://github.com/", () => {
43 | cy.get("[name='login']").type("blah");
44 | });
45 | });
46 | });
47 |
--------------------------------------------------------------------------------
/.github/workflows/dependency.yml:
--------------------------------------------------------------------------------
1 | name: Test Cypress
2 |
3 | on:
4 | workflow_call:
5 |
6 | jobs:
7 | cypress-run:
8 | runs-on: ubuntu-latest
9 | # Runs tests in parallel with matrix strategy https://docs.cypress.io/guides/guides/parallelization
10 | # https://docs.github.com/en/actions/using-jobs/using-a-matrix-for-your-jobs
11 | # Also see warning here https://github.com/cypress-io/github-action#parallel
12 | strategy:
13 | fail-fast: false # https://github.com/cypress-io/github-action/issues/48
14 | matrix:
15 | containers: [1, 2] # Uses 2 parallel instances
16 | steps:
17 | - name: Checkout
18 | uses: actions/checkout@v3
19 | - name: Cypress run
20 | # Uses the official Cypress GitHub action https://github.com/cypress-io/github-action
21 | uses: cypress-io/github-action@v5
22 | with:
23 | # Starts web server for E2E tests - replace with your own server invocation
24 | # https://docs.cypress.io/guides/continuous-integration/introduction#Boot-your-server
25 | # start: npm start
26 | # wait-on: 'http://localhost:3000' # Waits for above
27 | # Records to Cypress Cloud
28 | # https://docs.cypress.io/guides/cloud/projects#Set-up-a-project-to-record
29 | record: true
30 | parallel: true # Runs test in parallel using settings above
31 | env:
32 | # For recording and parallelization to work you must set your CYPRESS_RECORD_KEY
33 | # in GitHub repo → Settings → Secrets → Actions
34 | CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }}
35 | # Creating a token https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/creating-a-personal-access-token
36 | GITHUB_TOKEN: ${{ secrets.TOKEN_GIT }}
37 |
--------------------------------------------------------------------------------
/cypress/e2e/geo-location/geolocation.spec.js:
--------------------------------------------------------------------------------
1 | describe("Geolocation tests", () => {
2 | it.skip("Geolocation testing newyork", () => {
3 | cy.visit("https://locations.dennys.com/search.html/", {
4 | onBeforeLoad({ navigator }) {
5 | const latitude = 43.0;
6 | const longitude = -75.0;
7 | cy.stub(navigator.geolocation, "getCurrentPosition").callsArgWith(0, {
8 | coords: { latitude, longitude },
9 | });
10 | },
11 | });
12 | cy.contains(" 701 MOHAWK ST");
13 | });
14 |
15 | it("Geolocation testing california using lambdatest playground", () => {
16 | cy.intercept(
17 | {
18 | url: "https://geolocation-db.com/json/",
19 | method: "GET",
20 | },
21 | {
22 | statusCode: 200,
23 | body: {
24 | country_code: "US",
25 | country_name: "United States",
26 | city: "newyork",
27 | postal: "10001",
28 | latitude: 40.73061,
29 | longitude: -73.935242,
30 | IPv4: "100.1.245.30",
31 | state: "New York",
32 | },
33 | }
34 | ).as("wait");
35 | cy.visit(
36 | "https://www.lambdatest.com/selenium-playground/geolocation-testing"
37 | );
38 | cy.wait("@wait");
39 | cy.contains("p", "United States");
40 | });
41 |
42 | it.only("test Geo Location", () => {
43 | const latitude = 51.507351;
44 | const longitude = -0.127758;
45 | cy.visit("cypress/e2e/geo-location/index.html", {
46 | onBeforeLoad({ navigator }) {
47 | cy.stub(navigator.geolocation, "getCurrentPosition").callsArgWith(0, {
48 | coords: { latitude, longitude },
49 | });
50 | },
51 | });
52 | cy.contains("button", "Click me").click();
53 | cy.contains(
54 | `Your current location is (Latitude: ${latitude}, Longitude: ${longitude})`
55 | );
56 | });
57 | });
58 |
--------------------------------------------------------------------------------
/cypress.config.ts:
--------------------------------------------------------------------------------
1 | const { defineConfig } = require("cypress");
2 | // const preprocessor = require("@badeball/cypress-cucumber-preprocessor");
3 | // const browserify = require("@badeball/cypress-cucumber-preprocessor/browserify");
4 | const {
5 | cypressBrowserPermissionsPlugin,
6 | } = require("cypress-browser-permissions");
7 | import { tagify } from "cypress-tags";
8 | const fs = require("fs");
9 | const cypressSplit = require("cypress-split");
10 | const ExcelJS = require("exceljs");
11 |
12 | module.exports = defineConfig({
13 | experimentalModifyObstructiveThirdPartyCode: true,
14 | experimentalSessionAndOrigin: true,
15 | projectId: "6o7rte",
16 | e2e: {
17 | specPattern: ["cypress/e2e/**/*.js"],
18 | setupNodeEvents(on, config) {
19 | on("task", {
20 | async readXlsxData() {
21 | const workbook = await new ExcelJS.Workbook();
22 | return await workbook.xlsx
23 | .readFile("cypress/fixtures/userData.xlsx")
24 | .then(function () {
25 | console.log("test", workbook.getWorksheet("Sheet1"));
26 | return workbook.getWorksheet("Sheet1");
27 | });
28 | },
29 | });
30 | on("file:preprocessor", tagify(config));
31 | on("task", {
32 | log(message) {
33 | console.log(message);
34 |
35 | return null;
36 | },
37 | table(message) {
38 | console.table(message);
39 | // fs.writeFile("/../results/axe-report.txt", ...message);
40 | return null;
41 | },
42 | });
43 |
44 | // require("cypress-mochawesome-reporter/plugin")(on);
45 | cypressBrowserPermissionsPlugin(on, config);
46 | cypressSplit(on, config);
47 | // config.baseUrl = `https://${config.env.HOST}`;
48 | return config;
49 | },
50 | experimentalWebKitSupport: true,
51 | defaultCommandTimeout: 9000,
52 | videoCompression: 50,
53 | },
54 | });
55 |
--------------------------------------------------------------------------------
/.github/workflows/ci.yml:
--------------------------------------------------------------------------------
1 | name: Cypress Tests
2 | on:
3 | push:
4 | branches:
5 | -main
6 |
7 | jobs:
8 | cypress-run:
9 | runs-on: ubuntu-latest
10 | # Runs tests in parallel with matrix strategy https://docs.cypress.io/guides/guides/parallelization
11 | # https://docs.github.com/en/actions/using-jobs/using-a-matrix-for-your-jobs
12 | # Also see warning here https://github.com/cypress-io/github-action#parallel
13 | strategy:
14 | fail-fast: false # https://github.com/cypress-io/github-action/issues/48
15 | matrix:
16 | containers: [1, 2] # Uses 2 parallel instances
17 | steps:
18 | - name: Checkout
19 | uses: actions/checkout@v3
20 | - name: Cypress run
21 | # Uses the official Cypress GitHub action https://github.com/cypress-io/github-action
22 | uses: cypress-io/github-action@v5
23 | with:
24 | # Starts web server for E2E tests - replace with your own server invocation
25 | # https://docs.cypress.io/guides/continuous-integration/introduction#Boot-your-server
26 | # start: npm start
27 | # wait-on: 'http://localhost:3000' # Waits for above
28 | # Records to Cypress Cloud
29 | # https://docs.cypress.io/guides/cloud/projects#Set-up-a-project-to-record
30 | record: true
31 | parallel: true # Runs test in parallel using settings above
32 | env:
33 | # For recording and parallelization to work you must set your CYPRESS_RECORD_KEY
34 | # in GitHub repo → Settings → Secrets → Actions
35 | CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }}
36 | # Creating a token https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/creating-a-personal-access-token
37 | GITHUB_TOKEN: ${{ secrets.TOKEN_GIT }}
38 |
39 | RunSecondJob:
40 | name: "Run second job"
41 | uses: ./.github/workflows/dependency.yml
42 |
43 |
--------------------------------------------------------------------------------
/cypress/src/index.js:
--------------------------------------------------------------------------------
1 | const path = require("path");
2 | const fs = require("fs");
3 | const babel = require("@babel/parser");
4 | var Gherkin = require("@cucumber/gherkin");
5 | var Messages = require("@cucumber/messages");
6 | const parser = require("gherkin-parse");
7 | const glob = require("glob");
8 | const globby = require("globby");
9 |
10 | const source = fs.readFileSync(
11 | "cypress/e2e/alias-example/alias.spec.js",
12 | "utf8"
13 | );
14 |
15 | const readFiles = () => {
16 | let arrayTest = [];
17 | const path = require("path");
18 | const files = glob.sync(path.resolve(__dirname, "../e2e/features/*.feature"));
19 | files.forEach((file) => {
20 | const jsonObject = parser.convertFeatureFileToJSON(file);
21 | console.log("Feature :", jsonObject.feature.name);
22 |
23 | jsonObject.feature.children.forEach((value, index, array) => {
24 | console.log("My value:", value);
25 | if (value.type.includes("Scenario")) {
26 | let tagList = [];
27 | value.tags.forEach((tag) => {
28 | tagList.push(tag.name);
29 | });
30 | const testObj = {
31 | feature: jsonObject.feature.name,
32 | scenario: value.name,
33 | tags: tagList.toString(),
34 | };
35 | console.log("value :", testObj);
36 | arrayTest.push(testObj);
37 | }
38 | });
39 | });
40 | //arrayTest.push("1");
41 | generateXls(arrayTest);
42 | return arrayTest;
43 | };
44 |
45 | function generateXls(arr) {
46 | var fs = require("fs");
47 | var NodeXls = require("node-xls");
48 | var data = [
49 | {
50 | foo: "aaa",
51 | stux: new Date(),
52 | boom: "boom",
53 | },
54 | {
55 | foo: "bbb",
56 | stux: new Date(),
57 | boom: "boom again",
58 | },
59 | ];
60 | var tool = new NodeXls();
61 | // columns will be ordered by ["stux", "foo", "boom"]; column "boom" will be named "hello"
62 | var xls = tool.json2xls(arr);
63 | fs.writeFileSync(
64 | path.resolve(__dirname, "../e2e/features/output.xlsx"),
65 | xls,
66 | "binary"
67 | );
68 | }
69 |
70 | // generateXls();
71 | console.log("final output:", readFiles());
72 |
--------------------------------------------------------------------------------
/cypress/e2e/table/table-data.spec.js:
--------------------------------------------------------------------------------
1 | ///
2 |
3 | describe("Table validation", () => {
4 | it("let's validate table value based on columns", () => {
5 | cy.visit("./../../../cypress/table.html");
6 | cy.getTableData("Centro comercial Moctezuma", "Contact").should(
7 | "eq",
8 | "Francisco Chag"
9 | );
10 | });
11 |
12 | it("let's validate table value based on columns by query", () => {
13 | cy.visit("./../../../cypress/table.html");
14 | cy.contains("th", "Contact")
15 | .getTableDataByQuery("New Company")
16 | .should("eq", "New Contact");
17 | });
18 |
19 | Cypress.Commands.addQuery("getTableDataByQuery", (companyName) => {
20 | return ($el) => {
21 | let index = $el.index();
22 | console.log($el.index());
23 | console.log($el.parent());
24 | return $el
25 | .parents()
26 | .find(`td:contains(${companyName})`)
27 | .siblings()
28 | .eq(index - 1)
29 | .text();
30 | };
31 | });
32 |
33 | it("let's validate table value based on columns using then", () => {
34 | cy.visit("./../../../cypress/table.html");
35 | cy.contains("th", "Contact")
36 | .then(($el) => getTableDataByFn($el, "New Company"))
37 | .should("eq", "New Contact");
38 | });
39 |
40 | function getTableDataByFn($el, companyName) {
41 | let index = $el.index();
42 | console.log($el.index());
43 | console.log($el.parent());
44 | return $el
45 | .parents()
46 | .find(`td:contains(${companyName})`)
47 | .siblings()
48 | .eq(index - 1)
49 | .text();
50 | }
51 |
52 | it("Test cy.not", () => {
53 | cy.visit("./../../../cypress/table.html");
54 | cy.get(".headerRow").not(".selection");
55 | });
56 |
57 | Cypress.Commands.add("getSelectorById", (id) => {
58 | return cy.get(`#${id}`);
59 | });
60 |
61 | Cypress.Commands.addQuery("getElementCount", () => {
62 | return ($el) => $el.length;
63 | });
64 |
65 | Cypress.Commands.add("getTableData", (companyName, columnName) => {
66 | return cy
67 | .contains("th", columnName)
68 | .invoke("index")
69 | .then((index) => {
70 | cy.contains("td", companyName)
71 | .should("have.length", 1)
72 | .siblings()
73 | .eq(index - 1)
74 | .invoke("text");
75 | });
76 | });
77 | });
78 |
--------------------------------------------------------------------------------
/cypress/table.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
22 |
23 |
24 | HTML Table
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 | | Alfreds Futterkiste |
35 | Maria Anders |
36 | Germany |
37 |
38 |
39 | | Centro comercial Moctezuma |
40 | Francisco Chang |
41 | Mexico |
42 |
43 |
44 | | Ernst Handel |
45 | Roland Mendel |
46 | Austria |
47 |
48 |
49 | | Island Trading |
50 | Helen Bennett |
51 | UK |
52 |
53 |
54 | | Laughing Bacchus Winecellars |
55 | Yoshi Tannamuri |
56 | Canada |
57 |
58 |
59 | | Magazzini Alimentari Riuniti |
60 | Giovanni Rovelli |
61 | Italy |
62 |
63 |
64 |
65 |
82 |
83 |
84 |
--------------------------------------------------------------------------------
/cypress/horizontalScroll.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
24 |
25 |
29 |
30 |
31 |
32 |
33 |
50 |
51 | Horizontal Scrollable Menu
52 | Resize the browser window to see the effect.
53 |
54 | scroll down
55 |
56 |
57 |
58 |
59 |
60 |
61 | scroll down
62 |
63 |
64 |
65 |
66 |
67 | scroll down
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
91 |
98 |
99 |
100 |
101 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "src",
3 | "version": "1.0.0",
4 | "description": "cypress examples",
5 | "main": "index.js",
6 | "scripts": {
7 | "cypress:open": "./node_modules/.bin/cypress open",
8 | "cypress:run": "./node_modules/.bin/cypress run --config video=false --browser chrome",
9 | "merge-reports": "jrm results/combined-report.xml \"results/*.xml\"",
10 | "delete:result": "rm results/* || true",
11 | "combine-reports": "mochawesome-merge cypress/results/mocha/*.json > cypress/results/mochareports/report.json",
12 | "generate-report": "marge cypress/results/mochareports/report.json -f report -o cypress/results/mochareports -- inline"
13 | },
14 | "author": "Gurudatt",
15 | "license": "ISC",
16 | "dependencies": {
17 | "@cypress-audit/lighthouse": "1.2.0",
18 | "@faker-js/faker": "7.3.0",
19 | "@types/handlebars": "4.1.0",
20 | "@types/node": "^17.0.8",
21 | "chai": "^4.3.4",
22 | "chai-json-schema": "1.5.1",
23 | "cypress": "13.0.0",
24 | "cypress-cucumber-attach-screenshots-to-failed-steps": "1.0.0",
25 | "cypress-iframe": "^1.0.1",
26 | "cypress-multi-reporters": "^1.5.0",
27 | "cypress-parallel": "0.12.0",
28 | "cypress-plugin-api": "2.5.0",
29 | "cypress-tags": "1.1.2",
30 | "exceljs": "4.3.0",
31 | "gherkin-parse": "^1.0.6",
32 | "handlebars": "4.7.7",
33 | "import-cwd": "^3.0.0",
34 | "jasmine": "^3.10.0",
35 | "jquery-csv": "1.0.21",
36 | "jrm": "^1.0.1",
37 | "junit-report-merger": "^3.0.2",
38 | "junit-xml-to-html": "^1.0.4",
39 | "lighthouse": "9.4.0",
40 | "lodash": "^4.17.21",
41 | "mocha": "^8.3.2",
42 | "mochawesome": "^6.2.2",
43 | "mochawesome-merge": "^4.2.0",
44 | "mochawesome-report-generator": "^5.2.0",
45 | "multiple-cucumber-html-reporter": "^1.19.0",
46 | "soft-assert": "0.2.6",
47 | "tsify": "^5.0.4",
48 | "typescript": "^4.6.3",
49 | "node-xls": "0.0.8"
50 | },
51 | "devDependencies": {
52 | "@applitools/eyes-cypress": "^3.23.6",
53 | "@cucumber/gherkin": "26.2.0",
54 | "@cucumber/messages": "22.0.0",
55 | "@cypress/code-coverage": "3.9.12",
56 | "@faker-js/faker": "7.3.0",
57 | "@testing-library/cypress": "9.0.0",
58 | "@types/cypress-cucumber-preprocessor": "4.0.1",
59 | "axe-core": "4.6.2",
60 | "axe-html-reporter": "2.2.3",
61 | "cypress-axe": "1.3.0",
62 | "cypress-browser-permissions": "^1.1.0",
63 | "cypress-file-upload": "^5.0.8",
64 | "cypress-mochawesome-reporter": "3.2.3",
65 | "cypress-network-idle": "1.11.2",
66 | "cypress-plugin-tab": "1.0.5",
67 | "cypress-recurse": "^1.20.0",
68 | "cypress-split": "^1.2.0",
69 | "cypress-sql-server": "1.0.0",
70 | "find-cypress-specs": "1.34.5",
71 | "handlebars-faker": "^0.0.4",
72 | "mssql": "8.0.2",
73 | "playwright-webkit": "1.25.2",
74 | "tedious": "14.3.0"
75 | },
76 | "cypress-cucumber-preprocessor": {
77 | "nonGlobalStepDefinitions": false,
78 | "stepDefinitions": "cypress/e2e/features/*.js",
79 | "json": {
80 | "enabled": true,
81 | "formatter": "./jsonFormatter/cucumber-json-formatter",
82 | "output": "json-logs/report.json"
83 | }
84 | }
85 | }
86 |
--------------------------------------------------------------------------------
/cypress/e2e/lodash-examples/lodash.spec.js:
--------------------------------------------------------------------------------
1 | ///
2 |
3 | var _ = require("lodash");
4 |
5 | it("Assert all the elements are truely", () => {
6 | let testArry = [
7 | {
8 | processId: 1,
9 | status: 1,
10 | startDate: "2023-06-09T14:38:40.4404499",
11 | endDate: null,
12 | },
13 | {
14 | processId: 4,
15 | status: 2,
16 | startDate: "2023-06-09T14:31:40.9584041",
17 | endDate: "2023-06-09T14:31:40.9655563",
18 | },
19 | {
20 | processId: 6,
21 | status: 2,
22 | startDate: "2023-06-09T14:36:02.3850904",
23 | endDate: "2023-06-09T14:36:06.4816924",
24 | },
25 | ];
26 | cy.log(Cypress._.every(testArry, ["status", 2]));
27 |
28 | //assert with expect
29 | expect(Cypress._.every(testArry, ["status", 2])).to.deep.equal(true);
30 |
31 | //wrap it for later usage or assertion
32 | cy.wrap(Cypress._.every(testArry, ["status", 2])).as("status");
33 |
34 | //assert by using get function to get the wrapped alias
35 | cy.get("@status").should("equal", true);
36 | });
37 |
38 | it.only("test some", () => {
39 | let tst = [
40 | {
41 | fileId: "00000000-0000-0000-0000-000000000000",
42 | creationDate: "2023-06-13T11:50:21.132",
43 | status: 2,
44 | fileName: "company-1686656906589.csv",
45 | uploadUserName: "Gurudatt Sa",
46 | outputFileName: null,
47 | companyName: null,
48 | importFileType: null,
49 | },
50 | {
51 | fileId: "00000000-0000-0000-0000-000000000000",
52 | creationDate: "2023-06-13T11:40:22.878",
53 | status: 2,
54 | fileName: "company-1686656293026.csv",
55 | uploadUserName: "Gurudatt Sa",
56 | outputFileName: null,
57 | companyName: null,
58 | importFileType: null,
59 | },
60 | {
61 | fileId: "00000000-0000-0000-0000-000000000000",
62 | creationDate: "2023-06-13T11:35:40.536",
63 | status: 2,
64 | fileName: "product-1686655850850.csv",
65 | uploadUserName: "Gurudatt Sa",
66 | outputFileName: null,
67 | companyName: null,
68 | importFileType: null,
69 | },
70 | {
71 | fileId: "00000000-0000-0000-0000-000000000000",
72 | creationDate: "2023-06-13T11:35:19.443",
73 | status: 2,
74 | fileName: "company-1686655955538.csv",
75 | uploadUserName: "Gurudatt Sa",
76 | outputFileName: null,
77 | companyName: null,
78 | importFileType: null,
79 | },
80 | {
81 | fileId: "00000000-0000-0000-0000-000000000000",
82 | creationDate: "2023-06-13T11:30:19.457",
83 | status: 2,
84 | fileName: "company-1686655576559.csv",
85 | uploadUserName: "Gurudatt Sa",
86 | outputFileName: null,
87 | companyName: null,
88 | importFileType: null,
89 | },
90 | {
91 | fileId: "00000000-0000-0000-0000-000000000000",
92 | creationDate: "2023-06-13T11:21:01.878",
93 | status: 2,
94 | fileName: "project-1686654863289.csv",
95 | uploadUserName: "Gurudatt Sa",
96 | outputFileName: null,
97 | companyName: null,
98 | importFileType: null,
99 | },
100 | {
101 | fileId: "00000000-0000-0000-0000-000000000000",
102 | creationDate: "2023-06-13T11:20:42.389",
103 | status: 2,
104 | fileName: "product-1686654850224.csv",
105 | uploadUserName: "Gurudatt Sa",
106 | outputFileName: null,
107 | companyName: null,
108 | importFileType: null,
109 | },
110 | {
111 | fileId: "00000000-0000-0000-0000-000000000000",
112 | creationDate: "2023-06-13T11:20:20.381",
113 | status: 2,
114 | fileName: "company-1686654836709.csv",
115 | uploadUserName: "Gurudatt Sa",
116 | outputFileName: null,
117 | companyName: null,
118 | importFileType: null,
119 | },
120 | {
121 | fileId: "00000000-0000-0000-0000-000000000000",
122 | creationDate: "2023-06-12T13:55:13.485",
123 | status: 2,
124 | fileName: "transaction-1686577537784.csv",
125 | uploadUserName: "Gurudatt Sa",
126 | outputFileName: null,
127 | companyName: null,
128 | importFileType: null,
129 | },
130 | {
131 | fileId: "00000000-0000-0000-0000-000000000000",
132 | creationDate: "2023-06-12T12:35:23.128",
133 | status: 2,
134 | fileName: "transaction-tieredRetro-1686573208200.csv",
135 | uploadUserName: "Gurudatt Sa",
136 | outputFileName: null,
137 | companyName: null,
138 | importFileType: null,
139 | },
140 | ];
141 | let fileName = "transaction-tieredRetro-1686573208200";
142 | cy.log(
143 | Cypress._.some(tst, {
144 | status: 2,
145 | fileName: `${fileName}.csv`,
146 | })
147 | );
148 | });
149 |
--------------------------------------------------------------------------------