SlideShare a Scribd company logo
1 of 50
Test Automation
by
Cypress
www.arshadqa.com
Introduction
• Why Automate?
• Automation Test Pyramid
• Testing Quadrants
www.arshadqa.com
Why Automate?
www.arshadqa.com
Automation Test Pyramid
www.arshadqa.com
Testing Quadrants
www.arshadqa.com
Cypress
• Test Automation Tool
• Uses Java script
• Open source
• Web site:
• https://www.cypress.io/
www.arshadqa.com
Cypress Features
• Time Travel: Takes snapshots of application as your tests runs
• Debuggability readable errors and stack traces
• Automatic waits: automatically waits for commands and assertions
• Consistent Results: Doesn’t use Selenium or WebDriver, fast, consistent and
reliable
• Screenshots and Videos: Get screenshots and videos
• Cross browser Testing: Locally or remote (CI CD)
www.arshadqa.com
Cypress Features
• Eng to End Testing
• Integration Tests
• Units Tests
www.arshadqa.com
Cypress Project Setup
• Step 1 – Install Node.js
• Step 2 – Install Visual Studio Code
• Step 3: Create a new folder for cypress project
• Step 4: Open the folder in VS code
• Step 5: Open VS code terminal and run command npm init –y
• Step 6: npm install cypress
• Npx cypress -v
www.arshadqa.com
Java Script
• JavaScript completes its ninth year in a row as the most commonly used
programming language. For most developers, programming is web
programming. Python traded places with SQL to become the third most
popular language.
• https://insights.stackoverflow.com/survey/2021#overview
www.arshadqa.com
www.arshadqa.com
NodeJS
• Download
• https://nodejs.org/en/download/
www.arshadqa.com
Code Editor
• Visual Studio code
• Download
• https://code.visualstudio.com/download
www.arshadqa.com
Cypress 1st Test
• Step1: Create a file under cypress> Integration folder
• Step2: At the top mention ///<reference types=“cypress”/>
• Steps3: Write Test function
• Step 4: Run test npx cypress open
• Steps 5: Access elements
www.arshadqa.com
Cypress – Some Commands
• -cy.visit ()
• -cy.get()
• -type()
www.arshadqa.com
Variables
• Let
• Const
• var
www.arshadqa.com
.Should()
• .should('not.exist')
• .should(‘be.visible’)
• .should(‘be.not visible’)
• .should(‘contains’, ‘some text’)
• .should('have.text’, ‘some text')
• .should(‘eq’, ‘some text’)
• .should(‘be.enabled’)
• .should(‘be.disabled')
www.arshadqa.com
Verifying Page Title
• --cy.title().should(‘eq’, ‘ ‘)
Custom Waits
• --cy.wait(miliseconds)
• --npx cypress run --spec “cypress/integration/Demo_Project/Demo.js"
Random Function (Math.random()*5000)
• SSN
• Priority
• Unique value require for tests
Object Oriented Programming in Cypress
• Step 1: Create a class
• Step 2: Add functions
• Step 3: export that class so we can use it
• Step 4: import that class in test case where we can to use
• Step 5: Create a class object
• Step6: Call class functions
• Step 7: Run the main .js file and see (Note: .js file which is class, we can not
directly run it)
www.arshadqa.com
Data Driven Testing
• Files
• Fixtures
Working with Files
• cy.writeFile()
• cy.readFile()
www.arshadqa.com
Fixtures
• Fixtures are used to store and manage test data.
• Fixture files are located in cypress/fixtures by default but can be configured to
another directory.
• The test data is usually written inside a JSON file which can then be used
throughout your tests
www.arshadqa.com
Cypress Dashboard
• The Cypress Dashboard Service is an optional web-based companion to the
Test Runner.
• It provides timely, simple and powerful insights on all your tests run at a glance.
With automatic parallelization and load balancing you can optimize CI and run
significantly faster tests.
• https://www.cypress.io/pricing/
Cypress Dashboard
Cypress Dashboard
Cypress Dashboard Configuration
• Step 1: Register with dashboard. cypress.io and get the project id and key
• https://dashboard.cypress.io/
• Step 2: Enter the project id in Cypress.json file "projectId": "h245ts",
• Step 3: Run the test cases from terminal
• npx cypress run --record –key ffcbf60d-a72c-4a8d-a2ff-f1c8963eab46
Reports in Cypress
www.arshadqa.com
Step 1: Download Required npm Packages
www.arshadqa.com
npm install cypress-mochawesome-reporter junit-report-merger
mocha-junit-reporter cypress-multi-reporters mocha
Step 1: Download Required npm Packages
cypress-multi-reporters: This package is used for configuring multiple
reports in our case Junit reporter and HTML reporter.
mocha-junit-reporter: Mocha Junit Reporter generates Junit XML file for
each spec.
junit-report-merger: Since the Mocha Junit Reporter generates a JUnit XML
file for each spec we need to merge them all at the end to create a single XML
file.
cypress-mochawesome-reporter: This package helps to generate HTML
reports.
Step 2: Reports configuration in cypress.json
• "reporter": "cypress-multi-reporters",
• "reporterOptions": {
• "reporterEnabled": "cypress-mochawesome-reporter, mocha-junit-
reporter",
• "cypressMochawesomeReporterReporterOptions": {
• "reportDir": "cypress/reports",
• "charts": true,
• "reportPageTitle": "My Test Suite",
• "embeddedScreenshots": true,
• "html": true,
www.arshadqa.com
Step 2: Reports configuration in cypress.json
• "json": true,
• "inlineAssets": true
• },
• "mochaJunitReporterReporterOptions": {
• "mochaFile": "cypress/reports/junit/results-[hash].xml"
• }
• },
• "video": false
•
}
www.arshadqa.com
Step 3: Configure plugin/index.js File
Project root folder > open cypress folder > open plugin folder > open index.js file
www.arshadqa.com
Step 3: Configure plugin/index.js File
• //index.js inside plugin folder
• const { beforeRunHook, afterRunHook } = require('cypress-
mochawesome-reporter/lib');
• const exec = require('child_process').execSync;
• module.exports = (on) => {
• on('before:run', async (details) => {
• console.log('override before:run');
• await beforeRunHook(details);
www.arshadqa.com
Step 3: Configure plugin/index.js File
• //If you are using other than Windows remove below two lines
• await exec("IF EXIST cypressscreenshots rmdir /Q /S cypressscreenshots")
• await exec("IF EXIST cypressreports rmdir /Q /S cypressreports")
• });
• on('after:run', async () => {
• console.log('override after:run');
• //if you are using other than Windows remove below line (having await exec)
• await exec("npx jrm ./cypress/reports/junitreport.xml
./cypress/reports/junit/*.xml");
• await afterRunHook();
• });
• };
www.arshadqa.com
Step 4: Add an Entry Into support/index.js
Navigate to cypress folder > open support folder > open index.js file
www.arshadqa.com
Step 4: Add an Entry Into support/index.js
• //index.js inside support folder
• import 'cypress-mochawesome-reporter/register';
www.arshadqa.com
Step 5: Run Your Test
Run your test with either npx cypress run command.
www.arshadqa.com
npx cypress run --spec “cypress/integration/Demo_Project/Demo.js"
Step 6: Viewing HTML File
• Project Root folder > cypress > reports > index.html
• You can use this XML file when you integrate with CI/CD either Jenkins, Azure
DevOps, or any other tools.
www.arshadqa.com
BDD – Cucumber – Installation and Setup
• --npm install cypress-cucumber-preprocessor
• In Cypress.JSON file add this "testFiles":"**/*.feature"
• Create a file in integration folder for example “abc.feature” and folder with same
name as feature file for example “abc” in integration folder.
• Create a step definition file within the folder “abc” For example login.js
• Note: Step definition file could be name anything as you wish
Configuration
• Please make use of cosmiconfig to create a configuration for the plugin,
for example, by adding this section to your package.json:
• "cypress-cucumber-preprocessor":{
• "nonGlobalStepDefinations": true
• }
• -npm install cosmiconfig
Add it to your plugins:
• cypress/plugins/index.js
• const cucumber = require('cypress-cucumber-preprocessor').default
•
module.exports = (on, config) => {
• on('file:preprocessor', cucumber())
• }
BDD – Cucumber – Installation and Setup
• To highlight Gherkin Keywords type “Cucumber” in search and install the extension
Example Login Feature File 1
• Feature: Login
• I want to log into WebSite
• Scenario: WebSite login
• Given I open WebSite login page
• When I type in username and password
• And I click on Sign in button
• Then dashboard page should be shown
Example Login Feature File 2
Step Definition File
• Given(‘ I open the WebSite login page’, () => {
• --cy.visit (‘URL’)
• {);
• When (‘’,() => {
• });
• When (‘’,() => {
• });
• Then (‘’, () =>{
• });
Example Step Definition File
Thanks
www.arshadqa.com

More Related Content

Similar to Cypress.pptx

iOS Application Penetration Testing for Beginners
iOS Application Penetration Testing for BeginnersiOS Application Penetration Testing for Beginners
iOS Application Penetration Testing for BeginnersRyanISI
 
Android pentesting the hackers-meetup
Android pentesting the hackers-meetupAndroid pentesting the hackers-meetup
Android pentesting the hackers-meetupkunwaratul hax0r
 
DevOps on AWS: Accelerating Software Delivery with the AWS Developer Tools
DevOps on AWS: Accelerating Software Delivery with the AWS Developer ToolsDevOps on AWS: Accelerating Software Delivery with the AWS Developer Tools
DevOps on AWS: Accelerating Software Delivery with the AWS Developer ToolsAmazon Web Services
 
Automated Deployment and Configuration Engines. Ansible
Automated Deployment and Configuration Engines. AnsibleAutomated Deployment and Configuration Engines. Ansible
Automated Deployment and Configuration Engines. AnsibleAlberto Molina Coballes
 
Our Puppet Story (GUUG FFG 2015)
Our Puppet Story (GUUG FFG 2015)Our Puppet Story (GUUG FFG 2015)
Our Puppet Story (GUUG FFG 2015)DECK36
 
XPages -Beyond the Basics
XPages -Beyond the BasicsXPages -Beyond the Basics
XPages -Beyond the BasicsUlrich Krause
 
Node.js Development with Apache NetBeans
Node.js Development with Apache NetBeansNode.js Development with Apache NetBeans
Node.js Development with Apache NetBeansRyan Cuprak
 
IBM InterConnect 2015 - IIB in the Cloud
IBM InterConnect 2015 - IIB in the CloudIBM InterConnect 2015 - IIB in the Cloud
IBM InterConnect 2015 - IIB in the CloudAndrew Coleman
 
Introduction to node js - From "hello world" to deploying on azure
Introduction to node js - From "hello world" to deploying on azureIntroduction to node js - From "hello world" to deploying on azure
Introduction to node js - From "hello world" to deploying on azureColin Mackay
 
Server-side JS with NodeJS
Server-side JS with NodeJSServer-side JS with NodeJS
Server-side JS with NodeJSLilia Sfaxi
 
Architectures, Frameworks and Infrastructure
Architectures, Frameworks and InfrastructureArchitectures, Frameworks and Infrastructure
Architectures, Frameworks and Infrastructureharendra_pathak
 
Java script nirvana in netbeans [con5679]
Java script nirvana in netbeans [con5679]Java script nirvana in netbeans [con5679]
Java script nirvana in netbeans [con5679]Ryan Cuprak
 
O365Con18 - Implementing Automated UI Testing for SharePoint Solutions - Elio...
O365Con18 - Implementing Automated UI Testing for SharePoint Solutions - Elio...O365Con18 - Implementing Automated UI Testing for SharePoint Solutions - Elio...
O365Con18 - Implementing Automated UI Testing for SharePoint Solutions - Elio...NCCOMMS
 
Rock Solid Deployment of Web Applications
Rock Solid Deployment of Web ApplicationsRock Solid Deployment of Web Applications
Rock Solid Deployment of Web ApplicationsPablo Godel
 
T3 - Deploy, manage, and scale your apps
T3 - Deploy, manage, and scale your appsT3 - Deploy, manage, and scale your apps
T3 - Deploy, manage, and scale your appsAmazon Web Services
 
Twelve Factor Serverless Applications
Twelve Factor Serverless ApplicationsTwelve Factor Serverless Applications
Twelve Factor Serverless ApplicationsAmazon Web Services
 
Play Framework and Activator
Play Framework and ActivatorPlay Framework and Activator
Play Framework and ActivatorKevin Webber
 

Similar to Cypress.pptx (20)

iOS Application Penetration Testing for Beginners
iOS Application Penetration Testing for BeginnersiOS Application Penetration Testing for Beginners
iOS Application Penetration Testing for Beginners
 
Android pentesting the hackers-meetup
Android pentesting the hackers-meetupAndroid pentesting the hackers-meetup
Android pentesting the hackers-meetup
 
DevOps on AWS: Accelerating Software Delivery with the AWS Developer Tools
DevOps on AWS: Accelerating Software Delivery with the AWS Developer ToolsDevOps on AWS: Accelerating Software Delivery with the AWS Developer Tools
DevOps on AWS: Accelerating Software Delivery with the AWS Developer Tools
 
Automated Deployment and Configuration Engines. Ansible
Automated Deployment and Configuration Engines. AnsibleAutomated Deployment and Configuration Engines. Ansible
Automated Deployment and Configuration Engines. Ansible
 
Our Puppet Story (GUUG FFG 2015)
Our Puppet Story (GUUG FFG 2015)Our Puppet Story (GUUG FFG 2015)
Our Puppet Story (GUUG FFG 2015)
 
XPages -Beyond the Basics
XPages -Beyond the BasicsXPages -Beyond the Basics
XPages -Beyond the Basics
 
Node.js Development with Apache NetBeans
Node.js Development with Apache NetBeansNode.js Development with Apache NetBeans
Node.js Development with Apache NetBeans
 
IBM InterConnect 2015 - IIB in the Cloud
IBM InterConnect 2015 - IIB in the CloudIBM InterConnect 2015 - IIB in the Cloud
IBM InterConnect 2015 - IIB in the Cloud
 
Introduction to node js - From "hello world" to deploying on azure
Introduction to node js - From "hello world" to deploying on azureIntroduction to node js - From "hello world" to deploying on azure
Introduction to node js - From "hello world" to deploying on azure
 
Server-side JS with NodeJS
Server-side JS with NodeJSServer-side JS with NodeJS
Server-side JS with NodeJS
 
Architectures, Frameworks and Infrastructure
Architectures, Frameworks and InfrastructureArchitectures, Frameworks and Infrastructure
Architectures, Frameworks and Infrastructure
 
Java script nirvana in netbeans [con5679]
Java script nirvana in netbeans [con5679]Java script nirvana in netbeans [con5679]
Java script nirvana in netbeans [con5679]
 
O365Con18 - Implementing Automated UI Testing for SharePoint Solutions - Elio...
O365Con18 - Implementing Automated UI Testing for SharePoint Solutions - Elio...O365Con18 - Implementing Automated UI Testing for SharePoint Solutions - Elio...
O365Con18 - Implementing Automated UI Testing for SharePoint Solutions - Elio...
 
Rock Solid Deployment of Web Applications
Rock Solid Deployment of Web ApplicationsRock Solid Deployment of Web Applications
Rock Solid Deployment of Web Applications
 
Hosting Ruby Web Apps
Hosting Ruby Web AppsHosting Ruby Web Apps
Hosting Ruby Web Apps
 
iOS Application Exploitation
iOS Application ExploitationiOS Application Exploitation
iOS Application Exploitation
 
T3 - Deploy, manage, and scale your apps
T3 - Deploy, manage, and scale your appsT3 - Deploy, manage, and scale your apps
T3 - Deploy, manage, and scale your apps
 
Twelve Factor Serverless Applications
Twelve Factor Serverless ApplicationsTwelve Factor Serverless Applications
Twelve Factor Serverless Applications
 
DrupalCon 2011 Highlight
DrupalCon 2011 HighlightDrupalCon 2011 Highlight
DrupalCon 2011 Highlight
 
Play Framework and Activator
Play Framework and ActivatorPlay Framework and Activator
Play Framework and Activator
 

More from Arshad QA

Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsArshad QA
 
Test Automation Strategy for Frontend and Backend
Test Automation Strategy for Frontend and BackendTest Automation Strategy for Frontend and Backend
Test Automation Strategy for Frontend and BackendArshad QA
 
API Automation in Rest Assured by using BDD Approach with TestNG
API Automation in Rest Assured by using BDD Approach with TestNGAPI Automation in Rest Assured by using BDD Approach with TestNG
API Automation in Rest Assured by using BDD Approach with TestNGArshad QA
 
Behavior Driven Development(BDD) by using Cucumber Plugin in Cypress
Behavior Driven Development(BDD) by using Cucumber Plugin in CypressBehavior Driven Development(BDD) by using Cucumber Plugin in Cypress
Behavior Driven Development(BDD) by using Cucumber Plugin in CypressArshad QA
 
QATraining20Feb2023.pptx
QATraining20Feb2023.pptxQATraining20Feb2023.pptx
QATraining20Feb2023.pptxArshad QA
 
QATraining27Feb2023.pptx
QATraining27Feb2023.pptxQATraining27Feb2023.pptx
QATraining27Feb2023.pptxArshad QA
 
STC_InHouseDevelopment.pptx
STC_InHouseDevelopment.pptxSTC_InHouseDevelopment.pptx
STC_InHouseDevelopment.pptxArshad QA
 
STC-TestAutomation.pptx
STC-TestAutomation.pptxSTC-TestAutomation.pptx
STC-TestAutomation.pptxArshad QA
 
ISTQB-FL.pptx
ISTQB-FL.pptxISTQB-FL.pptx
ISTQB-FL.pptxArshad QA
 
JMeter_Performance Testing.pptx
JMeter_Performance Testing.pptxJMeter_Performance Testing.pptx
JMeter_Performance Testing.pptxArshad QA
 
NewRelic.pptx
NewRelic.pptxNewRelic.pptx
NewRelic.pptxArshad QA
 
RestAssured.pptx
RestAssured.pptxRestAssured.pptx
RestAssured.pptxArshad QA
 

More from Arshad QA (12)

Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview Questions
 
Test Automation Strategy for Frontend and Backend
Test Automation Strategy for Frontend and BackendTest Automation Strategy for Frontend and Backend
Test Automation Strategy for Frontend and Backend
 
API Automation in Rest Assured by using BDD Approach with TestNG
API Automation in Rest Assured by using BDD Approach with TestNGAPI Automation in Rest Assured by using BDD Approach with TestNG
API Automation in Rest Assured by using BDD Approach with TestNG
 
Behavior Driven Development(BDD) by using Cucumber Plugin in Cypress
Behavior Driven Development(BDD) by using Cucumber Plugin in CypressBehavior Driven Development(BDD) by using Cucumber Plugin in Cypress
Behavior Driven Development(BDD) by using Cucumber Plugin in Cypress
 
QATraining20Feb2023.pptx
QATraining20Feb2023.pptxQATraining20Feb2023.pptx
QATraining20Feb2023.pptx
 
QATraining27Feb2023.pptx
QATraining27Feb2023.pptxQATraining27Feb2023.pptx
QATraining27Feb2023.pptx
 
STC_InHouseDevelopment.pptx
STC_InHouseDevelopment.pptxSTC_InHouseDevelopment.pptx
STC_InHouseDevelopment.pptx
 
STC-TestAutomation.pptx
STC-TestAutomation.pptxSTC-TestAutomation.pptx
STC-TestAutomation.pptx
 
ISTQB-FL.pptx
ISTQB-FL.pptxISTQB-FL.pptx
ISTQB-FL.pptx
 
JMeter_Performance Testing.pptx
JMeter_Performance Testing.pptxJMeter_Performance Testing.pptx
JMeter_Performance Testing.pptx
 
NewRelic.pptx
NewRelic.pptxNewRelic.pptx
NewRelic.pptx
 
RestAssured.pptx
RestAssured.pptxRestAssured.pptx
RestAssured.pptx
 

Recently uploaded

Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataAdobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataBradBedford3
 
DNT_Corporate presentation know about us
DNT_Corporate presentation know about usDNT_Corporate presentation know about us
DNT_Corporate presentation know about usDynamic Netsoft
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsAlberto González Trastoy
 
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdfThe Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdfkalichargn70th171
 
why an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfwhy an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfjoe51371421
 
Introduction to Decentralized Applications (dApps)
Introduction to Decentralized Applications (dApps)Introduction to Decentralized Applications (dApps)
Introduction to Decentralized Applications (dApps)Intelisync
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software DevelopersVinodh Ram
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...stazi3110
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...kellynguyen01
 
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEBATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEOrtus Solutions, Corp
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxbodapatigopi8531
 
Engage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The UglyEngage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The UglyFrank van der Linden
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...MyIntelliSource, Inc.
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantAxelRicardoTrocheRiq
 
Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)OPEN KNOWLEDGE GmbH
 
Unit 1.1 Excite Part 1, class 9, cbse...
Unit 1.1 Excite Part 1, class 9, cbse...Unit 1.1 Excite Part 1, class 9, cbse...
Unit 1.1 Excite Part 1, class 9, cbse...aditisharan08
 
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...gurkirankumar98700
 
Cloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackCloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackVICTOR MAESTRE RAMIREZ
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comFatema Valibhai
 

Recently uploaded (20)

Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataAdobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
 
DNT_Corporate presentation know about us
DNT_Corporate presentation know about usDNT_Corporate presentation know about us
DNT_Corporate presentation know about us
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
 
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdfThe Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
 
why an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfwhy an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdf
 
Introduction to Decentralized Applications (dApps)
Introduction to Decentralized Applications (dApps)Introduction to Decentralized Applications (dApps)
Introduction to Decentralized Applications (dApps)
 
Exploring iOS App Development: Simplifying the Process
Exploring iOS App Development: Simplifying the ProcessExploring iOS App Development: Simplifying the Process
Exploring iOS App Development: Simplifying the Process
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software Developers
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
 
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEBATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptx
 
Engage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The UglyEngage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The Ugly
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service Consultant
 
Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)
 
Unit 1.1 Excite Part 1, class 9, cbse...
Unit 1.1 Excite Part 1, class 9, cbse...Unit 1.1 Excite Part 1, class 9, cbse...
Unit 1.1 Excite Part 1, class 9, cbse...
 
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
 
Cloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackCloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStack
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.com
 

Cypress.pptx

  • 2. Introduction • Why Automate? • Automation Test Pyramid • Testing Quadrants www.arshadqa.com
  • 6. Cypress • Test Automation Tool • Uses Java script • Open source • Web site: • https://www.cypress.io/ www.arshadqa.com
  • 7. Cypress Features • Time Travel: Takes snapshots of application as your tests runs • Debuggability readable errors and stack traces • Automatic waits: automatically waits for commands and assertions • Consistent Results: Doesn’t use Selenium or WebDriver, fast, consistent and reliable • Screenshots and Videos: Get screenshots and videos • Cross browser Testing: Locally or remote (CI CD) www.arshadqa.com
  • 8. Cypress Features • Eng to End Testing • Integration Tests • Units Tests www.arshadqa.com
  • 9. Cypress Project Setup • Step 1 – Install Node.js • Step 2 – Install Visual Studio Code • Step 3: Create a new folder for cypress project • Step 4: Open the folder in VS code • Step 5: Open VS code terminal and run command npm init –y • Step 6: npm install cypress • Npx cypress -v www.arshadqa.com
  • 10. Java Script • JavaScript completes its ninth year in a row as the most commonly used programming language. For most developers, programming is web programming. Python traded places with SQL to become the third most popular language. • https://insights.stackoverflow.com/survey/2021#overview www.arshadqa.com
  • 13. Code Editor • Visual Studio code • Download • https://code.visualstudio.com/download www.arshadqa.com
  • 14. Cypress 1st Test • Step1: Create a file under cypress> Integration folder • Step2: At the top mention ///<reference types=“cypress”/> • Steps3: Write Test function • Step 4: Run test npx cypress open • Steps 5: Access elements www.arshadqa.com
  • 15. Cypress – Some Commands • -cy.visit () • -cy.get() • -type() www.arshadqa.com
  • 16. Variables • Let • Const • var www.arshadqa.com
  • 17. .Should() • .should('not.exist') • .should(‘be.visible’) • .should(‘be.not visible’) • .should(‘contains’, ‘some text’) • .should('have.text’, ‘some text') • .should(‘eq’, ‘some text’) • .should(‘be.enabled’) • .should(‘be.disabled') www.arshadqa.com
  • 18. Verifying Page Title • --cy.title().should(‘eq’, ‘ ‘)
  • 19. Custom Waits • --cy.wait(miliseconds) • --npx cypress run --spec “cypress/integration/Demo_Project/Demo.js"
  • 20. Random Function (Math.random()*5000) • SSN • Priority • Unique value require for tests
  • 21. Object Oriented Programming in Cypress • Step 1: Create a class • Step 2: Add functions • Step 3: export that class so we can use it • Step 4: import that class in test case where we can to use • Step 5: Create a class object • Step6: Call class functions • Step 7: Run the main .js file and see (Note: .js file which is class, we can not directly run it) www.arshadqa.com
  • 22. Data Driven Testing • Files • Fixtures
  • 23. Working with Files • cy.writeFile() • cy.readFile() www.arshadqa.com
  • 24. Fixtures • Fixtures are used to store and manage test data. • Fixture files are located in cypress/fixtures by default but can be configured to another directory. • The test data is usually written inside a JSON file which can then be used throughout your tests www.arshadqa.com
  • 25. Cypress Dashboard • The Cypress Dashboard Service is an optional web-based companion to the Test Runner. • It provides timely, simple and powerful insights on all your tests run at a glance. With automatic parallelization and load balancing you can optimize CI and run significantly faster tests. • https://www.cypress.io/pricing/
  • 28. Cypress Dashboard Configuration • Step 1: Register with dashboard. cypress.io and get the project id and key • https://dashboard.cypress.io/ • Step 2: Enter the project id in Cypress.json file "projectId": "h245ts", • Step 3: Run the test cases from terminal • npx cypress run --record –key ffcbf60d-a72c-4a8d-a2ff-f1c8963eab46
  • 30. Step 1: Download Required npm Packages www.arshadqa.com npm install cypress-mochawesome-reporter junit-report-merger mocha-junit-reporter cypress-multi-reporters mocha
  • 31. Step 1: Download Required npm Packages cypress-multi-reporters: This package is used for configuring multiple reports in our case Junit reporter and HTML reporter. mocha-junit-reporter: Mocha Junit Reporter generates Junit XML file for each spec. junit-report-merger: Since the Mocha Junit Reporter generates a JUnit XML file for each spec we need to merge them all at the end to create a single XML file. cypress-mochawesome-reporter: This package helps to generate HTML reports.
  • 32. Step 2: Reports configuration in cypress.json • "reporter": "cypress-multi-reporters", • "reporterOptions": { • "reporterEnabled": "cypress-mochawesome-reporter, mocha-junit- reporter", • "cypressMochawesomeReporterReporterOptions": { • "reportDir": "cypress/reports", • "charts": true, • "reportPageTitle": "My Test Suite", • "embeddedScreenshots": true, • "html": true, www.arshadqa.com
  • 33. Step 2: Reports configuration in cypress.json • "json": true, • "inlineAssets": true • }, • "mochaJunitReporterReporterOptions": { • "mochaFile": "cypress/reports/junit/results-[hash].xml" • } • }, • "video": false • } www.arshadqa.com
  • 34. Step 3: Configure plugin/index.js File Project root folder > open cypress folder > open plugin folder > open index.js file www.arshadqa.com
  • 35. Step 3: Configure plugin/index.js File • //index.js inside plugin folder • const { beforeRunHook, afterRunHook } = require('cypress- mochawesome-reporter/lib'); • const exec = require('child_process').execSync; • module.exports = (on) => { • on('before:run', async (details) => { • console.log('override before:run'); • await beforeRunHook(details); www.arshadqa.com
  • 36. Step 3: Configure plugin/index.js File • //If you are using other than Windows remove below two lines • await exec("IF EXIST cypressscreenshots rmdir /Q /S cypressscreenshots") • await exec("IF EXIST cypressreports rmdir /Q /S cypressreports") • }); • on('after:run', async () => { • console.log('override after:run'); • //if you are using other than Windows remove below line (having await exec) • await exec("npx jrm ./cypress/reports/junitreport.xml ./cypress/reports/junit/*.xml"); • await afterRunHook(); • }); • }; www.arshadqa.com
  • 37. Step 4: Add an Entry Into support/index.js Navigate to cypress folder > open support folder > open index.js file www.arshadqa.com
  • 38. Step 4: Add an Entry Into support/index.js • //index.js inside support folder • import 'cypress-mochawesome-reporter/register'; www.arshadqa.com
  • 39. Step 5: Run Your Test Run your test with either npx cypress run command. www.arshadqa.com npx cypress run --spec “cypress/integration/Demo_Project/Demo.js"
  • 40. Step 6: Viewing HTML File • Project Root folder > cypress > reports > index.html • You can use this XML file when you integrate with CI/CD either Jenkins, Azure DevOps, or any other tools. www.arshadqa.com
  • 41. BDD – Cucumber – Installation and Setup • --npm install cypress-cucumber-preprocessor • In Cypress.JSON file add this "testFiles":"**/*.feature" • Create a file in integration folder for example “abc.feature” and folder with same name as feature file for example “abc” in integration folder. • Create a step definition file within the folder “abc” For example login.js • Note: Step definition file could be name anything as you wish
  • 42. Configuration • Please make use of cosmiconfig to create a configuration for the plugin, for example, by adding this section to your package.json: • "cypress-cucumber-preprocessor":{ • "nonGlobalStepDefinations": true • } • -npm install cosmiconfig
  • 43.
  • 44. Add it to your plugins: • cypress/plugins/index.js • const cucumber = require('cypress-cucumber-preprocessor').default • module.exports = (on, config) => { • on('file:preprocessor', cucumber()) • }
  • 45. BDD – Cucumber – Installation and Setup • To highlight Gherkin Keywords type “Cucumber” in search and install the extension
  • 46. Example Login Feature File 1 • Feature: Login • I want to log into WebSite • Scenario: WebSite login • Given I open WebSite login page • When I type in username and password • And I click on Sign in button • Then dashboard page should be shown
  • 48. Step Definition File • Given(‘ I open the WebSite login page’, () => { • --cy.visit (‘URL’) • {); • When (‘’,() => { • }); • When (‘’,() => { • }); • Then (‘’, () =>{ • });