CYPRESS AUTOMATION TOOL

    Cypress For Automation Testing


1. What is Cypress

  • Cypress is an end-to-end testing framework for web test automation. It is useful for front-end developers and test automation engineers to write automated web tests in JavaScript. The use of JavaScript makes Cypress automation especially attractive and easy to developers.

2. Summary 

  • Cypress is the automation tool and we can use cypress for automation testing.
  • We can test anything that runs on a web browser using cypress.
  • Cypress uses java script as scripting language for automation.
  • Cypress does not use selenium.
  • Cypress directly interact with browser , so it is very fast as there is no any intermediate driver.
  • Its open source tool so we can use freely.
  • We can use cypress for cross browser testing.

3. Steps for beginners

  • Setup test
  • Write test
  • Run test
  • Debug

4. Features of cypress

  • Time travel will take screenshot as your test run
  • Debuggability readable errors and stack trace
  • Automatic waiting automatically waits for command and assertion before moving on
  • Consistent result it doesn’t use web driver so it is fast consistent and reliable
  • You can get screenshots and videos
  • Cross Browser Testing locally or remote ( CI CD)

5. Types of testcases can be automated using cypress

  • Unit Test

  • End to End Test

  • Integration Test


6. Steps required for cypress setup

  • Install node js from https://nodejs.org/en/download/
  • Install vs code from https://code.visualstudio.com/download
  • Create folder within your drive and open it in VS code
  • Open terminal by clicking on terminal :- new terminal menu
  • Run command in terminal npm init -y
  • Install cypress using command npm install cypress@version
  • to check installed cypress version run command npx cypress -v
  • for opening the cypress run command npx cypress open
  • create your first file under cypress :- integration folder :- myfirstfile.js
  • for the autocompletion add below line to your file
    • /// <reference types=”cypress” />
  • We need test runner for writing test case :- cypress have built in test runner :- mocha
  • Write test function
    • it(‘google test’ , function() {
      cy.visit(“https://www.google.con”);
      })
  • Run the test

7. Element access using cypress

  • We can use below syntax for accessing element using cypress
    • cy.get('selector')
  • cy.get('h1')                                   // select by using tag name
  • cy.get('.class')                             // select by using class name
  • cy.get('#id')                                // select by using id
  • cy.get('[attribute = "value"]')    // select by attribute 

8. Important methods of cypress

  • cy.get('selector') :- for locating the element on webpage
  • cy.visit('url') :- for accessing webpage on browser
  • cy.get('selector').type('text to be written in input field') :- for passing value in input field
  • cy.get('selector').click() :- for perform click event on element
  • cy.wait(5000) :- for putting wait 
  • cy.contains('hello') :- for finding element that contains the given text

9. Folder structure of cypress


  • Fixtures :- it is set of static data that we can use during scripting. we should not provide hard coded data. it should use sources like csv , html , json, etc. we can use cy.fixture() method when we want to use the data in our testcase.

  • Integration :-  it is the place where we can put our testcases. By default cypress has example directory which contains some default sample testcases. We can also create our own folder under this and can put our testcases within that.

  • Plugins :- it is the place which contains all the plugins. By default there is one file under plugins folder with named index.js. If we want to modify existing behavior then we can do some changes in plugins based on our requirement.

  • Support :- it is the place where we can put our customized commands or reusable methods that can be used by our all spec files. 

  • Report :- it is the place where report of our testcases will be stored if we have integrated any report generation tool.

  • Screenshots :- it is the place where screenshots of our script execution will be stored if we have added logic for taking screenshot while script execution.

                
                                                                                                                        - Hina Murdhani.





Comments

Popular posts from this blog

PLAYWRIGHT : Automation Tool

MABL : Codeless Automation Tool

.JAVA to .JAR Conversion

Difference of Opinion on Node vs Go

BlazeMeter : How to write Jmeter script without prior knowledge of Jmeter

Why node-red is use for embedded programming ?

API testing using postman

Loadium tool For jmeter script from POSTMAN

Software Testing Life Cycle(STLC)