Skip to content

[YouTube] [SDET- QA Automation Techie] Cypress - JavaScript End to End Testing [ENG, 2022]

Notifications You must be signed in to change notification settings

wildmakaka/Cypress-JavaScript-End-to-End-Testing

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

34 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation


Part 01. Introduction


Part 02. Environment setup on Windows & Mac OS

$ npm init -y
$ npm install cypress

Start cypress

$ npx cypress open

or

$ node_modules/.bin/cypress open

Part 03. How To Write & Run Tests in Cypress


describe('My First Test', () => {
  it('verify title-positive', () => {
    cy.visit('https://opensource-demo.orangehrmlive.com/');
    cy.title().should('eq', 'OrangeHRM');
  });

  it('verify title-negative', () => {
    cy.visit('https://opensource-demo.orangehrmlive.com/');
    cy.title().should('eq', 'OrangeHRM123');
  });
});

$ node_modules/.bin/cypress run
$ node_modules/.bin/cypress run --headed
$ node_modules/.bin/cypress run --headless
$ node_modules/.bin/cypress run --spec cypress/e2e/MyFirstTest.cy.js
$ node_modules/.bin/cypress run --browser chrome
$ node_modules/.bin/cypress run --browser chrome --headed

Part 04. CSS & XPath Locators | get() & xpath() methods

http://automationpractice.com/ - not working right now

https://chrome.google.com/webstore/detail/selectorshub/ndgimibanhlabgdgjcpbbndiehljcpfh

$ npm install -D cypress-xpath

cypress/support/commands.js

/// <reference types"Cypress" />
/// <reference types"cypress-xpath" />

cypress/support/e2e.js

require('cypress-xpath')

CSSLocators.cy.js

describe('CSSLocators', () => {
  it('csslocators', () => {
    cy.visit('https://automationpractice.com/index.php');
    // cy.get('#search_query_top').type('T-Shirts');
    // cy.get('.search_query_top').type('T-Shirts');
    // cy.get("[name='search_query']").type('T-Shirts');

    cy.get("input.search_query_top[name='search_query']").type('T-Shirts');

    cy.get("[name='submit_searh']").click();
    cy.get('.lighter').contains('T-Shirts');
  });
});

XPathLocators.cy.js

describe('XPathLocators', () => {
  it('find no of products', () => {
    cy.visit('https://automationpractice.com/index.php');
    cy.xpath("//ui[@id='homefeatured']/li").should('have.length', 7);
  });

  it('chained xpath', () => {
    cy.visit('https://automationpractice.com/index.php');
    cy.xpath("//ui[@id='homefeatured']").xpath('./li').should('have.length', 7);
  });
});

Part 05. Assertions


Part 06. Folder Structure | IntelliSense Auto Suggestions


Cypress


Part 07. Interacting with Elements | Radio Buttons & Checkboxes

https://itera-qa.azurewebsites.net/ - not working right now


Part 08. Interacting with Elements | DropDowns


Part 09. Interacting with Elements | Alerts


Part 10. Interacting with Elements | Handling Child Tabs


Part 11. Interacting with Elements | Handling iFrames

$ npm install cypress-iframe

Part 12. Interacting with Elements | Handling Tables


Part 13. Interacting with Elements | Handling Mouse Events

$ npm install @4tw/cypress-drag-drop

Part 14. Interacting with Elements | Handling File Upload

$ npm install cypress-file-upload

Part 15. Hooks & Tags


Part 16. Fixtures & Data Driven Testing (Using JSON Data)


Part 17. How To Create Custom commands


Part 18. Browser Navigation | go() & reload()


Part 19. How To Capture Screenshots & Videos on Test Failures

$ npx cypress run --spec cypress/e2e/CaptureScreenshotsAndVideos.cy.js

Part 20. How To Generate HTML Reports | Headed & Headless mode execution

https://www.npmjs.com/package/cypress-mochawesome-reporter

$ npm install cypress-mochawesome-reporter

cypress.config.js

const { defineConfig } = require('cypress');

module.exports = defineConfig({
  reporter: 'cypress-mochawesome-reporter',
  e2e: {
    setupNodeEvents(on, config) {
      require('cypress-mochawesome-reporter/plugin')(on);
    },
  },
});

cypress/support/e2e.js

import 'cypress-mochawesome-reporter/register';

$ npx cypress run --spec cypress/e2e/MyFirstTest.cy.js

$ npx cypress run --spec cypress/e2e/MyFirstTest.cy.js --browser chrome

$ npx cypress run --headed --spec cypress/e2e/MyFirstTest.cy.js --browser chrome

Part 21. Page Object Model Pattern in Cypress

About

[YouTube] [SDET- QA Automation Techie] Cypress - JavaScript End to End Testing [ENG, 2022]

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •