<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Kailash Pathak</title>
    <description>The latest articles on DEV Community by Kailash Pathak (@kailashpathak).</description>
    <link>https://dev.to/kailashpathak</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F993432%2F7ef72158-9341-4143-8f9c-864bcf9301bc.jpeg</url>
      <title>DEV Community: Kailash Pathak</title>
      <link>https://dev.to/kailashpathak</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/kailashpathak"/>
    <language>en</language>
    <item>
      <title>How to Write Your First Cypress Test [With Examples]</title>
      <dc:creator>Kailash Pathak</dc:creator>
      <pubDate>Thu, 20 Jun 2024 12:16:15 +0000</pubDate>
      <link>https://dev.to/testmuai/how-to-write-your-first-cypress-test-with-examples-2p2e</link>
      <guid>https://dev.to/testmuai/how-to-write-your-first-cypress-test-with-examples-2p2e</guid>
      <description>&lt;p&gt;Choosing an ideal testing framework, especially with a different technology stack, can be challenging for new users, particularly those switching from other testing tools to Cypress. This shift might involve adapting to unfamiliar technological stacks. However, Cypress addresses this challenge by providing an in-built tool called ‘Cypress Studio’.&lt;/p&gt;

&lt;p&gt;There are two ways to write your first Cypress test:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Using ‘Cypress Studio’&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Writing your script&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;In this blog, we will discuss how a new user can start his journey in Cypress and efficiently write the first Cypress test. You will also see the implementation of Cypress tests on local machines and cloud grids.&lt;/p&gt;

&lt;h2&gt;
  
  
  What is Cypress Studio?
&lt;/h2&gt;

&lt;p&gt;Cypress Studio provides a user-friendly interface for test case creation. It is a record and playback tool that captures user interactions with the application being tested. Using Cypress Studio, you can record user interactions in JavaScript. Whatever the step you follow in UI, Cypress Studio automatically records the steps in the backend in the test file&lt;/p&gt;

&lt;p&gt;Here are some benefits of using Cypress Studio:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Record and Playback&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The interface supports a record-and-playback mechanism, allowing users to record their interactions with the application. This feature is particularly useful for users who may not have extensive programming knowledge, enabling them to create &lt;a href="https://www.lambdatest.com/learning-hub/test-scripts?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=june_20&amp;amp;utm_term=bh&amp;amp;utm_content=learning_hub" rel="noopener noreferrer"&gt;test scripts&lt;/a&gt; without manually writing code.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Codeless Test Automation&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;One of the primary advantages of Cypress Studio is its codeless approach. Users can create and edit test scripts without writing code, making it accessible to individuals with limited programming knowledge. This lowers the entry barrier for manual testers and non-developers to participate in &lt;a href="https://www.lambdatest.com/automation-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=june_20&amp;amp;utm_term=bh&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;test automation&lt;/a&gt;.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Reduce Learning Curve&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The simplicity and clarity of Cypress Studio’s interface reduce the learning curve for users new to &lt;a href="https://www.lambdatest.com/learning-hub/automation-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=june_20&amp;amp;utm_term=bh&amp;amp;utm_content=learning_hub" rel="noopener noreferrer"&gt;automated testing&lt;/a&gt;. This enables teams to onboard new members quickly and encourages broader team participation in the testing process.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Fast Script Creation&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Cypress Studio records all the steps of UI interaction so if someone wants to create the script fast he/she can record the script and can re-use the record script for further development.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Debugging the script&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://www.lambdatest.com/learning-hub/debugging?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=june_20&amp;amp;utm_term=bh&amp;amp;utm_content=learning_hub" rel="noopener noreferrer"&gt;Debugging &lt;/a&gt;in Cypress Studio involves examining and modifying the recorded script to ensure it accurately reflects the intended test scenario. Users can edit and debug the recorded script. This flexibility allows users to tweak tests as needed, which strikes a balance between codeless development and human scripting.&lt;br&gt;
&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/7CYgItuHq5M"&gt;
&lt;/iframe&gt;
&lt;br&gt;
In the next section, you will see how we can set up Cypress Studio.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;a href="https://www.lambdatest.com/test-website-on-different-browsers?utm_source=hashnode&amp;amp;utm_medium=organic&amp;amp;utm_campaign=june_20&amp;amp;utm_term=bh&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;**Test website on different browsers&lt;/a&gt; like Chrome, Safari, Firefox, and Opera for free on LambdaTest platform. Easily test on 3000+ desktop &amp;amp; mobile environments.**&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  Setting up Cypress Studio
&lt;/h2&gt;

&lt;p&gt;Before setting up Cypress Studio, you need to install Cypress. You can install Cypress using the following commands:&lt;/p&gt;

&lt;p&gt;npm install cypress --save-dev&lt;/p&gt;

&lt;p&gt;or&lt;/p&gt;

&lt;p&gt;yarn add cypress --dev&lt;/p&gt;

&lt;p&gt;In the screenshot below, you can see that the latest version of Cypress has been installed. However, when writing this blog on your first Cypress test, Cypress’s latest version was 13.6.2.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqewxalwybx9oljviysdm.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqewxalwybx9oljviysdm.png" width="800" height="462"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The next step is to enable Cypress Studio. To enable this feature, we must set &lt;em&gt;experimentalStudio:true&lt;/em&gt; in the configuration file.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; const { defineConfig } = require("cypress");
module.exports = defineConfig({
 e2e: {
   experimentalStudio:true,
   setupNodeEvents(on, config) {
     // implement node event listeners here
   },
 },
});
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxo6djgqril91z7k02kgn.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxo6djgqril91z7k02kgn.png" width="800" height="334"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We have updated the &lt;em&gt;cypress.config.js&lt;/em&gt; (configuration file)to enable the Cypress Studio feature. Now, the next step is to record the script.&lt;/p&gt;

&lt;h2&gt;
  
  
  Ways of Recording the Script
&lt;/h2&gt;

&lt;p&gt;We can record the script using Cypress Studio. Below are two options to record the script:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Create a test with Cypress Studio&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Add New Test&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Using the ‘Create test with Cypress Studio’ Option
&lt;/h2&gt;

&lt;p&gt;You should have some existing &lt;a href="https://www.lambdatest.com/learning-hub/test-case?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=june_20&amp;amp;utm_term=bh&amp;amp;utm_content=learning_hub" rel="noopener noreferrer"&gt;test cases&lt;/a&gt; before recording using the option ‘&lt;em&gt;Create test with Cypress Studio&lt;/em&gt;’ in Cypress Runner.&lt;/p&gt;

&lt;p&gt;Let’s run the following command to open &lt;a href="https://www.lambdatest.com/blog/cypress-cli-and-test-runner/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=june_20&amp;amp;utm_term=bh&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;Cypress Runner&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;yarn cypress open&lt;/p&gt;

&lt;p&gt;After opening the Cypress Runner, run an existing test case. As we run the command, it will open Cypress Runner with the option ‘&lt;em&gt;Create test with Cypress Studio.&lt;/em&gt;’&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fu6f79ulhlivx5lsfs0sy.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fu6f79ulhlivx5lsfs0sy.png" width="800" height="349"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Clicking on the ‘&lt;em&gt;Create test with Cypress Studio&lt;/em&gt;’ link in the Cypress Test Runner initiates Cypress Studio and prompts you to provide the URL of the application you want to test.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3200%2F0%2ALuwCM6O_Q7FclgSV.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3200%2F0%2ALuwCM6O_Q7FclgSV.png" width="800" height="239"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Let’s record the test scenario below.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Open the site &lt;a href="https://ecommerce-playground.lambdatest.io/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=june_20&amp;amp;utm_term=bh&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;https://ecommerce-playground.lambdatest.io/&lt;/a&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Click on My Account.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Enter User Name.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Enter Password.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;After logging in, log out of the application.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Once we record the above scenario, we will be asked to save the recorded commands.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3200%2F0%2AIoO-q2LuF6Dc3JB-.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3200%2F0%2AIoO-q2LuF6Dc3JB-.png" width="800" height="380"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Let’s save the command that is recorded by providing the recorded script’s name.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3200%2F0%2A7JcnuBY3fzdQW2O_.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3200%2F0%2A7JcnuBY3fzdQW2O_.png" width="800" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Once we save the recorded script, it is automatically saved under the path &lt;em&gt;‘e2e/LTCypressStudio’&lt;/em&gt;. This path indicates the location within your Cypress project where the test script file is stored.&lt;/p&gt;

&lt;p&gt;Below is the recorded script where you can see the generated code. Once the recording is done, it will end with line /*==== End Cypress Studio ==== */&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;describe('Cypress Studio Recorded Script', () =&amp;gt; {
/* ==== Test Created with Cypress Studio ==== */
it('LTCypressStudio', function() {
 /* ==== Generated with Cypress Studio ==== */
 cy.visit('https://ecommerce-playground.lambdatest.io/');
 cy.get('#widget-navbar-217834 &amp;gt; .navbar-nav &amp;gt; :nth-child(6) &amp;gt; .nav-link &amp;gt; .info &amp;gt; .title').click();
 cy.get('#input-email').clear('lambdatestnew@yopmail.com');
 cy.get('#input-email').type('lambdatestnew@yopmail.com');
 cy.get('#input-password').clear();
 cy.get('#input-password').type('Password1');
 cy.get('form &amp;gt; .btn').click();
 /* ==== End Cypress Studio ==== */
})
})
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;We have seen above one option to record the script by clicking on the link &lt;em&gt;‘Create test with Cypress Studio’&lt;/em&gt; from Cypress Runner.&lt;/p&gt;

&lt;p&gt;Let’s see the second option, i.e., ‘Add New Test’ to record the script.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Dive into the world of &lt;a href="https://www.lambdatest.com/free-online-tools/xpath-tester?utm_source=hashnode&amp;amp;utm_medium=organic&amp;amp;utm_campaign=june_20&amp;amp;utm_term=bh&amp;amp;utm_content=free_tool" rel="noopener noreferrer"&gt;XPath Tester&lt;/a&gt; to streamline your web scraping and automation projects. Discover its features, uses, and best practices for optimal performance.&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  Adding New Test
&lt;/h2&gt;

&lt;p&gt;This option is used when you want to create a completely new Cypress test. It lets you define and execute specific &lt;a href="https://www.lambdatest.com/learning-hub/test-scenario?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=june_20&amp;amp;utm_term=bh&amp;amp;utm_content=learning_hub" rel="noopener noreferrer"&gt;test scenarios&lt;/a&gt; in a new file.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3200%2F0%2AUrv_rb-PFFoVDsrD.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3200%2F0%2AUrv_rb-PFFoVDsrD.png" width="800" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;As we click on ‘Add New Test,’ it will ask us to enter the URL. Let’s record the scenario below.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Open the site &lt;a href="https://www.lambdatest.com/selenium-playground/auto-healing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=june_20&amp;amp;utm_term=bh&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;https://www.lambdatest.com/selenium-playground/auto-healing&lt;/a&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Enter User Name.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Enter Password.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Click on the Submit button.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3200%2F0%2ApiXFVordaClRnRpe.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3200%2F0%2ApiXFVordaClRnRpe.png" width="800" height="388"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;After recording, click Save Commands. Let’s give the name ‘LambdaTestAddNewTest.’&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3200%2F0%2AOV1OYJtfCKemetyD.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3200%2F0%2AOV1OYJtfCKemetyD.png" width="800" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Once we save the script by giving some name, the test case executes and passes successfully. Below is the recorded script by Cypress Studio.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; /* ==== Test Created with Cypress Studio ==== */
 it('https://www.lambdatest.com/selenium-playground/auto-healing', function() {
   /* ==== Generated with Cypress Studio ==== */
   cy.visit('https://www.lambdatest.com/selenium-playground/auto-healing');
   cy.get('#username').clear();
   cy.get('#username').type('LambdaTest');
   cy.get('#password').clear();
   cy.get('#password').type('Test@1234');
   cy.get('form &amp;gt; .flex &amp;gt; .bg-black').click();
   /* ==== End Cypress Studio ==== */
 });
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;h2&gt;
  
  
  Modifying the Existing Script
&lt;/h2&gt;

&lt;p&gt;Using Cypress Studio, we can add new scripts and update the existing script with more commands.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Add Commands to Test&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;This option is useful when adding Cypress commands to an existing test. It allows you to extend the functionality of an already defined test or modify its behavior by incorporating additional Cypress commands.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3200%2F0%2AaEPgdUE-FNKdhawt.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3200%2F0%2AaEPgdUE-FNKdhawt.png" width="800" height="307"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Let’s update one of the previously recorded scripts where we are login into &lt;a href="https://ecommerce-playground.lambdatest.io/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=june_20&amp;amp;utm_term=bh&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;https://ecommerce-playground.lambdatest.io/&lt;/a&gt;&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;it('LTCypressStudio', function() {
   /* ==== Generated with Cypress Studio ==== */
   cy.visit('https://ecommerce-playground.lambdatest.io/');
   cy.get('#widget-navbar-217834 &amp;gt; .navbar-nav &amp;gt; :nth-child(6) &amp;gt; .nav-link &amp;gt; .info &amp;gt; .title').click();
   cy.get('#input-email').clear('lambdatestnew@yopmail.com');
   cy.get('#input-email').type('lambdatestnew@yopmail.com');
   cy.get('#input-password').clear();
   cy.get('#input-password').type('Lambda123');
   /* ==== End Cypress Studio ==== */
 })
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Cover the below scenario to update the existing script using Cypress Studio.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;After logging in, search for the text ‘HP.’&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Click on the first item in the search results.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Click on Add to Cart.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Click on View Cart.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Click on ‘Add Commands to Test’ from Cypress Runner.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3200%2F0%2AhooICHWtUwAEVTTt.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3200%2F0%2AhooICHWtUwAEVTTt.png" width="800" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;As part of Cypress Studio, when we click ‘Add Commands to Test,’ the complete test case is rerun. In our case, the user is logged in to the site. After that, we can search for the product ‘HP,’ add it to the cart, and redirect to the View Cart page.&lt;/p&gt;

&lt;p&gt;The Cypress command log shows that each updated step is recorded with the ‘Save Commands’ button. Once you click the ‘Save Commands’ button, the script is updated with more steps.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3200%2F0%2Af9UBz9F6tr9A-keG.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3200%2F0%2Af9UBz9F6tr9A-keG.png" width="800" height="377"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The screenshot below shows that once the scenario is completed, the script will be updated with some more steps. You can see some more steps are added, so you can update the existing script using Cypress Studio. Below is the script that is recorded.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3200%2F0%2AmdghWhOP6k9qObv-.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3200%2F0%2AmdghWhOP6k9qObv-.png" width="800" height="321"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Cypress Studio is beneficial for those seeking to swiftly generate test scripts without needing to code, making it especially advantageous for novices getting started with Cypress.&lt;/p&gt;

&lt;p&gt;Despite being a handy tool for rapidly creating code-free test scripts, Cypress Studio encounters difficulties when handling intricate test scenarios or scenarios incorporating dynamic data.&lt;/p&gt;

&lt;p&gt;So far, we have seen how you can record scripts using the built-in tool Cypress Studio. In the next section, you will see how we can create a Cypress test case by writing our script.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Discover and evaluate JSONPath expressions with ease using the &lt;a href="https://www.lambdatest.com/free-online-tools/jsonpath-tester?utm_source=hashnode&amp;amp;utm_medium=organic&amp;amp;utm_campaign=june_20&amp;amp;utm_term=bh&amp;amp;utm_content=free_tool" rel="noopener noreferrer"&gt;JSONPath tester&lt;/a&gt; tool. Perfect for quick debugging and testing. Try for free now!&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  Writing First Cypress Test Script
&lt;/h2&gt;

&lt;p&gt;Writing Cypress scripts manually refers to crafting test code directly using JavaScript or TypeScript rather than relying on visual recording tools like Cypress Studio. Cypress uses &lt;a href="https://www.lambdatest.com/mocha-js?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=june_20&amp;amp;utm_term=bh&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;Mocha&lt;/a&gt; as its default &lt;a href="https://www.lambdatest.com/blog/automation-testing-frameworks/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=june_20&amp;amp;utm_term=bh&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;automation testing framework&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;When you install Cypress, it automatically includes Mocha, and you don’t need to install Mocha separately to use it with Cypress. Integrating Mocha with Cypress provides a structured and organized way to write end-to-end tests. Cypress leverages Mocha’s syntax, which includes &lt;em&gt;describe&lt;/em&gt; and &lt;em&gt;it&lt;/em&gt; blocks for test organization, as well as hooks for setup and teardown, to create a clear and readable testing structure.&lt;/p&gt;

&lt;p&gt;Before writing the script, we need to set up Cypress. Below are some of the steps that we have to follow.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 1: Install Cypress
&lt;/h2&gt;

&lt;p&gt;To write the script on your own, let’s set up Cypress using the following commands:&lt;/p&gt;

&lt;p&gt;npm install cypress —-save-dev&lt;/p&gt;

&lt;p&gt;or&lt;/p&gt;

&lt;p&gt;yarn add cypress —-dev&lt;/p&gt;

&lt;p&gt;The screenshot below shows that Cypress’s latest version was 13.6.2 when this blog on writing your first Cypress test was written.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2784%2F0%2A34LVz8B4tCYSYgeH.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2784%2F0%2A34LVz8B4tCYSYgeH.png" width="800" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;After installation, the folder structure looks like the one below, with different folders given in brief detail below.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2000%2F0%2Ag7flRhWfVfAWxIww.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2000%2F0%2Ag7flRhWfVfAWxIww.png" width="800" height="668"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The table below summarizes the purpose of each directory and file within the Cypress project.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2000%2F1%2AUuIwJGwW7nEtvr2_-2e1bg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2000%2F1%2AUuIwJGwW7nEtvr2_-2e1bg.png" width="800" height="427"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 2: Create a Test File
&lt;/h2&gt;

&lt;p&gt;Create a new test file under cypress/e2e/ to run the e2e test case. Let’s give a name to the file, e.g., &lt;em&gt;lambdatest_test_spec.cy.js&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2000%2F0%2AJyf0l4vRTaC5v-7N.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2000%2F0%2AJyf0l4vRTaC5v-7N.png" width="800" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 3: Write Your Test
&lt;/h2&gt;

&lt;p&gt;As we mentioned above, Cypress supports the Mocha framework. Therefore, we must grasp key concepts before proceeding to our initial script.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;describe() Block&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Mocha uses the &lt;em&gt;describe&lt;/em&gt; and &lt;em&gt;it&lt;/em&gt; blocks to structure test suites and individual test &lt;em&gt;cases.describe()&lt;/em&gt; is used to group tests.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2000%2F0%2AVvysMURvSxJ2jMK1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2000%2F0%2AVvysMURvSxJ2jMK1.png" width="800" height="375"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;it() Block&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;it()&lt;/em&gt; is used to define individual test cases.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2000%2F0%2AmASc7_pJjI8_CzIB.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2000%2F0%2AmASc7_pJjI8_CzIB.png" width="800" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Hooks&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Mocha supports hooks such as &lt;em&gt;before(), beforeEach(), after(),&lt;/em&gt; and &lt;em&gt;afterEach()&lt;/em&gt;. Cypress utilizes these hooks for setup and teardown tasks, like preparing the &lt;a href="https://www.lambdatest.com/blog/what-is-test-environment/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=june_20&amp;amp;utm_term=bh&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;test environment &lt;/a&gt;and cleaning up before running tests.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3102%2F0%2ACDivrY_G2Fvbdy7X.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3102%2F0%2ACDivrY_G2Fvbdy7X.png" width="800" height="825"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Assertions&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Mocha itself doesn’t include built-in assertion libraries. Cypress, however, provides its assertion library and extends Mocha with Chai assertions. Cypress uses Chai assertions to assert conditions in your tests.&lt;/p&gt;

&lt;p&gt;Some of the Examples are &lt;em&gt;.should(‘have.text’, ‘Expected Text’),.should(‘not.equal’, ‘Expected Text’),.should(‘exist’),.should(‘not.be.disabled’), .should(‘have.class’, ‘active’),&lt;/em&gt; etc.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3200%2F0%2AG1EQYhcm12wB7Dt_.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3200%2F0%2AG1EQYhcm12wB7Dt_.png" width="800" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Excluding the Tests&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;You can use the &lt;em&gt;.skip()&lt;/em&gt; method to exclude a specific Cypress test. This method can be applied to a Cypress test or a &lt;em&gt;description&lt;/em&gt; block.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3200%2F0%2AuTnPo3Q5Du3o04he.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3200%2F0%2AuTnPo3Q5Du3o04he.png" width="800" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Excluding the Tests&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;You can use the &lt;em&gt;.skip()&lt;/em&gt; method to exclude a specific Cypress test. This method can be applied to a Cypress test or a *description *block.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2872%2F0%2Aka6kIqx1qQm2zs_I.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2872%2F0%2Aka6kIqx1qQm2zs_I.png" width="800" height="446"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The &lt;em&gt;describe.skip()&lt;/em&gt; function in Cypress is used to skip the entire &lt;a href="https://www.lambdatest.com/learning-hub/test-suite" rel="noopener noreferrer"&gt;test suite&lt;/a&gt; within the *describe *block. Here’s an example:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2744%2F0%2AnKhYKmDf7978lO9I.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2744%2F0%2AnKhYKmDf7978lO9I.png" width="800" height="480"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Including the Tests&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;You can use the &lt;em&gt;.only() *method to run only specific tests or test suites during the &lt;a href="https://www.lambdatest.com/learning-hub/test-execution?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=june_20&amp;amp;utm_term=bh&amp;amp;utm_content=learning_hub" rel="noopener noreferrer"&gt;test execution&lt;/a&gt;. When you use *.only *on a Cypress test or a suite, only that test or suite will be executed, and all other tests without *.only&lt;/em&gt; will be skipped.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3200%2F0%2ANfhg78SFZp6XBtdu.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3200%2F0%2ANfhg78SFZp6XBtdu.png" width="800" height="529"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;So far, we have discussed some concepts required of a user writing his script for the first time. Let’s now put that knowledge into practice by crafting a simple Cypress Script.&lt;/p&gt;

&lt;p&gt;Let’s write the script for the below scenario.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Open the URL &lt;a href="https://ecommerce-playground.lambdatest.io/index.php?route=account/login?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=june_20&amp;amp;utm_term=bh&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;https://ecommerce-playground.lambdatest.io/index.php?route=account/login&lt;/a&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Enter Email.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Enter Password.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Click on the Login button.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Search product ‘VAIO.’&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Click the first product from the search result.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Verify that the searched product name should contain the text ‘Sony VAIO.’&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Open &lt;em&gt;lambdatest_test_spec.cy.js&lt;/em&gt; and write a simple Cypress test to visit a website, log in, and search for the product.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;/// &amp;lt;reference types="cypress" /&amp;gt;
describe("Lambdatest Login ",() =&amp;gt; {
 it("Open the URL", () =&amp;gt; {
   cy.visit(
     "https://ecommerce-playground.lambdatest.io/index.php?route=account/login"
   );
 });
 it("Login into the application", () =&amp;gt; {
   cy.get('[id="input-email"]').type("lambdatest@yopmail.com");
   cy.get('[id="input-password"]').type("lambdatest");
   cy.get('[type="submit"]').eq(0).click();
 });
 it("Search the Product", () =&amp;gt; {
   cy.get('[name="search"]').eq(0).type("VAIO");
   cy.get('[type="submit"]').eq(0).click();
 });
 it("Verify Product after search ", () =&amp;gt; {
   cy.contains("Sony VAIO");
 });
});
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Accessibility DevTools Chrome Extension redefines the standards of web &lt;a href="https://www.lambdatest.com/accessibility-devtools?utm_source=hashnode&amp;amp;utm_medium=organic&amp;amp;utm_campaign=june_20&amp;amp;utm_term=bh&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;accessibility testing chrome&lt;/a&gt;, your go-to Chrome extension on for developers, testers, and designers.&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;strong&gt;Code Walkthrough&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Let’s do a code walkthrough to understand the script in detail.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;describe Block&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;describe(“LambdaTest Login”, () =&amp;gt; { … }):&lt;/em&gt; This block represents a test suite named ‘Lambdatest Login’ that contains multiple Cypress test cases related to the LambdaTest login functionality*&lt;em&gt;.&lt;/em&gt;*&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3200%2F0%2AM2UZQRRtJmFt7xZS.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3200%2F0%2AM2UZQRRtJmFt7xZS.png" width="800" height="148"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Open the URL&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Visit the specified URL, which is the login page of the LambdaTest application.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3200%2F0%2AaEHVkJEVT9_8DZ-8.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3200%2F0%2AaEHVkJEVT9_8DZ-8.png" width="800" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Login into the application&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Enter the Email and Password input fields, enter the respective values, and click the Login button.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3200%2F0%2A865qQqSLSrQu7Pjm.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3200%2F0%2A865qQqSLSrQu7Pjm.png" width="800" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In the script, we used different &lt;a href="https://www.lambdatest.com/learning-hub/selenium-locators?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=june_20&amp;amp;utm_term=bh&amp;amp;utm_content=learning_hub" rel="noopener noreferrer"&gt;locator strategies&lt;/a&gt; to interact with elements on the web page. Locators identify and target HTML elements, allowing Cypress to perform actions like typing text, clicking buttons, etc.&lt;/p&gt;

&lt;p&gt;Here is the detail of each locator used here:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;[id=”input-email”]&lt;/em&gt;:&lt;/strong&gt; Targets the input element with the &lt;em&gt;ID&lt;/em&gt; attribute set to “&lt;em&gt;input-email&lt;/em&gt;.”&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3200%2F0%2ADoBlqa3Kdr7dTdpO.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3200%2F0%2ADoBlqa3Kdr7dTdpO.png" width="800" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;[id=”input-password”]&lt;/em&gt;:&lt;/strong&gt; This function targets the input element with the &lt;em&gt;ID&lt;/em&gt; attribute set to “&lt;em&gt;input-password&lt;/em&gt;.”&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3200%2F0%2AD4PMuChUKKglrlwt.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3200%2F0%2AD4PMuChUKKglrlwt.png" width="800" height="321"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;[type=”submit”]&lt;/em&gt;:&lt;/strong&gt; This function targets the Submit button(s). The &lt;em&gt;.eq(0)&lt;/em&gt; selects the first matching button.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3200%2F0%2AfFRpuVMEE32Y5-yu.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3200%2F0%2AfFRpuVMEE32Y5-yu.png" width="800" height="421"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Search the Product&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;You can search the data by entering a value in the input field, ‘VAIO,’ and clicking the Search button.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3200%2F0%2A0I5M7M9BDNwPkSDY.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3200%2F0%2A0I5M7M9BDNwPkSDY.png" width="800" height="218"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;**&lt;em&gt;[name=”search”]&lt;/em&gt;: **This function targets the input element with the *name *attribute set to “search.”&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3200%2F0%2AzZeZM_M02W--5_rQ.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3200%2F0%2AzZeZM_M02W--5_rQ.png" width="800" height="390"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;**&lt;em&gt;[type=”submit”]&lt;/em&gt;: *&lt;em&gt;This function targets the Submit button(s). The *.eq(0)&lt;/em&gt; selects the first matching button.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3200%2F0%2AvDW3fQ6T7tLFn7Ai.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3200%2F0%2AvDW3fQ6T7tLFn7Ai.png" width="800" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Verify Product after search&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Verifies that the search results page contains the text “Sony VAIO.”&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3200%2F0%2Atb1zaOnL0W_nnUQ2.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3200%2F0%2Atb1zaOnL0W_nnUQ2.png" width="800" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Discover best &lt;a href="https://www.lambdatest.com/blog/android-emulators-for-mac/?utm_source=hashnode&amp;amp;utm_medium=organic&amp;amp;utm_campaign=june_20&amp;amp;utm_term=bh&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;Android emulators Mac&lt;/a&gt;, comparing key features to find the perfect fit for your mobile app testing needs.&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  Step 4: Execute the Test Case
&lt;/h2&gt;

&lt;p&gt;There are different ways of executing the Cypress test cases.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Headed mode&lt;/strong&gt;: where we can see all executing steps in the browser window.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Headless mode&lt;/strong&gt;: where we execute tests without loading a complete web browser.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Running Test in Headed Mode
&lt;/h3&gt;

&lt;p&gt;To execute the Cypress test case in the headed mode locally, we must run the following command:&lt;/p&gt;

&lt;p&gt;yarn cypress open&lt;/p&gt;

&lt;p&gt;or&lt;/p&gt;

&lt;p&gt;npx cypress open&lt;/p&gt;

&lt;p&gt;As we run the command, it will open the below screen.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3200%2F0%2AiOglUV02ZePydIGS.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3200%2F0%2AiOglUV02ZePydIGS.png" width="800" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;There are two options: E2E testing and Component Testing.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.lambdatest.com/learning-hub/end-to-end-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=june_20&amp;amp;utm_term=bh&amp;amp;utm_content=learning_hub" rel="noopener noreferrer"&gt;E2E Testing&lt;/a&gt;: E2E testing allows users to simulate user interactions, navigate through the application, and validate the application’s behavior as a whole.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.lambdatest.com/learning-hub/component-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=june_20&amp;amp;utm_term=bh&amp;amp;utm_content=learning_hub" rel="noopener noreferrer"&gt;Component Testing&lt;/a&gt;: Component testing focuses on testing individual application components in isolation. Component testing aims to verify that each application part behaves as expected independently of the other components.&lt;/p&gt;

&lt;p&gt;Select E2E Testing from the above screenshot, then select the desired browser for testing. Finally, launch the Cypress Runner to initiate the testing environment.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3200%2F0%2A8YXFPlWvbxQlHd25.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3200%2F0%2A8YXFPlWvbxQlHd25.png" width="800" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Click on ‘lambdatest_test_spec.cy.js’ to start executing the tests, and finally, you will see all test steps passed.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3200%2F0%2ANBCCH-d0Hbal9dMd.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3200%2F0%2ANBCCH-d0Hbal9dMd.png" width="800" height="339"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Dive into automation testing using &lt;a href="https://www.lambdatest.com/blog/selenium-with-java/?utm_source=hashnode&amp;amp;utm_medium=organic&amp;amp;utm_campaign=june_20&amp;amp;utm_term=bh&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;Selenium Java&lt;/a&gt; with this detailed tutorial. Master the essentials to begin your Selenium Java testing journey confidently.&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3&gt;
  
  
  Running Test in Headless Mode
&lt;/h3&gt;

&lt;p&gt;By default, Cypress runs in ‘headless mode,’ where the browser runs in the background without opening a visible browser window.&lt;/p&gt;

&lt;p&gt;The command to run the Cypress test case in headless mode is:&lt;/p&gt;

&lt;p&gt;yarn cypress run&lt;/p&gt;

&lt;p&gt;or&lt;/p&gt;

&lt;p&gt;npx cypress run&lt;/p&gt;

&lt;p&gt;The screenshot below shows that all test cases are executed successfully in a headless browser.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3200%2F0%2A8PYD8YoETBHyUW2o.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3200%2F0%2A8PYD8YoETBHyUW2o.png" width="800" height="635"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;There are some other commands that you can use to execute the test cases.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Run a full test present in the e2e folder in the Headless mode:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Use the command:&lt;/p&gt;

&lt;p&gt;npx cypress run&lt;/p&gt;

&lt;p&gt;or&lt;/p&gt;

&lt;p&gt;yarn cypress run&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Run a particular test case on the default browser in the Headless browser:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The default browser is Electron when you run test cases in headless mode. Use the following command to execute a particular test case on the default browser:&lt;/p&gt;

&lt;p&gt;npx cypress run --spec "cypress/e2e/lambdatest/lambdatest_test_spec.cy.js"&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3200%2F0%2AUV7W6V1QTJMkUzZ_.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3200%2F0%2AUV7W6V1QTJMkUzZ_.png" width="800" height="601"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Selenium &lt;a href="https://www.lambdatest.com/learning-hub/webdriver?utm_source=hashnode&amp;amp;utm_medium=organic&amp;amp;utm_campaign=june_20&amp;amp;utm_term=bh&amp;amp;utm_content=learning_hub" rel="noopener noreferrer"&gt;WebDriver&lt;/a&gt;: Automate browser activities locally or remotely. Explore Selenium components, version 4, and its pivotal role in automated testing&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;strong&gt;Execute test case on a particular browser in the Headless mode:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Use the following command to execute a specific test case on a particular browser. In this case, we are running on the Chrome browser in headless mode.&lt;/p&gt;

&lt;p&gt;npx cypress run --browser chrome --spec "cypress/e2e/lambdatest/lambdatest_test_spec.cy.js"&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3200%2F0%2AMwiUXjJNqvKcBJO5.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3200%2F0%2AMwiUXjJNqvKcBJO5.png" width="800" height="519"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;So far, we have explored creating a test script using Cypress Studio and saw how to write the script manually. We have also reviewed different approaches for running these test cases in a local environment. Now, let’s see how we can execute the test cases in the cloud.&lt;/p&gt;

&lt;p&gt;Running Cypress test cases in the cloud has various benefits. Cloud-based testing platforms provide scalability, allowing you to scale your testing infrastructure based on the project’s needs. They also enable parallel testing, allowing you to run multiple tests concurrently.&lt;/p&gt;

&lt;p&gt;There are various cloud-based platforms in the market. LambdaTest emerges as a standout choice. LambdaTest is an AI-powered test orchestration and execution platform that lets you perform manual and &lt;a href="https://www.lambdatest.com/automation-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=june_20&amp;amp;utm_term=bh&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;automation testing&lt;/a&gt; at scale with over 3000+ browsers and OS combinations to help you automate Cypress test cases on the cloud. It also offers access to real devices and browsers, providing a more accurate simulation of how end-users will experience your web application.&lt;/p&gt;

&lt;h2&gt;
  
  
  How to Automate Your First Cypress Test on Cloud?
&lt;/h2&gt;

&lt;p&gt;Running Cypress test cases on the cloud is crucial for comprehensive and accurate testing of modern web applications. As cloud testing environments like LambdaTest gain prominence, it becomes imperative to validate that the infrastructure supports the intricacies of testing. This ensures that Cypress test cases can be tested in cloud-based environments, guaranteeing the application’s reliability and functionality in real-world scenarios.&lt;/p&gt;

&lt;p&gt;You can accelerate &lt;a href="https://www.lambdatest.com/blog/cypress-test-automation-framework/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=june_20&amp;amp;utm_term=bh&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;Cypress testing&lt;/a&gt; and reduce test execution time by multiple folds by running parallel tests on LambdaTest across multiple browsers and OS configurations.&lt;/p&gt;

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/86LQsMtBs5k"&gt;
&lt;/iframe&gt;
&lt;br&gt;
Subscribe to the &lt;a href="https://www.youtube.com/channel/UCCymWVaTozpEng_ep0mdUyw?sub_confirmation=1?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=june_20&amp;amp;utm_term=bh&amp;amp;utm_content=youtube" rel="noopener noreferrer"&gt;LambdaTest YouTube Channel&lt;/a&gt; for the latest updates on tutorials around &lt;a href="https://www.lambdatest.com/selenium-automation?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=june_20&amp;amp;utm_term=bh&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;Selenium testing&lt;/a&gt;, &lt;a href="https://www.lambdatest.com/cypress-e2e-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=june_20&amp;amp;utm_term=bh&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;Cypress e2e testing&lt;/a&gt;, and more.&lt;/p&gt;

&lt;p&gt;As we execute the test cases on the LambdaTest platform, we must configure our tests for the LambdaTest &lt;a href="https://www.lambdatest.com/cypress-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=june_20&amp;amp;utm_term=bh&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;Cypress cloud&lt;/a&gt; grid.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Prerequisite:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;You already have an &lt;a href="https://accounts.lambdatest.com/register" rel="noopener noreferrer"&gt;account on LambdaTest&lt;/a&gt; .&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;You have an access token to run test cases on LambdaTest.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The Username and Access key can be obtained from the &lt;a href="https://accounts.lambdatest.com/dashboard?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=june_20&amp;amp;utm_term=bh&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;LambdaTest Dashboard&lt;/a&gt;.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Learn &lt;a href="https://www.lambdatest.com/learning-hub/webdriverio?utm_source=hashnode&amp;amp;utm_medium=organic&amp;amp;utm_campaign=june_20&amp;amp;utm_term=bh&amp;amp;utm_content=learning_hub" rel="noopener noreferrer"&gt;WebdriverIO&lt;/a&gt; for web automation and empower yourself with in-depth knowledge for smooth execution.&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  Configuring Cypress Test on LambdaTest
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Step 1: Install the CLI&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The command-line interface of LambdaTest enables us to execute your Cypress tests on LambdaTest. Use the Cypress CLI command via npm, as shown below.&lt;/p&gt;

&lt;p&gt;npm install -g lambdatest-cypress-cli&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 2: Generate lambdatest-config.json&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Under the root folder, configure the browsers you want to run the tests. Use the *init *command to generate a sample lambdatest-config.json file or create one from scratch. Use the below command.&lt;/p&gt;

&lt;p&gt;lambdatest-cypress init&lt;/p&gt;

&lt;p&gt;In the generated lambdatest-config.json file, pass the information below. Fill in the required values in the &lt;em&gt;lambdatest_auth&lt;/em&gt;, &lt;em&gt;browsers&lt;/em&gt;, and &lt;em&gt;run_settings&lt;/em&gt;* ***sections to run your tests.&lt;/p&gt;

&lt;p&gt;In the file below, we pass three browsers (Chrome, Firefox, and Electron) and run the test case in two browsers simultaneously.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{
  "lambdatest_auth": {
     "username": "username",
     "access_key": "access_key"
  },
  "browsers": [
     {
        "browser": "Chrome",
        "platform": "Windows 11",
        "versions": [
           "latest-1"
        ]
     },
     {
        "browser": "Electron",
        "platform": "Windows 11",
        "versions": [
           "latest"
        ]
     },
     {
        "browser": "Firefox",
        "platform": "Windows 11",
        "versions": [
           "latest-1"
        ]
     }
  ],
  "run_settings": {
     "build_name": "Write First Script In Cypress",
     "parallels": 3,
     "specs": "./cypress/e2e/lambdatest/*.cy.js",
     "ignore_files": "",
     "network": true,
     "headless": false,
     "npm_dependencies": {
        "cypress": "13.6.2"
     }
  },
  "tunnel_settings": {
     "tunnel": false,
     "tunnel_name": null
  }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Run the below command to execute the test case on the LambdaTest.&lt;/p&gt;

&lt;p&gt;lambdatest-cypress run --sync=true&lt;/p&gt;

&lt;p&gt;As we run the above command, test execution starts, and test cases are run in parallel on the LambdaTest platform.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Learn to download and setup &lt;a href="https://www.lambdatest.com/blog/selenium-chromedriver-automation-testing-guide/?utm_source=hashnode&amp;amp;utm_medium=organic&amp;amp;utm_campaign=june_20&amp;amp;utm_term=bh&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;Selenium ChromeDriver&lt;/a&gt; to effortlessly run Selenium tests on Chrome browser.&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  Test Case Execution
&lt;/h2&gt;

&lt;p&gt;As we execute the test cases in the screenshot below, both test cases start executing in browsers (Chrome, Firefox) parallelly, and we can see the detailed report in the LambdaTest dashboard.&lt;/p&gt;

&lt;p&gt;LambdaTest Web Automation Dashboard offers users a convenient and intuitive interface to oversee test results, review test outcomes, and utilize various platform features. It enables live interactive testing, offering users a real-time view of the website or web application they are testing on a specific browser and operating system.&lt;/p&gt;

&lt;p&gt;The screenshot below shows the test case starting to execute in browsers (Chrome, Firefox, and Electron).&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3200%2F0%2AkfO_0x4ObLjRrF3E.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3200%2F0%2AkfO_0x4ObLjRrF3E.png" width="800" height="356"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The screenshot below shows that test cases are passed in the browser (Chrome, Firefox, and Electron).&lt;/p&gt;

&lt;p&gt;Here is the console log of executed test cases in the Chrome browser. You can see that three of the test cases have passed on the LambdaTest Grid.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3200%2F0%2AaCu49up7jJxMIF02.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3200%2F0%2AaCu49up7jJxMIF02.png" width="800" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Here is the console log of executed test cases in the Firefox browser. You can see that three test cases have passed on the LambdaTest Grid.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3200%2F0%2Al1TIcJtRLma-GQku.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3200%2F0%2Al1TIcJtRLma-GQku.png" width="800" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Here is the console log of executed test cases in the Electron browser. You can see that three of the test cases have passed on the LambdaTest Grid.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3200%2F0%2AHNqRkvQiVa_Mfg2C.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3200%2F0%2AHNqRkvQiVa_Mfg2C.png" width="800" height="446"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If you’re a developer or tester looking to elevate your skills with Cypress, consider diving into the &lt;a href="https://www.lambdatest.com/certifications/cypress-101?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=june_20&amp;amp;utm_term=bh&amp;amp;utm_content=certification" rel="noopener noreferrer"&gt;Cypress 101 certification&lt;/a&gt; to stay ahead of the game.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Explore the &lt;a href="https://www.lambdatest.com/learning-hub/junit-tutorial?utm_source=hashnode&amp;amp;utm_medium=organic&amp;amp;utm_campaign=june_20&amp;amp;utm_term=bh&amp;amp;utm_content=learning_hub" rel="noopener noreferrer"&gt;JUnit testing&lt;/a&gt; framework along with its architecture, JUnit 5 enhancement features and their differences, and more.&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;You have taken a comprehensive journey into &lt;a href="https://www.lambdatest.com/blog/cypress-test-automation-framework/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=june_20&amp;amp;utm_term=bh&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;Cypress test automation&lt;/a&gt;, breaking down the process step by step with live examples. You have also seen how to write the test case using the Cypress built-in tool ‘Cypress Studio’ and the manual script-writing process. Furthermore, you’ve explored the steps a new user can take to commence their Cypress experience and outlined effective strategies for starting to write scripts. Also, different ways of recording the script and how to update the existing script.&lt;/p&gt;

&lt;p&gt;Furthermore, we’ve discussed the integration of LambdaTest, an AI-powered test orchestration and execution platform, and how it enhances the capabilities of &lt;a href="https://www.lambdatest.com/blog/cypress-test-automation-framework/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=june_20&amp;amp;utm_term=bh&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;Cypress automation&lt;/a&gt;. By seamlessly running our Cypress tests across different browser versions and platforms, you can ensure our applications’ compatibility and reliability in diverse environments. This integration empowers you to deliver high-quality web experiences to users across the digital landscape.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;In this tutorial, learn how to &lt;a href="https://www.lambdatest.com/blog/how-to-automate-android-apps-using-appium/?utm_source=hashnode&amp;amp;utm_medium=organic&amp;amp;utm_campaign=june_20&amp;amp;utm_term=bh&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;Andriod automation&lt;/a&gt; apps using Appium framework.&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  Frequently Asked Questions (FAQs)
&lt;/h2&gt;

&lt;h3&gt;
  
  
  What is Cypress testing for?
&lt;/h3&gt;

&lt;p&gt;Cypress testing is primarily used to automate the testing of web applications. It allows developers and QA engineers to write, run, and debug tests directly within the browser. Cypress provides a comprehensive testing framework that facilitates end-to-end testing, integration testing, and unit testing of web applications. It enables testers to simulate user interactions, such as clicking buttons, filling out forms, navigating through the application, and then asserting expected behaviors and outcomes. Overall, Cypress testing helps ensure web application functionality, performance, and reliability across various browsers and environments.&lt;/p&gt;

&lt;h3&gt;
  
  
  What are Cypress function tests?
&lt;/h3&gt;

&lt;p&gt;Cypress function tests, also known as functional tests, are automated tests used to verify the functionality of web applications. In Cypress, function tests involve writing test scripts to simulate user interactions with the application’s features and functionalities. These tests validate whether the application behaves correctly according to its specifications and requirements.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Explore our comprehensive guide on Selenium testing. Learn what is &lt;a href="https://www.lambdatest.com/selenium?utm_source=hashnode&amp;amp;utm_medium=organic&amp;amp;utm_campaign=june_20&amp;amp;utm_term=bh&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;Selenium&lt;/a&gt;, its architecture, benefits, and how to automate web browsers with this open-source suite.&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

</description>
      <category>cypress</category>
      <category>beginners</category>
      <category>tutorial</category>
      <category>programming</category>
    </item>
    <item>
      <title>How to Handle Shadow DOM in Cypress</title>
      <dc:creator>Kailash Pathak</dc:creator>
      <pubDate>Thu, 07 Dec 2023 20:07:04 +0000</pubDate>
      <link>https://dev.to/testmuai/how-to-handle-shadow-dom-in-cypress-3a4j</link>
      <guid>https://dev.to/testmuai/how-to-handle-shadow-dom-in-cypress-3a4j</guid>
      <description>&lt;p&gt;The concept of componentization has revolutionized website development, completely transforming how they are built. At the heart of this revolutionary shift is the introduction of Shadow DOM, a key component in this paradigm change. With Shadow DOM’s powerful method, developers can isolate styles, scripts, and markup within specific components. This encapsulation is a barrier, effectively shielding these components from the broader scope and avoiding accidental interference. The introduction of Shadow DOM marks a significant advancement in web development practices.&lt;/p&gt;

&lt;p&gt;Developers may design modular and isolated components using Shadow DOM, guaranteeing their independence from the global scope. In addition to improving security, this separation makes maintenance easier and enables developers to concentrate on specific components without worrying about other variables interfering with their operation.&lt;/p&gt;

&lt;p&gt;When it comes to automating elements within the Shadow DOM, it can be quite challenging compared to elements in the regular DOM. However, &lt;a href="https://www.lambdatest.com/learning-hub/cypress-tutorial?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=dec_07&amp;amp;utm_term=bh&amp;amp;utm_content=learning_hub" rel="noopener noreferrer"&gt;Cypress&lt;/a&gt; provides a solution for automating elements under the Shadow DOM.&lt;/p&gt;

&lt;p&gt;In this blog, we will explore the complication of automating Shadow DOM in Cypress, a powerful &lt;a href="https://www.lambdatest.com/learning-hub/end-to-end-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=dec_07&amp;amp;utm_term=bh&amp;amp;utm_content=learning_hub" rel="noopener noreferrer"&gt;end-to-end testing&lt;/a&gt; framework.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Don’t waste time decoding binary data manually. Try our &lt;a href="https://www.lambdatest.com/free-online-tools/binary-to-text?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=dec_07&amp;amp;utm_term=bh&amp;amp;utm_content=free_online_tools" rel="noopener noreferrer"&gt;Binary to Text&lt;/a&gt; Converter tool to convert binary data to text. No more tedious manual conversion needed!&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  What is a Document Object Model (DOM)?
&lt;/h2&gt;

&lt;p&gt;The &lt;a href="https://www.lambdatest.com/blog/document-object-model/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=dec_07&amp;amp;utm_term=bh&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;Document Object Model (DOM&lt;/a&gt;) is fundamentally a programming interface that web developers are given access to by browsers. It displays the document’s structure as a tree of objects, each representing a different aspect of the document, such as its components, attributes, and textual content. When it comes to web pages, developers can dynamically interact with them, altering their appearance and functionality in real-time. This is made possible by the hierarchical structure of web pages.&lt;/p&gt;

&lt;p&gt;DOM serves as a fundamental interface for programs to dynamically manipulate the structure, style, and content of documents on the web. It empowers developers to create, read, update, and delete elements and attributes within a web page, enabling interactivity and dynamism. This dynamic capability of the DOM is crucial for crafting interactive web applications. By harnessing programming languages such as JavaScript, developers can access and modify the DOM, allowing them to build responsive and interactive web applications with unparalleled flexibility and power.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Document:&lt;/strong&gt; The web page you see in your browser is a document. When a web page is loaded, the browser creates a DOM of the page.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Object:&lt;/strong&gt; In the context of the DOM, an “Object” represents every element and component of a web page. These objects include paragraphs, headings, images, buttons, forms, etc. Each of these objects can be manipulated using code.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Model:&lt;/strong&gt; The DOM represents the document so that programs can change its structure, style, and content while in the browser. It provides a way for programs to manipulate the structure, style, and content of web documents.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3200%2F0%2AGzVwz2qDQfiqYJUt.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3200%2F0%2AGzVwz2qDQfiqYJUt.png" width="800" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In the DOM, every branch within the tree structure leads to a node, which is a fundamental unit. These nodes are pivotal elements in the DOM, encapsulating various objects and data.&lt;/p&gt;

&lt;p&gt;Each node represents a distinct document part, such as elements, attributes, and text content. This hierarchical arrangement allows web browsers to interpret and manipulate pages, enabling dynamic content and interactive user experiences.&lt;/p&gt;

&lt;p&gt;Let us take an example of an HTML page. In this example, the HTML document contains a head section with a title element, setting the page title to “A simple web page”. The body section contains a heading element (&amp;lt; &lt;em&gt;h1 *&amp;gt;) with the text “Hello LambdaTest” and a paragraph element (&amp;lt; *p&lt;/em&gt; &amp;gt;) with the text “How are you LambdaTest”. This HTML code would display a webpage with the specified content when rendered in a web browser.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;html lang=“en”&amp;gt;
   &amp;lt;head&amp;gt;
      &amp;lt;title&amp;gt;A simple web page&amp;lt;/title&amp;gt;
   &amp;lt;/head&amp;gt;
   &amp;lt;body&amp;gt;
      &amp;lt;h1&amp;gt;Hello LambdaTest&amp;lt;/h1&amp;gt;
      &amp;lt;p&amp;gt;How are you LambdaTest&amp;lt;/p&amp;gt;
   &amp;lt;/body&amp;gt;
&amp;lt;/html&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;As mentioned above, a logical tree of this HTML structure would look like this.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3200%2F0%2ARJ2nmtlM4pcHoYPq.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3200%2F0%2ARJ2nmtlM4pcHoYPq.png" width="800" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Need to convert CSV to JSON? Try our free&lt;a href="https://www.lambdatest.com/free-online-tools/csv-to-json?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=dec_07&amp;amp;utm_term=bh&amp;amp;utm_content=free_online_tools" rel="noopener noreferrer"&gt; CSV to JSON&lt;/a&gt; converter tool to convert your CSV files to JSON format. Simple and easy to use. Try it now for free!&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  What is a Shadow DOM?
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://www.lambdatest.com/blog/shadow-dom-in-selenium/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=dec_07&amp;amp;utm_term=bh&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;Shadow DOM&lt;/a&gt; stands for Shadow Document Object Model. It’s a web standard that offers a scoped subtree within a document, meaning that the DOM elements inside a Shadow DOM are hidden from the main document (&amp;amp; vice-versa). This encapsulation helps developers create widgets (or other components) with encapsulated styles and behaviors without worrying about conflicts with the styles or scripts of the main document (or other components).&lt;/p&gt;

&lt;p&gt;It is particularly useful in web development when developers have to create isolated components with their styles and behavior, preventing conflicts with the styles and scripts of the main document or other components on the same page.&lt;/p&gt;

&lt;p&gt;Shadow DOM enables the creation of multiple shadow trees alongside the standard document tree, representing the DOM structure of the entire project. Each tree possesses a root node, known as the shadow root, housing its unique elements and styling. These trees are linked to specific elements within the parent document tree or other shadow trees, with these connecting nodes referred to as shadow hosts. The demarcation line separating the regular DOM and the Shadow DOM is termed the shadow boundary.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3200%2F0%2AQNLV7PcD8Erod4ep.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3200%2F0%2AQNLV7PcD8Erod4ep.png" width="800" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Convert your JSON files to CSV format in seconds with our easy-to-use &lt;a href="https://www.lambdatest.com/free-online-tools/json-to-csv?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=dec_07&amp;amp;utm_term=bh&amp;amp;utm_content=free_online_tools" rel="noopener noreferrer"&gt;JSON to CSV&lt;/a&gt; Converter. It’s fast, reliable, and user-friendly, making data conversion simple.&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Here are some of the key components of Shadow DOM:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Shadow Host&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The regular DOM element to which a Shadow DOM is attached is the Shadow Host. It’s the element where the Shadow DOM is attached, effectively encapsulating the elements inside it.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Shadow Tree&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Inside the Shadow DOM, there is a Shadow Tree. This tree comprises the encapsulated DOM elements and their associated styles and behavior.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Shadow Root&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The shadow root is the root node of the shadow tree. It is a gateway between the Shadow DOM and the main document’s DOM.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Shadow Boundary&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;At this point, we transition from the Shadow DOM to the familiar territory of the regular DOM. Elements inside the Shadow DOM can’t be accessed or styled from outside the Shadow DOM unless specific mechanisms are provided.&lt;/p&gt;

&lt;h2&gt;
  
  
  Benefits of Shadow DOM
&lt;/h2&gt;

&lt;p&gt;Shadow DOM offers several benefits in web development. Here are some key benefits:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Encapsulation&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Protects DOM and styles from outside styles and scripts, preventing conflict. It also prevents styles and scripts from the outer document from leaking into the components, causing unintended styles and behavior.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Isolation&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Gives styles and scripts limited scope, avoiding clashes with global styles and scripts, as globally applied CSS and JavaScript may cause name conflicts and unwanted side effects.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Reusability&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Enables the creation of self-contained, reusable components that can be safely inserted into other web application components without worrying about style inconsistencies.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Simplified Styling&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Makes style easier by letting you create CSS for a single component without worrying about how it will affect the rest of the document, as traditional styling might require complex selectors to avoid conflicts.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;From &lt;a href="https://www.lambdatest.com/free-online-tools/sql-to-json?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=dec_07&amp;amp;utm_term=bh&amp;amp;utm_content=free_online_tools" rel="noopener noreferrer"&gt;SQL to JSON&lt;/a&gt; in a snap! Convert SQL queries to JSON effortlessly with our SQL to JSON converter, enhancing compatibility and data interchange. Try it now!&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Let’s explore an example that demonstrates the process of attaching Shadow DOM to HTML and how it helps encapsulate the structure and styles of HTML.&lt;/p&gt;

&lt;p&gt;Consider a simple example where you want to create a custom button component encapsulated within Shadow DOM:&lt;/p&gt;

&lt;p&gt;In this example, we define a custom button component &lt;em&gt;(&amp;lt; my-button &amp;gt;)&lt;/em&gt; that encapsulates its HTML structure and styles using Shadow DOM. The button’s appearance and behavior are isolated from the rest of the page, making it a self-contained component that can be used without interfering with the global CSS or JavaScript.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;!DOCTYPE html&amp;gt;
&amp;lt;html&amp;gt;
&amp;lt;head&amp;gt;
&amp;lt;title&amp;gt;Shadow DOM Example&amp;lt;/title&amp;gt;
&amp;lt;/head&amp;gt;
&amp;lt;body&amp;gt;
&amp;lt;my-button&amp;gt;&amp;lt;/my-button&amp;gt;
&amp;lt;/body&amp;gt;
&amp;lt;/html&amp;gt;


&amp;lt;script&amp;gt;
// Create a new custom element using the CustomElements API
class MyButton extends HTMLElement {
constructor() {
super();


// Create a Shadow DOM
const shadow = this.attachShadow({ mode: 'open' });


// Create a button element inside the Shadow DOM
const button = document.createElement('button');
button.textContent = 'Hi 👋 Click On Me';


// Add some styles to the Shadow DOM
const style = document.createElement('style');
style.textContent = `
button {
background-color: blue;
color: white;
padding: 10px 20px;
border: none;
cursor: pointer;
}
`;


// Attach the button and style to the Shadow DOM
shadow.appendChild(style);
shadow.appendChild(button);
}
}


// Define the custom element
customElements.define('my-button', MyButton);
&amp;lt;/script&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Here’s a breakdown of the code:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;The HTML document defines a &lt;em&gt;&amp;lt; my-button &amp;gt;&lt;/em&gt; custom element inside the .&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;In the &lt;em&gt;&amp;lt; script &amp;gt;&lt;/em&gt; block, a new custom element, *MyButton *is created by extending the *HTMLElement *class. The constructor of *MyButton *sets up the Shadow DOM and creates a button element inside it.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Inside the Shadow DOM, a button element is created and styled with a blue background, white text, padding, no border, and a pointer cursor.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;The custom element is defined using &lt;em&gt;customElements.define (‘ my-button ‘, MyButton)&lt;/em&gt;;, associating the custom element tag name &lt;em&gt;&amp;lt; my-button &amp;gt;&lt;/em&gt; with the &lt;em&gt;MyButton&lt;/em&gt; class.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Get faster loading times and better user experience with our efficient &lt;a href="https://www.lambdatest.com/free-online-tools/json-stringify?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=dec_07&amp;amp;utm_term=bh&amp;amp;utm_content=free_online_tools" rel="noopener noreferrer"&gt;JSON Stringify&lt;/a&gt; tool. Quickly compress your JSON data with ease and optimize your website now.&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Output:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The ‘Hi 👋 Click On Me’ button is inside the Shadow DOM.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3200%2F0%2Ajn_D420tPf0fzsPU.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3200%2F0%2Ajn_D420tPf0fzsPU.png" width="800" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Before delving into how to handle Shadow DOM elements using Cypress, it’s crucial to understand how to access these elements. The upcoming explanation will illuminate these challenges and solutions for effective Shadow DOM element handling in Cypress.&lt;/p&gt;

&lt;h2&gt;
  
  
  How to Access Shadow DOM Elements?
&lt;/h2&gt;

&lt;p&gt;Before discussing how we can handle Shadow DOM in Cypress, we must discuss what will happen if a user tries to access Shadow DOM elements without using the method that is provided by Cypress to handle these elements.&lt;/p&gt;

&lt;p&gt;Let’s examine the consequences of attempting to directly access Shadow DOM in Cypress, with detailed examples below.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Use Case 1&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Let’s take an example of the &lt;a href="https://www.lambdatest.com/selenium-playground/shadow-dom?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=dec_07&amp;amp;utm_term=bh&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;LambdaTest Playground&lt;/a&gt;, where we have to enter data in the Name and Email field.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Open the site &lt;a href="https://www.lambdatest.com/selenium-playground/shadow-dom" rel="noopener noreferrer"&gt;https://www.lambdatest.com/selenium-playground/shadow-dom&lt;/a&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Enter data in the Name field.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Enter data in the Email field.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Let’s inspect the fields Name and Email. The screenshot below shows the Name and Email fields inside the shadow DOM.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3200%2F0%2A0x_wuCG1qbLegH8r.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3200%2F0%2A0x_wuCG1qbLegH8r.png" width="800" height="348"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3200%2F0%2ASjnEEA4HCxFQIjyT.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3200%2F0%2ASjnEEA4HCxFQIjyT.png" width="800" height="383"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Use our free online &lt;a href="https://www.lambdatest.com/free-online-tools/random-number-generator?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=dec_07&amp;amp;utm_term=bh&amp;amp;utm_content=free_online_tools" rel="noopener noreferrer"&gt;Random Number Generator&lt;/a&gt; tool to create unique non-repeating random numbers. Input your lower and upper range and get numbers with a click.&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Let’s write Cypress code to enter data in the Name and Email text field and execute the code locally.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;it('Enter data in Field Name and Email', () =&amp;gt; {
cy.visit('https://www.lambdatest.com/selenium-playground/shadow-dom')
cy.get('[type="text"]').find('input[placeholder="Name"]').type('LambdaTest')
cy.get('[type="text"]').find('input[placeholder="Email"]').type('LambdaTest@qa.com'})
})
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Upon running the code, the error &lt;em&gt;"Expected to find element: #input, but never found it. Queried from:"&lt;/em&gt; appears in the command log below. The error occurs because the fields are within Shadow DOM.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3200%2F0%2AFH1lIS_S_vQtyPxX.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3200%2F0%2AFH1lIS_S_vQtyPxX.png" width="800" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3200%2F0%2Ahfh5fxIi1nswqrUy.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3200%2F0%2Ahfh5fxIi1nswqrUy.png" width="800" height="451"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Use Case 2&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Let’s take another example of the &lt;a href="https://www.lambdatest.com/selenium-playground/shadow-dom?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=dec_07&amp;amp;utm_term=bh&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;LambdaTest Playground&lt;/a&gt;, where we enter data in Sign Up Form fields inside the shadow DOM.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Open the site &lt;a href="https://www.lambdatest.com/selenium-playground/shadow-dom" rel="noopener noreferrer"&gt;https://www.lambdatest.com/selenium-playground/shadow-dom&lt;/a&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Enter data in the Username Field.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Enter data in the Email Field.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Enter data in the Password Field.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Enter data in the Confirm Password Field.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Let’s inspect the field. In the screenshot below, you can see that the Username and other fields are inside the shadow DOM&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3200%2F0%2Ax5q-kCQYSvYso6iu.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3200%2F0%2Ax5q-kCQYSvYso6iu.png" width="800" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Let’s write Cypress code to enter data in the Username, Email, Password, and Confirm Password text fields.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;it("Enter data in Fields Which are Inside the Shadow DOM ", () =&amp;gt; {
cy.visit("https://www.lambdatest.com/selenium-playground/shadow-dom");
cy.get('[name="username"]').type("LambdaTest", { force: true });
cy.get('[name="email"]').type("LambdaTest@qa.com", { force: true });
cy.get('[name="password"]').type("LambdaTest123", { force: true });
cy.get('[name="confirm_password"]').type("LambdaTest123", { force: true });
});
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Let’s run the above code. The screenshot below shows that the error displays &lt;em&gt;Timed out retrying after 4000ms: Expected to find element: [name=”username”],&lt;/em&gt; but never found it. The reason is that fields are inside the Shadow DOM.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3200%2F0%2AvkqTpDAIUkX4ZsBF.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3200%2F0%2AvkqTpDAIUkX4ZsBF.png" width="800" height="370"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Before explaining how we can solve the above issue, it’s mandatory to understand the method we can use to access Shadow DOM elements.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Need to encode your text into UTF-8 format? Use our &lt;a href="https://www.lambdatest.com/free-online-tools/utf8-encode?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=dec_07&amp;amp;utm_term=bh&amp;amp;utm_content=free_online_tools" rel="noopener noreferrer"&gt;UTF-8 Encode&lt;/a&gt; tool to encode your text for seamless communication across all platforms and devices. Try it for free today.&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  Methods for Handling Shadow DOM
&lt;/h2&gt;

&lt;p&gt;Below is the syntax to access the Shadow element. Let’s see the methods that are used in accessing the element that is inside the Shadow DOM with detail example&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Syntax:&lt;/strong&gt;&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;.shadow(selector)
.shadow(selector, options)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;Example:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Cypress provides a way to traverse into the Shadow DOM of an element for testing purposes. To interact with elements inside the Shadow DOM in Cypress, you can use the .*shadow() *command.&lt;/p&gt;

&lt;p&gt;Assuming you have an element with an ID of ‘my-element’ inside a Shadow DOM:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;my-element&amp;gt;
#shadow-root (open)
&amp;lt;div class="content"&amp;gt;Hi LambdaTest Content inside shadow DOM&amp;lt;/div&amp;gt;
&amp;lt;/my-element&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;To traverse into the Shadow DOM and interact with the element with class content, you can use the &lt;em&gt;.shadow()&lt;/em&gt; command in your Cypress test.&lt;/p&gt;

&lt;p&gt;In this example, &lt;em&gt;cy.get(‘my-element’).shadow()&lt;/em&gt; is used to traverse into the Shadow DOM of the &lt;em&gt;my-element&lt;/em&gt; and find the element with class content inside the Shadow DOM in Cypress.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// Your Cypress test
it('should interact with an element inside shadow DOM', () =&amp;gt; {
// Visit your webpage
cy.visit('http://your-app-url');


// Find the host element with ID "my-element"
cy.get('my-element').shadow().find('.content').should('have.text', 'Hi LambdaTest Content inside shadow DOM');


// Perform interactions or assertions on the element inside the shadow DOM
// For example, click the element inside the shadow DOM
cy.get('my-element').shadow().find('.content').click();
});
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;In the next section, you will see how we can handle the elements inside Shadow DOM in Cypress using the above-mentioned methods.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Convert your URLs into a secure and easy-to-read format with our &lt;a href="https://www.lambdatest.com/free-online-tools/url-encode?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=dec_07&amp;amp;utm_term=bh&amp;amp;utm_content=free_online_tools" rel="noopener noreferrer"&gt;URL Encode&lt;/a&gt; tool. Make sharing links easier and secured. Simply input your URL and let us do the rest!&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  Handling Shadow DOM in Cypress
&lt;/h2&gt;

&lt;p&gt;So far, you have seen an issue accessing the elements under the Shadow DOM. In Cypress, there are various methods to access Shadow DOM elements. The upcoming section will elaborate on these methods, providing a comprehensive understanding of how to interact with Shadow DOM elements effectively.&lt;/p&gt;

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/_ps5N3RoF1A"&gt;
&lt;/iframe&gt;
&lt;br&gt;
Below, you will see different ways to handle Shadow DOM in Cypress.&lt;/p&gt;
&lt;h2&gt;
  
  
  Using the .shadow() method
&lt;/h2&gt;

&lt;p&gt;Let’s take the same example and use the shadow() command to enter data in the Name and Email field.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Open the site &lt;a href="https://www.lambdatest.com/selenium-playground/shadow-dom" rel="noopener noreferrer"&gt;https://www.lambdatest.com/selenium-playground/shadow-dom&lt;/a&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Enter data in the Username Field.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Enter data in the Email Field.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Enter data in the Password Field.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Enter data in the Confirm Password Field.&lt;/p&gt;

&lt;p&gt;describe("Enter data in Fields Inside Shadow DOM Using shadow() method ", () =&amp;gt; {&lt;br&gt;
beforeEach(() =&amp;gt; {&lt;br&gt;
cy.visit("&lt;a href="https://www.lambdatest.com/selenium-playground/shadow-dom%22" rel="noopener noreferrer"&gt;https://www.lambdatest.com/selenium-playground/shadow-dom"&lt;/a&gt;);&lt;br&gt;
});&lt;br&gt;
it("Enter data in all Fields", () =&amp;gt; {&lt;br&gt;
cy.get("shadow-signup-form").shadow().find('input[name="username"]').type("Kailash", { for,ce: true });&lt;br&gt;
cy.get("shadow-signup-form").shadow().find('input[name="email"]').type("&lt;a href="mailto:lambdatest@qa.com"&gt;lambdatest@qa.com&lt;/a&gt;", { force: true });&lt;br&gt;
cy.get("shadow-signup-form").shadow().find('input[name="password"]').type("lambdatest@123");&lt;br&gt;
cy.get("shadow-signup-form").shadow().find('input[name="confirm_password"]').type("lambdatest@123");&lt;br&gt;
});&lt;br&gt;
});&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Code Walkthrough&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Here’s what each part does:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;describe(“Enter data in Fields Inside Shadow DOM Using shadow() method”, () =&amp;gt; { … });:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;This sets up a &lt;a href="https://www.lambdatest.com/learning-hub/test-suite" rel="noopener noreferrer"&gt;test suite&lt;/a&gt; with a description.&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;describe(“Enter data in Fields Inside Shadow DOM Using shadow() method “, () =&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;p&gt;&lt;strong&gt;beforeEach(() =&amp;gt; { … });:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;This is a hook that runs before each test case in the suite. In this case, it visits the specified web page before executing every test.&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;beforeEach(() =&amp;gt; {
cy.visit("https://www.lambdatest.com/selenium-playground/shadow-dom");
});
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;p&gt;&lt;strong&gt;it(“Enter data in all Fields”, () =&amp;gt; { … });:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;This is an individual test case with the description “Enter data in all Fields”. The test case is responsible for interacting with the elements inside the Shadow DOM and entering data into the specified fields.&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;it(“Enter data in all Fields”, () =&amp;gt; {}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;p&gt;&lt;strong&gt;cy.get(“shadow-signup-form”).shadow();:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;This line uses the &lt;em&gt;cy.get()&lt;/em&gt; command to locate the Shadow DOM element with the tag name &lt;em&gt;“shadow-signup-form”&lt;/em&gt;.&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;cy.get(“shadow-signup-form”).shadow().find();
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;p&gt;&lt;strong&gt;.shadow().find(‘input[name=”username”]’);:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The &lt;em&gt;.shadow()&lt;/em&gt; method is used to interact with elements inside the Shadow DOM, and &lt;em&gt;find(‘input[name=”username”]’)&lt;/em&gt; is used to find the input field with the name “username”.&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;cy.get(“shadow-signup-form”).shadow().find(‘input[name=”username”]’);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;p&gt;&lt;strong&gt;.type(“Kailash”, { force: true });:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The &lt;em&gt;.type()&lt;/em&gt; command is then used to simulate typing “Kailash” into this input field.&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;.type(“Kailash”, { force: true });
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;p&gt;Similar lines follow for other input fields like Email, Password, and Confirm Password, where data is entered using the &lt;em&gt;.type()&lt;/em&gt; command.&lt;/p&gt;

&lt;p&gt;To access the input box within the Shadow DOM, we have used the &lt;em&gt;.shadow()&lt;/em&gt; method. Once inside the shadow DOM, we can interact with the input box and enter the data in the ‘Username’, ’Email’, ‘Password’, and ‘Confirm Password’ fields.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3200%2F0%2AhaVwrwBH3WBZez1z.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3200%2F0%2AhaVwrwBH3WBZez1z.png" width="800" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Keep your data safe and secure by using our free online &lt;a href="https://www.lambdatest.com/free-online-tools/base64-encode?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=dec_07&amp;amp;utm_term=bh&amp;amp;utm_content=free_online_tools" rel="noopener noreferrer"&gt;Base64 Encode&lt;/a&gt;. With our tool, you can easily convert any type of data into a secured Base64 string. Try it now!&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h2&gt;
  
  
  Adding a Flag in Config File
&lt;/h2&gt;

&lt;p&gt;The second approach handles the Shadow DOM in Cypress by adding the flag ‘&lt;em&gt;includeShadowDom&lt;/em&gt;’ in the configuration file.&lt;/p&gt;

&lt;p&gt;Add the flag in the ‘cypress.config.js’ file. In the config file, you can add “&lt;em&gt;includeShadowDom&lt;/em&gt;“: true.&lt;/p&gt;

&lt;p&gt;The &lt;em&gt;includeShadowDom: true&lt;/em&gt; configuration option in Cypress enables interaction with elements inside Shadow DOM. When you set &lt;em&gt;includeShadowDom: true&lt;/em&gt; in your Cypress configuration, Cypress will enable support for Shadow DOM and allow you to interact with elements inside Shadow DOM using commands like &lt;em&gt;cy.get()&lt;/em&gt; and &lt;em&gt;cy.find()&lt;/em&gt;.&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const { defineConfig } = require("cypress");
module.exports = defineConfig({
"includeShadowDom": true,
e2e: {
setupNodeEvents(on, config) {
},
},
});
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;p&gt;Let’s write the code. Here, we are not using the .&lt;em&gt;shadow()&lt;/em&gt; command.&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;describe("Enter data in Fields Inside Shadow DOM By enabling Flag “includeShadowDom”: true, ", () =&amp;gt; {
beforeEach(() =&amp;gt; {
cy.visit("https://www.lambdatest.com/selenium-playground/shadow-dom");
});
it("Enter data in Fields Which are Inside the Shadow DOM ", () =&amp;gt; {
cy.visit("https://www.lambdatest.com/selenium-playground/shadow-dom");
cy.get('[name="username"]').type("LambdaTest", { force: true });
cy.get('[name="email"]').eq(0).type("LambdaTest@qa.com", { force: true });
cy.get('[name="password"]').type("LambdaTest123", { force: true });
cy.get('[name="confirm_password"]').type("LambdaTest123", { force: true });
});
});
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;h2&gt;
  
  
  Adding Flag with Specific Command
&lt;/h2&gt;

&lt;p&gt;The third approach is to handle the Shadow DOM in Cypress by adding the ‘&lt;em&gt;includeShadowDom&lt;/em&gt;’ flag within specific commands.&lt;/p&gt;

&lt;p&gt;In the third approach, instead of setting the ‘&lt;em&gt;includeShadowDom&lt;/em&gt;’ flag globally, a more flexible approach is to include it within specific commands. This allows for finer control, enabling us to specify whether to include Shadow DOM per command.&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;describe("Enter data in Fields Inside Shadow DOM By adding Flag in commands “includeShadowDom”: true, ", () =&amp;gt; {
beforeEach(() =&amp;gt; {
cy.visit("https://www.lambdatest.com/selenium-playground/shadow-dom");
});
it("Enter data in Fields Which are Inside the Shadow DOM ", () =&amp;gt; {
cy.get("shadow-signup-form").find('input[name="username"]',{ includeShadowDom: true }).type("Kailash", { force: true });
cy.get("shadow-signup-form").find('input[name="email"]',{ includeShadowDom: true }).type("lambdatest@qa.com", { force: true });
cy.get("shadow-signup-form").find('input[name="password"]',{ includeShadowDom: true }).type("lambdatest@123");
cy.get("shadow-signup-form").find('input[name="confirm_password"]',{ includeShadowDom: true }).type("lambdatest@123");
});
});
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;h2&gt;
  
  
  How to Automate Shadow DOM on Cloud?
&lt;/h2&gt;

&lt;p&gt;Handling Shadow DOM in Cypress on the cloud is crucial for comprehensive and accurate testing of modern web applications. The increasing trend of web applications utilizing Shadow DOM for encapsulating styles and functionality necessitates robust testing mechanisms.&lt;/p&gt;

&lt;p&gt;As cloud testing environments like LambdaTest gain prominence, it becomes imperative to validate that the infrastructure supports the intricacies of Shadow DOM testing. This ensures that applications leveraging Shadow DOM can be thoroughly tested in cloud-based environments, guaranteeing the reliability and functionality of the application in real-world scenarios.&lt;/p&gt;

&lt;p&gt;LambdaTest is an AI-based test execution and orchestration platform that offers over 3000 real browsers and operating systems to help you automate Shadow DOM in Cypress on the cloud. You can accelerate your &lt;a href="https://www.lambdatest.com/cypress-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=dec_07&amp;amp;utm_term=bh&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;Cypress testing &lt;/a&gt;with Java and reduce &lt;a href="https://www.lambdatest.com/learning-hub/test-execution?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=dec_07&amp;amp;utm_term=bh&amp;amp;utm_content=learning_hub" rel="noopener noreferrer"&gt;test execution&lt;/a&gt; time by multiple folds by running parallel tests on &lt;a href="https://www.lambdatest.com/cypress-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=dec_07&amp;amp;utm_term=bh&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;Cypress Cloud&lt;/a&gt; across multiple browsers and OS configurations.&lt;/p&gt;

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/SqQ8SugRDos"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;Subscribe to the &lt;a href="https://www.youtube.com/c/LambdaTest?sub_confirmation=1?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=dec_07&amp;amp;utm_term=bh&amp;amp;utm_content=youtube" rel="noopener noreferrer"&gt;LambdaTest YouTube Channel&lt;/a&gt; and stay updated with the latest tutorials around &lt;a href="https://www.lambdatest.com/learning-hub/automation-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=dec_07&amp;amp;utm_term=bh&amp;amp;utm_content=learning_hub" rel="noopener noreferrer"&gt;automated testing&lt;/a&gt;, &lt;a href="https://www.lambdatest.com/cypress-e2e-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=dec_07&amp;amp;utm_term=bh&amp;amp;utm_content=youtube" rel="noopener noreferrer"&gt;Cypress E2E testing&lt;/a&gt;, and more.&lt;/p&gt;

&lt;p&gt;As we will execute the test cases on the LambdaTest platform, we must configure our tests for the LambdaTest cloud grid.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Test native, hybrid, and web apps on any mobile OS with our free &lt;a href="https://www.lambdatest.com/android-emulator-online?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=dec_07&amp;amp;utm_term=bh&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;Android emulator&lt;/a&gt; online. Sign up to optimize app performance.&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;strong&gt;Prerequisite:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;You already have an &lt;a href="https://accounts.lambdatest.com/register?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=dec_07&amp;amp;utm_term=bh&amp;amp;utm_content=youtube" rel="noopener noreferrer"&gt;account on LambdaTest&lt;/a&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;You have an access token to run test cases on LambdaTest.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Configuring Cypress test on LambdaTest
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Step 1: Install the CLI&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The command-line interface of LambdaTest enables us to execute your Cypress tests on LambdaTest. Use the Cypress CLI command via npm as shown below&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm install -g lambdatest-cypress-cli
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;Step 2: Generate lambdatest-config.json&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Under the root folder, configure the browsers we want to run the tests. Use the init command to generate a sample lambdatest-config.json file or create one from scratch. Use the below command&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;lambdatest-cypress init
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;In the generated lambdatest-config.json file, pass the information below. Fill in the required values in the section &lt;em&gt;lambdatest_auth, browsers,&lt;/em&gt; and &lt;em&gt;run_settings&lt;/em&gt; to run your tests.&lt;/p&gt;

&lt;p&gt;In the file below, we pass three browsers (Chrome, Firefox, and Electron) and run the test case in two browsers simultaneously.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{
"lambdatest_auth": {
"username": "Enter username",
"access_key": "enter access key"
},
"browsers": [
{
"browser": "Chrome",
"platform": "Windows 10",
"versions": [
"latest-1"
]
},
{
"browser": "Firefox",
"platform": "Windows 10",
"versions": [
"latest-1"
]
}
],
"run_settings": {
"build_name": "Cypress With Shadow DOM Example ",
"parallels": 2,
"specs": "./cypress/e2e/shadowDom/*.cy.js",
"ignore_files": "",
"feature_file_suppport": false,
"network": true,
"headless": false,
"reporter_config_file": "",
"npm_dependencies": {
"cypress": "13.3.0"
}
},
"tunnel_settings": {
"tunnel": false,
"tunnel_name": null
}
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Run the below command to execute the test case on the LambdaTest.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;lambdatest-cypress run — sync=true
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;As we run the above command, test execution starts, and test cases are run in parallel on the LambdaTest platform.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;seamlessly test your mobile applications, websites,and web apps on mobile browsers and mobile devices Try Mobile &lt;a href="https://www.lambdatest.com/mobile-emulator-online?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=dec_07&amp;amp;utm_term=bh&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;Emulator Online&lt;/a&gt;.&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;strong&gt;Test case execution&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;As we execute the test cases in the screenshot below, both test cases start executing in browsers (Chrome, Firefox) parallelly, and we can see the detailed report in the LambdaTest dashboard.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://billing.lambdatest.com/billing/plans?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=dec_07&amp;amp;utm_term=bh&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;LambdaTest Dashboard&lt;/a&gt; offers users a convenient and intuitive interface to oversee test results, review test outcomes, and utilize various platform features. It enables live interactive testing, offering users a real-time view of the website or web application they are testing on a specific browser and operating system.&lt;/p&gt;

&lt;p&gt;The screenshot below shows the test case starts executing in browsers (Chrome, Firefox).&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3200%2F0%2AkiOJWs-vrCV51qMM.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3200%2F0%2AkiOJWs-vrCV51qMM.png" width="800" height="244"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The screenshot below shows that test cases are passed in the browser (Chrome, Firefox).&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3200%2F0%2AQPAy25KCShNjXGi7.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3200%2F0%2AQPAy25KCShNjXGi7.png" width="800" height="244"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Here is the console log of executed test cases in the Chrome browser. You can see that three of the test cases are passing in LambdaTest Grid.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3200%2F0%2AICA8iJ_JM-UvhqTi.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3200%2F0%2AICA8iJ_JM-UvhqTi.png" width="800" height="384"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Here is the console log of executed test cases in the Firefox browser. You can see that three test cases passed on the LambdaTest Grid.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3200%2F0%2AVN8n-1mY5068aYKq.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3200%2F0%2AVN8n-1mY5068aYKq.png" width="800" height="371"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;In this &lt;a href="https://www.lambdatest.com/learning-hub/cypress-tutorial?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=dec_07&amp;amp;utm_term=bh&amp;amp;utm_content=learning_hub" rel="noopener noreferrer"&gt;Cypress tutorial&lt;/a&gt; on handling Shadow DOM in Cypress, we’ve delved into the challenges of handling elements inside Shadow DOM, shedding light on the complexities of interacting with encapsulated components. We’ve explored various approaches and techniques to handle elements within the Shadow DOM effectively using Cypress.&lt;/p&gt;

&lt;p&gt;Furthermore, we’ve discussed the integration of LambdaTest, an AI-powered test orchestration and execution platform, and how it enhances the capabilities of &lt;a href="https://www.lambdatest.com/blog/cypress-test-automation-framework/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=dec_07&amp;amp;utm_term=bh&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;Cypress automation&lt;/a&gt;. By seamlessly running our Cypress tests across different browser versions and platforms, we ensure our applications’ compatibility and reliability in diverse environments. This integration empowers us to deliver high-quality web experiences to users across the digital landscape.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Perform browser automation testing on the most powerful cloud infrastructure. Leverage LambdaTest &lt;a href="https://www.lambdatest.com/automation-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=dec_07&amp;amp;utm_term=bh&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;automation testing&lt;/a&gt; for faster, reliable and scalable experience on cloud.&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  Frequently Asked Questions (FAQs)
&lt;/h2&gt;

&lt;h3&gt;
  
  
  What is shadow DOM used for?
&lt;/h3&gt;

&lt;p&gt;The Shadow DOM (Document Object Model) is a web standard that encapsulates styles, markup, and behavior within a scoped and isolated DOM subtree. It is primarily used to solve issues related to styling and the potential clash of CSS styles and JavaScript code in large and complex web applications. Here are some key purposes and use cases for the Shadow DOM&lt;/p&gt;

&lt;h3&gt;
  
  
  What is this shadowRoot?
&lt;/h3&gt;

&lt;p&gt;In the context of the Shadow DOM (Document Object Model), &lt;em&gt;shadowRoot&lt;/em&gt; is a property of an element that provides access to its own encapsulated subtree. The *shadowRoot *property refers to the root of the Shadow DOM subtree associated with a specific element.&lt;/p&gt;

</description>
      <category>opensource</category>
      <category>programming</category>
      <category>tutorial</category>
      <category>beginners</category>
    </item>
    <item>
      <title>How to Use Cypress in Headless Mode</title>
      <dc:creator>Kailash Pathak</dc:creator>
      <pubDate>Thu, 30 Nov 2023 09:20:37 +0000</pubDate>
      <link>https://dev.to/testmuai/how-to-use-cypress-in-headless-mode-obg</link>
      <guid>https://dev.to/testmuai/how-to-use-cypress-in-headless-mode-obg</guid>
      <description>&lt;p&gt;Tests are often carried out on real browsers to test the actual user experience. This approach ensures that the web application or site is examined in the real-world environment it is intended for, enabling testers to identify and address any issues that may impact user satisfaction and functionality. Testing on real browsers helps detect discrepancies that might not be apparent in simulated or emulated environments, ultimately leading to a more accurate assessment of the user experience.&lt;/p&gt;

&lt;p&gt;However, running tests on a real browser can be slow because the browser needs to start up and load each web page before the tests can run, which can take a significant amount of time.&lt;/p&gt;

&lt;p&gt;Additionally, running tests on a real browser can consume a lot of memory and other system resources, slowing down other processes and making the test environment less stable. This is why many developers opt to use headless browsers, which can simulate the behavior of a real browser without actually running the full application.&lt;/p&gt;

&lt;p&gt;Some common issues when performing &lt;a href="https://www.lambdatest.com/learning-hub/ui-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=nov_30&amp;amp;utm_term=bh&amp;amp;utm_content=learning_hub" rel="noopener noreferrer"&gt;UI testing&lt;/a&gt; with a web browser include:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Flakiness:&lt;/strong&gt; Tests may randomly fail or pass due to elements not loading correctly or other unpredictable behavior.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Slow performance:&lt;/strong&gt; Running tests on browser instances can be slow and time-consuming, especially if there are many tests or if the tests are running on multiple browsers.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;False negatives/positives:&lt;/strong&gt; Sometimes, the tests may fail or pass incorrectly due to timing, network connectivity, or race conditions.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Test environment setup:&lt;/strong&gt; Setting up the &lt;a href="https://www.lambdatest.com/blog/what-is-test-environment/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=nov_30&amp;amp;utm_term=bh&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;test environment&lt;/a&gt;, including installing the necessary browsers and drivers, can be challenging and time-consuming.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Page load time:&lt;/strong&gt; Page load time is the time that passes between the browser sending the request to the server and the page fully loading. Sometimes, even if we have a good infrastructure, the page takes too long to load, and it can cause UI tests to fail or produce unreliable results.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This is where headless browsers come into the picture. In web browsers, headless mode refers to running a browser instance without opening a visual window. This can be useful for automated testing or running a browser programmatically as part of a larger system.&lt;/p&gt;

&lt;p&gt;Most modern web browsers, including Chrome, Firefox, and WebKit, support headless mode. Headless testing can be faster and less resource-intensive than UI testing, as it does not require a real device or a simulation of the real environment.&lt;/p&gt;

&lt;p&gt;You can perform headless browser testing using Cypress on a cloud-based Grid that supports using &lt;a href="https://www.lambdatest.com/learning-hub/cypress-tutorial?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=nov_30&amp;amp;utm_term=bh&amp;amp;utm_content=learning_hub" rel="noopener noreferrer"&gt;Cypress&lt;/a&gt; in headless mode. This means that you can perform &lt;a href="https://www.lambdatest.com/cypress-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=nov_30&amp;amp;utm_term=bh&amp;amp;utm_content=learning_hub" rel="noopener noreferrer"&gt;Cypress testing&lt;/a&gt; in a browser environment without the need to have a GUI visible.&lt;/p&gt;

&lt;p&gt;In this tutorial, you will learn how to run tests using Cypress in headless mode on popular browsers like Chrome, Firefox, and WebKit.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Perform live mobile website tests on different devices with LT Browser 2.0. &lt;a href="https://www.lambdatest.com/test-site-on-mobile?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=nov_30&amp;amp;utm_term=bh&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;test website on all device&lt;/a&gt;&lt;/strong&gt; s*&lt;em&gt;and tablet viewports and debug UI issues on the go across 50+ device viewports!&lt;/em&gt;*&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  Why use Headless Browser Testing?
&lt;/h2&gt;

&lt;p&gt;When conducting &lt;a href="https://www.lambdatest.com/learning-hub/end-to-end-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=nov_30&amp;amp;utm_term=bh&amp;amp;utm_content=learning_hub" rel="noopener noreferrer"&gt;end-to-end tests&lt;/a&gt; with a headless browser, the application’s user interface won’t be loaded by the browser. As a result, everything operates more quickly, and there is less risk of instability because the tests immediately interact with the website. Your tests become quicker, more accurate, and more effective.&lt;/p&gt;

&lt;p&gt;There are several reasons why you might want to run Cypress in headless mode:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Speed:&lt;/strong&gt; Headless browsers are often faster and use fewer resources than traditional browsers because they do not have to render the GUI. This can be useful for tasks requiring a lot of processing power or running tests on a server with limited resources.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Flexibility:&lt;/strong&gt; Headless browsers can be run on various platforms, including Linux, Windows, and Mac. This makes running tests on different environments easy, which can help ensure that your website (or web app) works as expected on various devices and operating systems.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Cost-effectiveness:&lt;/strong&gt; Headless browser testing is cost-effective as it eliminates the need for expensive hardware and software to run tests.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Automation:&lt;/strong&gt; Headless browsers allow you to perform automated or repeatable tasks without interacting manually with the GUI. This can be particularly useful for tasks such as testing web applications or automating interactions on elements in any website.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Server-side rendering:&lt;/strong&gt; Headless browsers can render web pages on the server side. This helps optimize web application performance and improve the end-user experience.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Simulating real user behavior:&lt;/strong&gt; Headless browsers let developers simulate real user behavior on the website, which can help identify issues other methods may not catch.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Compatibility:&lt;/strong&gt; Headless browsers can test the website’s compatibility with different browser versions.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Testing:&lt;/strong&gt; Headless browsers can be used for &lt;a href="https://www.lambdatest.com/learning-hub/web-application-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=nov_30&amp;amp;utm_term=bh&amp;amp;utm_content=learning_hub" rel="noopener noreferrer"&gt;web application testing&lt;/a&gt;, as they let you simulate a browser environment and make assertions about the behavior of your application.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Realistic testing:&lt;/strong&gt; During headless testing, the browser operates in a manner akin to a genuine browser, actively loading all resources such as images, CSS, JavaScript, and more. This approach enables a more authentic testing experience, facilitating the detection of potential issues that might remain undetected when employing alternative testing methods.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;CI/CD Integration:&lt;/strong&gt; Headless tests reap more benefits when run with CI/CD tools because they consume fewer resources (i.e., CPU, RAM, etc.). Even in scenarios where the pipeline is executed in a remote environment, you can expect quicker results due to the inherently faster nature of headless testing.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Resource efficiency:&lt;/strong&gt; Running tests without a GUI requires fewer resources, making headless browser testing more efficient.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Criteria for Choosing Headless Browsers
&lt;/h2&gt;

&lt;p&gt;You should always choose a headless browser that is lightweight and uses very few resources so that you can run it in the background without hindering development work.&lt;/p&gt;

&lt;p&gt;Many headless options are available, including tools to simulate multiple browsers and headless versions of well-known browsers like Chrome and Firefox. We have some factors to utilize in deciding which browsers are optimal for web development and testing.&lt;/p&gt;

&lt;p&gt;Here are some factors to consider when selecting a headless browser for &lt;a href="https://www.lambdatest.com/learning-hub/web-application-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=nov_30&amp;amp;utm_term=bh&amp;amp;utm_content=learning_hub" rel="noopener noreferrer"&gt;web testing&lt;/a&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Compatibility:&lt;/strong&gt; Ensure the headless browser is compatible with your operating system and the programming language you plan to use for web testing.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Features:&lt;/strong&gt; Consider the features important for your web testing, such as support for JavaScript, cookies, and web standards. Some headless browsers offer advanced features such as automatic form-filling, screenshot capture, and network emulation.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Performance:&lt;/strong&gt; Consider the performance of the headless browser, including its speed and resource usage, as web testing can be resource-intensive when we have to test our application in multiple headless browsers.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Ease of use:&lt;/strong&gt; Consider how easy it is to use the headless browser and whether it has good documentation and a supportive community.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Support:&lt;/strong&gt; It’s important to choose a headless browser that is actively maintained and has a large community of users for support and troubleshooting.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Perform live mobile website tests on different devices with LT Browser 2.0. &lt;a href="https://www.lambdatest.com/test-site-on-mobile?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=nov_30&amp;amp;utm_term=bh&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;test website on mobile devices online free&lt;/a&gt; and tablet viewports and debug UI issues on the go across 50+ device viewports!&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Popular Headless Browsers
&lt;/h2&gt;

&lt;p&gt;The choice of using Cypress in headless mode depends entirely on the specific application requirements you are testing. Headless browser allows you to run the &lt;a href="https://www.lambdatest.com/learning-hub/test-case?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=nov_30&amp;amp;utm_term=bh&amp;amp;utm_content=learning_hub" rel="noopener noreferrer"&gt;test cases&lt;/a&gt; in a headless (i.e., GUI-less) environment, which can be useful for running tests in a Continuous Integration (CI) environment or scripts that don’t require a visible UI.&lt;/p&gt;

&lt;p&gt;Here are some commonly used headless browsers (irrespective of whether the framework is being used for &lt;a href="https://www.lambdatest.com/learning-hub/automation-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=nov_30&amp;amp;utm_term=bh&amp;amp;utm_content=learning_hub" rel="noopener noreferrer"&gt;automated testing)&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Firefox Headless&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Chrome Headless&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;WebKit Headless&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;PhantomJS&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;HtmlUnit Browsers&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Though I have listed all major headless browsers, it is important to note that Cypress supports Firefox, Chrome, and WebKit headless browsers.&lt;/p&gt;

&lt;h2&gt;
  
  
  Firefox headless mode
&lt;/h2&gt;

&lt;p&gt;Firefox headless mode is a web browser that allows you to test the application without the head. You cannot see anything while accessing any website using a headless browser. The application, however, operates in the background, and you can monitor the execution result once the test cases have finished running.&lt;/p&gt;

&lt;p&gt;Firefox headless mode can be an effective option for automating web browsing tasks using Cypress. By running Firefox using Cypress in headless mode, you can interact with the browser as a regular user.&lt;/p&gt;

&lt;h2&gt;
  
  
  Chrome headless mode
&lt;/h2&gt;

&lt;p&gt;Google’s Chrome team included headless Chrome mode in their browser, making running a Chrome headless browser from the command line easier.&lt;/p&gt;

&lt;p&gt;Running tests using Cypress in headless mode makes fast test case execution and eliminates the need for manual interaction with the browser during testing.&lt;/p&gt;

&lt;h2&gt;
  
  
  WebKit headless mode
&lt;/h2&gt;

&lt;p&gt;WebKit is an open-source web browser engine developed by Apple and used in the Safari browser. The headless mode of WebKit is a feature that allows the engine to run without a browser.&lt;/p&gt;

&lt;p&gt;You can run tests on WebKit using Cypress in headless mode. To run Cypress test cases in WebKit, we must do some config settings and add the dependency. Add &lt;em&gt;experimentalWebKitSupport:&lt;/em&gt; true in the cypress.config.js file to enable the experiment. Add dependency using the command to install the playwright-webkit NPM package in your repo to acquire WebKit: &lt;em&gt;npm install&lt;/em&gt; &lt;em&gt;–save-dev playwright-webkit&lt;/em&gt;.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Explore the evolution of Apple’s iOS! From iPhone OS to the latest iOS 16, dive into the journey that powers &lt;a href="https://www.lambdatest.com/software-testing-questions/what-is-an-ios-device?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=nov_30&amp;amp;utm_term=bh&amp;amp;utm_content=stq" rel="noopener noreferrer"&gt;ios mobile device&lt;/a&gt;&lt;/strong&gt;- &lt;strong&gt;iPhones, iPod Touches, and iPads. Uncover the history and future of this iconic operating system!&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  PhantomJS headless mode
&lt;/h2&gt;

&lt;p&gt;PhantomJS is a popular solution for running browser-based &lt;a href="https://www.lambdatest.com/learning-hub/unit-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=nov_30&amp;amp;utm_term=bh&amp;amp;utm_content=learning_hub" rel="noopener noreferrer"&gt;unit tests&lt;/a&gt; in a headless system like a continuous integration environment since it provides a JavaScript API that enables automated navigation, screenshots, user behavior, and assertions.&lt;/p&gt;

&lt;p&gt;Additionally, PhantomJS can be used to automate tasks such as filling out forms, clicking buttons, and navigating pages, which can be useful for functional and &lt;a href="https://www.lambdatest.com/learning-hub/regression-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=nov_30&amp;amp;utm_term=bh&amp;amp;utm_content=learning_hub" rel="noopener noreferrer"&gt;regression testing&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Some common use cases include:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;PhantomJS can interact with web pages similarly to a web browser, allowing developers to automate tasks such as filling out forms, clicking buttons, and navigating between pages.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;It can extract data from web pages, such as scraping product prices from an eCommerce site or extracting data from a table on a web page.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;PhantomJS can generate screenshots or PDFs of web pages, which can help create reports or test a website’s appearance on different devices and screen resolutions.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  HtmlUnit headless mode
&lt;/h2&gt;

&lt;p&gt;HtmlUnit is a Java-based headless browser that allows developers to automate web page interactions. It can be controlled programmatically, allowing developers to simulate a user navigating a website and interacting with its elements, such as clicking buttons and filling out forms. HtmlUnit supports JavaScript and can work with various web standards, making it a versatile tool for web development and testing.&lt;/p&gt;

&lt;p&gt;It can be integrated with popular testing frameworks such as JUnit and TestNG, allowing developers to write tests in Java and run them in HtmlUnit.&lt;/p&gt;

&lt;p&gt;Additionally, HtmlUnit can be useful for testing web applications by simulating interactions with the web page and checking the resulting page source or &lt;a href="https://www.lambdatest.com/blog/document-object-model/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=nov_30&amp;amp;utm_term=bh&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;DOM&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;​​Use case in &lt;a href="https://www.lambdatest.com/learning-hub/software-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=nov_30&amp;amp;utm_term=bh&amp;amp;utm_content=learning_hub" rel="noopener noreferrer"&gt;software testing&lt;/a&gt; using HtmlUnit headless browser:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Developers could use HtmlUnit to simulate a user logging into a web application by navigating to the login page, filling out the login form, and submitting it.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;You can use HtmlUnit to navigate to various web application pages, interacting with elements such as buttons and links and asserting that the expected results occur.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;As mentioned, Cypress supports Firefox, Chrome, and WebKit headless browsers. Hence, I would be demonstrating Cypress headless testing on the said browsers.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;a href="https://www.lambdatest.com/real-device-cloud?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=nov_30&amp;amp;utm_term=bh&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;**Mobile device test&lt;/a&gt; and website on real iOS and Android devices hosted on the cloud. LambdaTest is a convenient, cost-effective and centralised solution for running realtime and Automated test on real device cloud.**&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  Testing with Cypress in Headless Mode
&lt;/h2&gt;

&lt;p&gt;Before explaining how to run the test cases in headless mode in Cypress, let’s set up a Cypress project first.&lt;/p&gt;

&lt;p&gt;To explain how we can run test cases in headless mode in Cypress, I will test a typical eCommerce site: &lt;a href="https://ecommerce-playground.lambdatest.io/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=nov_30&amp;amp;utm_term=bh&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;LambdaTest eCommerce Playground&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Implementation Test Scenario
&lt;/h2&gt;

&lt;p&gt;In this &lt;a href="https://www.lambdatest.com/learning-hub/cypress-tutorial?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=nov_30&amp;amp;utm_term=bh&amp;amp;utm_content=learning_hub" rel="noopener noreferrer"&gt;Cypress tutorial&lt;/a&gt;, we are using the below example to run the Cypress test case in a headless browser in Local Grid and LambdaTest Grid.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Test Scenario:&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Open the Site &lt;a href="https://ecommerce-playground.lambdatest.io/index.php?route=account/login" rel="noopener noreferrer"&gt;https://ecommerce-playground.lambdatest.io/index.php?route=account/login&lt;/a&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Enter the email address.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Enter the password.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Click on the Login button.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Click on the ‘All Categories’ drop-down.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Enter the product to search.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Search the product.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Verify the correct product is searched.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Setting up Cypress
&lt;/h2&gt;

&lt;p&gt;You can establish a new Cypress project by following the instructions below:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 1:&lt;/strong&gt; Create a folder and generate package.json.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Create a project by Cypress_Headless.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Create a package.json file using the npm init command.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Step 2:&lt;/strong&gt; Install Cypress&lt;/p&gt;

&lt;p&gt;Run this command in the newly created folder to install Cypress.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm install cypress — save-dev
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;OR&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;yarn add cypress — dev
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;​​Cypress will be installed locally as a dev dependency for your project.&lt;/p&gt;

&lt;p&gt;**&lt;em&gt;Note: **Cypress version 12.3.0 is installed, as shown below. At the time of writing this blog, the most recent version of Cypress is 12.3.0&lt;/em&gt;&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{
 "name": "cypress_headless",
 "version": "1.0.0",
 "description": "",
 "main": "index.js",
 "scripts": {
   "test": "echo \"Error: no test specified\" &amp;amp;&amp;amp; exit 1"
 },
 "author": "Kailash Pathak",
 "license": "ISC",
 "dependencies": {
   "cypress": "^12.3.0"
 }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Stop using the same password for everything! Create strong and unique passwords that are difficult to guess with our &lt;a href="https://www.lambdatest.com/free-online-tools/random-password-generator?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=nov_30&amp;amp;utm_term=bh&amp;amp;utm_content=free_online_tools" rel="noopener noreferrer"&gt;Random Password Generator&lt;/a&gt;. Try it now!&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  Different ways to run Cypress tests in a headless browser
&lt;/h2&gt;

&lt;p&gt;There are various ways of executing the Cypress test cases in headless browser mode.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;To run all the test cases of the e2e folder in headless mode, use the &lt;em&gt;yarn cypress run&lt;/em&gt; command. This command will run all the test cases under the e2e folder.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;To run the particular .spec file in the headless mode, you can run the command &lt;em&gt;yarn cypress run –spec cypress/e2e/example.cy.js&lt;/em&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Another way of running the test cases in headless mode is by adding scripts to the package.json. To run all test cases, we must run the command &lt;em&gt;yarn run cy:run&lt;/em&gt; in the terminal. This command will execute all the test cases in headless mode.&lt;/p&gt;

&lt;p&gt;{&lt;br&gt;
 "name": "cypress_headless",&lt;br&gt;
 "version": "1.0.0",&lt;br&gt;
 "description": "",&lt;br&gt;
 "main": "index.js",&lt;br&gt;
 "scripts": {&lt;br&gt;
   "cy:run": "yarn cypress run"&lt;br&gt;
 },&lt;br&gt;
 "author": "&amp;lt;&amp;gt;",&lt;br&gt;
 "license": "ISC",&lt;br&gt;
 "dependencies": {&lt;br&gt;
   "cypress": "^12.3.0"&lt;br&gt;
 }&lt;br&gt;
}&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;To run the test case on a particular browser in headless mode, we can add the script in package.json. To run all test cases in the Chrome browser, use the &lt;em&gt;yarn run cy:run:chrome&lt;/em&gt; command in the terminal. To run all test cases in the Firefox browser, use the command &lt;em&gt;yarn run cy:run:firefox&lt;/em&gt; in the terminal. To run all test cases in the Electron browser, use the command &lt;em&gt;yarn run cy:run:electron&lt;/em&gt; in the terminal.&lt;/p&gt;

&lt;p&gt;"name": "cypress_headless",&lt;br&gt;
 "version": "1.0.0",&lt;br&gt;
 "description": "",&lt;br&gt;
 "main": "index.js",&lt;br&gt;
 "scripts": {&lt;br&gt;
  "cy:run:chrome": “yarn cypress run --browser  chrome --headless"&lt;br&gt;
  "cy:run:firefox": “yarn cypress run --browser firefox --headless"&lt;br&gt;
  "cy:run:electron": “yarn cypress run --browser electron --headless"&lt;br&gt;
 },&lt;br&gt;
 "author": "&amp;lt;&amp;gt;",&lt;br&gt;
 "license": "ISC",&lt;br&gt;
 "dependencies": {&lt;br&gt;
   "cypress": "^12.3.0"&lt;br&gt;
 }&lt;br&gt;
}&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Another way to run the Cypress test cases in headless mode is running the test cases in the CI/CD pipeline. Below is an example of GitHub Action. Here, you can see we are executing Cypress test cases in the container with the Chrome browser.&lt;/p&gt;

&lt;p&gt;name: Cypress Tests &lt;br&gt;
on: [push]&lt;br&gt;
jobs:&lt;br&gt;
 cypress-run:&lt;br&gt;
   runs-on: ubuntu-latest&lt;br&gt;
   container: cypress/browsers:node12.18.3-chrome87-ff82&lt;br&gt;
   steps:&lt;br&gt;
     - name: Checkout&lt;br&gt;
       uses: actions/checkout@v2&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; # Install NPM
 # and run all Cypress tests
 - name: Cypress run
   uses: cypress-io/github-action@v4
   with:
     # Specify the Browser
     browser: chrome
&lt;/code&gt;&lt;/pre&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Generate custom QR codes for your business or personal needs with our fast and easy-to-use &lt;a href="https://www.lambdatest.com/free-online-tools/qr-code-generator?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=nov_30&amp;amp;utm_term=bh&amp;amp;utm_content=free_online_tools" rel="noopener noreferrer"&gt;QR code generator&lt;/a&gt; online tool in seconds. Try it now!&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Folder Structure
&lt;/h2&gt;

&lt;p&gt;The default folder structure for Cypress is displayed below. Under the “&lt;strong&gt;e2e&lt;/strong&gt;” subdirectory, test cases can be created.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2000%2F0%2AN7Lh5Wehbi0pl2D7.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2000%2F0%2AN7Lh5Wehbi0pl2D7.png" width="410" height="602"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Let’s create test cases under the folder Cypress_Headless -&amp;gt; e2e. Create a .spec file with the name &lt;em&gt;login_searchproduct.cy.js&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2000%2F0%2A_nm9iOM2PPp5bYie.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2000%2F0%2A_nm9iOM2PPp5bYie.png" width="588" height="904"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Create a &lt;em&gt;login_searchproduct.spec.js&lt;/em&gt; file with the script below. This includes logging into the application and conducting a product search. Verify the right product should be displayed after the search.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;/// &amp;lt;reference types="cypress" /&amp;gt;
context("GIVEN Browser is already open  ", { testIsolation: false }, () =&amp;gt; {
 it("WHEN User Open the Url", () =&amp;gt; {
   cy.visit(
     "https://ecommerce-playground.lambdatest.io/index.php?route=account/login"
   );
 });
 it("AND Login into the application", () =&amp;gt; {
   cy.get('[id="input-email"]').type("lambdatest@yopmail.com");
   cy.get('[id="input-password"]').type("lambdatest");
   cy.get('[type="submit"]').eq(0).click();
 });
 it("AND Click On All Categories drop down and Search the Product", () =&amp;gt; {
   cy.get('[data-toggle="dropdown"]').eq(0).click();
   cy.contains("Laptops").click({ force: true });
   cy.get('[name="search"]').eq(0).type("Apple").should("have.value", "Apple");
   cy.get('[type="submit"]').eq(0).click();
 });
 it("THEN Verify Correct Product with name'iPod Shuffle' should display after Search ", () =&amp;gt; {
   cy.contains("iPod Shuffle");
 });
});
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Need to know how many characters are in your text? Get an accurate &lt;a href="https://www.lambdatest.com/free-online-tools/character-count?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=nov_30&amp;amp;utm_term=bh&amp;amp;utm_content=free_online_tools" rel="noopener noreferrer"&gt;characters count&lt;/a&gt; in your text with our free online tool. Try it now and see how easy it is!&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;strong&gt;Code Walkthrough&lt;/strong&gt;&lt;br&gt;
In the above code snippet, we have opened the target URL using &lt;em&gt;cy.visit()&lt;/em&gt;, and second, &lt;em&gt;it()&lt;/em&gt; block is used to log in to the application by entering email and password.&lt;/p&gt;

&lt;p&gt;In the third, &lt;em&gt;it()&lt;/em&gt; block clicks on the ‘All Categories’ drop down and searches for the product., Finally, the last &lt;em&gt;it()&lt;/em&gt; block is used to verify the searched product.&lt;/p&gt;

&lt;p&gt;In the below screenshot, you can see how we can inspect the element. We have located the element by &lt;em&gt;id&lt;/em&gt; for the email field.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;cy.get(‘[id=”input-email”]’).type(“lambdatest@yopmail.com”);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3200%2F0%2ANNI5IX0z1ewcvclt.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3200%2F0%2ANNI5IX0z1ewcvclt.png" width="800" height="453"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now, let’s run the above test scenario in headless browsers. We will run the test cases first locally, then we will run the same scenario on the &lt;a href="https://www.lambdatest.com/cypress-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=nov_30&amp;amp;utm_term=bh&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;LambdaTest Cypress cloud&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Cypress Headless Testing on Local Grid
&lt;/h2&gt;

&lt;h2&gt;
  
  
  Running tests on Chrome using Cypress in Headless Mode
&lt;/h2&gt;

&lt;p&gt;Headless Chrome is a web browser that can run automated tests without opening a Chrome window. This empowers you to create tests capable of mimicking user interactions with your web application and verifying that the application functions as intended.&lt;/p&gt;

&lt;p&gt;Run the above scenario locally in headless mode using Chrome using the below command.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;yarn cypress run — browser chrome — headless
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;As we run the above command, test cases start executing locally in the Chrome headless mode.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2802%2F0%2AldUpuTNNDYTilU0h.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2802%2F0%2AldUpuTNNDYTilU0h.png" width="800" height="913"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Accurately count the number of words in your text with our easy-to-use word count tool. Perfect for meeting &lt;a href="https://www.lambdatest.com/free-online-tools/word-count?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=nov_30&amp;amp;utm_term=bh&amp;amp;utm_content=free_online_tools" rel="noopener noreferrer"&gt;word count&lt;/a&gt; requirements. Try it out now for free!&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  Running tests on Firefox using Cypress in Headless Mode
&lt;/h2&gt;

&lt;p&gt;To run the Cypress test cases in Firefox’s headless browser, you have to run the below command, which will run in the background, and finally, you will get the Pass/Fail result in the form of a report.&lt;/p&gt;

&lt;p&gt;Run the above scenario locally in headless mode using Firefox using the below command.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;yarn cypress run — browser firefox — headless
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;As we run the above command, test cases start executing locally in the Firefox headless mode.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3200%2F0%2A9R-zZjvuwHHMvIh-.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3200%2F0%2A9R-zZjvuwHHMvIh-.png" width="800" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3200%2F0%2ALPPRI8ObweNlceWn.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3200%2F0%2ALPPRI8ObweNlceWn.png" width="800" height="346"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Running tests on WebKit using Cypress in Headless Mode
&lt;/h2&gt;

&lt;p&gt;Run the above scenario locally in headless mode using WebKit using the below command&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;yarn cypress run — browser webkit — headless
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;As we run the above command, test cases start executing locally in WebKit headless mode.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2988%2F0%2AIm8m-l2kWzR9y-f7.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2988%2F0%2AIm8m-l2kWzR9y-f7.png" width="800" height="856"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Cypress Headless Testing on Cloud Grid
&lt;/h2&gt;

&lt;p&gt;In this section, you will find how to perform &lt;a href="https://www.lambdatest.com/cypress-parallel-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=nov_30&amp;amp;utm_term=bh&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;Cypress parallel testing&lt;/a&gt; on a cloud grid like LambdaTest.&lt;/p&gt;

&lt;p&gt;LambdaTest is an AI-powered test orchestration and execution platform that lets you perform &lt;a href="https://www.lambdatest.com/blog/cypress-test-automation-framework/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=nov_30&amp;amp;utm_term=bh&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;Cypress automation&lt;/a&gt; using headless mode across 40+ browser versions on the cloud. You can also run the Cypress test on the cloud parallel to the browser (Chrome, Firefox, and WebKit).&lt;br&gt;
&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/mGL7rSct3CU"&gt;
&lt;/iframe&gt;
&lt;br&gt;
Subscribe to the &lt;a href="https://www.youtube.com/channel/UCCymWVaTozpEng_ep0mdUyw?sub_confirmation=1?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=nov_30&amp;amp;utm_term=bh&amp;amp;utm_content=youtube" rel="noopener noreferrer"&gt;LambdaTest YouTube Channel&lt;/a&gt; for the latest updates on tutorials around &lt;a href="https://www.lambdatest.com/selenium-automation?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=nov_30&amp;amp;utm_term=bh&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;Selenium testing&lt;/a&gt;, &lt;a href="https://www.lambdatest.com/cypress-e2e-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=nov_30&amp;amp;utm_term=bh&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;Cypress e2e testing&lt;/a&gt;, &lt;a href="https://www.lambdatest.com/appium-mobile-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=nov_30&amp;amp;utm_term=bh&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;Appium&lt;/a&gt;, and more.&lt;/p&gt;

&lt;p&gt;Before running the test case in LambdaTest Grid, we have to do the set-up for LambdaTest. Below are some steps for setup.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Get plain text from XML documents. Simply copy and paste your XML data to extract text using our online free &lt;a href="https://www.lambdatest.com/free-online-tools/extract-text-from-xml?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=nov_30&amp;amp;utm_term=bh&amp;amp;utm_content=free_online_tools" rel="noopener noreferrer"&gt;Extract Text from XML&lt;/a&gt; tool. Give it a try now!&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  Prerequisite to setup LambdaTest for test cases execution
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;You already signed up for LambdaTest&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;You have an access token to run test cases on LambdaTest.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Setup LambdaTest for Cypress test case execution
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Step 1: Install the CLI&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Install the LambdaTest using Cypress CLI command via npm. The command-line interface of LambdaTest enables us to execute your Cypress tests on LambdaTest.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm install -g lambdatest-cypress-cli
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;Step 2: Generate lambdatest-config.json&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Under the root folder, configure the browsers we want to run the tests. Use the &lt;em&gt;init&lt;/em&gt; command to generate a sample lambdatest-config.json file or create one from scratch. Use the below command.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;lambdatest-cypress init
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;In the generated lambdatest-config.json file, pass the below information. Fill in the required values in the section lambdatest_auth, browsers, and run_settings to run your tests.&lt;/p&gt;

&lt;p&gt;In the below file, you can see we are passing three browsers (Chrome, Firefox, and Electron) and running the test case in two browsers simultaneously.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{
 "lambdatest_auth": {
   "username": "&amp;lt;&amp;gt;",
   "access_key": "&amp;lt;&amp;gt;"
 },
 "browsers": [
   {
     "browser": "Chrome",
     "platform": "Windows 10",
     "versions": ["latest-1"]
   },
   {
     "browser": "Firefox",
     "platform": "Windows 10",
     "versions": ["latest"]
   },
   {
     "browser": "Electron",
     "platform": "Windows 10",
     "versions": ["latest"]
   }
 ],
 "run_settings": {
   "build_name": "Headless Browser Testing build-name",
   "parallels": 2,
   "specs": "./cypress/e2e/*.cy.js",
   "ignore_files": "",
   "network": true,
   "headless": true,
   "npm_dependencies": {
     "cypress": "12.3.0"
   }
 },
 "tunnel_settings": {
   "tunnel": false,
   "tunnel_name": null
 }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Run the below command to execute the test case on LambdaTest.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;lambdatest-cypress run — sync=true
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;As we run the above command, test case execution starts locally and parallelly on the LambdaTest platform.&lt;/p&gt;

&lt;h2&gt;
  
  
  LambdaTest Dashboard
&lt;/h2&gt;

&lt;p&gt;The &lt;a href="https://automation.lambdatest.com/onboarding?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=nov_30&amp;amp;utm_term=bh&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;LambdaTest Dashboard&lt;/a&gt; provides a user-friendly interface for users to manage their test sessions, view test results, and access other platform features. It also allows users to perform live interactive testing by providing a live view of the website or web application being tested on a particular browser and operating system combination.&lt;/p&gt;

&lt;p&gt;In the below screen, test cases start running in two browsers (Chrome, Electron), and in one other browser (Firefox), test case execution is in queue.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3200%2F0%2ATXZ3JjA0mSK2pkXc.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3200%2F0%2ATXZ3JjA0mSK2pkXc.png" width="800" height="378"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Once the execution of the two test cases mentioned above is completed in either the Chrome or Electron browser, the subsequent test case enters a queue. It initiates its execution in the Firefox browser. This transition is visually represented in the screenshot below.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3200%2F0%2ACV_SU9JET1RW7bvG.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3200%2F0%2ACV_SU9JET1RW7bvG.png" width="800" height="344"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Here is the console log of executed test cases in the Firefox browser. You can see all test cases are passing in LambdaTest Grid.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3200%2F0%2AmO4lMeLJgElG2GCR.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3200%2F0%2AmO4lMeLJgElG2GCR.png" width="800" height="410"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3200%2F0%2AnE_-5eDhLTID4RSW.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3200%2F0%2AnE_-5eDhLTID4RSW.png" width="800" height="381"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Here is the console log of executed test cases in the Chrome browser. You can see all test cases are passing in LambdaTest Grid.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3200%2F0%2ASwRd4vM5Ypv_5004.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3200%2F0%2ASwRd4vM5Ypv_5004.png" width="800" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;As indicated in the console log displayed below, the test cases have successfully passed when executed in the Electron browser. Furthermore, it’s worth noting that all test cases exhibit successful outcomes within the LambdaTest Grid.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3200%2F0%2AobBDofKn8WDr1uru.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3200%2F0%2AobBDofKn8WDr1uru.png" width="800" height="428"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Are you ready to elevate your Cypress automation proficiency? Join the &lt;a href="https://www.lambdatest.com/certifications/cypress-101?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=nov_30&amp;amp;utm_term=bh&amp;amp;utm_content=certification" rel="noopener noreferrer"&gt;Cypress 101 certification&lt;/a&gt; program, crafted for developers and testers seeking to deepen their expertise in Cypress test automation. Gain advanced insights, polish your skills, and unlock many opportunities along your test automation journey.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Keep your JavaScript code safe from syntax errors with our free online &lt;a href="https://www.lambdatest.com/free-online-tools/js-escape?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=nov_30&amp;amp;utm_term=bh&amp;amp;utm_content=free_online_tools" rel="noopener noreferrer"&gt;JS Escape&lt;/a&gt; tool by quickly and easily converting special characters in your JavaScript.&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  Wrapping up
&lt;/h2&gt;

&lt;p&gt;Using a headless browser, you can run the test cases without a graphical user interface (GUI) that allows developers to run automated tests, web scraping, and other tasks without visual browser representation. LambdaTest is an AI-powered test orchestration and execution platform enabling developers to perform &lt;a href="https://www.lambdatest.com/cypress-ui-automation?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=nov_30&amp;amp;utm_term=bh&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;Cypress UI automation&lt;/a&gt; across a diverse spectrum of browsers and operating systems using a headless browser. This empowers developers to thoroughly assess their websites and web applications across many configurations, all while eliminating the requirement for costly hardware and software investments.&lt;/p&gt;

&lt;h2&gt;
  
  
  Frequently Asked Questions (FAQs)
&lt;/h2&gt;

&lt;h3&gt;
  
  
  What is Cypress in headless mode?
&lt;/h3&gt;

&lt;p&gt;Cypress headless mode is a feature of the Cypress testing framework that allows you to run tests without a visible browser UI. In Cypress headless mode, the test runs in the background without rendering a graphical user interface for the browser being used for testing. This is particularly useful for automated testing in CI/CD pipelines or when you simply want to run tests without the overhead of a visible browser window.&lt;/p&gt;

&lt;h3&gt;
  
  
  What is the difference between headless and headed mode in Cypress?
&lt;/h3&gt;

&lt;p&gt;The difference between headless and headed mode in Cypress lies in the visibility of the browser user interface during test execution. In headed mode, Cypress displays a graphical user interface of the browser, allowing developers and testers to visually inspect the web page, interact with it manually, and observe test execution in real time. This mode is useful for debugging and development.&lt;/p&gt;

&lt;p&gt;Conversely, Cypress headless mode runs tests without a visible browser UI, making it ideal for automated testing scenarios, especially in continuous integration (CI) environments. Since there’s no UI rendering, Cypress headless mode offers faster test execution and greater efficiency, making it well-suited for batch test runs where human interaction with the browser is unnecessary. The choice between the two modes depends on the testing context and whether manual interaction or automation efficiency is the primary focus.&lt;/p&gt;

&lt;h3&gt;
  
  
  Is Cypress headless faster?
&lt;/h3&gt;

&lt;p&gt;Yes, Cypress in headless mode is typically faster than running it in headed mode with a visible browser UI. The main reason for this speed difference is that in headless mode, there is no graphical user interface to render, which reduces the computational overhead and allows the tests to execute more efficiently.&lt;/p&gt;

&lt;p&gt;In headless mode, Cypress runs the tests in the background, and the absence of a visible browser window means fewer resources are dedicated to rendering and displaying the web page. As a result, test execution can be significantly faster, which is especially beneficial in automated testing scenarios such as continuous integration (CI) pipelines, where speed and efficiency are essential.&lt;/p&gt;

&lt;p&gt;However, it’s important to note that the actual speed difference may vary depending on the complexity of the tests and the specific use case. For many automated testing scenarios, especially those involving many tests, Cypress in headless mode is preferred to maximize testing efficiency&lt;/p&gt;

</description>
      <category>cypress</category>
      <category>webdev</category>
      <category>programming</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>How to Perform E2E Testing Using Cypress CLI and Test Runner</title>
      <dc:creator>Kailash Pathak</dc:creator>
      <pubDate>Tue, 12 Sep 2023 06:43:09 +0000</pubDate>
      <link>https://dev.to/testmuai/how-to-perform-e2e-testing-using-cypress-cli-and-test-runner-13m6</link>
      <guid>https://dev.to/testmuai/how-to-perform-e2e-testing-using-cypress-cli-and-test-runner-13m6</guid>
      <description>&lt;p&gt;End-to-End (E2E) testing is a software testing methodology that focuses on testing an application’s workflow from start to finish, simulating real user interactions, and verifying that all components of the system work together correctly.&lt;/p&gt;

&lt;p&gt;To illustrate E2E testing, let’s consider a live scenario involving an eCommerce website. The goal is to test the entire purchasing process, from when a user adds items to the shopping cart until the order is successfully placed. We usually follow the below approach.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Test Setup:&lt;/strong&gt; Ensure the &lt;a href="https://www.lambdatest.com/blog/what-is-test-environment/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=sept_11&amp;amp;utm_term=bh&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;testing environment&lt;/a&gt; is prepared with the latest version of the application and necessary test data.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Test Case/Automation script Preparation:&lt;/strong&gt; Define &lt;a href="https://www.lambdatest.com/learning-hub/test-case?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=sept_11&amp;amp;utm_term=bh&amp;amp;utm_content=learning_hub" rel="noopener noreferrer"&gt;test cases&lt;/a&gt;/scripts to cover the complete order placement process, including adding items to the cart, user authentication, shipping selection, payment processing, and order confirmation.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Test Execution:&lt;/strong&gt; Begin the test by simulating user interactions, such as adding items to the cart, filling in user details, selecting shipping options, entering payment information, and confirming the order.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Test Completion:&lt;/strong&gt; Review the test results, identify critical issues, and summarize the overall findings, including bugs, errors, or unexpected behavior.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Selenium &lt;a href="https://www.lambdatest.com/learning-hub/webdriverio?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=sept_11&amp;amp;utm_term=bh&amp;amp;utm_content=learning_hub" rel="noopener noreferrer"&gt;WebdriverIO&lt;/a&gt; is Javascript based test automation framework built over nodeJs. Learn with this guide how to use webdriverIO to perform web automation testing.&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;By performing E2E testing in a live scenario like this, you can gain confidence in the reliability and functionality of the eCommerce website’s purchasing process.&lt;/p&gt;

&lt;p&gt;Running E2E tests using Cypress CLI helps you configure test runs, generate reports, and integrate with other tools and services to streamline your testing process. It provides a command-line interface to manage and execute E2E tests efficiently. The Cypress CLI provides a comprehensive set of commands and features that empower developers and testers to perform robust and efficient E2E testing.&lt;/p&gt;

&lt;p&gt;The other way to run E2E tests is using Cypress Test Runner, which provides an interactive graphical interface that allows developers and testers to run their tests, monitor their progress, and analyze the results in real-time. When using the Cypress Test Runner, you can select specific test files or &lt;a href="https://www.lambdatest.com/learning-hub/test-suite?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=sept_11&amp;amp;utm_term=bh&amp;amp;utm_content=learning_hub" rel="noopener noreferrer"&gt;test suites&lt;/a&gt; to execute and then observe the &lt;a href="https://www.lambdatest.com/learning-hub/test-execution?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=sept_11&amp;amp;utm_term=bh&amp;amp;utm_content=learning_hub" rel="noopener noreferrer"&gt;test execution&lt;/a&gt; step by step.&lt;/p&gt;

&lt;p&gt;You will learn more about different ways of running tests in Cypress, i.e., using Cypress CLI and Test Runner in the later sections of this &lt;a href="https://www.lambdatest.com/learning-hub/cypress-tutorial?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=sept_11&amp;amp;utm_term=bh&amp;amp;utm_content=learning_hub" rel="noopener noreferrer"&gt;Cypress tutorial&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  What is E2E Testing?
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://www.lambdatest.com/learning-hub/end-to-end-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=sept_11&amp;amp;utm_term=bh&amp;amp;utm_content=learning_hub" rel="noopener noreferrer"&gt;End-to-End (E2E) testing&lt;/a&gt; is a software testing strategy that focuses on verifying the complete flow of an application from start to finish. It aims to ensure that all system components, including user interfaces, APIs, databases, and integrations, work together properly and meet the desired functionality.&lt;/p&gt;

&lt;p&gt;It is often performed after &lt;a href="https://www.lambdatest.com/learning-hub/unit-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=sept_11&amp;amp;utm_term=bh&amp;amp;utm_content=learning_hub" rel="noopener noreferrer"&gt;unit testing&lt;/a&gt; and &lt;a href="https://www.lambdatest.com/learning-hub/integration-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=sept_11&amp;amp;utm_term=bh&amp;amp;utm_content=learning_hub" rel="noopener noreferrer"&gt;integration testing&lt;/a&gt;, which test individual components and their interactions, respectively. By conducting E2E testing, the entire system is evaluated as a whole, simulating real-world user scenarios and ensuring that the application behaves as expected in a production-like environment.&lt;/p&gt;

&lt;p&gt;The primary goal of E2E testing is to validate the application’s functionality, reliability, and performance from end to end. It helps uncover any defects or issues arising from the interactions between different components. By thoroughly testing the application’s complete flow, E2E testing provides confidence that the system works as intended and meets the requirements of the end-users or business.&lt;/p&gt;

&lt;p&gt;Let’s take an example of a simple E2E test scenario where you login into &lt;a href="https://ecommerce-playground.lambdatest.io/index.php?route=account/login?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=sept_11&amp;amp;utm_term=bh&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;LambdaTest’s eCommerce Playground&lt;/a&gt; with valid credentials. After login subscribe to the newsletter and verify whether the subscription was successful.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Which are the most wanted &lt;a href="https://www.lambdatest.com/blog/automation-testing-tools/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=sept_11&amp;amp;utm_term=bh&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;automation testing tools &lt;/a&gt;in 2023 that have climbed the top of the ladder so far? Let’s take a look.&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F08a6je0a2311vncw3rj8.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F08a6je0a2311vncw3rj8.png" width="800" height="305"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Why Cypress for End-to-End Testing?
&lt;/h2&gt;

&lt;p&gt;E2E testing is a type of &lt;a href="https://www.lambdatest.com/learning-hub/software-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=sept_11&amp;amp;utm_term=bh&amp;amp;utm_content=learning_hub" rel="noopener noreferrer"&gt;software testing&lt;/a&gt; that verifies the entire application from start to finish. This means that E2E tests simulate real user interactions with the application, ensuring that all of the application’s features work together as expected. &lt;a href="https://www.lambdatest.com/learning-hub/cypress-tutorial?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=sept_11&amp;amp;utm_term=bh&amp;amp;utm_content=learning_hub" rel="noopener noreferrer"&gt;Cypress&lt;/a&gt; is the best fit for E2E testing for several reasons:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Ease of Use&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Cypress provides an intuitive and easy-to-use API, which makes it user-friendly and allows developers/testers to write tests quickly. Its syntax is straightforward, and the documentation is extensive and well-maintained.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Automatic waiting and real-time reloading&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Cypress automatically waits for &lt;a href="https://www.lambdatest.com/blog/document-object-model/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=sept_11&amp;amp;utm_term=bh&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;DOM&lt;/a&gt; elements to become available and actions to complete, eliminating the need for manual waits or timeouts. It also provides real-time reloading, which means developers/testers can see the impact of their code changes immediately during test execution.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Automatic screenshots and video recording&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Cypress automatically captures screenshots and records videos during test runs. This is helpful for visual debugging and for documenting test failures, making it easier to understand and reproduce issues.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Built-in Test Runner&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Cypress comes with a built-in Test Runner, which means there is no need to set up or configure additional tools or frameworks. The Test Runner provides a clear interface to view test results, manage test files, and execute tests with a simple command.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Active and supportive community&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Cypress has a vibrant and active community of developers who contribute to its development and provide support. The official documentation is comprehensive and regularly updated, and there are numerous community-written tutorials, blog posts, and plugins available&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Full control over the application&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;To understand &lt;a href="https://www.lambdatest.com/blog/cypress-end-to-end-testing/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=sept_11&amp;amp;utm_term=bh&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;Cypress E2E testing&lt;/a&gt;, let’s take a closer look at the &lt;a href="https://www.lambdatest.com/learning-hub/test-pyramid?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=sept_11&amp;amp;utm_term=bh&amp;amp;utm_content=learning_hub" rel="noopener noreferrer"&gt;test automation pyramid&lt;/a&gt;. We routinely do each level of testing listed in this pyramid while performing &lt;a href="https://www.lambdatest.com/cypress-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=sept_11&amp;amp;utm_term=bh&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;Cypress testing&lt;/a&gt;.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Deep dive to learn &lt;a href="https://www.lambdatest.com/learning-hub/automation-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=sept_11&amp;amp;utm_term=bh&amp;amp;utm_content=learning_hub" rel="noopener noreferrer"&gt;what is automation testing&lt;/a&gt;, its uasage, types and also gain insights on how to get started with automated testing.&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/jX3v3N6oN5M"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;Subscribe to the &lt;a href="https://www.youtube.com/channel/UCCymWVaTozpEng_ep0mdUyw?sub_confirmation=1?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=sept_11&amp;amp;utm_term=bh&amp;amp;utm_content=youtube" rel="noopener noreferrer"&gt;LambdaTest YouTube Channel&lt;/a&gt; to get the latest updates on tutorials around &lt;a href="https://www.lambdatest.com/selenium-automation?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=sept_11&amp;amp;utm_term=bh&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;Selenium testing&lt;/a&gt;, &lt;a href="https://www.lambdatest.com/cypress-e2e-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=sept_11&amp;amp;utm_term=bh&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;Cypress e2e testing&lt;/a&gt;, &lt;a href="https://www.lambdatest.com/appium-mobile-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=sept_11&amp;amp;utm_term=bh&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;Appium&lt;/a&gt;, and more.&lt;/p&gt;

&lt;h2&gt;
  
  
  Testing Pyramid Layers in Cypress
&lt;/h2&gt;

&lt;p&gt;Cypress team introduced &lt;a href="https://www.lambdatest.com/learning-hub/component-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=sept_11&amp;amp;utm_term=bh&amp;amp;utm_content=learning_hub" rel="noopener noreferrer"&gt;component testing&lt;/a&gt; with &lt;a href="https://www.lambdatest.com/blog/cypress-10-migration/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=sept_11&amp;amp;utm_term=bh&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;Cypress 10 &lt;/a&gt;that allows developers to test individual components quickly, regardless of their complexity. Component tests differ from E2E tests in that instead of visiting a URL to pull up an entire app; a component can be “mounted” and tested on its own.&lt;/p&gt;

&lt;p&gt;In the context of Cypress, here’s how the testing pyramid can be applied:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F6ua6g54bavavh6rz1vcc.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F6ua6g54bavavh6rz1vcc.png" width="800" height="666"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Unit Tests&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;These tests focus on testing individual components or functions in isolation. In Cypress, you can use frameworks like &lt;a href="https://www.lambdatest.com/mocha-js?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=sept_11&amp;amp;utm_term=bh&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;Mocha&lt;/a&gt; or &lt;a href="https://www.lambdatest.com/jest?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=sept_11&amp;amp;utm_term=bh&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;Jest&lt;/a&gt; to write unit tests for your JavaScript functions.&lt;/p&gt;

&lt;p&gt;These tests are typically executed quickly and frequently, ensuring that each component of your application works as expected.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Component Tests&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;These tests verify the behavior of individual components or UI elements in your application. In Cypress, you can write component tests that interact with specific UI elements and verify their functionality.&lt;/p&gt;

&lt;p&gt;These tests ensure that each component functions correctly within the application’s context.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Integration Tests&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Integration tests focus on testing the interactions between different components or modules in your application. In Cypress, you can write integration tests that simulate user interactions and verify the integration of various components.&lt;/p&gt;

&lt;p&gt;These tests ensure that the different parts of your application work together seamlessly.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;End-to-End (E2E) Tests&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;These tests span the entirety of the application’s process, validating its behavior holistically. Within Cypress, E2E tests can be authored to replicate user actions, engage with the UI, and authenticate anticipated results.&lt;/p&gt;

&lt;p&gt;Although these tests often demand more time for execution, they deliver a sense of assurance in the comprehensive functionality of your application.&lt;/p&gt;

&lt;p&gt;To know more about component testing, let’s see the difference between &lt;a href="https://www.lambdatest.com/learning-hub/end-to-end-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=sept_11&amp;amp;utm_term=bh&amp;amp;utm_content=learning_hub" rel="noopener noreferrer"&gt;end-to-end testing&lt;/a&gt; and component testing. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2440%2F1%2APAcBSehHcyBhz9jBrb3keQ.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2440%2F1%2APAcBSehHcyBhz9jBrb3keQ.png" width="800" height="730"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;This blog discusses the most exciting features of 13 best &lt;a href="https://www.lambdatest.com/blog/best-test-automation-frameworks-2021/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=sept_11&amp;amp;utm_term=bh&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;automation testing frameworks&lt;/a&gt; in 2021.&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Here is an example of Cypress E2E test scenario:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Test Scenario&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt; Visit the site&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://ecommerce-playground.lambdatest.io/index.php?route=account/login?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=sept_11&amp;amp;utm_term=bh&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;https://ecommerce-playground.lambdatest.io/index.php?route=account/login&lt;/a&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Search with valid data and verify the search data should be displayed.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Search with invalid data and verify the message.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Implementation&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;In the following scenario, we will navigate to the website and perform searches using both valid and invalid data.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;describe('Search  with valid and Invalid data' , () =&amp;gt; {
 beforeEach(() =&amp;gt; {
 cy.visit('https://ecommerce-playground.lambdatest.io/index.php?route=account/login')
 })
 it('Searches for the valid text  "Apple" and  verify the results', () =&amp;gt; {
  // Enter the search data and submit the form
   cy.get('[name="search"]').eq(0).type('Apple')
   cy.get('.type-text').click()
   // Verify the search results
   cy.url().should('include', 'search=Apple')
   cy.contains('Search - Apple').should('be.visible')
   cy.get('.product-layout').should('have.length.gt', 0)
 })
 it('Displays message with no search results for invalid search term', () =&amp;gt; {
   // Enter search term and verify returns no results and submit form
   cy.get('[name="search"]').eq(0).type('xyz')
   cy.get('.type-text').click()
   // Verify message for no search results
   cy.contains('There is no product that matches the search criteria.').should('be.visible')
 })
})
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Let’s execute the test cases in Searchwith_validAndinvalid_data.cy.js.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Execution&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3200%2F0%2A4GLWUIRXSfW_-cgM.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3200%2F0%2A4GLWUIRXSfW_-cgM.png" width="800" height="377"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Discover the 17 key &lt;a href="https://www.lambdatest.com/blog/17-key-benefits-of-automation-testing-for-a-successful-release/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=sept_11&amp;amp;utm_term=bh&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;benefits of automation testing&lt;/a&gt;, which will help you decide whether this is the right call for your SDLC.&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  What is Cypress CLI (Command Line Interface)?
&lt;/h2&gt;

&lt;p&gt;CLI stands for Command-Line Interface. It is a text-based interface used to interact with a computer operating system or software by typing commands instead of using a graphical user interface (GUI).&lt;/p&gt;

&lt;p&gt;Typically, CLI commands consist of a command followed by optional parameters or arguments. The user enters the command, and the system responds with the requested action or provides feedback on the command’s execution. CLI is popular among developers and system administrators due to its efficiency, flexibility, and ability to automate tasks through scripts or batch files.&lt;/p&gt;

&lt;p&gt;Some well-known examples of CLI interfaces include the Windows Command Prompt (cmd.exe), PowerShell (for Windows), the Unix/Linux shell (such as Bash), and the macOS Terminal (based on the Unix shell).&lt;/p&gt;

&lt;p&gt;The Cypress CLI provides a set of commands that enable developers and testers to interact with the WebElements and control the Cypress testing framework from the command line. It allows you to initialize new Cypress projects, run tests, open the Cypress Test Runner, and perform various other testing-related tasks.&lt;/p&gt;

&lt;p&gt;With the Cypress CLI, you can perform various tasks, including:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Opening the Cypress Test Runner:&lt;/strong&gt; The CLI allows you to open the Cypress Test Runner, which provides a graphical user interface for running and debugging your tests. You can use this interface to select and execute individual test files or suites, view test results, and debug failing tests.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Running tests in headless mode:&lt;/strong&gt; Using Cypress CLI, you can run &lt;a href="https://www.lambdatest.com/blog/cypress-test-automation-framework/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=sept_11&amp;amp;utm_term=bh&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;Cypress test automation&lt;/a&gt; in headless mode, which means the tests run without displaying the graphical user interface of the Test Runner. This is useful for running tests in a &lt;a href="https://www.lambdatest.com/blog/what-is-continuous-integration-and-continuous-delivery/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=sept_11&amp;amp;utm_term=bh&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;Continuous Integration (CI)&lt;/a&gt; environment or as part of an automated test suite.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Running tests in different browsers:&lt;/strong&gt; The Cypress CLI lets you specify the browser in which you want to run your Cypress tests. You can choose from popular browsers like Chrome, Firefox, or Electron or even specify custom browser configurations.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;**Running tests in parallel: **If you have a large suite of tests, the Cypress CLI enables you to run &lt;a href="https://www.lambdatest.com/cypress-parallel-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=sept_11&amp;amp;utm_term=bh&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;Cypress parallel testing&lt;/a&gt; across multiple instances of Cypress. This can significantly reduce the overall test execution time.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Generating test reports:&lt;/strong&gt; You can generate HTML or JSON reports for your test runs using the Cypress CLI. These reports provide detailed information about the test results, including passed and failed tests, execution times, and error messages.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Managing configuration options:&lt;/strong&gt; The Cypress CLI allows you to configure various options for Cypress, such as specifying the test file patterns to include or exclude, setting environment variables, configuring plugins, and more.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;This article on the Best &lt;a href="https://www.lambdatest.com/blog/top-ui-automated-testing-tools/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=sept_11&amp;amp;utm_term=bh&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;UI Automation Testing Tools&lt;/a&gt; cover what is UI automated testing, challenges while performing UI testing, and top tools that can help you perform UI testing.&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Here are some common commands we can run using Cypress CLI:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2668%2F1%2A77afPBPnPDBYLoR_GHXSgg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2668%2F1%2A77afPBPnPDBYLoR_GHXSgg.png" width="800" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  What is a Cypress Test Runner?
&lt;/h2&gt;

&lt;p&gt;Cypress also comes with a built-in Test Runner GUI that provides an interactive interface for running and debugging tests. To launch the Test Runner, you can use the Cypress open command. This opens a Test Runner window where you can select and run individual tests, view test results, and debug your code.&lt;/p&gt;

&lt;p&gt;The Cypress Test Runner operates directly in the browser and runs tests within it, enabling real-time visibility into the application under test. It offers a built-in time-traveling feature that allows developers to inspect and debug the application’s state at any point during the test execution. This makes it easier to troubleshoot and identify the causes of test failures.&lt;/p&gt;

&lt;p&gt;Some key features of Cypress Test Runner include:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Interactive Test Runner:&lt;/strong&gt; Cypress Test Runner has an interactive user interface that allows you to view the test execution in real time. You can see the commands being executed, their results, and any errors or failures. This live feedback makes it easy to identify and diagnose issues during test execution.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Time Travel:&lt;/strong&gt; Cypress allows you to “time travel” through your application and see exactly what happens at each step of your test. You can pause the test execution, step forward or backward, and inspect the application’s state at any time.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Debugging with DevTools:&lt;/strong&gt; Cypress integrates with the browser’s Developer Tools, allowing you to debug your application and tests directly from the Cypress Test Runner. You can set breakpoints, inspect variables, step through code, and interact with the application while the test is running.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Real-Time Reloads:&lt;/strong&gt; Cypress automatically detects changes made to the test code and reloads them in the Test Runner interface. This live reload functionality provides a seamless development experience, allowing developers to see the immediate effects of their code changes without manually reloading the page.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Network Stubbing and Spying:&lt;/strong&gt; Cypress allows developers to stub or intercept network requests made by the application. This enables you to simulate different network scenarios, control the responses from APIs, and test edge cases.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Below is the screenshot of Cypress Runner, which opens when the user runs the command ‘&lt;em&gt;yarn cypress open&lt;/em&gt;’.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3200%2F0%2A34ddezglapZGA6q0.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3200%2F0%2A34ddezglapZGA6q0.png" width="800" height="397"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Test native, hybrid, and web apps on any mobile OS with our free &lt;a href="https://www.lambdatest.com/android-emulator-online?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=sept_11&amp;amp;utm_term=bh&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;online emulator Android&lt;/a&gt;. Sign up to optimize app performance.&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  Running Test Cases in Cypress
&lt;/h2&gt;

&lt;p&gt;When it comes to running Cypress test cases, there are different approaches you can take depending on your specific requirements and testing environment.&lt;/p&gt;

&lt;p&gt;Here we will be discussing how you can run Cypress test cases using:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Cypress CLI&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Cypress Test Runner&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The Cypress CLI provides a straightforward way to run &lt;a href="https://www.lambdatest.com/blog/cypress-test-automation-framework/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=sept_11&amp;amp;utm_term=bh&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;Cypress automation&lt;/a&gt; from the command line. You can use the cypress run command to run your tests in headless mode or cypress open to run them in interactive mode. The Cypress CLI also offers various options and flags to customize the test run, such as specifying specific test files, setting environment variables, and generating &lt;a href="https://www.lambdatest.com/learning-hub/test-reports?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=sept_11&amp;amp;utm_term=bh&amp;amp;utm_content=learning_hub" rel="noopener noreferrer"&gt;test reports&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Now let’s take some examples to execute the test cases in Cypress CLI.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Test Scenario&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Visit the Site &lt;a href="https://ecommerce-playground.lambdatest.io/index.php?route=account/login?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=sept_11&amp;amp;utm_term=bh&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;https://ecommerce-playground.lambdatest.io/index.php?route=account/login&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Login into the site valid credential.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Do subscribe to the newsletter.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Verify newsletter is successfully subscribed.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Implementation&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Let’s create a new folder under the e2e folder named “demoCypressCLIRunner” to perform &lt;a href="https://www.lambdatest.com/cypress-ui-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=sept_11&amp;amp;utm_term=bh&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;Cypress UI testing&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Create the first test spec to check the login feature for the site with the name subscriptionScenario..cy.js under the folder ‘demoCypressCLIRunner’.&lt;/p&gt;

&lt;p&gt;For demo purposes, we are using the &lt;a href="https://ecommerce-playground.lambdatest.io/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=sept_11&amp;amp;utm_term=bh&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;LambdaTest eCommerce Playground&lt;/a&gt; site.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Use Case&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Login into the application and update the newsletter subscription.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;describe('Login and Subscribe', () =&amp;gt; {
 it('Logs in and subscribes to newsletter', () =&amp;gt; {
   // Visit the web site
   cy.visit('https://ecommerce-playground.lambdatest.io/index.php?route=account/login')


// Click on login button
 cy.get('[value="Login"]').click()
// Enter the valid email and password
cy.get('#input-email').type('lambdatestnew@yopmail.com')
cy.get('#input-password').type('Lambda123')


// Click on login button
cy.get('[value="Login"]').click()


// Verify user logged in successfully
cy.url().should('include', 'index.php?route=account/account')
cy.contains('My Account').should('be.visible')


// Subscribe the newsletter
 cy.contains('Newsletter').click()
 cy.get('#input-newsletter-yes').click({force:true})
 cy.get('[value="Continue"]').click()


 // Verify the subscription success message
   cy.get('.alert-success').should('contain', 'Success: Your newsletter subscription has been successfully updated!')
 })
})
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Test native, hybrid, and web apps on any mobile OS with our free &lt;a href="https://www.lambdatest.com/android-emulator-online?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=sept_11&amp;amp;utm_term=bh&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;online android emulator&lt;/a&gt;. Sign up to optimize app performance.&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  How to Run Test Cases in CLI?
&lt;/h2&gt;

&lt;p&gt;There are different ways to run the Cypress test cases in CLI.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Command 1:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Run all Cypress tests using Cypress CLI in the Electron default headless browser.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2000%2F0%2A_36KGth2UVYubW1j.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2000%2F0%2A_36KGth2UVYubW1j.png" width="710" height="266"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Output&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;All the tests are in headless mode in the default browser Electron. The Cypress command ran successfully, and our tests got executed.&lt;/p&gt;

&lt;p&gt;Now, let’s understand some important aspects of this execution marked by the numbered tickets:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Command used to run all the test files present under the “e2e” folder.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Test cases started with Cypress, Browser, and Node versions with the number of test .spec files.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Test cases are executed one by one in the 3rd sticker. It shows that the first .spec file is passed.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Recording of all the test cases is saved under the ‘videos’ folder, which greatly helps during debugging.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Final test cases execution result report with parameters like Tests, Passing Test, Failing Test, Pending, and Skipped Tests.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3200%2F0%2AdFOdUsfgVmAq2hC4.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3200%2F0%2AdFOdUsfgVmAq2hC4.png" width="800" height="733"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3200%2F0%2A27mKvwpdkMxClkOu.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3200%2F0%2A27mKvwpdkMxClkOu.png" width="800" height="591"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;A comprehensive &lt;a href="https://www.lambdatest.com/learning-hub/end-to-end-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=sept_11&amp;amp;utm_term=bh&amp;amp;utm_content=learning_hub" rel="noopener noreferrer"&gt;end-to-end Testing&lt;/a&gt; tutorial that covers what E2E Testing is, its importance, benefits, and how to perform it with real-time examples.&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;strong&gt;Command 2:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Run the particular test in headless mode in the default browser Electron.&lt;/p&gt;

&lt;p&gt;To run specific spec files from the list of test cases under the e2e folder, we can mention the path using “&lt;em&gt;–spec&lt;/em&gt;” along with the “&lt;em&gt;cypress run&lt;/em&gt;” command.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3200%2F0%2AEWSXzt5i9bcUw4xt.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3200%2F0%2AEWSXzt5i9bcUw4xt.png" width="800" height="764"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2992%2F0%2AQfRHPFHh-z3PlNqr.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2992%2F0%2AQfRHPFHh-z3PlNqr.png" width="800" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Output&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;In the output, we can see the test case execution report of a particular .spec.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Command 3:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Run all the tests in Cypress CLI to run tests in Chrome (Headless Mode).&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2000%2F0%2ANI6KxsU0lyEN0NKy.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2000%2F0%2ANI6KxsU0lyEN0NKy.png" width="800" height="281"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Output&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;In the output, we can see the test case execution report of all test cases in the Chrome browser.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3200%2F0%2AsbLkF8P7YZxNZaZB.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3200%2F0%2AsbLkF8P7YZxNZaZB.png" width="800" height="757"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Command 4:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Run a particular test case in Cypress CLI to run tests in (Headless Mode).&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3196%2F0%2AKTbd4lW5iEZe00No.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3196%2F0%2AKTbd4lW5iEZe00No.png" width="800" height="164"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Output&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;In the output, we can see the test case execution report of a particular .spec in the Chrome browser.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3200%2F0%2AnR9WbCANepYhIBvd.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3200%2F0%2AnR9WbCANepYhIBvd.png" width="800" height="715"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;A comprehensive end-to-end Testing tutorial that covers what &lt;a href="https://www.lambdatest.com/learning-hub/end-to-end-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=sept_11&amp;amp;utm_term=bh&amp;amp;utm_content=learning_hub" rel="noopener noreferrer"&gt;e2e Testing &lt;/a&gt;is, its importance, benefits, and how to perform it with real-time examples.&lt;/strong&gt;&lt;br&gt;
Let’s take one more scenario.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;strong&gt;Test Scenario&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Visit the site&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://ecommerce-playground.lambdatest.io/index.php?route=account/login?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=sept_11&amp;amp;utm_term=bh&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;https://ecommerce-playground.lambdatest.io/index.php?route=account/login&lt;/a&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Search with valid data and verify the search data should be displayed.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Search with invalid data and verify the message.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Implementation&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Create the second test case with the name “Searchwith_validAndinvalid_data.cy.js” under the LambdaTest folder.&lt;/p&gt;

&lt;p&gt;In the below test case, we are covering the search with valid and invalid data and verifying the search result.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Use Case&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Open the site and search with valid and invalid data.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;describe('Search  with valid and Invalid data' , () =&amp;gt; {
 beforeEach(() =&amp;gt; {
 cy.visit('https://ecommerce-playground.lambdatest.io/index.php?route=account/login')
 })
 it('Searches for the valid text  "Apple" and  verify the results', () =&amp;gt; {
  // Enter the search data and submit the form
   cy.get('[name="search"]').eq(0).type('Apple')
   cy.get('.type-text').click()
   // Verify the search results
   cy.url().should('include', 'search=Apple')
   cy.contains('Search - Apple').should('be.visible')
   cy.get('.product-layout').should('have.length.gt', 0)
 })
 it('Displays message with no search results for invalid search term', () =&amp;gt; {
   // Enter search term and verify returns no results and submit form
   cy.get('[name="search"]').eq(0).type('xyz')
   cy.get('.type-text').click()
   // Verify message for no search results
   cy.contains('There is no product that matches the search criteria.').should('be.visible')
 })
})
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;Command 1:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Run all the tests in Cypress CLI in default browser Electron (Headless Mode).&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;yarn cypress run
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;Output&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3200%2F0%2AKpNt0U2S1Jbyz36n.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3200%2F0%2AKpNt0U2S1Jbyz36n.png" width="800" height="378"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Command 2:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Run a particular test in Cypress CLI to run tests in Chrome (Headless Mode).&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;yarn cypress run --spec cypress/e2e/demoCypressCLIRunner/Searchwith_validAndinvalid_data.cy.js
Chrome
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;Output&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3200%2F0%2Av3xiruV615U2xUJ0.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3200%2F0%2Av3xiruV615U2xUJ0.png" width="800" height="423"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Command 3:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Run all test cases in Cypress CLI to run tests in Chrome (Headless Mode).&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;yarn cypress run — headless — browser chrome
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;Output&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3200%2F0%2AQw2qUYFOUxSC4oZO.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3200%2F0%2AQw2qUYFOUxSC4oZO.png" width="800" height="583"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Command 4:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Run particular test in headless mode in Chrome browser.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;yarn cypress run - spec cypress/e2e/demoCypressCLIRunner/Searchwith_validAndinvalid_data.cy.js
Chrome
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;Output&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3200%2F0%2AMGd38TVd7mzwnH_u.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3200%2F0%2AMGd38TVd7mzwnH_u.png" width="800" height="734"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;In this Appium tutorial, learn about Appium and its benefits for mobile automation testing. Take a look at how Appium works and see how to perform &lt;a href="https://www.lambdatest.com/appium?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=sept_11&amp;amp;utm_term=bh&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;Appium automation&lt;/a&gt; testing of your mobile applications.&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  How to Run Test Cases in Cypress Test Runner?
&lt;/h2&gt;

&lt;p&gt;Cypress Test Runner provides a user interface (UI) that allows you to interact with and run your Cypress tests. After executing the appropriate command to start the Test Runner, the UI will be launched. From there, you have several options for running your tests.&lt;/p&gt;

&lt;p&gt;By default, Cypress will launch the Test Runner UI with its default browser, which is typically Electron. However, you can switch to a different browser by selecting it from the available options in the browser drop-down menu.&lt;/p&gt;

&lt;p&gt;To run a single test, just enter the particular .spec name and execute the test case.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3200%2F0%2AZ3EEPN6ToQZ51atv.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3200%2F0%2AZ3EEPN6ToQZ51atv.png" width="800" height="318"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Another way to run a single test is to click on a specific test case, and it will start executing.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3200%2F0%2Axf-RWMQrMjJkCB5i.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3200%2F0%2Axf-RWMQrMjJkCB5i.png" width="800" height="346"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If you want to run the test case, run the command ‘&lt;em&gt;yarn cypress open&lt;/em&gt;’, which will open the Cypress Test Runner from where you can execute the test cases.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Execution&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Let’s execute both test cases Searchwith_validAndinvalid_data.cy.js and subscriptionScenario.cy.js in non headless mode using UI by passing –&lt;em&gt;ui&lt;/em&gt; in command.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3200%2F0%2ATHBfOd3eyNJ2U-ms.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3200%2F0%2ATHBfOd3eyNJ2U-ms.png" width="800" height="377"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3200%2F0%2A8TM4DGcF9YCIbdpm.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3200%2F0%2A8TM4DGcF9YCIbdpm.png" width="800" height="385"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You can also leverage the potential of Cypress E2E testing on the cloud and run Cypress test cases over real browsers and OS combinations. AI-powered test orchestration and execution platforms like LambdaTest offer a scalable &lt;a href="https://www.lambdatest.com/cypress-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=sept_11&amp;amp;utm_term=bh&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;Cypress cloud&lt;/a&gt; to perform &lt;a href="https://www.lambdatest.com/automation-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=sept_11&amp;amp;utm_term=bh&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;automation testing&lt;/a&gt; across 40+ real desktop browsers.&lt;/p&gt;

&lt;p&gt;Ready to elevate your Cypress automation skills? Join our specialized &lt;a href="https://www.lambdatest.com/certifications/cypress-101?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=sept_11&amp;amp;utm_term=bh&amp;amp;utm_content=certification" rel="noopener noreferrer"&gt;Cypress 101 certification&lt;/a&gt; program tailored for developers and testers seeking to expand their proficiency in Cypress test automation. Gain advanced insights, hone your abilities, and unlock a world of opportunities on your journey in test automation.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;A comprehensive &lt;a href="https://www.lambdatest.com/learning-hub/exploratory-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=sept_11&amp;amp;utm_term=bh&amp;amp;utm_content=learning_hub" rel="noopener noreferrer"&gt;Exploratory Testing&lt;/a&gt; tutorial that covers what Exploratory Testing is, its importance, benefits, and how to perform it with real-time examples.&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;With Cypress CLI, you can run tests from the command line, which helps integrate tests into your CI/CD pipelines or run them in headless environments.&lt;/p&gt;

&lt;p&gt;On the other hand, Cypress Test Runner offers a range of features that enhance the testing experience. It provides a real-time view of your application as tests run, allowing you to see each step executed and the application’s response. This helps in debugging and understanding the test flow.&lt;/p&gt;

&lt;h2&gt;
  
  
  Frequently Asked Questions (FAQs)
&lt;/h2&gt;

&lt;h3&gt;
  
  
  How to run Cypress cmd?
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;1.Navigate to Your Project Directory:&lt;/strong&gt; Open your command prompt or terminal and navigate to the root directory of your Cypress project.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. Run the Command:&lt;/strong&gt; Use the following command to execute Cypress tests:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npx cypress open
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;This command will open the Cypress Test Runner, allowing you to select and run your test files interactively.&lt;/p&gt;

&lt;p&gt;If you want to run tests in headless mode (without the interactive Test Runner UI), you can use:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npx cypress run
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;3.Select the Test File: In the Test Runner, select the test file you want to run from the list of available test files.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Run Tests: Click on the test file name to run the tests within that file.&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  What is a Cypress command?
&lt;/h3&gt;

&lt;p&gt;The “Cypress command” typically refers to the command-line interface (CLI) commands provided by the Cypress testing framework. These commands allow you to interact with Cypress, run tests, manage configurations, and perform various testing-related tasks. Some common Cypress commands include:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;&lt;em&gt;cypress open:&lt;/em&gt;&lt;/strong&gt; Opens the Cypress Test Runner, providing an interactive interface to run and debug tests.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;&lt;em&gt;cypress run:&lt;/em&gt;&lt;/strong&gt; Executes tests in headless mode, which is suitable for &lt;a href="https://www.lambdatest.com/learning-hub/automation-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=sept_11&amp;amp;utm_term=bh&amp;amp;utm_content=learning_hub" rel="noopener noreferrer"&gt;automated testing&lt;/a&gt; and integration with CI/CD pipelines.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;&lt;em&gt;cypress install:&lt;/em&gt;&lt;/strong&gt; Installs the Cypress framework and its dependencies within your project.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;&lt;em&gt;cypress verify:&lt;/em&gt;&lt;/strong&gt; Checks the installed version of Cypress and its compatibility with your project.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;&lt;em&gt;cypress –help:&lt;/em&gt;&lt;/strong&gt; Displays the list of available commands and their descriptions.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;&lt;em&gt;cypress –version:&lt;/em&gt;&lt;/strong&gt; Displays the currently installed version of Cypress.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;&lt;em&gt;cypress run –spec :&lt;/em&gt;&lt;/strong&gt; Runs a specific test spec file.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;&lt;em&gt;cypress run –record:&lt;/em&gt;&lt;/strong&gt; Records test runs in the Cypress Dashboard for insights and videos.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;&lt;em&gt;cypress run –parallel:&lt;/em&gt;&lt;/strong&gt; Runs tests in parallel with a paid Cypress Dashboard plan.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;These commands are executed in your terminal or command prompt and allow you to control various aspects of your testing workflow using the Cypress framework.&lt;/p&gt;

</description>
      <category>beginners</category>
      <category>tutorial</category>
      <category>programming</category>
      <category>devops</category>
    </item>
    <item>
      <title>How To Use Cypress For File Upload and Download</title>
      <dc:creator>Kailash Pathak</dc:creator>
      <pubDate>Tue, 11 Jul 2023 08:15:56 +0000</pubDate>
      <link>https://dev.to/testmuai/how-to-use-cypress-for-file-upload-and-download-2mo8</link>
      <guid>https://dev.to/testmuai/how-to-use-cypress-for-file-upload-and-download-2mo8</guid>
      <description>&lt;p&gt;On web applications, downloading and uploading files are operations we normally do, mainly for activities like banking, social media platforms, etc. In an online banking system, customers may need to upload documents such as income statements, bank statements, or identification proofs as part of a loan application process. Also, banking applications have features from which customers can download account statements.&lt;/p&gt;

&lt;p&gt;Similarly, social media platforms enable us to share photos, videos with our friends and followers. We upload these files from our devices to the social media platform, where they are stored and made accessible to others who can then download and view them.&lt;/p&gt;

&lt;p&gt;If a web application does not have an upload/download feature, it means that users won’t be able to transfer files directly between their devices and the application’s server through the application’s interface. It can result in potential business losses and impact user experience.&lt;/p&gt;

&lt;p&gt;Automation of uploading and downloading functionality involves automating the process of testing file transfer capabilities in a web application. It aims to efficiently and accurately validate the uploading and downloading features through automated scripts.&lt;/p&gt;

&lt;p&gt;Uploading files is typically done using a file input element on a web page, and the selected file is sent to the server as part of an HTTP request. In &lt;a href="https://www.lambdatest.com/learning-hub/cypress-tutorial" rel="noopener noreferrer"&gt;Cypress&lt;/a&gt;, you can automate file uploads by simulating user interaction with the file input element and attaching a file to it using the &lt;em&gt;.attach()&lt;/em&gt; command.&lt;/p&gt;

&lt;p&gt;Downloading files is typically done by sending an HTTP request to the server and receiving a file as part of the response. In Cypress, you can automate file downloads by intercepting the HTTP response and saving the file to a specified location on the user’s computer using the &lt;em&gt;.writeFile()&lt;/em&gt; command.&lt;/p&gt;

&lt;p&gt;Considering the criticality of these operations (i.e., using download/upload) in many businesses (e.g., banking, social media, eCommerce, etc.), it becomes imperative to test these functionalities as a part of the automated CI/CD pipeline.&lt;/p&gt;

&lt;p&gt;By the end of this &lt;a href="https://www.lambdatest.com/learning-hub/cypress-tutorial?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jul_11&amp;amp;utm_term=bh&amp;amp;utm_content=learning_hub" rel="noopener noreferrer"&gt;Cypress tutorial,&lt;/a&gt; you will learn how to use Cypress for file upload and download.&lt;/p&gt;

&lt;p&gt;So, let’s get started!&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Get ready for your Mocha interview with our expert-curated list of &lt;a href="https://www.lambdatest.com/learning-hub/mocha-interview-questions?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jul_11&amp;amp;utm_term=bh&amp;amp;utm_content=learning_hub" rel="noopener noreferrer"&gt;Mocha interview questions&lt;/a&gt; tips. Impress your potential employer and land your dream job!&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  How to use Cypress for file upload?
&lt;/h2&gt;

&lt;p&gt;Uploading files is a common scenario in web applications that allow users to upload their files. In the uploading files process, we select the file from the local machine to a web application during a test. Using Cypress for file upload involves testing adding a file with the below-supported format.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;​​Images:&lt;/strong&gt; JPEG (.jpg, .jpeg), PNG (.png), GIF (.gif).&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Documents:&lt;/strong&gt; PDF (.pdf), Microsoft Word (.doc, .docx), Microsoft Excel (.xls, .xlsx).&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Videos:&lt;/strong&gt; MP4 (.mp4), WebM (.webm), AVI (.avi), MOV (.mov)) to a web application using the &lt;a href="https://www.lambdatest.com/cypress-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jul_11&amp;amp;utm_term=bh&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;Cypress testing&lt;/a&gt; framework.&lt;br&gt;
&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/jX3v3N6oN5M"&gt;
&lt;/iframe&gt;
&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Boost your testing skills with &lt;a href="https://www.lambdatest.com/learning-hub/pytest-interview-questions?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jul_11&amp;amp;utm_term=bh&amp;amp;utm_content=learning_hub" rel="noopener noreferrer"&gt;Pytest interview questions&lt;/a&gt;. Beginner, intermediate, and advanced levels covered. Prepare and excel in your interviews.!&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;There are multiple ways to use Cypress for file upload. Here are some common approaches:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Using Cypress for file upload with the &lt;em&gt;selectFile().&lt;/em&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Using Cypress for file upload with the &lt;em&gt;cypress-file-upload&lt;/em&gt; plugin.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Using Cypress for file upload with the selectFile()
&lt;/h2&gt;

&lt;p&gt;There are various ways of uploading files using the &lt;em&gt;selectFile()&lt;/em&gt; command.&lt;/p&gt;

&lt;h3&gt;
  
  
  Using selectFile()
&lt;/h3&gt;

&lt;p&gt;Before explaining uploading files using &lt;em&gt;selectFile()&lt;/em&gt;, let’s learn about the command &lt;em&gt;selectFile()&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;The &lt;em&gt;selectFile()&lt;/em&gt; command in Cypress enables you to upload a single file, an array of files and simulate the selection of files with additional options. In Cypress, the &lt;em&gt;selectFile()&lt;/em&gt; command allows you to interact with file input elements (e.g., &amp;lt;&lt;em&gt;input type=”file&lt;/em&gt;“&amp;gt;)&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Syntax&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The &lt;em&gt;selectFile()&lt;/em&gt; method takes multiple arguments, as shown below:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2000%2F0%2A7cP_whXCUN-5PiGX.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2000%2F0%2A7cP_whXCUN-5PiGX.png" width="800" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In Cypress, the &lt;em&gt;selectFile()&lt;/em&gt; command can be used to imitate dragging a file or files into the browser, as well as selecting and uploading files to an HTML5 input element.&lt;/p&gt;

&lt;p&gt;When you invoke the &lt;em&gt;selectFile()&lt;/em&gt; command in Cypress for file upload, it opens a file selection dialog in the browser. You can then provide file paths or an array of file paths to the command to simulate the selection of files.&lt;/p&gt;

&lt;p&gt;The &lt;em&gt;selectFile()&lt;/em&gt; command in Cypress for file upload supports various file types for imitating file selection or upload actions in a browser or HTML5 input element. It can handle common file types such as:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Text files (e.g., .txt, .csv)&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Image files (e.g., .jpg, .png, .gif)&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Document files (e.g., .doc, .docx, .pdf)&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Audio files (e.g., .mp3, .wav)&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Video files (e.g., .mp4, .avi)&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If you are getting started with Cypress and want to install Cypress, you can go through this blog that covers &lt;a href="https://www.lambdatest.com/blog/getting-started-with-cypress/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jul_11&amp;amp;utm_term=bh&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;installing Cypress&lt;/a&gt; in detail. You can consider installing the latest version. However, the version at the time of writing this blog is 12.11.0.&lt;/p&gt;

&lt;p&gt;The &lt;em&gt;cy.selectFile(file)&lt;/em&gt; command lets you specify a file or files to be uploaded through an input element of type “file” on a web page.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;tr&gt;
&lt;td&gt;OPERATION&lt;/td&gt;
&lt;td&gt;COMMAND&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Upload JSON File&lt;/td&gt;
&lt;td&gt;cy.get(‘input[type=file]’).selectFile(‘file.json’)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Upload txt File&lt;/td&gt;
&lt;td&gt;cy.get(‘input[type=file]’).selectFile(‘file.txt’)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Upload image file (jpg, png)&lt;/td&gt;
&lt;td&gt;"cy.get(‘input[type=file]’).selectFile(‘image1.jpg’)
cy.get(‘input[type=file]’).selectFile(‘image2.png’)"&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Upload video file&lt;/td&gt;
&lt;td&gt;cy.get(‘input[type=file]’).selectFile(video.mp4′)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Upload audio file&lt;/td&gt;
&lt;td&gt;cy.get(‘input[type=file]’).selectFile(audio.mp3′)&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Ace your QA interviews with our comprehensive guide on 60+&lt;/strong&gt; &lt;a href="https://www.lambdatest.com/learning-hub/specflow-interview-questions?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jul_11&amp;amp;utm_term=bh&amp;amp;utm_content=learning_hub" rel="noopener noreferrer"&gt;&lt;strong&gt;SpecFlow Interview Questions&lt;/strong&gt;&lt;/a&gt; &lt;strong&gt;and Answers. Boost your BDD knowledge and showcase your SpecFlow expertise.&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;strong&gt;Options&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The options parameter is an optional object that allows you to customize the behavior of the &lt;em&gt;cy.selectFile()&lt;/em&gt;. In options, you can pass the following parameters.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;PARAMETER&lt;/strong&gt;&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;tr&gt;
&lt;td&gt;action&lt;/td&gt;
&lt;td&gt;select&lt;/td&gt;
&lt;td&gt;Switch modes. Valid values are select and drag-drop.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;force&lt;/td&gt;
&lt;td&gt;FALSE&lt;/td&gt;
&lt;td&gt;Forces the action, disables waiting for actionability.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;log&lt;/td&gt;
&lt;td&gt;TRUE&lt;/td&gt;
&lt;td&gt;Displays the command in the Command log.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;timeout&lt;/td&gt;
&lt;td&gt;defaultCommandTimeout&lt;/td&gt;
&lt;td&gt;Time to wait for .selectFile() to resolve before timing out.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;waitForAnimations&lt;/td&gt;
&lt;td&gt;waitForAnimations&lt;/td&gt;
&lt;td&gt;Whether to wait for elements to finish animating before executing the command.&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;Demo — Using Cypress for file upload using the selectFile()&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Test Scenario&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Visit the site: &lt;a href="https://the-internet.herokuapp.com/upload" rel="noopener noreferrer"&gt;https://the-internet.herokuapp.com/upload&lt;/a&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Upload the .png file.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Click on the Submit button.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;After submitting, verify the “File Uploaded” message.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;In this example, we are uploading the image file using &lt;em&gt;selectFile()&lt;/em&gt; with select mode. This command is used to select a file to upload to an input field. The command first selects the file input element using the &lt;em&gt;cy.get()&lt;/em&gt; method with the &lt;em&gt;input[type=file]&lt;/em&gt; selector.&lt;/p&gt;

&lt;p&gt;Then, the &lt;em&gt;selectFile()&lt;/em&gt; method is called on the selected element with the argument ‘image.png’. This will simulate selecting the file image.png in the file selection dialog that appears when a user clicks on the file input field.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Implementation&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;For demo purposes, I am taking the example from the site: &lt;a href="https://the-internet.herokuapp.com/upload" rel="noopener noreferrer"&gt;https://the-internet.herokuapp.com/upload&lt;/a&gt;&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;it("Upload the file using .selectFile with select mode", () =&amp;gt; {
   cy.visit("https://the-internet.herokuapp.com/upload");
   cy.get("#file-upload").selectFile("cypress/fixtures/images/nature_evening.png");
   cy.get("#file-submit").click();
   cy.get("#uploaded-files").contains("nature_evening.png");
   cy.get("h3", { timeout: 30000 }).should("have.text","File Uploaded!");
 });
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Ace your Cypress interview with these 60+ &lt;a href="https://www.lambdatest.com/learning-hub/cypress-interview-questions?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jul_11&amp;amp;utm_term=bh&amp;amp;utm_content=learning_hub" rel="noopener noreferrer"&gt;Cypress interview questions&lt;/a&gt;. Boost you confidence and land your dream job with this comprehensive guide.&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;You can use the *cy.get() *command and pass in the Id of the element. For example, the following code would locate an element with the ID ‘file-upload.’&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;cy.get(“#file-upload”)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3200%2F0%2ALNcX8Z0s1m_7Bgqh.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3200%2F0%2ALNcX8Z0s1m_7Bgqh.png" width="800" height="231"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;cy.get(“#file-submit”).
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;You can use the &lt;em&gt;cy.get()&lt;/em&gt; command and pass in the Id of the element. For example, the following code would locate an element with the ID ‘file-submit’.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3200%2F0%2AxRzgJQuCJAi2KgvR.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3200%2F0%2AxRzgJQuCJAi2KgvR.png" width="800" height="220"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;cy.get(“#uploaded-files”).
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;You can use the &lt;em&gt;cy.get()&lt;/em&gt; command and pass in the Id of the element. For example, the following code would locate an element with the ID ‘uploaded-files’.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3200%2F0%2AG4h7oeIw9IO9UBJD.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3200%2F0%2AG4h7oeIw9IO9UBJD.png" width="800" height="159"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Code Walkthrough&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;We have kept the .png file under the images folder. After uploading the image, click on the upload button and verify the message &lt;strong&gt;“File Uploaded!”&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 1&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;It navigates to the specified URL, which is the file upload page of a web application.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2616%2F0%2AMc245HZ039yG4jbQ.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2616%2F0%2AMc245HZ039yG4jbQ.png" width="800" height="243"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 2&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;It selects a file for upload. The code targets the file input element with the ID “file-upload” and uses the &lt;em&gt;.selectFile()&lt;/em&gt; command to specify the file path to be uploaded (“cypress/fixtures/images/nature_evening.png”).&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2616%2F0%2AhhdOSuEaDIC2V4iD.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2616%2F0%2AhhdOSuEaDIC2V4iD.png" width="800" height="223"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Here’s 295+ &lt;a href="https://www.lambdatest.com/learning-hub/selenium-interview-questions?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jul_11&amp;amp;utm_term=bh&amp;amp;utm_content=learning_hub" rel="noopener noreferrer"&gt;Selenium Interview Questions&lt;/a&gt; with Answers that will help you boost your confidence in an Interview.&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;strong&gt;Step 3&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;This line clicks on the “file-submit” button to initiate the file upload process.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2616%2F0%2A1JGM7TAxOoAlHNA1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2616%2F0%2A1JGM7TAxOoAlHNA1.png" width="800" height="223"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 4&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;It verifies that the uploaded file is displayed on the page. The code targets the element with the ID “uploaded-files” and checks if it contains the text “nature_evening.png.”&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2616%2F0%2ADVJy2JiAfgda6Ug8.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2616%2F0%2ADVJy2JiAfgda6Ug8.png" width="800" height="223"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 5&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;This line waits for an &amp;lt; h3 &amp;gt; element to appear on the page (with a maximum timeout of 30 seconds) and asserts that its text content is “File Uploaded!”. This assertion ensures that the file upload operation was successful.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2616%2F0%2AaR_QxkSABxrFeExq.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2616%2F0%2AaR_QxkSABxrFeExq.png" width="800" height="223"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Output&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3200%2F0%2ADkT6RA_c9uCw91tb.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3200%2F0%2ADkT6RA_c9uCw91tb.png" width="800" height="523"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;If you are preparing for a Playwright automation interview, this list of &lt;a href="https://www.lambdatest.com/learning-hub/playwright-interview-questions?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jul_11&amp;amp;utm_term=bh&amp;amp;utm_content=learning_hub" rel="noopener noreferrer"&gt;Playwright interview questions&lt;/a&gt; can help you get a list of the most asked questions with detailed answers.&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3&gt;
  
  
  Uploading files using the command selectFile() and options
&lt;/h3&gt;

&lt;p&gt;This command is used to select a file to upload to an input field using a drag-and-drop action. The command first selects the file input element using the &lt;em&gt;cy.get()&lt;/em&gt; method with the &lt;em&gt;input[type=file]&lt;/em&gt; selector.&lt;/p&gt;

&lt;p&gt;Then, the &lt;em&gt;selectFile()&lt;/em&gt; method is called on the selected element with two arguments. The first argument is image.png’, which is the name of the file you want to upload. The second argument is an options object with the action property set to ‘drag-drop’. This will simulate dragging and dropping the file onto the input field rather than using the file selection dialog.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Demo — Uploading files using the selectFile() and options&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;In this tutorial on Cypress for file upload, let’s look at the demonstration for uploading files using the &lt;em&gt;selectFile()&lt;/em&gt; and options.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Visit the site: &lt;a href="https://the-internet.herokuapp.com/upload" rel="noopener noreferrer"&gt;https://the-internet.herokuapp.com/upload&lt;/a&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Upload the .png file.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Click on the Submit button.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;After submitting, verify the “File Uploaded” message.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Implementation&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;For demo purposes, I am taking the example from the site: &lt;a href="https://the-internet.herokuapp.com/upload" rel="noopener noreferrer"&gt;https://the-internet.herokuapp.com/upload&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;In the below example, the location of uploading the file is from the local system.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;it("Upload the file using .selectFile with with drag and drop mode", () =&amp;gt; {
   cy.visit("https://the-internet.herokuapp.com/upload");
   cy.get("#file-upload").selectFile("cypress/fixtures/images/nature_night.png", {action: "drag-drop"});
   cy.get("#file-submit").click();
   cy.get("#uploaded-files").contains("nature_night.png");
   cy.get("h3", { timeout: 30000 }).should("have.text","File Uploaded!");
 });
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;Code Walkthrough&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 1&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The &lt;em&gt;cy.visit(“&lt;a href="https://the-internet.herokuapp.com/upload%E2%80%9D" rel="noopener noreferrer"&gt;https://the-internet.herokuapp.com/upload”&lt;/a&gt;)&lt;/em&gt; command is used to navigate to the specified URL, which is the web application’s file upload page.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2616%2F0%2AjlHHSEQ7aAL5B2ZD.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2616%2F0%2AjlHHSEQ7aAL5B2ZD.png" width="800" height="227"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Here’s a list of 70 &lt;a href="https://www.lambdatest.com/learning-hub/cucumber-interview-questions?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jul_11&amp;amp;utm_term=bh&amp;amp;utm_content=learning_hub" rel="noopener noreferrer"&gt;Cucumber Interview Questions&lt;/a&gt; and Answers that will help you boost your confidence in an Interview.&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;strong&gt;Step 2&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;It targets the file input element with the ID “file-upload” and uses the &lt;em&gt;.selectFile()&lt;/em&gt; command to specify the file path to be uploaded (“cypress/fixtures/images/nature_night.png”).&lt;/p&gt;

&lt;p&gt;Additionally, the {action: “drag-drop”} option indicates that the file should be selected using the drag-and-drop mode.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2616%2F0%2AAX0OHPjI1tc_9Aeu.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2616%2F0%2AAX0OHPjI1tc_9Aeu.png" width="800" height="249"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 3&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Clicks on the “file-submit” button to initiate the file upload process.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2616%2F0%2A7CX9dB3zb3vtz5vF.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2616%2F0%2A7CX9dB3zb3vtz5vF.png" width="800" height="223"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 4&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The &lt;em&gt;cy.get(“#uploaded-files”).contains(“nature_night.png”)&lt;/em&gt; verifies that the uploaded file is displayed on the page. It targets the element with the ID “uploaded-files” and checks if it contains the text “nature_night.png”.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2616%2F0%2A27IdPoVhImV9XjVB.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2616%2F0%2A27IdPoVhImV9XjVB.png" width="800" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 5&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The &lt;em&gt;cy.get(“h3”, { timeout: 30000 }).should(“have.text”,”File Uploaded!”)&lt;/em&gt; waits for an &amp;lt; h3 &amp;gt; element to appear on the page (with a maximum timeout of 30 seconds) and asserts that its text content is “File Uploaded!”.&lt;/p&gt;

&lt;p&gt;This assertion ensures that the file upload operation was successful.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2616%2F0%2AjRqEze9Mg6_zi0N_.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2616%2F0%2AjRqEze9Mg6_zi0N_.png" width="800" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The maximum file size that can be uploaded using the &lt;em&gt;cy.selectFile()&lt;/em&gt; command in Cypress depends on the underlying browser. We can give a timeout with a particular command to handle if a file takes a long time to upload.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Output&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3200%2F0%2AWMO0BxJw4-EyZgyh.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3200%2F0%2AWMO0BxJw4-EyZgyh.png" width="800" height="465"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Get ready for your BDD interview with 100+ &lt;a href="https://www.lambdatest.com/learning-hub/bdd-interview-questions?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jul_11&amp;amp;utm_term=bh&amp;amp;utm_content=learning_hub" rel="noopener noreferrer"&gt;BDD interview questions&lt;/a&gt;. Boost your confidence and impress your interviewer with this comprehensive guide covering principles &amp;amp; techniques&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3&gt;
  
  
  Uploading an array of files using the selectFile()
&lt;/h3&gt;

&lt;p&gt;The command first selects the file input element using the &lt;em&gt;cy.get()&lt;/em&gt; method with the &lt;em&gt;input[type=file]&lt;/em&gt; selector.&lt;/p&gt;

&lt;p&gt;Then, the &lt;em&gt;selectFile()&lt;/em&gt; method is called on the selected element with the argument [imag1.png’, ‘image2.png’]. This will simulate selecting multiple files in the file selection dialog that appears when a user clicks on the file input field.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Demo — Uploading an array of files using the selectFile()&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Test Scenario&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Visit the site: &lt;a href="https://postimages.org/" rel="noopener noreferrer"&gt;https://postimages.org/&lt;/a&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Upload multiple .png files with the drag-drop option.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;After upload, verify the text “Upload completed”.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;After uploading, verify the title of all uploaded images.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Implementation&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;For demo purposes, I am taking the example from the site:&lt;br&gt;
&lt;a href="https://postimages.org/" rel="noopener noreferrer"&gt;https://postimages.org/&lt;/a&gt;&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;it("Upload multiple file using selectFile", () =&amp;gt; {
cy.visit("https://postimages.org/");
   cy.get("#uploadFile").selectFile(["cypress/fixtures/images/nature_evening.png","cypress/fixtures/images/nature_night.png"],{ action: "drag-drop" });
     cy.origin('https://postimg.cc/', () =&amp;gt; {
     cy.get('.controls', { timeout: 20000 }).contains('Upload completed!');
     cy.get(".imagetitle").eq(0).should("have.text", "nature_evening");
     cy.get(".imagetitle").eq(1).should("have.text", "nature_night");
   });
 })
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;The test visits the PostImages website, selects two image files using the &lt;em&gt;“selectFile”&lt;/em&gt; method, and then asserts that the files were uploaded successfully by checking for the presence of the file names in the UI.&lt;/p&gt;

&lt;p&gt;The test also uses the “origin” command to ensure that the assertions are performed on the correct domain and sets a timeout of 20 seconds for the “controls” element to appear.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;cy.get(“#uploadFile”).
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3200%2F0%2AKjApi-VRi6PpBxHj.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3200%2F0%2AKjApi-VRi6PpBxHj.png" width="800" height="154"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;cy.get(“.imagetitle”).
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3200%2F0%2AxuNFa_l-8quvhg1i.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3200%2F0%2AxuNFa_l-8quvhg1i.png" width="800" height="194"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;cy.get(‘.controls’)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3200%2F0%2AH839x5lFVRb3A4l1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3200%2F0%2AH839x5lFVRb3A4l1.png" width="800" height="139"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Code Walkthrough&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 1&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;It visits the “&lt;a href="https://postimages.org/%E2%80%9D" rel="noopener noreferrer"&gt;https://postimages.org/”&lt;/a&gt; website.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2616%2F0%2AV1c0paSyUx3b7NoF.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2616%2F0%2AV1c0paSyUx3b7NoF.png" width="800" height="223"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 2&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;It selects the file inputs with the ID “uploadFile”.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2616%2F0%2AJZfLv8aZmk-aWXsB.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2616%2F0%2AJZfLv8aZmk-aWXsB.png" width="800" height="242"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 3&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Below command is used to navigate to a URL starting with “&lt;a href="https://postimg.cc" rel="noopener noreferrer"&gt;https://postimg.cc&lt;/a&gt; /” using the &lt;em&gt;cy.origin()&lt;/em&gt; command.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2616%2F0%2ApCl11GTXuONRns73.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2616%2F0%2ApCl11GTXuONRns73.png" width="800" height="381"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 4&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;After uploading the image successfully, you can verify the message “&lt;strong&gt;File Uploaded!&lt;/strong&gt;”&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Output&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;In the output, you can see images are uploaded successfully, and the message “File Uploaded!” is verified.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3200%2F0%2AOn8WHXoaXFndEQJs.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3200%2F0%2AOn8WHXoaXFndEQJs.png" width="800" height="331"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3200%2F0%2Am_4OGjlSU2liZRZ8.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3200%2F0%2Am_4OGjlSU2liZRZ8.png" width="800" height="372"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Ace your Protractor interview with these 50+ &lt;a href="https://www.lambdatest.com/learning-hub/protractor-interview-questions?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jul_11&amp;amp;utm_term=bh&amp;amp;utm_content=learning_hub" rel="noopener noreferrer"&gt;Protractor interview questions&lt;/a&gt;. Boost you confidence and land your dream job with this comprehensive guide.&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  Using Cypress for file upload with the cypress-file-upload plugin
&lt;/h2&gt;

&lt;p&gt;Another way to upload the file is using the plugin &lt;em&gt;cypress-file-upload&lt;/em&gt;. It is a third-party plugin for the Cypress testing framework that allows you to simulate file uploads in your Cypress tests.&lt;/p&gt;

&lt;p&gt;With &lt;em&gt;cypress-file-upload&lt;/em&gt;, you can simulate file uploads using the &lt;em&gt;attachFile()&lt;/em&gt; command, which can take various options such as file content, file name, and MIME type. This makes it easy to test different file types and sizes and to ensure that your file upload functionality is working as expected.&lt;/p&gt;

&lt;p&gt;Some of the key features of the *cypress-file-uploa*d plugin include:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Support for multiple file selection and upload&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Automatic handling of file input visibility and focus&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Support for drag-and-drop file upload&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Customizable upload options, such as file name and MIME type&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Integration with other Cypress plugins and framework&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Let’s first install the &lt;em&gt;cypress-file-upload&lt;/em&gt; plugin.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 1&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Run the below command:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm install — save-dev cypress-file-upload
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2900%2F0%2AwtIBV9drFHZvsvGM.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2900%2F0%2AwtIBV9drFHZvsvGM.png" width="800" height="134"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The package will be visible once the above command has been properly executed. The &lt;em&gt;cypress-file-upload&lt;/em&gt; plugin has updated JSON.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2332%2F0%2AdL6D0rbPhREkP9BI.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2332%2F0%2AdL6D0rbPhREkP9BI.png" width="800" height="455"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 2&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Update commands.js with the below line under cypress &amp;gt; support &amp;gt; commands.js.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import ‘cypress-file-upload’;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;Demo — Uploading files using the cypress-file-upload plugin&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Test Scenario&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Visit the site: &lt;a href="https://the-internet.herokuapp.com/upload" rel="noopener noreferrer"&gt;https://the-internet.herokuapp.com/upload&lt;/a&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Provide the path of the .png file you want to upload.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Then attach the file to the input element using the method &lt;em&gt;attachFile()&lt;/em&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;After uploading, verify the title of the uploaded image.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Let’s take an example with the site &lt;a href="https://the-internet.herokuapp.com/upload" rel="noopener noreferrer"&gt;https://the-internet.herokuapp.com/upload&lt;/a&gt; to upload the file using the plugin.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;it('File Upload using cypress-file-upload npm package', () =&amp;gt; {
     cy.visit('https://the-internet.herokuapp.com/upload')
       const filePath = 'images/nature_evening.png'
       cy.get('input[type="file"]').attachFile(filePath)
       cy.get('#file-submit').click()
       cy.get('#uploaded-files').contains('nature_evening.png')
   })
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;Code Walkthrough&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;This is a Cypress test that automates file upload functionality using the &lt;em&gt;cypress-file-upload npm&lt;/em&gt; package. Here’s what the test does:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 1&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Visit the upload page of the “the-internet.herokuapp.com” website.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2616%2F0%2AW3L4HED4D4YoErHK.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2616%2F0%2AW3L4HED4D4YoErHK.png" width="800" height="223"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 2&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;It defines a &lt;em&gt;filePath&lt;/em&gt; variable that contains the path of the file to be uploaded.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2616%2F0%2AaRtPvgPblGmZDLt4.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2616%2F0%2AaRtPvgPblGmZDLt4.png" width="800" height="242"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 3&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;This command attaches the file to it using the &lt;em&gt;attachFile()&lt;/em&gt; command provided by cypress-file-upload.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2616%2F0%2Ac14A-1qCVjqrJSv3.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2616%2F0%2Ac14A-1qCVjqrJSv3.png" width="800" height="242"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 4&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;It clicks on the “Upload” button using &lt;em&gt;cy.get(‘#file-submit’).click()&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2616%2F0%2ACq_JuHcss2mRdaco.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2616%2F0%2ACq_JuHcss2mRdaco.png" width="800" height="242"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 5&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;It verifies that the file has been uploaded successfully by checking if the file name is displayed on the page, using &lt;em&gt;cy.get(‘#uploaded-files’).contains(‘nature_evening.png’)&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2616%2F0%2AyHsjzlC6N4q4N2GI.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2616%2F0%2AyHsjzlC6N4q4N2GI.png" width="800" height="242"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Output&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3200%2F0%2ACGUP_2b3ooozXnqp.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3200%2F0%2ACGUP_2b3ooozXnqp.png" width="800" height="470"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  How to use Cypress for file download?
&lt;/h2&gt;

&lt;p&gt;Cypress does not natively support file downloads. This means you cannot use Cypress commands to download a file from your web application.&lt;/p&gt;

&lt;p&gt;You can use Cypress for file download using the below methods:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Using Cypress for file download with the &lt;em&gt;readFile()&lt;/em&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Using Cypress for file download with the &lt;em&gt;cypress-downloadfile&lt;/em&gt; plugin.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Wait and verify for the file to be downloaded using &lt;em&gt;cy-verify-downloads&lt;/em&gt; plugin.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Using Cypress for file download with the readFile()
&lt;/h2&gt;

&lt;p&gt;We can use &lt;em&gt;readFile()&lt;/em&gt; to verify the content in the file, which already downloads under the folder, e.g.,/cypress/downloads/.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Syntax&lt;/strong&gt;&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;cy.readFile(‘cypress/downloads/uploadData.txt’)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Below is the example to read the downloaded file from the particular path.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;it("Upload the file using .selectFile with select mode", () =&amp;gt; {
   cy.readFile('cypress/downloads/uploadData.txt').should('contain', 'download file functionality in cypress')
 });
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;Code Walkthrough&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Using the &lt;em&gt;cy.readFile()&lt;/em&gt; command read the contents of a file called *uploadData.txt *located in the cypress/downloads directory.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2616%2F0%2A9LEYGbDANO4cDFrR.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2616%2F0%2A9LEYGbDANO4cDFrR.png" width="800" height="226"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Output (Pass Scenario)&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;When the string ‘download file functionality in cypress’ matches, the test case is passed.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3200%2F0%2AI3kX1Ol4XAWCHWII.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3200%2F0%2AI3kX1Ol4XAWCHWII.png" width="800" height="345"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Output (Fail Scenario)&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;When the expected string does not match, the test case fails. For example, do a minor tweak to the string ‘download file functionality in cypress test’.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;it("Download the file in cypress", () =&amp;gt; {
   cy.readFile('cypress/downloads/uploadData.txt').should('contain', 'download file functionality in cypress test')
 });
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3200%2F0%2Aq4l7v0TDU0VYYct9.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3200%2F0%2Aq4l7v0TDU0VYYct9.png" width="800" height="436"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Using Cypress for file download using the cypress-downloadfile plugin
&lt;/h2&gt;

&lt;p&gt;This plugin allows you to simulate file downloads in your Cypress tests and verify the downloaded files. Using the &lt;em&gt;cypress-downloadfile&lt;/em&gt; plugin, you can automate and validate file download functionality in your Cypress tests, ensuring that the expected files are being downloaded correctly. It provides a convenient way to handle file downloads and perform necessary assertions and validations.&lt;/p&gt;

&lt;p&gt;Let’s install the plugin &lt;em&gt;cypress-downloadfile&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 1&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Run the below command to download the plugin.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm i — save-dev cypress-downloadfile
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2928%2F0%2AVWrurpDubz2A4p_h.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2928%2F0%2AVWrurpDubz2A4p_h.png" width="800" height="133"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In package.json, we can see the package &lt;em&gt;cypress-downloadfile&lt;/em&gt; is installed.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2144%2F0%2AuJLyU6j-TJLYhLQV.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2144%2F0%2AuJLyU6j-TJLYhLQV.png" width="800" height="497"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 2&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Add the following code under the file cypress/support/commands.js.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;require(‘cypress-downloadfile/lib/downloadFileCommand’)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;Step 3&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Add the following code under the file cypress.config.js.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const { defineConfig } = require("cypress");
const {downloadFile} = require('cypress-downloadfile/lib/addPlugin');


module.exports = defineConfig({
 e2e: {
   setupNodeEvents(on, config) {
     on('task', {downloadFile});
     // implement node event listeners here
   },
 },
});
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;Demo — Downloading files using the cypress-downloadfile plugin&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Test Scenario&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Download the file using the &lt;em&gt;downloadFile()&lt;/em&gt; method: &lt;a href="https://www.learningcontainer.com/wp-content/uploads/2020/04/sample-text-file.txt" rel="noopener noreferrer"&gt;https://www.learningcontainer.com/wp-content/uploads/2020/04/sample-text-file.txt&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;After downloading, verify the text ‘Lorem ipsum dolor sit amet’ in the downloaded file.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Implementation&lt;/strong&gt;&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;it('File Download using cypress-downloadfile npm package', () =&amp;gt; {
     cy.downloadFile('https://www.learningcontainer.com/wp-content/uploads/2020/04/sample-text-file.txt',
         'cypress/fixtures/download_folder', 'data.txt')
     cy.readFile('cypress/fixtures/download_folder/data.txt').should('contain', 'Lorem ipsum dolor sit amet')   
 })
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Here’s Top 30&lt;a href="https://www.lambdatest.com/learning-hub/robot-framework-interview-questions?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jul_11&amp;amp;utm_term=bh&amp;amp;utm_content=learning_hub" rel="noopener noreferrer"&gt; Robot Framework Interview Questions&lt;/a&gt; and Answers that will help you boost your confidence in an Interview.&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;strong&gt;Code Walkthrough&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 1&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The &lt;em&gt;cy.downloadFile&lt;/em&gt; is used to download a file from the URL &lt;a href="https://www.learningcontainer.com/wp-content/uploads/2020/04/sample-text-file.txt" rel="noopener noreferrer"&gt;https://www.learningcontainer.com/wp-content/uploads/2020/04/sample-text-file.txt&lt;/a&gt;. The file is saved to the directory cypress/fixtures/download_folder with the name data.txt.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2616%2F0%2AL3V3I53iaO3IcL74.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2616%2F0%2AL3V3I53iaO3IcL74.png" width="800" height="261"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 2&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The &lt;em&gt;cy.readFile&lt;/em&gt; is used to read the contents of the downloaded file at cypress/fixtures/download_folder/data.txt.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2616%2F0%2AsjXHV5kmdgGJBUGX.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2616%2F0%2AsjXHV5kmdgGJBUGX.png" width="800" height="243"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 3&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Finally, the .&lt;a href="https://www.lambdatest.com/blog/cypress-should-command/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jul_11&amp;amp;utm_term=bh&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;*should() *assertion method in Cypress&lt;/a&gt; is used to verify that the contents of the file contain the string ‘Lorem ipsum dolor sit amet’.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Output&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3200%2F0%2AQ_vEOom0-TVMwndT.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3200%2F0%2AQ_vEOom0-TVMwndT.png" width="800" height="252"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You can also use Cypress for file upload and download on a cloud-based testing platform. This helps you improve the reliability and robustness of your Cypress tests and ensure your web applications work correctly on a multitude of browsers and platforms. For this, you can leverage a digital experience testing platform like LambdaTest that offers a scalable &lt;a href="https://www.lambdatest.com/cypress-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jul_11&amp;amp;utm_term=bh&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;Cypress cloud&lt;/a&gt; to perform &lt;a href="https://www.lambdatest.com/cypress-ui-automation?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jul_11&amp;amp;utm_term=bh&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;Cypress UI automation&lt;/a&gt; across 50+ real browsers and operating systems.&lt;/p&gt;

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/SBY669U14Oo"&gt;
&lt;/iframe&gt;
&lt;br&gt;
Subscribe to the &lt;a href="https://www.youtube.com/channel/UCCymWVaTozpEng_ep0mdUyw?sub_confirmation=1?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jul_11&amp;amp;utm_term=bh&amp;amp;utm_content=video" rel="noopener noreferrer"&gt;LambdaTest YouTube Channel&lt;/a&gt; to get the latest updates on tutorials around &lt;a href="https://www.lambdatest.com/selenium-automation?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jul_11&amp;amp;utm_term=bh&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;Selenium testing&lt;/a&gt;, &lt;a href="https://www.lambdatest.com/cypress-e2e-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jul_11&amp;amp;utm_term=bh&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;Cypress e2e testing&lt;/a&gt;,&lt;a href="https://www.lambdatest.com/appium-mobile-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jul_11&amp;amp;utm_term=bh&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt; Appium,&lt;/a&gt; and more.&lt;/p&gt;

&lt;p&gt;You can even accelerate your software release cycles by performing &lt;a href="https://www.lambdatest.com/cypress-parallel-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jul_11&amp;amp;utm_term=bh&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;Cypress parallel testing &lt;/a&gt;on multiple browsers and platforms simultaneously.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; Here is our support documentation to help you &lt;a href="https://www.lambdatest.com/support/docs/getting-started-with-cypress-testing/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jul_11&amp;amp;utm_term=bh&amp;amp;utm_content=support_doc" rel="noopener noreferrer"&gt;get started with Cypress testing.&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Are you prepared to enhance your proficiency in &lt;a href="https://www.lambdatest.com/blog/cypress-test-automation-framework/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jul_11&amp;amp;utm_term=bh&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;Cypress automation?&lt;/a&gt; Enroll in our exclusive &lt;a href="https://www.lambdatest.com/certifications/cypress-101?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jul_11&amp;amp;utm_term=bh&amp;amp;utm_content=certification" rel="noopener noreferrer"&gt;Cypress 101 certification&lt;/a&gt; program designed specifically for developers and testers aiming to broaden their expertise in &lt;a href="https://www.lambdatest.com/cypress-automation-tool?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jul_11&amp;amp;utm_term=bh&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;Cypress test automation&lt;/a&gt;. Acquire advanced knowledge, refine your skills, and unlock a realm of new possibilities on your test automation path.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;Downloading and uploading files are commonly used features in many applications. Automating these tasks using the &lt;a href="https://www.lambdatest.com/cypress-automation-tool?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jul_11&amp;amp;utm_term=bh&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;Cypress automation tool&lt;/a&gt; can improve the reliability and robustness of your tests. By automating these features, you can simulate user interactions and validate the expected behavior of these functionalities.&lt;/p&gt;

&lt;p&gt;By incorporating these automated tests into Cypress for file upload and download, you can catch potential issues and ensure that the download and upload functionalities of your application are working as intended. It provides an additional layer of confidence in the functionality and stability of your application.&lt;/p&gt;

&lt;h2&gt;
  
  
  Frequently Asked Questions (FAQs)
&lt;/h2&gt;

&lt;h3&gt;
  
  
  How to upload an xlsx file in Cypress?
&lt;/h3&gt;

&lt;p&gt;To upload an XLSX file using Cypress, you can follow these steps:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Prepare the XLSX file&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Write the Test Script&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Run the Test&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Ensure that the XLSX file is placed in the cypress/fixtures folder or adjust the path accordingly in the test script. Also, note that the mimeType provided in the attachFile command corresponds to the XLSX file format.&lt;/p&gt;

&lt;p&gt;That’s it! You can now upload XLSX files using Cypress and perform necessary assertions or validations as needed.&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>javascript</category>
      <category>programming</category>
      <category>beginners</category>
    </item>
    <item>
      <title>How To Use Cypress Intercept For Handling Network Requests</title>
      <dc:creator>Kailash Pathak</dc:creator>
      <pubDate>Thu, 09 Mar 2023 09:34:53 +0000</pubDate>
      <link>https://dev.to/testmuai/how-to-use-cypress-intercept-for-handling-network-requests-3013</link>
      <guid>https://dev.to/testmuai/how-to-use-cypress-intercept-for-handling-network-requests-3013</guid>
      <description>&lt;p&gt;Before intercepting network requests, one of the main challenges was that it was difficult to debug and diagnose network-related issues. Developers needed more visibility into what was happening with network traffic between a client and a server.&lt;/p&gt;

&lt;p&gt;Intercepting network requests provides insight into the network traffic generated by the application. Without this capability, troubleshooting issues can become more complex and time-consuming. The team may not have the necessary information to identify the cause of the problem, which can result in delays in the testing process.&lt;/p&gt;

&lt;p&gt;Moreover, QA teams had little access to the requests and responses transmitted between the client and server due to their inability to intercept and examine network data. Because of this, it was challenging to comprehend the application’s behavior.&lt;/p&gt;

&lt;p&gt;Many tools can be used for intercepting network requests. &lt;a href="https://www.lambdatest.com/learning-hub/cypress-tutorial?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=mar09_bh&amp;amp;utm_term=bh&amp;amp;utm_content=learning_hub" rel="noopener noreferrer"&gt;Cypress&lt;/a&gt; is one of the most popular &lt;a href="https://www.lambdatest.com/blog/automation-testing-frameworks/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=mar09_bh&amp;amp;utm_term=bh&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;automation testing frameworks&lt;/a&gt; through which you can intercept network requests. Cypress intercept — cy.intercept() is a method provided by Cypress that allows you to intercept and modify network requests made by your application. It will enable you to simulate different server responses or network conditions to test how your application handles them. This can be very useful when writing end-to-end tests. This can be very useful when writing &lt;a href="https://www.lambdatest.com/learning-hub/end-to-end-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=mar09_bh&amp;amp;utm_term=bh&amp;amp;utm_content=learning_hub" rel="noopener noreferrer"&gt;end-to-end tests.&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;To use the Cypress intercept — cy.intercept() method, you can call it within a Cypress test like this:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;cy.intercept(&amp;lt;url&amp;gt;, &amp;lt;options&amp;gt;)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;The parameter specifies the URL of the network request you want to intercept, and is an object that can be used to specify additional options, such as the response to return and the status code to use, and so on.&lt;/p&gt;

&lt;p&gt;Before deep diving into using Cypress intercept for handling network requests, let’s first understand the nuances of network testing while performing &lt;a href="https://www.lambdatest.com/cypress-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=mar09_bh&amp;amp;utm_term=bh&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;Cypress testing&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Test your native, hybrid, and web apps across all legacy and latest mobile operating systems on the most powerful &lt;a href="https://www.lambdatest.com/android-emulator-online?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=mar09_bh&amp;amp;utm_term=bh&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;online emulator Android&lt;/a&gt;.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  What are Network Requests?
&lt;/h2&gt;

&lt;p&gt;Network requests refer to exchanging data between a client and a server over a network. When testing web applications, verifying the correct metadata, such as headers, cookies, authentication tokens, and other information sent with the request, can be important.&lt;/p&gt;

&lt;p&gt;In testing, network request metadata can be used to verify that the correct headers and cookies are being sent with the request, to ensure that the data is being sent in the correct format, and to verify that the authentication tokens are being set correctly. Tools such as Cypress provide APIs for intercepting and inspecting network request metadata, making it easy to test the behavior of network requests and ensure that they are being handled correctly.&lt;/p&gt;

&lt;p&gt;Network requests can be made using HTTP (Hypertext Transfer Protocol) or HTTPS (Hypertext Transfer Protocol Secure) protocols. HTTP is the traditional protocol for sending and receiving data over the Internet. It’s a simple, text-based protocol for sending and receiving information between clients and servers.&lt;/p&gt;

&lt;p&gt;HTTPS is a secure version of the HTTP protocol that uses SSL/TLS encryption to secure the data transmitted between the client and the server. HTTPS protects sensitive data, such as passwords, credit card information, and other personal information. When you make an HTTPS request, your browser establishes an encrypted connection with the server. All data exchanged between the two parties is encrypted to ensure that third parties cannot intercept and read it.&lt;/p&gt;

&lt;p&gt;This is crucial to how the Internet works and allows data transfer between devices.&lt;/p&gt;

&lt;p&gt;Here’s an example:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;A user opens a web browser and types in the URL for a website, such as “www.example.com”.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The browser sends a network request to the server hosting the website, asking for the HTML, CSS, and JavaScript files that make up the website.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The server receives the request and sends back the requested files.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The browser receives the files and uses them to render the website on the user’s screen.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The user interacts with the website by clicking a button or filling out a form.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The browser sends another network request to the server with additional data, such as the information the user entered in the form.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The server processes the request and returns the appropriate response, such as confirming the form submission or sending back data for the next page of the website.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;In the below diagram, you can see there is a network request between a client (the web browser) and a server (the website host). The client requests resources and the server sends back the requested information. The process can be repeated as the user interacts with the website.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2400%2F0%2ATsfKAHDQiQLT1wQO.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2400%2F0%2ATsfKAHDQiQLT1wQO.png" width="800" height="418"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Assess the performance of your native, hybrid, and web apps on the most potent &lt;a href="https://www.lambdatest.com/android-emulator-online?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=mar09_bh&amp;amp;utm_term=bh&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;online Android emulator&lt;/a&gt;, covering both current and older mobile operating systems.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  What is Intercepting Network Requests?
&lt;/h2&gt;

&lt;p&gt;Intercepting network requests refers to intercepting and inspecting the traffic between a client and a server during communication over a network. Web development usually involves intercepting HTTP requests and responses.&lt;/p&gt;

&lt;p&gt;Intercepting network requests can be helpful in various situations:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Debugging and troubleshooting network issues.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Inspect the request and response payloads.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Modify the requests in real time.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;By intercepting and modifying network requests, inspecting and manipulating various aspects of the communication, such as headers, parameters, cookies, and response data, is possible.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;When intercepting network requests, usually have a proxy between the client and the server. The proxy will intercept all network traffic between the two endpoints and allow the user or tool to inspect and modify the traffic before forwarding it to its intended destination.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2400%2F0%2AcYx1Vpwxr9aFCYDf.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2400%2F0%2AcYx1Vpwxr9aFCYDf.png" width="800" height="418"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In the diagram above, the client is requesting the server, but the request is intercepted by a proxy before it reaches the server. The proxy can then analyze and modify the request before forwarding it to the server and can also analyze and modify the response before sending it back to the client.&lt;/p&gt;

&lt;p&gt;One commonly used tool for analyzing network traffic is &lt;strong&gt;Wireshark&lt;/strong&gt;. Wireshark is a free and open-source packet analyzer that lets you capture and analyze network traffic in real time.&lt;/p&gt;

&lt;p&gt;Another tool for analyzing network traffic is &lt;strong&gt;tcpdump&lt;/strong&gt;. It can capture and filter network traffic for various protocols, including TCP, UDP, ICMP, and more.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Experience seamless testing of your native, hybrid, and web apps across an array of current and older mobile operating systems on the highly robust &lt;a href="https://www.lambdatest.com/android-emulator-online?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=mar09_bh&amp;amp;utm_term=bh&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;Android online emulator&lt;/a&gt;.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Why Intercept Network Requests?
&lt;/h2&gt;

&lt;p&gt;Intercepting network requests can provide many benefits, depending on the context and the reason for the interception. Here are a few examples:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Debugging&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;By intercepting network requests, developers can easily see what data is being sent and received during different application stages. This can help to quickly identify and resolve any issues related to the application’s network communication.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Testing&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Intercepting network requests can be beneficial for automating tests of web applications. Test scripts can be written to simulate user actions and inspect the resulting network traffic, allowing developers to automate the testing of complex workflows and scenarios.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Data Modification&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Interception can modify network requests, allowing developers to manipulate the data sent over the network.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Accelerating test execution&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;By intercepting network requests and returning mock responses, you can reduce the number of requests your application makes to the server.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Security:&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Intercepting network requests can also be used as a security measure. For example, In organizations, you can monitor network traffic to detect malicious activity, such as a cyber-attack.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Modifying network requests:&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;By intercepting network requests, developers can modify the requests made by an application to test different scenarios or to implement new features. LT Debug by LambdaTest is a useful tool for modifying network requests during testing and debugging. By modifying requests and analyzing responses, you can quickly identify and fix issues in your code.&lt;/p&gt;

&lt;p&gt;You can learn more about it through this &lt;a href="https://www.lambdatest.com/blog/introducing-lt-debug/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=mar09_bh&amp;amp;utm_term=bh&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;LT Debug tutorial.&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Below are some other benefits of intercepting the network request, which are helpful for the network team.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Traffic analysis:&lt;/strong&gt; By capturing and analyzing network requests, network administrators can gain insights into network usage patterns, identify potential performance bottlenecks, and optimize the network for better performance.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Content filtering:&lt;/strong&gt; By intercepting network requests, organizations can filter content based on various criteria, such as security policies, bandwidth limitations, or content type.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Monitoring:&lt;/strong&gt; Interception can also be used for monitoring purposes, for example, to gather statistics about the usage of an application or to gain insights into user behavior.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Are you using &lt;a href="https://www.lambdatest.com/playwright-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=mar09_bh&amp;amp;utm_term=bh&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;Playwright&lt;/a&gt; for automation testing? Run your Playwright test scripts instantly on 50+ browser/OS combinations using the LambdaTest cloud.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  QA Tools for Intercepting Network Requests
&lt;/h2&gt;

&lt;p&gt;Here are some QA &lt;a href="https://www.lambdatest.com/blog/automation-testing-tools/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=mar09_bh&amp;amp;utm_term=bh&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;automation testing tools &lt;/a&gt;that can be used for intercepting network requests&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Cypress:&lt;/strong&gt; Cypress can intercept network requests and manipulate their responses. In Cypress, you can intercept network requests using the Cypress intercept — cy. intercept() method. This command allows you to intercept and modify network requests and responses.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Playwright:&lt;/strong&gt; With &lt;a href="https://www.lambdatest.com/playwright?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=mar09_bh&amp;amp;utm_term=bh&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;Playwright,&lt;/a&gt; you can intercept network requests using the page.route() method. This method allows you to intercept network requests and provide a custom response.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Postman:&lt;/strong&gt; Postman is a popular API development and testing tool that allows you to inspect and modify network requests. It has a user-friendly interface and a wide range of features, making it a great option for QA &lt;a href="https://www.lambdatest.com/automation-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=mar09_bh&amp;amp;utm_term=bh&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;automation testing&lt;/a&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Charles:&lt;/strong&gt; Charles is a web debugging proxy tool that can inspect, debug, and modify network requests. It is widely used by developers to troubleshoot issues with web applications and APIs.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Fiddler:&lt;/strong&gt; Fiddler is a web debugging proxy tool that allows you to inspect and modify network requests, and it is widely used for QA automation testing.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;JMeter:&lt;/strong&gt; JMeter is a popular open-source load testing tool with features for intercepting and modifying network requests. JMeter can be used to test the performance of web applications and APIs.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Burp Suite:&lt;/strong&gt; Burp Suite is a powerful and widely used tool for testing web applications. It allows you to intercept and manipulate HTTP requests and responses and provides detailed information about the requests &amp;amp; responses.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;SoapUI:&lt;/strong&gt; SoapUI is an open-source tool for testing web services, including features for intercepting network requests. It is widely used for testing SOAP and REST APIs.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Selenium:&lt;/strong&gt; &lt;a href="https://www.lambdatest.com/selenium?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=mar09_bh&amp;amp;utm_term=bh&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;Selenium&lt;/a&gt; is a popular open-source framework for automating &lt;a href="https://www.lambdatest.com/web-application-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=mar09_bh&amp;amp;utm_term=bh&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;web application testing&lt;/a&gt;. While Selenium itself does not have built-in capabilities for intercepting network requests.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In addition to the above tools, popular cloud testing platforms like LambdaTest provide integration with such QA tools, including Cypress, Selenium, and Playwright. With LambdaTest, you can perform &lt;a href="https://www.lambdatest.com/blog/cypress-test-automation-framework/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=mar09_bh&amp;amp;utm_term=bh&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;Cypress automation&lt;/a&gt; at scale over an &lt;a href="https://www.lambdatest.com/online-browser-farm?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=mar09_bh&amp;amp;utm_term=bh&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;online browser farm &lt;/a&gt;of 3000+ browsers and operating systems. Furthermore, you can perform &lt;a href="https://www.lambdatest.com/cypress-parallel-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=mar09_bh&amp;amp;utm_term=bh&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;Cypress parallel testing&lt;/a&gt; and cut down your test execution time by multiple folds.&lt;br&gt;
&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/jX3v3N6oN5M"&gt;
&lt;/iframe&gt;
&lt;br&gt;
&lt;strong&gt;&lt;em&gt;A comprehensive &lt;a href="https://www.lambdatest.com/learning-hub/end-to-end-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=mar09_bh&amp;amp;utm_term=bh&amp;amp;utm_content=learning_hub" rel="noopener noreferrer"&gt;end to end Testing&lt;/a&gt; tutorial that covers what E2E Testing is, its importance, benefits, and how to perform it with real-time examples.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Intercepting Network Requests with Cypress
&lt;/h2&gt;

&lt;p&gt;Here are some common use cases for using Cypress intercept for handling network requests.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Mocking APIs&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Cypress allows developers to create mock APIs to simulate different server responses. This is useful when testing application behavior under different conditions, such as when the server is down, or the response is delayed.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Testing HTTP requests and responses&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;By intercepting network requests, the Cypress UI automation tool allows developers to test how the application handles HTTP requests and responses. This includes testing error response handling, response time, and response code.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Testing authorization and authentication&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Using Cypress, developers can test how their application handles authentication and authorization by intercepting network requests and passing the authorization tokens.&lt;/p&gt;

&lt;p&gt;Here are some circumstances under which authorization and authentication are used in intercepting network requests:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Access Control:&lt;/strong&gt; Authorization is used to control access to resources such as files, web pages, APIs, and databases. By requiring authorization, only authorized users or systems are granted access to the resource.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Secure Data Transmission:&lt;/strong&gt; Authentication ensures data is securely transmitted between systems. By authenticating the sender and receiver, data can be encrypted and decrypted only by the intended parties.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Testing for performance-related issues&lt;/strong&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://www.lambdatest.com/cypress-ui-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=mar09_bh&amp;amp;utm_term=bh&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;Cypress UI testing tool &lt;/a&gt;can be used to measure the performance of web applications by intercepting network requests and measuring the response times of each request. This can help developers identify performance bottlenecks in their applications and optimize performance.&lt;/p&gt;

&lt;h2&gt;
  
  
  Using Cypress Intercepts for Handling Network Requests
&lt;/h2&gt;

&lt;p&gt;Cypress is a JavaScript-based end-to-end testing framework that makes writing, running, and debugging tests for web applications easy. It has built-in support for intercepting and stubbing network requests, allowing you to control the data returned from the server and make assertions about the network requests made by your application while performing &lt;a href="https://www.lambdatest.com/cypress-e2e-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=mar09_bh&amp;amp;utm_term=bh&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;Cypress end to end testing.&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You can use the Cypress intercept — cy.intercept() command to intercept network requests in Cypress. This Cypress intercept command takes a URL pattern and a callback function as arguments and will intercept all requests that match the pattern. In the callback function, you can then modify the request, return a response, or continue the request to the network.&lt;/p&gt;

&lt;p&gt;Below are the methods you can use in Cypress for Spy and stub network requests and responses.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;cy.intercept(url)
cy.intercept(method, url)
cy.intercept(routeMatcher)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Here’s a simple example of how you could use the Cypress intercept command to return a fake response for a certain request:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;cy.intercept('/api/data', {
 method: 'GET'
}).as('getData')
 .reply(200, {
   data: 'Test Data'
 });


// ... Perform your test logic ...
cy.wait('@getData')
 .its('response.body')
 .should('deep.equal', {
   data: 'Test Data'
 });
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;In this example, the Cypress intercept — &lt;strong&gt;cy.intercept()&lt;/strong&gt; command is used to intercept all GET requests to the &lt;strong&gt;/api/data&lt;/strong&gt; endpoint. The .reply method is then used to return a fake response with a status code of 200 and a JSON body of { data: Test Data’ }.&lt;/p&gt;

&lt;p&gt;The cy.wait() command is then used to wait for the request to be intercepted and complete, and the response body is asserted to match the expected value.&lt;/p&gt;

&lt;p&gt;Before explaining all the methods in detail, let’s first see how the Cypress intercept — &lt;em&gt;cy.intercept()&lt;/em&gt; method works.&lt;/p&gt;

&lt;h2&gt;
  
  
  How does the cy.intercept() method work?
&lt;/h2&gt;

&lt;p&gt;The Cypress intercept or &lt;strong&gt;cy.intercept()&lt;/strong&gt; is a method used to intercept and modify HTTP requests and responses made by the application during testing. This allows you to simulate different network scenarios and test the behavior of your application under different conditions.&lt;/p&gt;

&lt;p&gt;In the diagram below, the Cypress intercept — &lt;strong&gt;cy.intercept()&lt;/strong&gt; method intercepts the requests and responses made by the Application Under Test (AUT). The Cypress intercept method can intercept requests to specific URLs or requests made by specific methods (e.g., GET, POST, etc.)&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2400%2F0%2APrxi9b73IuKJSVcx.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2400%2F0%2APrxi9b73IuKJSVcx.png" width="800" height="612"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The steps of the diagram are explained below:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;The client (browser) initiates a request to the server.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The server receives the request and sends back a response.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The client receives the response and handles it.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Cypress test code intercepts the request before it reaches the server.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The test code can modify the request or the response in any way it wants, such as adding headers, delaying the response, or changing the status code.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The test code returns a stubbed response that replaces the actual response from the server.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The client receives the stubbed response and handles it as if it came from the server.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Once you get the response, we can verify the stubbed response by explaining the assertion below with various examples.&lt;/p&gt;

&lt;h2&gt;
  
  
  Different ways of Intercepting Network Requests in Cypress
&lt;/h2&gt;

&lt;p&gt;There are various ways to use Cypress intercept for handling network requests:&lt;/p&gt;

&lt;h2&gt;
  
  
  Matching URL
&lt;/h2&gt;

&lt;p&gt;First way of intercepting the request is by Matching the URL. There are three ways of matching the URL.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;Interception by matching the exact URL.&lt;/p&gt;

&lt;p&gt;it('Intercept by Url', () =&amp;gt; {&lt;br&gt;
   cy.visit('&lt;a href="https://reqres.in/'" rel="noopener noreferrer"&gt;https://reqres.in/'&lt;/a&gt;);&lt;br&gt;
   cy.intercept('&lt;a href="https://reqres.in/api/users/').as('posts'" rel="noopener noreferrer"&gt;https://reqres.in/api/users/').as('posts'&lt;/a&gt;)&lt;br&gt;
   cy.get("[data-id=users]").click()&lt;br&gt;
   cy.wait('@posts').its('response.body.data').should('have.length', 6)&lt;br&gt;
 })&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;In this example, we are intercepting the complete https ://reqres.in/api/users/ URL. The intercepted request is assigned a named alias ‘posts’ using the .as method. The test then waits for the ‘posts’ request to complete and verifies the length of the response body.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;Interception of multiple URLs using pattern matching.&lt;/p&gt;

&lt;p&gt;it('Intercept by use pattern-matching to match URLs', () =&amp;gt; {&lt;br&gt;
   cy.visit('&lt;a href="https://reqres.in/'" rel="noopener noreferrer"&gt;https://reqres.in/'&lt;/a&gt;);&lt;br&gt;
   cy.intercept('/api/users/').as('posts')&lt;br&gt;
   cy.get("[data-id=users]").click()&lt;br&gt;
   cy.wait('@posts').its('response.body.data').should('have.length', 6)&lt;br&gt;
 })&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;In this example, we are intercepting the request having the URL matches the /api/users/ pattern. The intercepted request is assigned a named alias ‘posts’ using the .as method.&lt;/p&gt;

&lt;p&gt;The test then waits for the ‘posts’ request to complete and verifies the length of the response body.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;Interception of the URL using a regex pattern.&lt;/p&gt;

&lt;p&gt;it('Intercept by regular expression', () =&amp;gt; {&lt;br&gt;
   cy.visit('&lt;a href="https://reqres.in/'" rel="noopener noreferrer"&gt;https://reqres.in/'&lt;/a&gt;);&lt;br&gt;
   cy.intercept('/\/api/users?page=2').as('posts')&lt;br&gt;
   cy.get("[data-id=users]").click()&lt;br&gt;
   cy.wait('@posts').its('response.body.data').should('have.length', 6)&lt;br&gt;
 })&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;In this example, the Cypress intercept — cy.intercept() method intercepts the URL that matches the regex pattern /\/api\/users. The as() method gives a name to the intercepted request, which can be later used with cy.wait() to wait for the response. In this case, cy.wait(‘&lt;a href="http://twitter.com/posts" rel="noopener noreferrer"&gt;@posts&lt;/a&gt;’) waits for the intercepted request to complete before proceeding with the test.&lt;/p&gt;

&lt;h2&gt;
  
  
  Matching method
&lt;/h2&gt;

&lt;p&gt;Another way of intercepting the request is by Matching the methods. By default, if you don’t pass a method argument, then all HTTP methods (GET, POST, PUT, PATCH, DELETE, etc.) will match. By passing the method in the &lt;em&gt;cy.intercept()&lt;/em&gt; it will intercept a particular method request in a network call.&lt;/p&gt;

&lt;p&gt;Suppose you have provided an interceptor command like &lt;em&gt;cy.intercept&lt;/em&gt;('/api/users/'). In that case, we will match parameters in all Methods (GET, POST, PUT, PATCH, DELETE, etc.)&lt;/p&gt;

&lt;p&gt;But if you pass the Method name in command cy.intercept ('GET', '/users?page=2'), then in that case, only the GET method is intercepted.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;it('Intercept by matching GET method', () =&amp;gt; {
   cy.visit('https://reqres.in/');
   cy.intercept('GET','api/users?page=2').as('posts')
   cy.get("[data-id=users]").click()
   cy.wait('@posts').its('response.body.data').should('have.length', 6)
 })
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Another example of POST request where we have manipulated the response with providing the data in the body. In the below example, we have provided the data in the body, and thus, we have mocked the data with provided data in the body.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;it('Intercept by matching POST method', () =&amp;gt; {
   cy.visit('https://reqres.in/');
   cy.intercept('POST', 'api/users', (req) =&amp;gt; {
     req.reply({
       status: 200,
       body: {
         "name": "John",
         "job": "QA Manager",
     }
     })
   }).as('updateuser')
   cy.get("[data-id=post]").click()
   cy.wait('@updateuser')
 })
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Below is the output of the above test case. You can see we have mocked the data by intercepting the POST call.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3200%2F0%2AMBx1zsW-rqYvgeC7.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3200%2F0%2AMBx1zsW-rqYvgeC7.png" width="800" height="322"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Matching with RouteMatcher
&lt;/h2&gt;

&lt;p&gt;RouteMatcher is a part of the Cypress API that allows you to match specific network requests based on their URL, method, headers, and other attributes.&lt;/p&gt;

&lt;p&gt;By using a RouteMatcher, you can match requests based on their URL patterns, which provides a flexible way to intercept API requests and test our application’s behavior under different conditions.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;it('Intercept by RouteMatcher ', () =&amp;gt; {
   cy.visit('https://reqres.in/')
   cy.intercept({
     method: 'GET',
     url: 'https://reqres.in/api/users/**'
   }, (req) =&amp;gt; {
     req.reply({
       statusCode: 200,
       body: {
         data: [{
           id: 7,
           email: 'tim.Bluth@reqres.in',
           first_name: 'tim',
           last_name: 'Bluth',
           avatar: 'https://reqres.in/img/faces/1-image.jpg'}, {
             id: 8,
             email: 'janet.weaver@reqres.in',
             first_name: 'Janet',
             last_name: 'Weaver',
             avatar: 'https://reqres.in/img/faces/2-image.jpg'
           }
         ]
       }
     })
   }).as('postdata')
   cy.wait('@postdata').its('response.body.data').should('have.length', 2)
 })
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;In this example, we have used a RouteMatcher to match any GET request to the &lt;a href="https://reqres.in/api/users/**" rel="noopener noreferrer"&gt;https://reqres.in/api/users/**&lt;/a&gt; endpoint. The ** notation matches any path after /api/users/. We then use the req.reply() function to return a custom response for matching requests. Finally, we load our application and verify that the response has length 2.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Output:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The output of the above test case is attached below:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3200%2F0%2AhX3VQPRuuxv2QsbK.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3200%2F0%2AhX3VQPRuuxv2QsbK.png" width="800" height="385"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Pattern Matching
&lt;/h2&gt;

&lt;p&gt;In Pattern matching, you can provide the matching pattern string like in the below example any GET Or PATCH requests that match the pattern &lt;strong&gt;/users/&lt;/strong&gt; will be intercepted.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;it('Intercept by Pattern Matching using glob matching ', () =&amp;gt; {
   cy.visit('https://reqres.in/')
   cy.intercept({
     method: '+(GET|PATCH)',
     url: '**/users/**'
   }, (req) =&amp;gt; {
     req.reply({
       statusCode: 200,
       body: {
         data: [{
           id: 7,
           email: 'kim.smith@reqres.in',
           first_name: 'Kim',
           last_name: 'Smith',
           avatar: 'https://reqres.in/img/faces/1-image.jpg'}, {
             id: 8,
             email: 'janet.weaver@reqres.in',
             first_name: 'Janet',
             last_name: 'Weaver',
             avatar: 'https://reqres.in/img/faces/2-image.jpg'
           }
         ]
       }
     })
   }).as('postdata')
   cy.wait('@postdata').its('response.body.data').should('have.length', 2)
 })
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;Output:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;In the below code you can see the data that we have mock displaying under response body&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3200%2F0%2AJF-IGM55dgeVDQ8Z.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3200%2F0%2AJF-IGM55dgeVDQ8Z.png" width="800" height="355"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Stubbing a response
&lt;/h2&gt;

&lt;p&gt;In Cypress, stubbing a response refers to the process of intercepting a network request made by the application being tested and returning a predefined response instead of the actual response from the server.&lt;/p&gt;

&lt;p&gt;There are two ways to stub a response for a network request:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;With a string&lt;/strong&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Here’s an example of how you can use the Cypress intercept — &lt;em&gt;cy.intercept()&lt;/em&gt; method to stub a response for a network request by passing a string in the body.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;it('Stubbing a response With a string', () =&amp;gt; {
   cy.visit('https://reqres.in/')
   cy.intercept('GET', '**/users/**', {
     statusCode: 200,
     body: 'Hello, world!'
   }).as('getUsers')
   cy.wait('@getUsers')
   cy.get('@getUsers').then((interception) =&amp;gt; {
     expect(interception.response.body).to.equal('Hello, world!')
})
 })
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;Output:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3200%2F0%2AXZRlWyp0VYFx5aUs.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3200%2F0%2AXZRlWyp0VYFx5aUs.png" width="800" height="378"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. With Fixture files&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Another way of stubbing the response using the fixture file. You can mock the data from the fixture file instead of providing data in the body.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;it('Stubbing a response With Fixture file', () =&amp;gt; {
   cy.visit('https://reqres.in/')
   cy.intercept('GET', 'https://reqres.in/api/users?page=2', { fixture: 'users.json' }).as('getUsers')
cy.visit('https://reqres.in/')
cy.wait('@getUsers')
cy.get('.data').should('have.length', 6)
 })
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;In this example, we are intercepting a GET request to the endpoint https: //reqres.in/api/users?page=2, and responding with a fixture file called users.json. We also use the .as() method to assign the intercepted request to an alias to wait for the response before performing further actions.&lt;/p&gt;

&lt;p&gt;Assuming you have a fixture file named users.json in your cypress/fixtures directory, this test will verify that the .data element on the page has a length of 6, which matches the number of records in the users.json fixture file.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Output:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;In the below output of the above code, you can see the data we have mocked using the fixture file.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3200%2F0%2AAhxkJ4HwQiV3STE4.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3200%2F0%2AAhxkJ4HwQiV3STE4.png" width="800" height="385"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Changing Headers
&lt;/h2&gt;

&lt;p&gt;You can also use the Cypress intercept &lt;em&gt;— cy. intercept()&lt;/em&gt; method to mock header data.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;it('Intercept a request and modify headers', () =&amp;gt; {
   cy.visit('https://reqres.in');
   cy.intercept('GET', 'https://reqres.in/api/users', (req) =&amp;gt; {
     req.headers['Authorization'] = 'Bearer my-token';
   }).as('getUserList');
   //cy.visit('https://reqres.in/api/users');
   cy.wait('@getUserList')
   cy.get('@getUserList').then((interception) =&amp;gt; {
     const requestHeaders = interception.request.headers;
     expect(requestHeaders).to.have.property('Authorization', 'Bearer my-token');
   });
 });
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;In this example, we intercept a GET request to https: //reqres.in/api/users and modify the Authorization header by adding a token value. We give this interception a unique alias using the .as() command so that we can wait for it to complete using cy.wait().&lt;/p&gt;

&lt;p&gt;After waiting for the interception to complete, we use the cy.get(‘@ getUserList’) command to get the interception object and assert that the Authorization header was modified correctly.&lt;/p&gt;

&lt;h2&gt;
  
  
  How to Override an existing Cypress intercept?
&lt;/h2&gt;

&lt;p&gt;Overriding an existing Cypress intercept allows you to modify or cancel an existing network request intercept that has already been defined in your test code. This can be useful when you want to change the behavior of an existing intercept, for example, to simulate a different response from a server or to modify the request data in a different way.&lt;/p&gt;

&lt;p&gt;The main difference between intercepting network requests and overriding an existing intercept is that intercepting allows you to define new intercepts in your test code, while overriding allows you to modify existing intercepts. Cypress provides a rich API for working with both intercepts and overrides to help you thoroughly test and debug your web applications.&lt;/p&gt;

&lt;p&gt;The below example shows how you can use the Cypress intercept &lt;em&gt;— cy.intercept()&lt;/em&gt; method to override an existing intercept and modify the behavior of your application during testing.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;describe.only('Override an existing intercept example', () =&amp;gt; {
 beforeEach(() =&amp;gt; {
   cy.intercept('GET', 'https://reqres.in/api/users').as('getUsers')
 })


 it('overrides the response of the /api/users request', () =&amp;gt; {
   cy.visit('https://reqres.in/')
   cy.intercept('GET', 'https://reqres.in/api/users', (req) =&amp;gt; {
     req.reply((res) =&amp;gt; {
       res.send({
         data: [{ id: 1, email: 'test@test.com' }],
         page: 1,
         per_page: 1,
         total: 1,
         total_pages: 1
       })
     })
   }).as('getUsers')


   cy.wait('@getUsers').then((interception) =&amp;gt; {
     expect(interception.response.body.data).to.have.length(1)
     expect(interception.response.body.data[0].email).to.eq('test@test.com')
   })
 })
})
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;In this example, we first define an intercept for the GET /api/users request and give it an alias of getUsers. Then, in the test itself, we override the same request by defining a new intercept with the same alias of getUsers.&lt;/p&gt;

&lt;p&gt;In the new intercept, we use the req.reply() function to override the original request’s response and return a new response that includes a single user with an email of ‘test@ test. com‘. Finally, we use the cy.wait() command to wait for the getUsers alias to complete, and then we test the response to ensure it contains the expected data.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Output:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3200%2F0%2AKilIPFHKjL86bsiv.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3200%2F0%2AKilIPFHKjL86bsiv.png" width="800" height="392"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Looking to take your Cypress automation skills to the next level? This Cypress 101 certification course is designed for developers and testers who already understand Cypress and want to advance their knowledge and skills around &lt;a href="https://www.lambdatest.com/blog/cypress-test-automation-framework/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=mar09_bh&amp;amp;utm_term=bh&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;Cypress test automation.&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;In this &lt;a href="https://www.lambdatest.com/appium?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=mar09_bh&amp;amp;utm_term=bh&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;Appium tutorial&lt;/a&gt;, learn about Appium and its benefits for mobile automation testing. Take a look at how Appium works and see how to perform Appium testing of your mobile applications.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Wrapping up
&lt;/h2&gt;

&lt;p&gt;Using stubbing, requests to a network are intercepted and replaced with predefined responses, rather than sending the request over the network and waiting for a response.&lt;/p&gt;

&lt;p&gt;However, stubbing can also lead to false positives, as the behavior of the stubbed requests may not accurately reflect the behavior of the actual requests. This can lead to a false sense of security in your tests and may miss bugs or errors that only occur in the actual network request.&lt;/p&gt;

&lt;p&gt;On the other hand, not using stubbing with the Cypress intercept &lt;strong&gt;&lt;em&gt;— cy .intercept()&lt;/em&gt;&lt;/strong&gt; can provide a more accurate picture of the behavior of your application in the real world. By allowing actual network requests to be made and handling them accordingly, you can be more confident that your tests accurately reflect the behavior of your application in the wild.&lt;/p&gt;

&lt;h2&gt;
  
  
  Frequently Asked Questions (FAQs)
&lt;/h2&gt;

&lt;h3&gt;
  
  
  1. What does intercept do in Cypress?
&lt;/h3&gt;

&lt;p&gt;In Cypress, intercept is a method used to intercept and modify network requests the application makes under test. When intercepting a network request, Cypress can manipulate its request/response headers and body or even simulate network failures. This is useful for testing scenarios involving network requests, such as testing authentication or how the application handles different responses.&lt;/p&gt;

&lt;h3&gt;
  
  
  2. What is the difference between Cypress intercept and request?
&lt;/h3&gt;

&lt;p&gt;Cypress is a JavaScript end-to-end testing framework that allows you to write and run automated tests for web applications.&lt;/p&gt;

&lt;p&gt;cy.intercept() intercepts and modifies HTTP requests and responses made by your application. It allows you to mock or stub server responses, modify the request headers, and perform assertions on the intercepted requests and responses.&lt;/p&gt;

&lt;p&gt;cy.request(), on the other hand, sends an HTTP request to the specified URL and returns the server’s response. It allows you to simulate HTTP requests and verify the server response in your tests.&lt;/p&gt;

</description>
      <category>cypress</category>
      <category>tutorial</category>
      <category>news</category>
      <category>cypressintercept</category>
    </item>
    <item>
      <title>Playwright vs Selenium vs Cypress: A Detailed Comparison</title>
      <dc:creator>Kailash Pathak</dc:creator>
      <pubDate>Thu, 19 Jan 2023 00:14:45 +0000</pubDate>
      <link>https://dev.to/testmuai/playwright-vs-selenium-vs-cypress-a-detailed-comparison-5e4l</link>
      <guid>https://dev.to/testmuai/playwright-vs-selenium-vs-cypress-a-detailed-comparison-5e4l</guid>
      <description>&lt;p&gt;With multiple testing frameworks available, choosing which is best for your product becomes more challenging. While various testing tools are available in the market, Selenium has been a well-established player for quite some time. However, newer &lt;a href="https://www.lambdatest.com/blog/best-test-automation-frameworks-2021/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jan18_sd&amp;amp;utm_term=sd&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;automation testing frameworks&lt;/a&gt; such as Cypress and Playwright have recently provided Selenium with serious competition. I have used Selenium and Cypress, and recently started using Playwright.&lt;/p&gt;

&lt;p&gt;Every tool/framework has its pros and cons. When I switched from Selenium to Cypress, I found that Cypress was speedy and less flaky compared to Selenium. I saw test cases that had previously taken a long time and resulted in a failure, now executed well in the local environment and the CI/CD pipeline.&lt;/p&gt;

&lt;p&gt;Playwright, comparatively a newer entrant in the market, is an open-source framework primarily used for &lt;a href="https://www.lambdatest.com/learning-hub/end-to-end-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jan18_sd&amp;amp;utm_term=sd&amp;amp;utm_content=learning_hub" rel="noopener noreferrer"&gt;end to end testing&lt;/a&gt;. Built by Microsoft, it supports prominent languages like Python, Java, JavaScript, C#, and more. It comprises features and capabilities more aligned with the modern web.&lt;/p&gt;

&lt;p&gt;When a new user plans to develop a framework from scratch, choosing the right tool or framework can sometimes be tricky as they are trying to figure out which framework will work best for their project. As I started my career in automation, I used Java, which allowed me to leverage the benefits of the Selenium framework to automate &lt;a href="https://www.lambdatest.com/web-application-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jan18_sd&amp;amp;utm_term=sd&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;web application testing&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Nevertheless, I am also facing many challenges with my current project at the moment. To solve these difficulties, I am forced to look into other tools to assist me.&lt;/p&gt;

&lt;p&gt;Given that there are several considerations to take into account, including in-house technical expertise, ease of use, and CI/CD integration, it is important to determine which framework or tool would be the most suitable option based on these factors and others that are important in selecting the optimal solution. Needless to mention that the framework must let you run tests in a CI/CD pipeline.&lt;/p&gt;

&lt;p&gt;The Cypress framework has been my go-to tool for the last three or four years. It offers many features (Automatic Waiting, Flake Detection, Network Traffic Control, Screenshots and Videos, Debuggability, etc.).&lt;/p&gt;

&lt;p&gt;However, several alternatives to Selenium and Cypress are currently challenging them (one of which is Playwright, which offers a variety of functionalities).&lt;/p&gt;

&lt;p&gt;In this Playwright vs Selenium vs Cypress blog, you will learn more about each tool/framework, and I’ll also compare Playwright, Selenium, and Cypress. The learnings of this Playwright vs Selenium vs Cypress blog will help you choose the ideal tool for your project.&lt;/p&gt;

&lt;p&gt;Below are the npm trends of Playwright vs Selenium vs Cypress.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F5oxxno6y72n8h91ztmmw.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F5oxxno6y72n8h91ztmmw.png" width="800" height="539"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;**&lt;em&gt;Note: **I have used tools and frameworks interchangeably throughout this blog on Playwright vs Selenium vs Cypress.&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  What is Playwright?
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://www.lambdatest.com/playwright-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jan18_sd&amp;amp;utm_term=sd&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;Playwright&lt;/a&gt; is an open-source automation framework for end-to-end testing. It supports most modern rendering browsers, including Firefox, Chromium, and Webkit. Playwright is created and maintained by Microsoft and has steadily been gaining in popularity.&lt;/p&gt;

&lt;p&gt;It is a Node library that automates the Chromium, WebKit, and Firefox browsers using a single API. It enables quick, efficient, competent, and reliable cross-browser c.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.lambdatest.com/playwright-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jan18_sd&amp;amp;utm_term=sd&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;Playwright test&lt;/a&gt; framework supports Jest, Mocha, Jasmine, and other prominent CI servers using a single API. Playwright offers cross-language support, which includes TypeScript, JavaScript, Python, .NET, and Java.&lt;/p&gt;

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/wawbt1cATsk"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;Here are some of the prominent features of &lt;a href="https://www.lambdatest.com/blog/playwright-framework/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jan18_sd&amp;amp;utm_term=sd&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;Playwright automation&lt;/a&gt; framework:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;One API for any browser/platform&lt;/strong&gt;: Playwright supports all modern rendering engines, including Chromium, Firefox, and WebKit. It supports Windows, Linux, and macOS and additionally supports native mobile emulation of Google Chrome for Android and Mobile Safari.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Reduced flakiness&lt;/strong&gt;: Playwright waits for actionable elements before performing actions. To reduce flakiness, features like test retries, execution trace capture, videos, and screenshots are also available.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Test Case Execution in Isolation&lt;/strong&gt;: Every test that Playwright runs has a unique browser context. The same thing as a new browser profile is browser context. With no additional overhead, this gives complete test isolation.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Powerful Tooling&lt;/strong&gt;: Playwright comes bundled with tools like Codegen, Playwright inspector, and Trace Viewer:&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Codegen&lt;/strong&gt;: Using Codegen, you can record the test cases and save them in any language (JavaScript, Python, .NET, Java, TypeScript). Recording the test cases is helpful for the beginner from a learning perspective. But if you want to use the recorded script in a live project, it’s not a good approach from a maintainability perspective.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Playwright inspector&lt;/strong&gt;: Using Playwright inspector, you can inspect the page, see click points, and explore execution logs.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Trace Viewer&lt;/strong&gt;: Capture all the information that helps investigate the test failure.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;As per the Playwright GitHub repository, Playwright continues to attain popularity with:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Stars: 46.4k&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Forks: 2.3k&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Used By: 20.5k&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Releases: 91&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Contributors: 345&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fpjyf29v2kyux6ysdss2g.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fpjyf29v2kyux6ysdss2g.png" width="800" height="324"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Playwright Architecture
&lt;/h2&gt;

&lt;p&gt;Playwright works directly with the WebSocket, which means once you trigger the test, the code will be converted into JSON format and will be sent to the server using Web socket protocol. Once the connection or handshake connection is established, commands are sent between your test and the Playwright server.&lt;/p&gt;

&lt;p&gt;Client and server connections will remain active until one or both parties discontinue them. After closing the connection, the connection is terminated from both ends. One of the reasons that Playwright is fast is because the connection stays active as long as neither party terminates it.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fs9mb4slexw11pkms8hzu.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fs9mb4slexw11pkms8hzu.png" width="593" height="214"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;To learn more about &lt;a href="https://www.lambdatest.com/blog/playwright-framework/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jan18_sd&amp;amp;utm_term=sd&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;Playwright automation testing&lt;/a&gt;, you can refer to this blog on the Playwright framework.&lt;/p&gt;

&lt;p&gt;In the next section of this blog on Playwright vs Selenium vs Cypress, we will learn about the Selenium test automation framework.&lt;/p&gt;

&lt;h2&gt;
  
  
  What is Selenium?
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://www.lambdatest.com/selenium?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jan18_sd&amp;amp;utm_term=sd&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;Selenium&lt;/a&gt; is an open-source framework for automated testing that is used to verify web applications across many platforms and browsers. Using Selenium, you can automate your application with major browsers in different programming languages such as Java, JavaScript, C#, Ruby, PHP, and Python.&lt;/p&gt;

&lt;p&gt;Using the Selenium framework, testers can use a grid of browser instances to run test cases in parallel, which can help to speed up the testing process. By running test cases in parallel, you can complete the testing phase of your CI/CD pipeline more quickly, which can help to accelerate the overall development process.&lt;/p&gt;

&lt;p&gt;We’re not going to do a long explanation of Selenium’s tool suite here. Instead, I will give you a brief overview of the Selenium suite:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fvybsrz55aretqu6046uj.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fvybsrz55aretqu6046uj.png" width="512" height="313"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Selenium WebDriver
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://www.lambdatest.com/blog/selenium-webdriver-tutorial-with-examples/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jan18_sd&amp;amp;utm_term=sd&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;Selenium WebDriver&lt;/a&gt; is a library whose APIs are called from the code, post which the commands are run on the browser of your choice. Using &lt;a href="https://www.lambdatest.com/learning-hub/selenium-locators?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jan18_sd&amp;amp;utm_term=sd&amp;amp;utm_content=learning_hub" rel="noopener noreferrer"&gt;Selenium locators&lt;/a&gt;, elements can be identified and located, which is used to generate test cases. Then, using the WebDriver APIs, you may take action on those items and interact with them.&lt;/p&gt;

&lt;p&gt;The script you create interacts directly with the browser, which is one of the reasons it runs significantly faster than Selenium RC, which has been deprecated. There are different drivers for different browsers, which ‘interpret’ the script you write for it.&lt;/p&gt;

&lt;h2&gt;
  
  
  Selenium IDE
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://www.lambdatest.com/blog/selenium-ide-what-is-it-why-is-it-must-for-every-qa/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jan18_sd&amp;amp;utm_term=sd&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;Selenium IDE&lt;/a&gt; allows the user to record and edit the test steps and then play those steps. IDE (Integrated Development Environment) is a Firefox, Chrome, and Edge add-on used to build and run test cases. It is a simple tool that allows you to quickly create and execute automated tests without the need to write any code.&lt;/p&gt;

&lt;p&gt;With Selenium IDE, you can record your actions in the browser, such as clicking on elements and filling out forms and then play them back to test the functionality of your web application. Selenium IDE also allows you to edit your scripts, add assertions to verify the behavior of your application, and export your scripts to other formats, such as HTML, Java, Python, and C#.&lt;/p&gt;

&lt;h2&gt;
  
  
  Selenium Grid
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://www.lambdatest.com/blog/selenium-grid-setup-tutorial/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jan18_sd&amp;amp;utm_term=sd&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;Selenium Grid&lt;/a&gt; is a tool that allows you to run your tests on different machines against different browsers in parallel. It allows you to run your tests on different machines, operating systems, and browsers. This can be particularly useful if you have a large &lt;a href="https://www.lambdatest.com/learning-hub/test-suite?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jan18_sd&amp;amp;utm_term=sd&amp;amp;utm_content=learning_hub" rel="noopener noreferrer"&gt;test suite&lt;/a&gt; and want to run your tests as quickly as possible. It’s an environment where we have one ‘master’ system (the hub) which controls the child systems (the nodes).&lt;/p&gt;

&lt;p&gt;With Selenium Grid, you can set up a hub, which is a central point that manages the &lt;a href="https://www.lambdatest.com/learning-hub/test-execution?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jan18_sd&amp;amp;utm_term=sd&amp;amp;utm_content=learning_hub" rel="noopener noreferrer"&gt;test execution&lt;/a&gt; on the connected nodes. You can then connect any number of nodes to the hub, and these nodes can be used to execute tests in parallel. Each node represents a combination of operating systems, browsers, and versions, and you can specify which tests should be run on which nodes.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;For example&lt;/strong&gt;, you might set up a hub with three nodes: one running Chrome on Windows, one running Firefox on macOS, and one running Safari on iOS. You can then use Selenium Grid to run your tests concurrently on all three nodes, allowing you to test your application on all three platforms and browsers simultaneously.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How Selenium Grid Works:&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;You set up a hub, a central point of communication for the nodes that will execute your tests.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;You set up one or more nodes, the machines that will run the tests. Each node can run tests on a different browser or operating system.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;You configure the nodes to connect to the hub.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;You write tests and use a client library, such as the Selenium WebDriver, to send commands to the hub. The hub will forward the commands to the appropriate node, executing the tests and sending the results back to the hub.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Using Selenium Grid can significantly speed up your test execution time, allowing you to run tests in parallel on multiple machines and browsers.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Selenium Trends on GitHub:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;As per the Selenium GitHub repository, Selenium persists in acquiring popularity with:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Stars: 25.5k stars&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Forks: 7.3k forks&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Watching: 1.3k watching&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Used By:175k&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Contributors: 673&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fp7hx1nm0tpom2n60lmhj.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fp7hx1nm0tpom2n60lmhj.png" width="800" height="305"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Selenium Architecture
&lt;/h2&gt;

&lt;p&gt;Selenium is an open-source testing framework used for &lt;a href="https://www.lambdatest.com/learning-hub/selenium-4?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jan18_sd&amp;amp;utm_term=sd&amp;amp;utm_content=learning_hub" rel="noopener noreferrer"&gt;web automation&lt;/a&gt; testing. The JSON Wire Protocol was removed in &lt;a href="https://www.lambdatest.com/learning-hub/selenium-4?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jan18_sd&amp;amp;utm_term=sd&amp;amp;utm_content=learning_hub" rel="noopener noreferrer"&gt;Selenium 4&lt;/a&gt; in favor of the W3C WebDriver Protocol, which is now the official standard for controlling web browsers. Nevertheless, the Selenium team continues to support the outdated protocol, which may be done via Selenium-supported language Bindings and Selenium Server.&lt;/p&gt;

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/Mmp_FiNIYtQ"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;The new protocol is called “&lt;a href="https://www.lambdatest.com/blog/selenium4-w3c-webdriver-protocol/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jan18_sd&amp;amp;utm_term=sd&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;WebDriver W3C&lt;/a&gt;”. It has acquired the acceptance of the “World Wide Web Consortium” (W3C). In Selenium 4 architecture, we can see direct communication between the client and server without needing the JSON Wire Protocol. The same protocol is used by Selenium WebDriver and web browsers, making test case execution quick and flakiness extremely low.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fvahra47natu72l22o3w4.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fvahra47natu72l22o3w4.png" width="800" height="470"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;There are several benefits of using WebDriver W3C Protocol. WebDriver W3C Protocol is richer in comparison to the one JSON Wire Protocol. The Actions API is revamped to work with the WebDriver Spec. Action APIs would now let you perform multi-touch actions, zoom-in, zoom-out, pressing two keys simultaneously, and more.&lt;/p&gt;

&lt;p&gt;For example, the Pinch-zoom sequence in W3C Protocol is represented by an action sequence consisting of three ticks and two-pointer devices of type-touch.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fyru39qwfclvqhwor8m1q.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fyru39qwfclvqhwor8m1q.png" width="800" height="154"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In the next section of this blog on Playwright vs Selenium vs Cypress, we will learn about the Cypress test automation framework.&lt;/p&gt;

&lt;h2&gt;
  
  
  What is Cypress?
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://www.lambdatest.com/learning-hub/cypress-tutorial?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jan18_sd&amp;amp;utm_term=sd&amp;amp;utm_content=learning_hub" rel="noopener noreferrer"&gt;Cypress&lt;/a&gt; is a &lt;a href="https://www.lambdatest.com/learning-hub/front-end-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jan18_sd&amp;amp;utm_term=sd&amp;amp;utm_content=learning_hub" rel="noopener noreferrer"&gt;front-end testing&lt;/a&gt; tool built for the modern web. It supports JavaScript and is used for end-to-end testing with the &lt;a href="https://www.lambdatest.com/mocha-js?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jan18_sd&amp;amp;utm_term=sd&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;Mocha&lt;/a&gt; test framework. Mocha is a feature-rich &lt;a href="https://www.lambdatest.com/blog/best-javascript-framework-2020/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jan18_sd&amp;amp;utm_term=sd&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;JavaScript-based testing framework&lt;/a&gt; that simplifies asynchronous testing. Cypress is a powerful automation tool gaining popularity and becoming a viable alternative to Selenium.&lt;/p&gt;

&lt;p&gt;In Cypress, you don’t need to install multiple dependencies; most required things for writing the test cases come as a bundle in Cypress. Cypress runs a test suite inside the browser, making it very fast compared to frameworks like Selenium. In the Cypress bundle, we have an in-built Chai assertion library that supports the Mocha framework, which provides the syntax for implementing test cases in &lt;a href="https://www.lambdatest.com/blog/behaviour-driven-development-by-selenium-testing-with-gherkin/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jan18_sd&amp;amp;utm_term=sd&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;Behavior-Driven Development (BDD)&lt;/a&gt; style.&lt;/p&gt;

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/jX3v3N6oN5M"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.lambdatest.com/cypress-automation-tool?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jan18_sd&amp;amp;utm_term=sd&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;Cypress automation&lt;/a&gt; tool addresses the following key pain points developers and QA engineers face when testing modern applications.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Easy installation&lt;/strong&gt;: You can install Cypress with npm or their desktop application. Moreover, you do not need to install additional libraries, dependencies, drivers, nor need to install additional libraries, dependencies drivers.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Real-time reloads&lt;/strong&gt;: In Cypress, you do not need to reload the test case. When you make changes to your test case, it is smart enough to trigger and run the test automatically.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Write Test case faster&lt;/strong&gt;: Cypress is faster; within minutes, you can start writing the test case. Cypress runs tests within the browser that give us results almost identical to what users will experience.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Automatic waiting&lt;/strong&gt;: In &lt;a href="https://www.lambdatest.com/cypress-ui-automation?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jan18_sd&amp;amp;utm_term=sd&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;Cypress UI automation&lt;/a&gt;, you don’t need to add wait times or sleep to your tests. Cypress automatically waits for commands and assertions before moving on to the next step.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Screenshots and videos&lt;/strong&gt;: Video of the entire suite is automatically captured. You can also capture Screenshots automatically of failure when running headlessly. This is extremely useful when tests fail.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Instructive Dashboard&lt;/strong&gt;: Using &lt;a href="https://www.lambdatest.com/cypress-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jan18_sd&amp;amp;utm_term=sd&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;Cypress cloud&lt;/a&gt;, we can run your test cases in CI/CD providers and record test results.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fccw5eqv9qztb0tbexhfa.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fccw5eqv9qztb0tbexhfa.png" width="800" height="154"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Cypress Trends on GitHub:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;As per the Cypress GitHub repository, Cypress persists in acquiring popularity with:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Stars: 42.3k&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Forks: 2.7k&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Used By: 660k&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Releases: 293&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Contributors: 413&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fvrptz5dhbdlw5peg785h.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fvrptz5dhbdlw5peg785h.png" width="800" height="321"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Check this out: &lt;a href="https://www.lambdatest.com/free-online-tools/base64-decode?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jan18_sd&amp;amp;utm_term=sd&amp;amp;utm_content=free_tools" rel="noopener noreferrer"&gt;Base64 Decode&lt;/a&gt; — Base64 decoding is a way of translating text form into binary data so that it can be transmitted more easily via e-mail and HTML form data.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Cypress Architecture
&lt;/h2&gt;

&lt;p&gt;Cypress is a testing framework that is used to automate web applications. It has a unique architecture designed to make testing faster and more reliable. In &lt;a href="https://www.lambdatest.com/cypress-ui-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jan18_sd&amp;amp;utm_term=sd&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;Cypress UI testing&lt;/a&gt;, all commands are executed inside the browser without any driver binaries dependency. In the below screenshot, you can see tests are run inside the browser, so test execution is faster without any network lags.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fyr20rjf4txtbnwngegjt.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fyr20rjf4txtbnwngegjt.png" width="600" height="430"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;There is a Node server behind Cypress, and the Node process constantly communicates, synchronizes, and performs jobs on behalf of each other. The Node server and browser communicate through WebSocket, which starts once the proxy is created.&lt;/p&gt;

&lt;p&gt;Since tests are running inside the browser, it’s very easy to work directly on:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;DOM&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Local storage&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Network layer&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Window object&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;As the things mentioned above are very simple to access in Cypress, this is a significant advantage when running tests on Cypress in comparison to other test automation frameworks.&lt;/p&gt;

&lt;p&gt;To learn more about &lt;a href="https://www.lambdatest.com/cypress-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jan18_sd&amp;amp;utm_term=sd&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;Cypress testing&lt;/a&gt;, you can refer to this blog on &lt;a href="https://www.lambdatest.com/blog/cypress-test-automation-framework/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jan18_sd&amp;amp;utm_term=sd&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;Cypress test automation&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Check this out: This &lt;a href="https://www.lambdatest.com/free-online-tools/json-prettify?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jan18_sd&amp;amp;utm_term=sd&amp;amp;utm_content=free_tools" rel="noopener noreferrer"&gt;Prettify JSON&lt;/a&gt; online tool is completely free to use.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Comparing Playwright vs Selenium vs Cypress Features
&lt;/h2&gt;

&lt;p&gt;Below are a few points for comparing Playwright vs Selenium vs Cypress.&lt;/p&gt;

&lt;h2&gt;
  
  
  Installation &amp;amp; Configuration
&lt;/h2&gt;

&lt;p&gt;In this section, we will take a look at how to install and configure each of these tools, and what benefits they offer in terms of installation and setup.&lt;/p&gt;

&lt;h3&gt;
  
  
  Playwright:
&lt;/h3&gt;

&lt;p&gt;When comparing Playwright vs Selenium vs Cypress installation and configuration, Playwright is easy to install and set up. There are different ways to install Playwright, some of which are explained below:&lt;/p&gt;

&lt;p&gt;Here are some basic prerequisites for Playwright:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Ensure you have NodeJS installed.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Install a code editor. I will be using Visual Studio Code.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;There are two ways of installing the Playwright:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Using the VS Code extension.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Using the init command.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Using the VS Code extension&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Create a folder, e.g., Install_playwright.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Open the folder in VS Code.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Search Playwright extension in VS Code and install it.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fyacrjb2qk7s2ywvijrwc.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fyacrjb2qk7s2ywvijrwc.png" width="800" height="168"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Now Press command+shift+P (in Mac) and finally click on the OK button.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4s0wmzworn22xowfgrpf.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4s0wmzworn22xowfgrpf.png" width="800" height="63"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fgpb3y4iuwp8jte6zwa50.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fgpb3y4iuwp8jte6zwa50.png" width="800" height="210"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;As we click on the OK button, the Playwright installation will start.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ft79uozyhv23v3tzo7i2j.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ft79uozyhv23v3tzo7i2j.png" width="800" height="224"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Using the init command&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Create a folder, e.g., playwright_new_script.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Open the folder in VS Code.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Run from the project’s root directory npm init playwright@latest.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;As we run the above commands, Playwright starts installing. (At the time of writing this blog, the latest version of Playwright is 1.29 ).&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;In the below screenshot, you can see we have two options. You can select either TypeScript or JavaScript.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmd1nvh0uttkqidlnb3s7.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmd1nvh0uttkqidlnb3s7.png" width="800" height="235"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fb3gpkiqrjrv979m3smwa.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fb3gpkiqrjrv979m3smwa.png" width="800" height="507"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We can see the default .spec file after successful installation.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fbitepi0var6dpl4o8ltv.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fbitepi0var6dpl4o8ltv.png" width="800" height="843"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;To know more about how to set up and run the test cases in Playwright, you can follow this blog on &lt;a href="https://www.lambdatest.com/learning-hub/how-to-install-playwright?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jan18_sd&amp;amp;utm_term=sd&amp;amp;utm_content=learning_hub" rel="noopener noreferrer"&gt;end to end testing with Playwright&lt;/a&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  Selenium:
&lt;/h3&gt;

&lt;p&gt;To set up Selenium, we usually need to follow the steps below. This applies to the local Selenium Grid. The below steps are also applicable to Python and other Selenium-supported languages. Installation of Selenium Grid and Server is not applicable for cloud Selenium Grids like LambdaTest.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Install Java. Here’s the link to download and install JDK.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxdksf6n5uba1g8rni6jo.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxdksf6n5uba1g8rni6jo.png" width="800" height="436"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Install IDE. You can learn more about it through this blog on &lt;a href="https://www.lambdatest.com/blog/configure-cucumber-setup-in-eclipse-and-intellij/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jan18_sd&amp;amp;utm_term=sd&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;configuring Eclipse and IntelliJ&lt;/a&gt;.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F37j8ye8y5z9o3zb4yaju.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F37j8ye8y5z9o3zb4yaju.png" width="800" height="751"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Download Selenium WebDriver and Java Client Driver to be set up in Eclipse.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Create a TestNG project and run the Selenium test script. You can learn more about it through this blog on &lt;a href="https://www.lambdatest.com/blog/create-testng-project-in-eclipse-run-selenium-test-script/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jan18_sd&amp;amp;utm_term=sd&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;creating TestNG project in Eclipse.&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  Cypress:
&lt;/h3&gt;

&lt;p&gt;In Cypress, installation is super easy. The good thing about Cypress is it has a folder structure. Just follow the folder structure and start developing the test cases. Using a predefined folder structure, you can develop the framework for your project.&lt;/p&gt;

&lt;p&gt;To set up Cypress, follow the steps below:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Pre-requisites: Node should already be installed.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Generate package.json using the command &lt;strong&gt;npm init&lt;/strong&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;**npm install cypress –save-dev **command installs the latest version of Cypress. At the time of writing this blog, the latest version of Cypress is 12.2.0.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fggh7tq8v2ujy64jnlr8f.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fggh7tq8v2ujy64jnlr8f.png" width="628" height="740"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Once the setup is done, open the Cypress, which will open with all default .spec files.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fpe7ofdoi27w6ynuiu551.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fpe7ofdoi27w6ynuiu551.png" width="800" height="379"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;To perform end-to-end testing using Cypress, follow the blog on &lt;a href="https://www.lambdatest.com/blog/cypress-end-to-end-testing/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jan18_sd&amp;amp;utm_term=sd&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;Cypress end to end Testing&lt;/a&gt; to know in detail.&lt;/p&gt;

&lt;p&gt;In the next section of this blog on Playwright vs Selenium vs Cypress, we will learn about different runners available for Playwright, Selenium, and Cypress.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Check this out: &lt;a href="https://www.lambdatest.com/free-online-tools/json-minify?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jan18_sd&amp;amp;utm_term=sd&amp;amp;utm_content=free_tools" rel="noopener noreferrer"&gt;Minify JSON&lt;/a&gt; helps to minify, compress and reformat JSON data. Just load your JSON and it will automatically get minified.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Runner
&lt;/h2&gt;

&lt;p&gt;Runner is a tool you can use to run/execute test cases. After executing the test cases, you can view and export the test execution results.&lt;/p&gt;

&lt;h3&gt;
  
  
  Playwright:
&lt;/h3&gt;

&lt;p&gt;Playwright has its runner and has the adaptability to operate with third-party runners such as Playwright Test Jest / Jasmine, AVA, Mocha Vitest, and multiple browsers. You can connect Playwright to your current JavaScript test runner with a few lines of code.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Playwright Test​:&lt;/strong&gt; First-party suggested test runner for Playwright is called Playwright Test.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Jest/Jasmine:&lt;/strong&gt; You can use jest-playwright for Jest. However, requiring the Playwright directly works well as a simple approach. This also applies to Jasmine, which has a shared syntax with Jest.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;**AVA: **A single page variable cannot be shared between tests in AVA since tests run concurrently. Use a macro function to create new pages instead.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;**Mocha: **Mocha functions similarly to the Jest/Jasmine configuration and has a similar appearance.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Vitest:&lt;/strong&gt; Vitest looks similar to the Jest/Jasmine setup and functions similarly.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Multiple Browsers:&lt;/strong&gt; We can execute the test cases using an environment variable in multiple browsers.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In Playwright, we can run a single test case/set of test cases or all test cases. By default, test cases are run in headless mode. Test cases are run in the terminal, and results can only be seen in the terminal. Below are the commands that we can use to run the test cases.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Performing &lt;a href="https://www.lambdatest.com/blog/playwright-framework/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jan18_sd&amp;amp;utm_term=sd&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;Playwright browser testing&lt;/a&gt; in headless mode:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
    npx playwright test
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Running a single Playwright test case:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;   npx playwright test fileName.spec.js
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Run a set of Playwright test cases:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; npx playwright test tests/page/home-page/
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Running Playwright tests in headed mode:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    npx playwright test home-page.spec.js --headed
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In Playwright, you can run the test case in debug mode. Playwright has a built-in tool, i.e., Playwright Inspector, which permits you to step via Playwright API calls, see their debug logs, and explore selectors. The Playwright Inspector also helps in finding the locators. We can find the locator by hovering over the element during the inspection.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fw26agdhw5a6g8iyb6wzu.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fw26agdhw5a6g8iyb6wzu.png" width="800" height="298"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In debug mode, Playwright opens the “Playwright Inspector,” where we can go line-wise and easily check the reason for the failure of the test case in the Inspector itself.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fw4yyxxlvci8oka87i5uh.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fw4yyxxlvci8oka87i5uh.png" width="800" height="293"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Selenium:
&lt;/h3&gt;

&lt;p&gt;Selenium Runner is a command-line tool that allows you to run Selenium scripts. There are several runners available for Selenium, each with its own set of features and capabilities. Below is a list of a few runners normally used to run test cases in Selenium.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Selenium WebDriver:&lt;/strong&gt; This is the most widely used runner for Selenium. It allows you to automate web browser actions, such as clicking on elements, filling out forms, and navigating between pages.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Selenium Grid:&lt;/strong&gt; This runner allows you to run your Selenium scripts on a remote machine or in the cloud. It is useful for running tests in parallel on multiple machines and different browsers and operating system configurations.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;**TestNG: **This is a popular testing framework often used with Selenium. It allows you to create test cases, define test suites, and support running tests in parallel.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://www.lambdatest.com/learning-hub/junit-tutorial?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jan18_sd&amp;amp;utm_term=sd&amp;amp;utm_content=learning_hub" rel="noopener noreferrer"&gt;**JUnit&lt;/a&gt;:** This is another popular testing framework often used with Selenium. It allows you to create test cases, define test suites, and support running tests in parallel.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://www.lambdatest.com/learning-hub/jenkins?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jan18_sd&amp;amp;utm_term=sd&amp;amp;utm_content=learning_hub" rel="noopener noreferrer"&gt;**Jenkins&lt;/a&gt;: **This is a &lt;a href="https://www.lambdatest.com/blog/what-is-continuous-integration-and-continuous-delivery/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jan18_sd&amp;amp;utm_term=sd&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;continuous integration&lt;/a&gt; tool that can run your Selenium tests. It automates the build, test, and deployment process and supports running tests in parallel.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;**Maven: **This is a build automation tool that can be used to manage your Selenium tests. It allows you to define dependencies, build and test your code, and manage the deployment process.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://www.lambdatest.com/blog/benefits-of-cloud-testing/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jan18_sd&amp;amp;utm_term=sd&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;Cloud testing&lt;/a&gt; tools like LambaTest can be used as a test case runner to execute automated tests on a variety of different operating systems, browsers, and devices. With LambdaTest, you can run end-to-end automated tests using Selenium on a safe, dependable, and scalable Selenium infrastructure. This can help users to ensure that their websites and applications are compatible with a wide range of different platforms and devices and to identify and fix any issues that may arise.&lt;/p&gt;

&lt;p&gt;Using LambdaTest, you can automate &lt;a href="https://www.lambdatest.com/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jan18_sd&amp;amp;utm_term=sd&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;cross browser testing&lt;/a&gt; on more than 3000 distinct operating systems and browsers with Selenium scripts, which leads to greater &lt;a href="https://www.lambdatest.com/learning-hub/test-coverage?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jan18_sd&amp;amp;utm_term=sd&amp;amp;utm_content=learning_hub" rel="noopener noreferrer"&gt;test coverage&lt;/a&gt; and significantly quicker build times.&lt;/p&gt;

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/WZlsHlReRww"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;h3&gt;
  
  
  Cypress:
&lt;/h3&gt;

&lt;p&gt;Cypress has a test runner where we can see the executing commands. Apart from that, in Cypress, you can see the application under test with real-time data. Using Cypress runner, you can see the change in UI after hovering over the log in the command log.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F7e4avq8kqpfkzdo7ep0t.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F7e4avq8kqpfkzdo7ep0t.png" width="800" height="313"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fd4zsuba5wunccbwnnxg0.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fd4zsuba5wunccbwnnxg0.png" width="800" height="379"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Run your Cypress automation scripts across 3000+ environments. &lt;a href="https://accounts.lambdatest.com/register?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jan18_sd&amp;amp;utm_term=sd&amp;amp;utm_content=register" rel="noopener noreferrer"&gt;Try LambdaTest Now!&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Check this out: &lt;a href="https://www.lambdatest.com/free-online-tools/json-escape?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jan18_sd&amp;amp;utm_term=sd&amp;amp;utm_content=free_tools" rel="noopener noreferrer"&gt;JSON Escape&lt;/a&gt; removes offending characters that can cause parsing errors. Special characters such as quotes, newlines and backslashes will be replaced with their escaped counterparts.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Record &amp;amp; Playback
&lt;/h2&gt;

&lt;p&gt;When comparing Playwright vs Selenium vs Cypress, most tools typically have a record and playback feature, which is quite beneficial for first-time users. You can change an existing test, record new tests, and run the recorded steps using the Record &amp;amp; Playback tool.&lt;/p&gt;

&lt;p&gt;All three tools, i.e., Playwright vs Selenium vs Cypress, include Record &amp;amp; Playback, which are described in more depth below.&lt;/p&gt;

&lt;h3&gt;
  
  
  Playwright:
&lt;/h3&gt;

&lt;p&gt;In Playwright, you will generate the code for the user interactions. You can use CodeGen to generate the actions we perform in the browser. Playwright will generate the code for the user action performed. You can use the below commands to open the Playwright Inspector.&lt;/p&gt;

&lt;p&gt;In the below screenshot, you can see code is generated when you click on the Home, Blog, and Mega Menu link.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
    npx playwright codegen https://ecommerce-playground.lambdatest.io.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4j04pvax90z5devkl88h.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4j04pvax90z5devkl88h.png" width="800" height="296"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Selenium:
&lt;/h3&gt;

&lt;p&gt;We have Selenium IDE to record and playback the code in Selenium. Selenium IDE doesn’t need any additional setup before usage other than installing the plugin in your browser.&lt;/p&gt;

&lt;p&gt;It does not require any programming logic to develop its test scripts, unlike Selenium WebDriver and RC. Instead, you may only record your browser interactions to create test cases. The playback option can then be used to rerun the test scenarios.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fj0j25fbt2672l7yiu2ry.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fj0j25fbt2672l7yiu2ry.png" width="800" height="822"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Selenium IDE records multiple locators for every element it interacts with. It tries to attempt the locator until one is successful if one fails during playback. You can reuse existing test cases inside of another by using the run command (e.g., allowing you to reuse your login logic in multiple places throughout a suite). In the below screenshot, you can see we have reused VerifyHomePage test steps in another test case.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fnzq4a5yoogfm9jecudh2.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fnzq4a5yoogfm9jecudh2.png" width="800" height="823"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The Selenium IDE comes preloaded with a robust control flow structure that includes available commands like if, while, and times.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fywcss3h1iqzjo9ia566p.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fywcss3h1iqzjo9ia566p.png" width="800" height="785"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Cypress:
&lt;/h3&gt;

&lt;p&gt;We can use Cypress Studio to capture the test case in Cypress. By capturing interactions with the application being tested, Cypress Studio offers a visual approach to developing tests within Cypress.&lt;/p&gt;

&lt;p&gt;Cypress Studio provides a visual approach to create tests within Cypress by recording interactions against the application under test. When interacting with the DOM inside of Cypress Studio, the &lt;em&gt;.type().click(),.check(),.uncheck(), and .select()&lt;/em&gt; Cypress commands are available and will produce test code.&lt;/p&gt;

&lt;p&gt;To enable the Cypress Studio, we have to do the below setting &lt;em&gt;(experimentalStudio: true) in cypress.config.js&lt;/em&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;   const { defineConfig } = require("cypress");
    module.exports = defineConfig({
     e2e: {
       experimentalStudio: true,
     },
    });

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;After doing the above setting when we run the test cases. We can see two options to record the test cases:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Add New Tests.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Add commands to Test.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fax8pghiti9fafulvv0ej.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fax8pghiti9fafulvv0ej.png" width="800" height="456"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F48kp4rx3i58bn8uli7um.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F48kp4rx3i58bn8uli7um.png" width="800" height="522"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Add New Tests&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Using Add New Test, we can add a new Test, save it and re-run it. In the below screenshot, we can see steps are recorded by Cypress Studio. Just save the commands, and a new script is created.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fila71tko0lz3zxne7kw6.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fila71tko0lz3zxne7kw6.png" width="800" height="427"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Add commands to Test&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Using Add commands to Test, we can add more steps in existing test cases.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fycgfh18l93o7h7klbhe5.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fycgfh18l93o7h7klbhe5.png" width="800" height="442"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In the screenshot below, you can see whatever steps added in the first test case are recorded on an existing script. This way, we can update our existing script with new additional steps.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    /// &amp;lt;reference types="cypress" /&amp;gt;
    describe("Cypress Studio -- &amp;gt;", { testIsolation: false }, () =&amp;gt; {
     it("WHEN User Open the Url", () =&amp;gt; {
       cy.visit(
         "https://ecommerce-playground.lambdatest.io/index.php?route=account/login"
       );
       /* ==== Generated with Cypress Studio ==== */
       cy.get('#widget-navbar-217834 &amp;gt; .navbar-nav &amp;gt; :nth-child(1) &amp;gt; .icon-left &amp;gt; .info &amp;gt; .title').click();
       cy.get('#widget-navbar-217834 &amp;gt; .navbar-nav &amp;gt; :nth-child(3) &amp;gt; .icon-left &amp;gt; .info &amp;gt; .title').click();
       /* ==== End Cypress Studio ==== */
     });
     it("AND Login into the application", () =&amp;gt; {
       cy.get('[id="input-email"]').type("lambdatest@yopmail.com");
       cy.get('[id="input-password"]').type("lambdatest");
       cy.get('[type="submit"]').eq(0).click();
     });
     it("AND After login Search the Product", () =&amp;gt; {
       cy.get('[name="search"]')
         .eq(0)
         .type("Sony VAIO")
         .should("have.value", "Sony VAIO");
       cy.get('[type="submit"]').eq(0).click();
     });
     it("THEN Verify Correct Product should display after search ", () =&amp;gt; {
       cy.contains("Sony VAIO");
     });
    });
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In the next section of this blog on Playwright vs Selenium vs Cypress, we will learn about different ways to select elements in Playwright, Selenium, and Cypress.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Check this out: &lt;a href="https://www.lambdatest.com/free-online-tools/json-unescape?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jan18_sd&amp;amp;utm_term=sd&amp;amp;utm_content=free_tools" rel="noopener noreferrer"&gt;Unescape JSON&lt;/a&gt; removes traces of offending characters that could prevent parsing. To unescape JSON strings, several libraries and tools are available in different programming languages.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Element Selection
&lt;/h2&gt;

&lt;p&gt;Element selection is a way where we filter out all elements with a given tag in documents and make sure the element you are making assertions is detached from the DOM. We have different types of tags (e.g., Id, CSS, Class, Attribute, Tag Name, Link Text, Name Attribute)&lt;/p&gt;

&lt;h3&gt;
  
  
  Playwright:
&lt;/h3&gt;

&lt;p&gt;In Playwright, we have an auto-wait concept that makes the command fast and the test case execution fast. Playwright auto-waits for all the relevant checks to pass. Once these checks pass, then only perform the requested action.&lt;/p&gt;

&lt;p&gt;Here is the list of actionability checks performed for each action on the elements.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
    &lt;tr&gt;
        &lt;td&gt;ACTION&lt;/td&gt;
        &lt;td&gt;ATTACHED&lt;/td&gt;
        &lt;td&gt;VISIBLE&lt;/td&gt;
        &lt;td&gt;STABLE&lt;/td&gt;
        &lt;td&gt;RECEIVES EVENTS&lt;/td&gt;
        &lt;td&gt;ENABLED&lt;/td&gt;
        &lt;td&gt;EDITABLE &lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
        &lt;td&gt;check&lt;/td&gt;
        &lt;td&gt;Yes&lt;/td&gt;
        &lt;td&gt;Yes&lt;/td&gt;
        &lt;td&gt;Yes&lt;/td&gt;
        &lt;td&gt;Yes&lt;/td&gt;
        &lt;td&gt;Yes&lt;/td&gt;
        &lt;td&gt;– &lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
        &lt;td&gt;press&lt;/td&gt;
        &lt;td&gt;Yes&lt;/td&gt;
        &lt;td&gt;–&lt;/td&gt;
        &lt;td&gt;–&lt;/td&gt;
        &lt;td&gt;–&lt;/td&gt;
        &lt;td&gt;–&lt;/td&gt;
        &lt;td&gt;– &lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
        &lt;td&gt;setInputFiles&lt;/td&gt;
        &lt;td&gt;Yes&lt;/td&gt;
        &lt;td&gt;–&lt;/td&gt;
        &lt;td&gt;–&lt;/td&gt;
        &lt;td&gt;–&lt;/td&gt;
        &lt;td&gt;–&lt;/td&gt;
        &lt;td&gt;– &lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
        &lt;td&gt;selectOption&lt;/td&gt;
        &lt;td&gt;Yes&lt;/td&gt;
        &lt;td&gt;Yes&lt;/td&gt;
        &lt;td&gt;–&lt;/td&gt;
        &lt;td&gt;–&lt;/td&gt;
        &lt;td&gt;Yes&lt;/td&gt;
        &lt;td&gt;– &lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
        &lt;td&gt;textContent&lt;/td&gt;
        &lt;td&gt;Yes&lt;/td&gt;
        &lt;td&gt;–&lt;/td&gt;
        &lt;td&gt;–&lt;/td&gt;
        &lt;td&gt;–&lt;/td&gt;
        &lt;td&gt;–&lt;/td&gt;
        &lt;td&gt;– &lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
        &lt;td&gt;type&lt;/td&gt;
        &lt;td&gt;Yes&lt;/td&gt;
        &lt;td&gt;–&lt;/td&gt;
        &lt;td&gt;–&lt;/td&gt;
        &lt;td&gt;–&lt;/td&gt;
        &lt;td&gt;–&lt;/td&gt;
        &lt;td&gt;– &lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
        &lt;td&gt;click&lt;/td&gt;
        &lt;td&gt;Yes&lt;/td&gt;
        &lt;td&gt;Yes&lt;/td&gt;
        &lt;td&gt;Yes&lt;/td&gt;
        &lt;td&gt;Yes&lt;/td&gt;
        &lt;td&gt;Yes&lt;/td&gt;
        &lt;td&gt;– &lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
        &lt;td&gt;dblclick&lt;/td&gt;
        &lt;td&gt;Yes&lt;/td&gt;
        &lt;td&gt;Yes&lt;/td&gt;
        &lt;td&gt;Yes&lt;/td&gt;
        &lt;td&gt;Yes&lt;/td&gt;
        &lt;td&gt;Yes&lt;/td&gt;
        &lt;td&gt;– &lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
        &lt;td&gt;setChecked&lt;/td&gt;
        &lt;td&gt;Yes&lt;/td&gt;
        &lt;td&gt;Yes&lt;/td&gt;
        &lt;td&gt;Yes&lt;/td&gt;
        &lt;td&gt;Yes&lt;/td&gt;
        &lt;td&gt;Yes&lt;/td&gt;
        &lt;td&gt;– &lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
        &lt;td&gt;tap&lt;/td&gt;
        &lt;td&gt;Yes&lt;/td&gt;
        &lt;td&gt;Yes&lt;/td&gt;
        &lt;td&gt;Yes&lt;/td&gt;
        &lt;td&gt;Yes&lt;/td&gt;
        &lt;td&gt;Yes&lt;/td&gt;
        &lt;td&gt;– &lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
        &lt;td&gt;uncheck&lt;/td&gt;
        &lt;td&gt;Yes&lt;/td&gt;
        &lt;td&gt;Yes&lt;/td&gt;
        &lt;td&gt;Yes&lt;/td&gt;
        &lt;td&gt;Yes&lt;/td&gt;
        &lt;td&gt;Yes&lt;/td&gt;
        &lt;td&gt;– &lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
        &lt;td&gt;hover&lt;/td&gt;
        &lt;td&gt;Yes&lt;/td&gt;
        &lt;td&gt;Yes&lt;/td&gt;
        &lt;td&gt;Yes&lt;/td&gt;
        &lt;td&gt;Yes&lt;/td&gt;
        &lt;td&gt;–&lt;/td&gt;
        &lt;td&gt;– &lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
        &lt;td&gt;scrollIntoViewIfNeeded&lt;/td&gt;
        &lt;td&gt;Yes&lt;/td&gt;
        &lt;td&gt;–&lt;/td&gt;
        &lt;td&gt;Yes&lt;/td&gt;
        &lt;td&gt;–&lt;/td&gt;
        &lt;td&gt;–&lt;/td&gt;
        &lt;td&gt;– &lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
        &lt;td&gt;screenshot&lt;/td&gt;
        &lt;td&gt;Yes&lt;/td&gt;
        &lt;td&gt;Yes&lt;/td&gt;
        &lt;td&gt;Yes&lt;/td&gt;
        &lt;td&gt;–&lt;/td&gt;
        &lt;td&gt;–&lt;/td&gt;
        &lt;td&gt;– &lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
        &lt;td&gt;fill&lt;/td&gt;
        &lt;td&gt;Yes&lt;/td&gt;
        &lt;td&gt;Yes&lt;/td&gt;
        &lt;td&gt;–&lt;/td&gt;
        &lt;td&gt;–&lt;/td&gt;
        &lt;td&gt;Yes&lt;/td&gt;
        &lt;td&gt;Yes &lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
        &lt;td&gt;selectText&lt;/td&gt;
        &lt;td&gt;Yes&lt;/td&gt;
        &lt;td&gt;Yes&lt;/td&gt;
        &lt;td&gt;–&lt;/td&gt;
        &lt;td&gt;–&lt;/td&gt;
        &lt;td&gt;–&lt;/td&gt;
        &lt;td&gt;– &lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
        &lt;td&gt;dispatchEvent&lt;/td&gt;
        &lt;td&gt;Yes&lt;/td&gt;
        &lt;td&gt;–&lt;/td&gt;
        &lt;td&gt;–&lt;/td&gt;
        &lt;td&gt;–&lt;/td&gt;
        &lt;td&gt;–&lt;/td&gt;
        &lt;td&gt;– &lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
        &lt;td&gt;focus&lt;/td&gt;
        &lt;td&gt;Yes&lt;/td&gt;
        &lt;td&gt;–&lt;/td&gt;
        &lt;td&gt;–&lt;/td&gt;
        &lt;td&gt;–&lt;/td&gt;
        &lt;td&gt;–&lt;/td&gt;
        &lt;td&gt;– &lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
        &lt;td&gt;getAttribute&lt;/td&gt;
        &lt;td&gt;Yes&lt;/td&gt;
        &lt;td&gt;–&lt;/td&gt;
        &lt;td&gt;–&lt;/td&gt;
        &lt;td&gt;–&lt;/td&gt;
        &lt;td&gt;–&lt;/td&gt;
        &lt;td&gt;– &lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
        &lt;td&gt;innerText&lt;/td&gt;
        &lt;td&gt;Yes&lt;/td&gt;
        &lt;td&gt;–&lt;/td&gt;
        &lt;td&gt;–&lt;/td&gt;
        &lt;td&gt;–&lt;/td&gt;
        &lt;td&gt;–&lt;/td&gt;
        &lt;td&gt;– &lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
        &lt;td&gt;innerHTML&lt;/td&gt;
        &lt;td&gt;Yes&lt;/td&gt;
        &lt;td&gt;–&lt;/td&gt;
        &lt;td&gt;–&lt;/td&gt;
        &lt;td&gt;–&lt;/td&gt;
        &lt;td&gt;–&lt;/td&gt;
        &lt;td&gt;–&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
    &lt;/tr&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Below are the points that the Playwright will ensure before taking action on any of the elements on the page.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;element is bound to the DOM&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;element is visible&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;element is enabled&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;element receives events, as in not obscured by other elements&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Below are a few examples of Playwright. In the case of the Playwright, “waits” is included by default against each action on the element.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;   await page.goto('https://www.bing.com')
    const element = await page.$('[aria-label="Enter your search term"]')
    await element.click()
    await element.type('LambdaTest')
    await element.press('Enter')

    await page.locator('text=Log in').click();
    await page.locator('article:has-text("Playwright")').click();
    await page.locator('#nav-bar &amp;gt;&amp;gt; text=Contact Us').click();

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;&lt;em&gt;Check this out: With this free online &lt;a href="https://www.lambdatest.com/free-online-tools/adler32-hash-calculator?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jan18_sd&amp;amp;utm_term=sd&amp;amp;utm_content=free_tools" rel="noopener noreferrer"&gt;Alder32 Hash Calculator&lt;/a&gt;, you can provide input in plain text, Base64, or as a binary file. Hit the Calculate button above and voila! Your Adler-32 checksum will be generated in no time.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Selenium:
&lt;/h3&gt;

&lt;p&gt;WebElements in Selenium are used to interact with DOM elements. We normally used different types of locators (mentioned above) to connect with the page’s elements. Sometimes when we search for the element, we assume that the element will already be loaded on the page.&lt;/p&gt;

&lt;p&gt;In my opinion, this is one of Selenium’s biggest limitations. As a result of the test frequently failing after repeated attempts to find the element, we must start loading the element with &lt;a href="https://www.lambdatest.com/blog/types-of-waits-in-selenium/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jan18_sd&amp;amp;utm_term=sd&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;implicit or explicit waits&lt;/a&gt; to avoid flakiness.&lt;/p&gt;

&lt;p&gt;To avoid failure of the test case, here we check whether the element is available in DOM.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    WebElement button = new WebDriverWait(driver, 30).until(ExpectedConditions.presenceOfElementLocated(By.id("buttonId")));
    button.click();
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Cypress:
&lt;/h3&gt;

&lt;p&gt;In the case of Cypress, things are the opposite, as interactions of elements are done through the locators. There is an inbuilt “wait mechanism” in Cypress, which makes the execution of the tests much more stable and decreases the flakiness during the execution of the test cases.&lt;/p&gt;

&lt;p&gt;​​This duration is configured by the defaultCommandTimeout option — which has a default of &lt;strong&gt;4000&lt;/strong&gt; ms. This means that when acting on the element, Cypress will wait up to 4 seconds to move to the next command. You will get an error message if the element is not loaded within the default time. We can increase &lt;strong&gt;defaultCommandTimeout&lt;/strong&gt; from &lt;strong&gt;cypress.config.js file&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;     const { defineConfig } = require('cypress')

    module.exports = defineConfig({
     defaultCommandTimeout: 10000
    })

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Cypress automatically pauses for the network call to complete before moving to the next command. In the below commands of Cypress, for every command, Cypress will wait for 4 seconds.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    cy.get('.btn').click() // Click on to the button
    cy.focused().click() // Click on element with focus
    cy.contains('Welcome').click() // Click on first el containing 'Welcome'
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;&lt;em&gt;Check this out: &lt;a href="https://www.lambdatest.com/free-online-tools/html-escape?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jan18_sd&amp;amp;utm_term=sd&amp;amp;utm_content=free_tools" rel="noopener noreferrer"&gt;HTML Escape&lt;/a&gt; is a simple tool that turns normal HTML into escaped HTML, making it easier to display HTML text in the pre&amp;gt; tag.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Language/Browser Support
&lt;/h2&gt;

&lt;p&gt;Language/browser support is one of the key differentiators among Playwright vs Selenium vs Cypress.&lt;/p&gt;

&lt;h3&gt;
  
  
  Playwright:
&lt;/h3&gt;

&lt;p&gt;It supports most languages, including Python, Java, Java Script, and .Net. Playwright has the full support of all modern browsers that include Google Chrome and Microsoft Edge (with Chromium), Safari (with WebKit), and Firefox.&lt;/p&gt;

&lt;h3&gt;
  
  
  Selenium:
&lt;/h3&gt;

&lt;p&gt;Selenium is a suite of tools that enables &lt;a href="https://www.lambdatest.com/automation-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jan18_sd&amp;amp;utm_term=sd&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;automated testing&lt;/a&gt; of web applications. It supports various programming languages, including Java, Python, C#, Ruby, and JavaScript. You can use any of these languages to &lt;a href="https://www.lambdatest.com/blog/how-to-write-test-scripts-in-selenium/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jan18_sd&amp;amp;utm_term=sd&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;write your Selenium test scripts&lt;/a&gt;, and run them on various web browsers, including Google Chrome, Mozilla Firefox, Internet Explorer, Microsoft Edge, and Safari. Selenium also provides support for headless browsers, which allow you to run your tests without actually launching a web browser window.&lt;/p&gt;

&lt;p&gt;To use Selenium with a particular programming language and web browser, you must install the appropriate language bindings and &lt;a href="https://www.lambdatest.com/learning-hub/webdriver?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jan18_sd&amp;amp;utm_term=sd&amp;amp;utm_content=learning_hub" rel="noopener noreferrer"&gt;WebDriver&lt;/a&gt;. These will allow you to interact with the browser and perform actions such as navigating a web page, clicking on elements, and entering text.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;For example&lt;/strong&gt;, if you want to use &lt;a href="https://www.lambdatest.com/learning-hub/python-tutorial?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jan18_sd&amp;amp;utm_term=sd&amp;amp;utm_content=learning_hub" rel="noopener noreferrer"&gt;Selenium with Python&lt;/a&gt; and Chrome, you must install the Python bindings for Selenium and the ChromeDriver web driver. You can then use the Python bindings to control Chrome and perform your tests.&lt;/p&gt;

&lt;h3&gt;
  
  
  Cypress:
&lt;/h3&gt;

&lt;p&gt;Cypress is a JavaScript-based end-to-end testing tool designed to work with web applications. As a result, it is primarily designed to work with web pages and applications written in HTML, CSS, and JavaScript. It is compatible with all modern browsers, including Google Chrome, Mozilla Firefox, Microsoft Edge, and Apple Safari.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Check this out: The &lt;a href="https://www.lambdatest.com/free-online-tools/html-unescape?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jan18_sd&amp;amp;utm_term=sd&amp;amp;utm_content=free_tools" rel="noopener noreferrer"&gt;html unescape&lt;/a&gt; method helps us to convert the ascii string into html script by replacing ascii characters with special HTML characters. This tool will convert HTML entities to a string or convert plain text to HTML entities.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Parallel Execution
&lt;/h2&gt;

&lt;p&gt;Parallel execution is a crucial feature for automating web browsers as it allows running multiple test cases simultaneously, thus reducing the overall execution time. When it comes to parallel execution, Playwright, Selenium, and Cypress are all popular choices among developers.&lt;/p&gt;

&lt;p&gt;In this comparison, we will take a look at how each of these tools handles parallel execution, what kind of parallel execution options they offer, and how easy it is to implement parallel execution with these tools.&lt;/p&gt;

&lt;h3&gt;
  
  
  Playwright:
&lt;/h3&gt;

&lt;p&gt;When it comes to comparing Playwright vs Selenium vs Cypress, Playwright supports parallel execution across multiple machines.&lt;br&gt;
Let’s take an example to run the test cases in parallel.&lt;/p&gt;

&lt;p&gt;Below is the &lt;strong&gt;code snippet&lt;/strong&gt; where we are opening one &lt;a href="https://ecommerce-playground.lambdatest.io/" rel="noopener noreferrer"&gt;eCommerce website&lt;/a&gt;, then clicking on the Home, Blog link, and verifying the user is redirected to the correct URL.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    // @ts-check
    const { test, expect } = require("@playwright/test");

    test.describe("Test suite", () =&amp;gt; {
     test.beforeEach(async ({ page }) =&amp;gt; {
       await page.goto("https://ecommerce-playground.lambdatest.io/");
     });
     test("Open the Lambdatest Site Click on Home Link and verify user re-direct to correct url", async ({ page }) =&amp;gt; {
       await page.locator('span:has-text("Home")').click();
       await expect(page).toHaveURL(
         "https://ecommerce-playground.lambdatest.io/index.php?route=common/home"
       );
     });
     test("Open the Lambdatest Site Click on Blog Link and verify user re-direct to correct url", async ({ page }) =&amp;gt; {
       await page.locator("#widget-navbar-217834 &amp;gt;&amp;gt; text=Blog").click();
       await expect(page).toHaveURL(
         "https://ecommerce-playground.lambdatest.io/index.php?route=extension/maza/blog/home"
       );
     });
    });
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Running the script with 1 Worker in Playwright:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;In below screenshot, we can see we have 2 test cases that are running one by one [1/2].&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ffw8mnfy2c94yqfuak5dy.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ffw8mnfy2c94yqfuak5dy.png" width="800" height="149"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Here we can see that when we were running test cases in a Single worker, it took &lt;strong&gt;16s&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqszn5zdf80sello8l6au.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqszn5zdf80sello8l6au.png" width="800" height="276"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;By default, test cases are run in a single worker, but if we have to run the test cases in parallel in different machines, we have to provide the number of workers either through the command line by updating the config file passing npx playwright test --workers 4 where “4” is the number of workers on which we want to execute our test cases.&lt;/p&gt;

&lt;p&gt;Another way to run the test cases in parallel is by bypassing the worker in &lt;strong&gt;playwright.config.js.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Setting to update the Worker&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;To update the number of workers, we have to update &lt;strong&gt;playwright.config.js.&lt;/strong&gt; In the below screenshot, you can see I have updated the worker to “2” in line number #33.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fhspt14p639e7cbfmkb0f.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fhspt14p639e7cbfmkb0f.png" width="800" height="323"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Running the script with 2 Workers in Playwright:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;In the below screenshot, we can see both the test cases are executed parallelly [2/2].&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4a33s26nfm9emykx438a.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4a33s26nfm9emykx438a.png" width="800" height="133"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;When we run the same script with 2 workers taking 13s.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F7s7twirtv42rw8e1fbdb.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F7s7twirtv42rw8e1fbdb.png" width="800" height="228"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;LambdaTest allows you to perform &lt;a href="https://www.lambdatest.com/blog/what-is-parallel-testing-and-why-to-adopt-it/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jan18_sd&amp;amp;utm_term=sd&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;parallel testing&lt;/a&gt; with Playwright across 50+ browsers and OS to automate your several test cases simultaneously. You can run one test case across various browsers or multiple test case scenarios in the same browser with different browser versions.&lt;/p&gt;

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/ioJaNCYX7Qc"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;Subscribe to &lt;a href="https://www.youtube.com/c/LambdaTest?sub_confirmation=1" rel="noopener noreferrer"&gt;LambdaTest YouTube Channel&lt;/a&gt; and stay updated with detailed tutorials around &lt;a href="https://www.lambdatest.com/playwright-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jan18_sd&amp;amp;utm_term=sd&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;Playwright testing&lt;/a&gt;, &lt;a href="https://www.lambdatest.com/selenium-automation?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jan18_sd&amp;amp;utm_term=sd&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;Selenium testing&lt;/a&gt;, &lt;a href="https://www.lambdatest.com/cypress-testing?utm_source=medium&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jan18_sd&amp;amp;utm_term=sd&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;Cypress testing&lt;/a&gt;, and more.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Check this out: An &lt;a href="https://www.lambdatest.com/free-online-tools/md4-hash-calculator?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jan18_sd&amp;amp;utm_term=sd&amp;amp;utm_content=free_tools" rel="noopener noreferrer"&gt;MD4 hash calculator&lt;/a&gt; is a tool that calculates the MD4 hash value of a file or data.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Selenium:
&lt;/h3&gt;

&lt;p&gt;Parallel execution means executing the test case of different modules in parallel instead of running them in series. In Selenium, you can do parallel execution using TestNG. Below is the structure for defining the attribute in the TestNG XML file to run the test cases in parallel.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
    &amp;lt;suite name=”ParallelTesting” parallel=”methods” thread-count=”3"&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In the above example, in place of “method,” we can pass the below values.&lt;/p&gt;

&lt;p&gt;Below pointer mentioned here is specific to Java. It might vary for other Selenium-supported languages.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Methods:&lt;/strong&gt; All the methods with &lt;a class="mentioned-user" href="https://dev.to/test"&gt;@test&lt;/a&gt; annotation will run in parallel.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Instances:&lt;/strong&gt; Helps execute all methods in the same instance in the same thread.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Tests:&lt;/strong&gt; All the test cases inside the tag of the Testing XML file will run parallel.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Classes:&lt;/strong&gt; All the test cases inside a Java class will run in parallel.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Thread Count:&lt;/strong&gt; No of threads you want to run in parallel.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In the above code snippet, attribute thread count helps in defining the number of threads that we want while executing the test cases in parallel.&lt;/p&gt;

&lt;p&gt;Let’s take an example of how a thread works. Suppose we have three methods and two threads to run the test cases in parallel. So initially, two methods will run with two available threads. Once any thread between two freezes, the third method in the queue starts executing.&lt;/p&gt;

&lt;p&gt;Let’s Take an example to run the test cases in parallel. Open the Site &lt;a href="https://ecommerce-playground.lambdatest.io/" rel="noopener noreferrer"&gt;https://ecommerce-playground.lambdatest.io/&lt;/a&gt;, Verify the title, Click on the Home Page, and Verify the user is redirected to the correct URL.&lt;/p&gt;

&lt;p&gt;Create three Classes, “ChromeParallelTest,” ”ForefoxParallelTest,” and “SafariParallelTest” to run the test cases in three browsers.&lt;/p&gt;

&lt;p&gt;Below is the code snippet for Class “ChromeParallelTest”:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    package ParallelTestCase;

    import org.openqa.selenium.By;
    import org.openqa.selenium.WebDriver;
    import org.openqa.selenium.WebElement;
    import org.openqa.selenium.chrome.ChromeDriver;
    import org.testng.Assert;
    import org.testng.annotations.AfterClass;
    import org.testng.annotations.BeforeTest;
    import org.testng.annotations.Test;

    public class ChromeParallelTest {

     WebDriver driver;

     @BeforeTest
     public void setUp() {
       System.setProperty("webdriver.chrome.driver", "/Users/xxxxx/Desktop/Chromedriver/chromedriver");
       driver = new ChromeDriver();
       driver.navigate().to("https://ecommerce-playground.lambdatest.io/");
       driver.manage().window().maximize();
     }

     @Test
     public void VerifyTitle() {
       System.out.println("The thread ID for Running First Test In Chrome Browser is  " + Thread.currentThread().getId());
       Assert.assertEquals(driver.getTitle(), "Your Store");
     }

     @Test
     public void ClickOnHomeLink() {
       System.out.println("The thread ID for Running Second Test In Chrome Browser is  " + Thread.currentThread().getId());
       WebElement homeLink = driver.findElement(By.xpath("//span[contains(text(),'Home')]"));
       homeLink.click();
       String redirectURL = driver.getCurrentUrl();
       Assert.assertEquals(redirectURL, "https://ecommerce-playground.lambdatest.io/index.php?route=common/home");
     }

     @AfterTest
     public void close() {
       driver.quit();
     }
    }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Below is the code snippet for the Class “FirefoxParallelTest”.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    package ParallelTestCase;

    import org.openqa.selenium.By;
    import org.openqa.selenium.WebDriver;
    import org.openqa.selenium.WebElement;
    import org.openqa.selenium.firefox.FirefoxDriver;
    import org.testng.Assert;
    import org.testng.annotations.AfterClass;
    import org.testng.annotations.BeforeTest;
    import org.testng.annotations.Test;

    public class FirefoxParallelTest {

     WebDriver driver;

     @BeforeTest
     public void setUp() {
       System.setProperty("webdriver.chrome.driver", "/Users/xxxxxxx/Desktop/Chromedriver/chromedriver");
       driver = new FirefoxDriver();
       driver.navigate().to("https://ecommerce-playground.lambdatest.io/");
       driver.manage().window().maximize();
     }

     @Test
     public void VerifyTitle() {
       System.out.println("The thread ID for Running First Test In Firefox Browser is " + Thread.currentThread().getId());
       Assert.assertEquals(driver.getTitle(), "Your Store");
     }

     @Test
     public void ClickOnHomeLink() {
       System.out.println("The thread ID for Running Second Test In Firefox Browser iss " + Thread.currentThread().getId());
       WebElement homeLink = driver.findElement(By.xpath("//span[contains(text(),'Home')]"));
       homeLink.click();
       String redirectURL = driver.getCurrentUrl();
       Assert.assertEquals(redirectURL, "https://ecommerce-playground.lambdatest.io/index.php?route=common/home");
     }

     @AfterTest
     public void close() {
       driver.quit();
     }
    }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Below is the code snippet for Class “SafariParallelTest”.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    package ParallelTestCase;

    import org.openqa.selenium.By;
    import org.openqa.selenium.WebDriver;
    import org.openqa.selenium.WebElement;
    import org.openqa.selenium.firefox.FirefoxDriver;
    import org.testng.Assert;
    import org.testng.annotations.AfterClass;
    import org.testng.annotations.BeforeTest;
    import org.testng.annotations.Test;

    public class SafariParallelTest {

     WebDriver driver;

     @BeforeTest
     public void setUp() {
       System.setProperty("webdriver.chrome.driver", "/Users/xxxxxx/Desktop/Chromedriver/chromedriver");
       driver = new SafariDriver();
       driver.navigate().to("https://ecommerce-playground.lambdatest.io/");
       driver.manage().window().maximize();
     }

     @Test
     public void VerifyTitle() {
       System.out.println("The thread ID for Running First Test In Firefox Browser is " + Thread.currentThread().getId());
       Assert.assertEquals(driver.getTitle(), "Your Store");
     }

     @Test
     public void ClickOnHomeLink() {
       System.out.println("The thread ID for Running Second Test In Firefox Browser iss " + Thread.currentThread().getId());
       WebElement homeLink = driver.findElement(By.xpath("//span[contains(text(),'Home')]"));
       homeLink.click();
       String redirectURL = driver.getCurrentUrl();
       Assert.assertEquals(redirectURL, "https://ecommerce-playground.lambdatest.io/index.php?route=common/home");
     }

     @AfterTest
     public void close() {
       driver.quit();
     }
    }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To run the test cases in parallel, let’s create a testng.xml file with the following config.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    &amp;lt;?xml version="1.0" encoding="UTF-8"?&amp;gt;
    &amp;lt;!DOCTYPE suite SYSTEM "https://testng.org/testng-1.0.dtd"&amp;gt;
    &amp;lt;suite name="Suite" parallel="tests" thread-count="2"&amp;gt;
    &amp;lt;test name="Parallel Test Case Execution In Chrome"&amp;gt;
       &amp;lt;classes&amp;gt;
         &amp;lt;class name="ParallelTestCase.ChromeParallelTest"/&amp;gt;
       &amp;lt;/classes&amp;gt;
     &amp;lt;/test&amp;gt; &amp;lt;!-- Test Case END --&amp;gt;
      &amp;lt;test name="Parallel Test Case Execution In FireFox"&amp;gt;
       &amp;lt;classes&amp;gt;
         &amp;lt;class name="ParallelTestCase.FirefoxParallelTest"/&amp;gt;
       &amp;lt;/classes&amp;gt;
     &amp;lt;/test&amp;gt; &amp;lt;!-- Test Case END --&amp;gt;

     &amp;lt;test name="Parallel Test Case Execution In Safari"&amp;gt;
       &amp;lt;classes&amp;gt;
         &amp;lt;class name="ParallelTestCase.SafariParallelTest"/&amp;gt;
       &amp;lt;/classes&amp;gt;
     &amp;lt;/test&amp;gt; &amp;lt;!-- Test Case END --&amp;gt;
     &amp;lt;/suite&amp;gt; &amp;lt;!-- Suite END --&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In the above screenshot, we can see we have given thread-count “2”. So the first two test cases are run in two threads. Once the threads are free, the next test case starts executing.&lt;/p&gt;

&lt;p&gt;Let’s execute the test cases. We have to right-click on testng.xml and then “Run As” -&amp;gt; TestNG Suite.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fkn1emgzy9o71y8sie3kj.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fkn1emgzy9o71y8sie3kj.png" width="800" height="804"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You can see in the screenshot below that “FirefoxTest” and “ChromeTest” were running concurrently on Threads 15 and 16, respectively, as seen in the console logs. Later, “SafariTest” was executed on Thread 15 because it was released before 16.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fikxy7vi4cis2llccxq4v.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fikxy7vi4cis2llccxq4v.png" width="800" height="319"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Run your Selenium automation scripts across 3000+ environments. &lt;a href="https://accounts.lambdatest.com/register?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jan18_sd&amp;amp;utm_term=sd&amp;amp;utm_content=register" rel="noopener noreferrer"&gt;Try LambdaTest Now!&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Cypress:
&lt;/h3&gt;

&lt;p&gt;Cypress supports parallel execution across multiple machines from version 3.1.0. By default, the &lt;strong&gt;cypress run&lt;/strong&gt; command executes the test cases serially. In Cypress, we can execute test cases in parallel, which saves your team time and good ROI when running tests in Continuous Integration (CI) tests.&lt;/p&gt;

&lt;p&gt;To run Cypress test cases locally, we can use the command &lt;strong&gt;npx cypress run –record –key xxxxxx-xxx-xxxx0-xx-xxxxx.&lt;/strong&gt; Record Keys allow you to record test results, screenshots, and videos in Cypress.&lt;/p&gt;

&lt;p&gt;Let’s run the below Cypress test case in Cypress Cloud for the site &lt;a href="https://ecommerce-playground.lambdatest.io/" rel="noopener noreferrer"&gt;https://ecommerce-playground.lambdatest.io/&lt;/a&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    describe("Verify title of ecommerce-playground.lambdatest.io", function () {
     it("Should display the correct title", function () {
       cy.visit("https://ecommerce-playground.lambdatest.io/");

       cy.title().should("include", "Your Store");
     });
     it("Should navigate to the Blog page", function () {
       cy.visit("https://ecommerce-playground.lambdatest.io/");

       cy.contains("Blog").click({ force: true });

       cy.url().should("include", "/blog/");
     });
    });
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;When we run the above test case using the command npx cypress **run –record –key xxxxxx-xxx-xxxx0-xx-xxxxx. **The test case starts running in Cypress cloud.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fw7mlwdqg9mnm9l3d6wcw.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fw7mlwdqg9mnm9l3d6wcw.png" width="800" height="302"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In the below screenshot, we can see the test case running in 1 machine.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F651cpcrxehr0j3fm6if5.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F651cpcrxehr0j3fm6if5.png" width="800" height="214"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;To run the Cypress test case in parallel, we must connect the Cypress cloud with CI/CD. There are numerous CI/CD solutions supported by Cypress, and they are simple to connect with Cypress cloud. To run tests with GitHub Actions, you can refer to this blog on &lt;a href="https://www.lambdatest.com/blog/cypress-with-github-actions/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jan18_sd&amp;amp;utm_term=sd&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;how to run Cypress tests with GitHub Actions&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Cloud-based cross browser testing solutions like LambdaTest allow you to test your web application or website across a wide range of desktop and mobile browsers. One of the features of LambdaTest is the ability to perform parallel testing, which allows you to run multiple tests simultaneously, significantly reducing the time it takes to complete your testing.&lt;/p&gt;

&lt;p&gt;When using LambdaTest and Cypress together, you can use the LambdaTest platform to run your Cypress tests across a wide range of browsers and devices in parallel, reducing the time it takes to complete your testing. You can read through this blog to perform &lt;a href="https://www.lambdatest.com/cypress-parallel-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jan18_sd&amp;amp;utm_term=sd&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;Cypress testing with LambdaTest Cypress CLI&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In the next section of this blog on Playwright vs Selenium vs Cypress, we will learn about how to handle flakiness in test automation frameworks like Playwright, Selenium, and Cypress.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Check this out: The &lt;a href="https://www.lambdatest.com/free-online-tools/md2-hash-calculator?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jan18_sd&amp;amp;utm_term=sd&amp;amp;utm_content=free_tools" rel="noopener noreferrer"&gt;MD2 Hash Generator&lt;/a&gt; creates a unique string of characters that functions as a password or key.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Flakiness
&lt;/h2&gt;

&lt;p&gt;&lt;em&gt;​​A test is considered flaky when it can pass and fail across multiple retry attempts without any code changes.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;As one of the Google blogs says — &lt;em&gt;​​Almost 16% of our tests have some flakiness associated with them! This is a staggering number; more than 1 in 7 of the tests written by our world-class engineers occasionally fail in a way not caused by changes to the code or tests.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;In one of the research, it was found that 72 percent of test failures are false positives. Think about all the tests you have and all the test failures reported for each run. False positives consume a lot of resources that could be dedicated to much more valuable work.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fvligz6v89rr5amtlr8bq.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fvligz6v89rr5amtlr8bq.png" width="800" height="454"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Check this out: The free online &lt;a href="https://www.lambdatest.com/free-online-tools/lines-count?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jan18_sd&amp;amp;utm_term=sd&amp;amp;utm_content=free_tools" rel="noopener noreferrer"&gt;line counter&lt;/a&gt; tool is used to count the number of lines in a document or passage of text. It allows you to count lines with or without blanks.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Playwright:
&lt;/h3&gt;

&lt;p&gt;There are many ways to handle the flakiness in Playwright. Following are some best ways of handling the flakiness in Playwright.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Auto-wait feature&lt;/strong&gt;
In Auto-wait, we make sure when you perform an action, like clicking on the element, selecting a value, and entering the data on the text field, the element should be loaded before the action is performed.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Below is a code snippet with the assertion:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    test("Verify button enable or not", () =&amp;gt; {
       const submit = page.locator("button", {hasText: "Previous"});
       // Will check  button is enabled or not
       expect(await submit.isEnabled()).toBeTruthy()
       await submit.click();
    })
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In the above code, we don’t need the below line; you are just wasting testing time on a non-necessary assertion. The playwright has an auto-wait mechanism and automatically handles the assertion part.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;expect(await submit.isEnabled()).toBeTruthy()&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;   test("Verify button enable or not", () =&amp;gt; {
       const submit = page.locator("button", {hasText: "Previous"});
       // Will check  button is enabled or not
       await submit.click();
    })

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Use Methods like waitForLoadState waitForNavigation waitForSelector to avoid flakiness.&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;We can use these methods to avoid the flakiness. Using these methods, we can make sure the page is fully loaded before it interacts with the element on the page.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Method waitForLoadState is used to wait till a specific state of the page has been reached.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Method waitForNavigation is suggested when Before beginning navigation, clicking an element may cause asynchronous processing to take place.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Method waitForSelector used to hold off till the selector satisfies the state option (e.g either appear/disappear from the DOM, or become visible/hidden).&lt;br&gt;
&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    await page.waitForLoadState('domcontentloaded', { timeout: 1000 });
    await page.waitForLoadState('networkidle', { timeout: 5000 });
    await page.waitForLoadState('load', { timeout: 2000 });

    await Promise.all([
     page.waitForNavigation({ url: '**/login' }),
     page.click('button'), 
    ]);

    await page.waitForSelector('.myDiv')
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Another feature using which we can avoid flakiness is Retries.&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Sometimes when the page loads for the first time, the required element is not present, and test cases fail. We can avoid this situation by using the Retries option. We can provide the Retries option in the Playwright.config.js file so that when test cases fail, the system will retry again, and the probability of the test case passing is increased.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;   const config = {
       // Give failing tests 2 retry attempts
       retries: 2,
     }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Selenium:
&lt;/h3&gt;

&lt;p&gt;In Selenium, test cases can be flaky due to the flakiness in the test code or the flakiness in the &lt;a href="https://www.lambdatest.com/learning-hub/test-infrastructure?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jan18_sd&amp;amp;utm_term=sd&amp;amp;utm_content=learning_hub" rel="noopener noreferrer"&gt;test infrastructure&lt;/a&gt;. Flakiness on the infrastructure front can be avoided by moving test execution to a cloud platform like LambdaTest.&lt;/p&gt;

&lt;p&gt;A flaky test is a test that randomly passes or fails for the same code, giving inconsistent results. One time it passes; another time, it fails; and the next time, it passes without any change being made to the build.&lt;/p&gt;

&lt;p&gt;There are several ways to avoid flakiness in Selenium tests:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Use stable selectors:&lt;/strong&gt; Instead of using dynamic selectors such as XPath, try to use stable selectors such as class name or Id to locate elements. Dynamic selectors can be affected by changes in the structure of the HTML, leading to test flakiness.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Use explicit waits:&lt;/strong&gt; Instead of using implicit waits, use explicit waits to allow the page to load and stabilize before interacting with elements. This can help prevent tests from failing due to elements not being immediately available.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Add retry logic:&lt;/strong&gt; &lt;a href="https://www.lambdatest.com/learning-hub/iretryanalyzer-in-testng?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jan18_sd&amp;amp;utm_term=sd&amp;amp;utm_content=learning_hub" rel="noopener noreferrer"&gt;Implement retry logic&lt;/a&gt; in your tests to retry failed assertions a certain number of times before giving up. This can help reduce flakiness caused by temporary network or server issues.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Use a stable &lt;a href="https://www.lambdatest.com/blog/what-is-test-environment/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jan18_sd&amp;amp;utm_term=sd&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;testing environment&lt;/a&gt;:&lt;/strong&gt; Make sure your tests run in a stable environment with consistent network and server conditions.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Debug failing tests:&lt;/strong&gt; When tests fail, take the time to debug and understand the root cause of the failure. This can help you identify and fix underlying issues that are causing flakiness.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Use a test framework:&lt;/strong&gt; Use a test framework such as &lt;a href="https://www.lambdatest.com/blog/testng-vs-junit-which-testing-framework-should-you-choose/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jan18_sd&amp;amp;utm_term=sd&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;JUnit or TestNG&lt;/a&gt; to structure your tests and provide built-in support for handling test failures. This can make it easier to identify and debug failing tests.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Use a reliable testing framework:&lt;/strong&gt; Use a reliable testing framework, such as JUnit or TestNG, to manage the execution of tests and handle any issues that may arise.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Use a reliable continuous integration (CI) server:&lt;/strong&gt; Use a reliable CI server, such as Jenkins or Azure DevOps, to run tests automatically and track the results of test runs.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;One way to use a cloud platform like LambdaTest to &lt;strong&gt;avoid flakiness&lt;/strong&gt; in Selenium is to run your Selenium scripts on the cloud infrastructure instead of running them locally on your machine.&lt;/p&gt;

&lt;h3&gt;
  
  
  Cypress:
&lt;/h3&gt;

&lt;p&gt;Cypress handles flakiness very well. In Cypress, there are different ways of handling flakiness.&lt;/p&gt;

&lt;p&gt;Following are some best ways of handling the flakiness in Cypress.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Adding .contains('element') .should('be.visible'),.should('exist') before clicking on element.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Test Retires&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Use timeouts instead of waits.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Use cy.intercept() to wait for the XHR request to finish execution.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;The first and very straightway method to reduce the flakiness is by using .should('exist') .should('be.visible') .contains('element'). These assertions reduce the chance of test case failure.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The second method in Cypress to reduce the flakiness is to use Test Retires. You can set the Test Retires option at Global Configuration, Individual Test, or Test Suite level.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fbjkpj0a5uj03xehm6e4f.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fbjkpj0a5uj03xehm6e4f.png" width="800" height="381"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Another way to reduce the flakiness is to use timeouts instead of waits.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Sometimes, we have required a higher timeout for a particular element to load into the page​​. You can handle such cases by providing a timeout on a particular element instead of using cy.wait().&lt;/p&gt;

&lt;p&gt;The difference between cy.wait() and set the timeout at the field level is, in the case of cy.wait() Cypress will wait for the complete time that we have provided under cy.wait(), but in case of timeout, if the element load before the specified timeout, Cypress will move to the next command to execute. This way, sometimes timeout is effective as it saves time.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
    cy.get(“#first-name”, {timeout: 10000}).type(“Mike”)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;We can use cy.intercept() to wait for the XHR request to finish execution. We can intercept the particular network call and wait till the call is not finished.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;In the below screenshot, after clicking on the form model, we presume there is some unfinished request. cy.wait() wait for the request/response cycle to complete. By using the cy.wait("@getModel") we have access to the XHR object. Cypress will wait for the API call to end before moving forward as long as the request is not finished. So you can prevent test cases from failing in this manner.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fu8vgg8resijb3aigsd5t.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fu8vgg8resijb3aigsd5t.png" width="800" height="229"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Check this out: This online &lt;a href="https://www.lambdatest.com/free-online-tools/md5-hash-calculator?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jan18_sd&amp;amp;utm_term=sd&amp;amp;utm_content=free_tools" rel="noopener noreferrer"&gt;MD5 hash generator&lt;/a&gt; is a tool for encoding passwords, credit card numbers, and other sensitive data into MySQL, Postgress, and similar databases.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Screenshots
&lt;/h2&gt;

&lt;p&gt;Screenshots play a very important role when test cases fail regularly. The screenshot gives an idea about the steps where test cases fail and help you make the test case less flaky.&lt;/p&gt;

&lt;h3&gt;
  
  
  Playwright:
&lt;/h3&gt;

&lt;p&gt;While comparing Playwright vs Selenium vs Cypress, it is very easy to take screenshots in Playwright. There are three ways to take a screenshot.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;​​&lt;a href="https://www.lambdatest.com/automated-screenshot?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jan18_sd&amp;amp;utm_term=sd&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;Full page screenshots&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Capture into buffer&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Element screenshot&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Full page screenshots&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;To take Full page screenshots, we have to write the below code:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    await page.screenshot({ path: ‘screenshot.png’, fullPage: true });
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Capture into buffer&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Instead of writing into a file, you can get a buffer with the image and post-process it or pass it to a third-party pixel diff facility.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    const buffer = await page.screenshot();
    console.log(buffer.toString('base64'));
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Element screenshot&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;We can take the screenshot at the element level too, using the below code.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;   await page.locator(‘.header’).screenshot({ path: ‘screenshot.png’ });
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Selenium:
&lt;/h3&gt;

&lt;p&gt;A screenshot in Selenium WebDriver is helpful for bug investigation. In Selenium, if you want to take the screenshot during execution, you can use the &lt;strong&gt;TakesScreenshot&lt;/strong&gt; method, which informs the WebDriver to grab the screenshot.&lt;/p&gt;

&lt;p&gt;Code snippet to take the screenshot of the Page attached below.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    import org.apache.commons.io.FileUtils;
    import org.openqa.selenium.OutputType;
    import org.openqa.selenium.TakesScreenshot;
    import org.openqa.selenium.WebDriver;
    import org.openqa.selenium.chrome.ChromeDriver;
    import java.io.File;
    import java.io.IOException;

    public class ScreenshotCapture {
       public static void main(String[] args) {
           //set the location of chrome browser
           System.setProperty("webdriver.chrome.driver", "C:\\chromedriver.exe");
           // Initialize the browser
           WebDriver driver = new ChromeDriver();
           //navigate to the url
           driver.get("https://www.lambdatest.com/");
          //Take screenshot
           File screenshot = ((TakesScreenshot) driver).getScreenshotAs(OutputType.FILE);
           //Copy the file to a location
           try {
               FileUtils.copyFile(screenshot, new File("C:\\xxx\\xxx.png"));
           } catch (IOException e) {
               System.out.println(e.getMessage());
           }
           //closing the webdriver
           driver.close();
       }
    }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We can take screenshots of elements in Selenium. Code Snippet to take the screenshot of the element attached below.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;   import org.apache.commons.io.FileUtils;
    import org.openqa.selenium.*;
    import org.openqa.selenium.chrome.ChromeDriver;
    import java.io.File;
    import java.io.IOException;

    public class SeleniumelementTakeScreenshot {
     public static void main(String args[]) throws IOException {
       WebDriver driver = new ChromeDriver();
       driver.get("https://www.lambdatest.com/");
       WebElement element = driver.findElement(By.cssSelector("h1"));
       File scrFile = element.getScreenshotAs(OutputType.FILE);
       FileUtils.copyFile(scrFile, new File("./image.png"));
       driver.quit();
     }
    }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Cypress:
&lt;/h3&gt;

&lt;p&gt;Cypress has an in-built ability to take screenshots. You can run test cases via “cypress open” OR “cypress run”. You can use &lt;strong&gt;cy.screenshot()&lt;/strong&gt; if you want to take screenshots manually.&lt;/p&gt;

&lt;p&gt;Capturing screenshots when a test fails can be turned off completely by specifying &lt;strong&gt;screenshotOnRunFailure&lt;/strong&gt; to false from within the Cypress configuration or by specifying screenshotOnRunFailure to false in the Cypress.Screenshot.defaults().&lt;/p&gt;

&lt;p&gt;Below are different syntaxes to capture the screenshot in Cypress.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    cy.screenshot()
    cy.screenshot(fileName)
    cy.screenshot(options)
    cy.screenshot(fileName, options)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In the below Code snippet, you can see the screenshot saved by default under the screenshots folder when test cases are failing.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    // cypress/e2e/login.cy.js

    describe('Screenshot tests', () =&amp;gt; {
       it('takes a screenshot', () =&amp;gt; {
         // screenshot will be saved as
         // cypress/screenshots/login.cy.js/Screenshot tests -- takes a screenshot.png
         cy.screenshot()
       })
     })
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;By default, screenshot capture is true. However, you can disable it by the following setting under the &lt;strong&gt;support/index.js&lt;/strong&gt; file.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    Cypress.Screenshot.defaults({
     screenshotOnRunFailure: false,
    })
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;&lt;em&gt;Check this out: &lt;a href="https://www.lambdatest.com/free-online-tools/ripemd320-hash-calculator?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jan18_sd&amp;amp;utm_term=sd&amp;amp;utm_content=free_tools" rel="noopener noreferrer"&gt;RIPE MD 320 Hash Generator&lt;/a&gt; - The goal of using a cryptographic hash function, such as RIPEMD-320, is to take an input (or “message”) and generate a fixed-length string of characters, known as the “hash value,” that is unique to the input. This can be used for many things, including digital signatures, message authentication, and data integrity.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Video
&lt;/h2&gt;

&lt;p&gt;Video features help in finding the bug and make debugging easy when there is the failure of the test case. Since we can watch what happens when a series of test steps are running, it becomes very easy to track down the exact step when some test case fails. Here we are comparing Playwright vs Selenium vs Cypress to see how we can take videos using these frameworks.&lt;/p&gt;

&lt;h3&gt;
  
  
  Playwright:
&lt;/h3&gt;

&lt;p&gt;In the Playwright video of test cases handled by the “video” option in the config file. By default videos are off.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    // @ts-check
    /** @type {import('@playwright/test').PlaywrightTestConfig} */
    const config = {
     use: {
       video: 'on-first-retry',
     },
    };
    module.exports = config;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In option video, we can pass the below parameter&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;“&lt;strong&gt;off&lt;/strong&gt;” — Do not record video.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;“&lt;strong&gt;on&lt;/strong&gt;” — Record video for each test.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;“&lt;strong&gt;retain-on-failure&lt;/strong&gt;” — Record video for each test, but remove all videos from successful test runs.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;“&lt;strong&gt;on-first-retry&lt;/strong&gt;” — Record video only when retrying a test for the first time.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Selenium:
&lt;/h3&gt;

&lt;p&gt;Selenium WebDriver does not have any built-in mechanism to record videos of the test cases that are executed. In Selenium, to capture the video, we have extensions available. Using these extensions, we can record the test case execution steps, and when some of the test cases fail to record, it is helpful to know the exact reason for test step failure.&lt;/p&gt;

&lt;h3&gt;
  
  
  Cypress:
&lt;/h3&gt;

&lt;p&gt;Cypress records the video automatically of every .spec file. When we run the command &lt;strong&gt;cypress run&lt;/strong&gt; video of each .spec file is recorded. Videos are saved automatically under the folder &lt;strong&gt;cypress/videos&lt;/strong&gt;. We can turn off the video entirely by making the flag video: **false **in the configuration file.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F0s2g36736uu3t6svuk6p.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F0s2g36736uu3t6svuk6p.png" width="490" height="776"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Run your Playwright automation scripts across 3000+ environments. &lt;a href="https://accounts.lambdatest.com/register?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jan18_sd&amp;amp;utm_term=sd&amp;amp;utm_content=register" rel="noopener noreferrer"&gt;Try LambdaTest Now!&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Check this out: A &lt;a href="https://www.lambdatest.com/free-online-tools/sentence-count?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jan18_sd&amp;amp;utm_term=sd&amp;amp;utm_content=free_tools" rel="noopener noreferrer"&gt;sentence Counter&lt;/a&gt; is a tool to determine how many sentences make up a given article or document.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  iFrame
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://www.lambdatest.com/blog/handling-frames-and-iframes-in-selenium-javascript/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jan18_sd&amp;amp;utm_term=sd&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;iFrame&lt;/a&gt; is an HTML element that embeds another document within the current HTML document. Using iFrames, you can add content from another website to a web page. It allows you to engage users by supplementing your content, including sharing and embedding YouTube videos and external photos.&lt;/p&gt;

&lt;p&gt;Below is the syntax for iFrame:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    &amp;lt;iframe id="parent_iframe" name="demo_parent_iframe" width="700" height="450" src="https://bit.ly/38erOdQ"&amp;gt; 
    &amp;lt;/iframe&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Below screenshot is the example of Nested iFrame where we have Parent and Child both iFrame. The screenshot below shows the “Click Here” button in the Parent and Child iFrame.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fgbcbvrra3m1dkvzttowv.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fgbcbvrra3m1dkvzttowv.png" width="800" height="306"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fke4epf6lhrx8dzaygt7f.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fke4epf6lhrx8dzaygt7f.png" width="800" height="289"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Playwright:
&lt;/h3&gt;

&lt;p&gt;When testing iFrames in Playwright, we can use the method &lt;strong&gt;FrameLocator&lt;/strong&gt;, which allows us to retrieve the iFrame and locate elements inside that iFrame. FrameLocator captures the logic sufficient to retrieve the iFrame and locate elements in that iFrame.&lt;/p&gt;

&lt;p&gt;Let’s take a simple example:&lt;br&gt;
Let us now launch​​ &lt;a href="https://the-internet.herokuapp.com/iframe%E2%80%8B%E2%80%8B" rel="noopener noreferrer"&gt;https://the-internet.herokuapp.com/iframe​​&lt;/a&gt;. We have to enter the data in the text area, which is under the iFrame.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fpfbenokuam0fb92pumv7.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fpfbenokuam0fb92pumv7.png" width="800" height="301"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Inspect the text area of this frame.​​ Notice below that it is represented by the tag ‘iframe’ having the ‘id’ mentioned below.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fcw9gr6proe8pqqiwqxia.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fcw9gr6proe8pqqiwqxia.png" width="800" height="190"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F30bx7taxxiyz0iiscwzy.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F30bx7taxxiyz0iiscwzy.png" width="800" height="540"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We have a method called “frameLocator” in the Playwright, as seen below. Using this method, we can identify the above frame that we have inspected​​.&lt;/p&gt;

&lt;p&gt;Here we are using the &lt;a href="https://www.lambdatest.com/blog/how-pro-testers-use-css-selectors-in-selenium-automation-scripts/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jan18_sd&amp;amp;utm_term=sd&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;CSS Selector&lt;/a&gt; to identify the frame&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    ​​const​​ frame1​​ =​​ page.frameLocator(‘#mce_0_ifr’).locator(‘html’)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Once we have located the frame, we have to click it before we start typing into it​​. Code snippet attached below&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    import​​ {test,expect}​​ from​​ '@playwright/test'

    test("frames",​​ async​​ ({​​ page​​ })​​ =&amp;gt;​​ {
      ​​await​​ page.goto('https://the-internet.herokuapp.com/iframe')
      ​​const​​ frame1 =​​ page.frameLocator('#mce_0_ifr').locator('html')
      ​​ await​​ frame1.click()   
      ​​await​​ frame1.type('Welcome to playwright')
      ​​ await​​ page.pause()   
    })
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Selenium:
&lt;/h3&gt;

&lt;p&gt;Selenium is capable of working with iFrames in a simple way. In the case of Selenium, we have to move to the iFrame window and do all activities that you want to do. Once all actions are done, then move back to the main page of the application to do further actions.&lt;/p&gt;

&lt;p&gt;By default, Selenium has access to the parent browser driver. The driver focus must change from the main browser window to the frame to access a frame element.&lt;/p&gt;

&lt;p&gt;There are various ways to switch to frames.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;switchTo().frame(id)&lt;/strong&gt; — The frame’s id or name is passed as input to the switchTo() method.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;switchTo().frame(i)&lt;/strong&gt; — The index of the frame is passed as an argument. The index starts from zero.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;switchTo().frame(webelement n)&lt;/strong&gt; — The webelement of the frame is passed as an argument.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;switchTo().defaultContent()&lt;/strong&gt; — Switching focus from the frame to the main page.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Let’s take a simple example:&lt;/p&gt;

&lt;p&gt;Launch​​ &lt;a href="https://the-internet.herokuapp.com/iframe%E2%80%8B%E2%80%8B" rel="noopener noreferrer"&gt;https://the-internet.herokuapp.com/iframe​​&lt;/a&gt;. We have to copy the text located under the left bottom iFrame.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fd26qk1gh05vjcljq70zl.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fd26qk1gh05vjcljq70zl.png" width="800" height="392"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Code snippet is attached below.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    import org.openqa.selenium.By;
    import org.openqa.selenium.WebDriver;
    import org.openqa.selenium.WebElement;
    import org.openqa.selenium.chrome.ChromeDriver;
    import java.util.concurrent.TimeUnit;
    public class iFrameTest{
      public static void main(String[] args) {
         System.setProperty("webdriver.chrome.driver", "C:\Users\kailashpathak\Desktop\Java\chromedriver.exe");
         WebDriver driver = new ChromeDriver();
         driver.get("https://the-internet.herokuapp.com/frames");
         driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
         // Click in Nested link
         driver.findElement(By.partialLinkText("Nested")).click();
         // In below line we are switching to the frame in left bottom side
         driver.switchTo().frame("frame-bottom");
         WebElement text = driver.findElement(By.cssSelector("body"));
         System.out.println("Frame text: " +text.getText());
         driver.close();
      }
    }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Cypress:
&lt;/h3&gt;

&lt;p&gt;Cypress does not handle iFrame directly; we need to install the plugin and use the plugin to perform actions on elements inside the iframe. We can install the plugin and then use the custom commands.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  npm install -D cypress-iframe
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Notice below that it is represented by the tag ‘iframe’ having the ‘class’ mentioned below.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fg9g60q8u02et5yqqezsw.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fg9g60q8u02et5yqqezsw.png" width="800" height="403"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The below code works with elements inside an iFrame.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    import 'cypress-iframe'
    describe('ifrane example', function () {
      // test case
      it('iframe Test cases', function (){
         // launch the URL
         cy.visit("https://jqueryui.com/draggable/");
         // frame is loading in below line
         cy.frameLoaded('.demo-frame');
         //shifting the focus
         cy.iframe().find("#draggable").then(function(t){
            const frmtxt = t.text()
            //assertion to verify text
            expect(frmtxt).to.contains('Drag me around');
            cy.log(frmtxt);
         })
      });
    });
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;&lt;em&gt;Check this out: &lt;a href="https://www.lambdatest.com/free-online-tools/sha384-hash-calculator?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jan18_sd&amp;amp;utm_term=sd&amp;amp;utm_content=free_tools" rel="noopener noreferrer"&gt;SHA384 hash generator&lt;/a&gt; generates a SHA384 hash (SHA384 encoded) containing 96 hexadecimal digits. This can be used as a secure password or as a key to protecting essential data, such as personal information, money transactions, and much more.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Handling API Requests
&lt;/h2&gt;

&lt;p&gt;Testing doesn’t mean to do verification of elements in UI only, but we also have to verify data that is bound with these elements from the API side as well.&lt;/p&gt;

&lt;p&gt;API (Application Programming Interface) is the middle layer between the presentation and the database layer. APIs play a very important role in communication between one software application to another. Because of this reason, testing of API’s has become very important nowadays. Here we are comparing Playwright vs Selenium vs Cypress to see how we can do API testing using these frameworks.&lt;/p&gt;

&lt;h3&gt;
  
  
  Playwright:
&lt;/h3&gt;

&lt;p&gt;Playwright can be used to get access to the REST API of your application. Below are examples of how we can automate the API request using the methods (GET, POST, PUT, and DELETE)&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;GET Method&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;   // @ts-check
    const { test, expect } = require("@playwright/test");
    test.describe("API Testing with Playwright", () =&amp;gt; {
     const baseurl = "https://reqres.in/api";

     test("GET API Request with -- Valid 200 Response ", async ({ request }) =&amp;gt; {
       const response = await request.get(`${baseurl}/users/2`);
       expect(response.status()).toBe(200);
     });
    });
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;POST Method&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;   // @ts-check
    const { test, expect } = require("@playwright/test");
    test.describe("API Testing with Playwright", () =&amp;gt; {
     const baseurl = "https://reqres.in/api";
     test("POST API Request with -- Valid 201 Response ", async ({ request }) =&amp;gt; {
       const response = await request.post(`${baseurl}/users/2`, {
         data: {
           id: 123,
         },
       });
       const responseBody = JSON.parse(await response.text());
       expect(responseBody.id).toBe(123);
       expect(response.status()).toBe(201);
     });
    });
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;PUT Method&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    // @ts-check
    const { test, expect } = require("@playwright/test");
    test.describe("API Testing with Playwright", () =&amp;gt; {
     const baseurl = "https://reqres.in/api";
     test("PUT API Request with -- Valid 201 Response ", async ({ request }) =&amp;gt; {
       const response = await request.put(`${baseurl}/users/2`, {
         data: {
           id: 245,
         },
       });
       const responseBody = JSON.parse(await response.text());
       expect(responseBody.id).toBe(245);
       expect(response.status()).toBe(200);
     });
    });
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;DELETE Method&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    // @ts-check
    const { test, expect } = require("@playwright/test");
    test.describe("API Testing with Playwright", () =&amp;gt; {
     const baseurl = "https://reqres.in/api";
     test("DELETE API Request with -- Valid 201 Response ", async ({
       request,
     }) =&amp;gt; {
       const response = await request.delete(`${baseurl}/users/2`, {});
       expect(response.status()).toBe(204);
     });
    });
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Selenium:
&lt;/h3&gt;

&lt;p&gt;Selenium is primarily a browser automation tool and is not designed for &lt;a href="https://www.lambdatest.com/blog/everything-you-need-to-know-about-api-testing/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jan18_sd&amp;amp;utm_term=sd&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;API testing&lt;/a&gt;. It allows you to interact with web browsers and automate user interactions on a website or web application. But, Selenium can’t be used to directly test the functionality of an API, as it doesn’t provide any functionality to send HTTP requests and assert on the API’s response.&lt;/p&gt;

&lt;p&gt;However, LambdaTest can be used to perform &lt;a href="https://www.lambdatest.com/support/api-doc/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jan18_sd&amp;amp;utm_term=sd&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;API automation using Selenium&lt;/a&gt;. LambdaTest is a cloud-based platform that provides a Selenium Grid that allows you to perform &lt;a href="https://www.lambdatest.com/selenium-automation?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jan18_sd&amp;amp;utm_term=sd&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;Selenium automation testing&lt;/a&gt; on various browsers, operating systems, and devices.&lt;/p&gt;

&lt;p&gt;One way to use Selenium to test an API using LambdaTest is by launching a browser on LambdaTest’s Selenium grid, navigating to the API endpoint URL, and then using Selenium to interact with the API by sending HTTP requests and asserting on the response. This is similar to how you would test a website or web application.&lt;/p&gt;

&lt;h3&gt;
  
  
  Cypress:
&lt;/h3&gt;

&lt;p&gt;Using Cypress, we can do API automation. To make a Cypress API call, Cypress has provided the command cy.request(). GET, POST, PUT, and DELETE are some methods that are part of the API (Application Programming Interface) testing, which can be performed by Cypress.&lt;/p&gt;

&lt;p&gt;Below are the example of different methods:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;GET Method&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;To perform a GET operation, we shall make an HTTP request with the cy.request() and pass two parameters in cy.request() Method name and URL.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    it("GET API testing Using Cypress", () =&amp;gt; {
     cy.request("GET", "https://reqres.in/api/users?page=2").should((response) =&amp;gt; {
       expect(response.status).to.eq(200);
     });
    });
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;POST Method&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;To perform a POST operation, we shall make an HTTP request with the cy.request() and pass three parameters in cy.request() Method name and URL and body.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;   it("POST API testing Using Cypress", () =&amp;gt; {
     cy.request("POST", "https://reqres.in/api/users", {
       name: "morpheus",
       job: "leader",
     }).should((response) =&amp;gt; {
       expect(response.status).to.eq(201);
     });
    });
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;PUT Method&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;To perform a PUT operation, we shall make an HTTP request with the cy.request() and pass three parameters in cy.request() Method name and URL and body.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    it("PUT API testing Using Cypress", () =&amp;gt; {
     cy.request("PUT", "https://reqres.in/api/users/2", {
       name: "morpheus",
       job: "zion resident",
     }).should((response) =&amp;gt; {
       expect(response.status).to.eq(200);
     });
    });
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;DELETE Method&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;To perform a DELETE operation, we shall make an HTTP request with the cy.request() and pass two parameters in cy.request() Method name and URL.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;   it("DELETE API testing Using Cypress", () =&amp;gt; {
     cy.request("DELETE", "https://reqres.in/api/users/2").should((response) =&amp;gt; {
       expect(response.status).to.eq(204);
     });
    });
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;&lt;em&gt;Check this out: &lt;a href="https://www.lambdatest.com/free-online-tools/sha256-hash-calculator?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jan18_sd&amp;amp;utm_term=sd&amp;amp;utm_content=free_tools" rel="noopener noreferrer"&gt;SHA256 hash function generator&lt;/a&gt; generates a SHA256 hash (SHA256 encoded) containing 64 hexadecimal digits. This can be used as a secure password or as a key to protecting essential data, such as personal information, money transactions, and much more.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Community support
&lt;/h2&gt;

&lt;p&gt;Selenium is an open-source suite of tools for automated &lt;a href="https://www.lambdatest.com/learning-hub/web-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jan18_sd&amp;amp;utm_term=sd&amp;amp;utm_content=learning_hub" rel="noopener noreferrer"&gt;web testing&lt;/a&gt;, and it has a large and active community of users and developers. There are several ways that community members can get support and help with Selenium. Here we are comparing Playwright vs Selenium vs Cypress to see their community support.&lt;/p&gt;

&lt;h3&gt;
  
  
  Playwright:
&lt;/h3&gt;

&lt;p&gt;Playwright is a new player in the market and has a smaller but growing set of community resources. There are numerous resources available to help users get started with Playwright and troubleshoot any issues they may encounter. The Playwright team has great documentation and an active presence on GitHub, where users can submit bug reports and feature requests, and contribute to the development of the tool. The team is also responsive to questions and feedback from the community.&lt;/p&gt;

&lt;p&gt;In addition to the official channels, there are a number of community-run forums and resources where users can get help with Playwright. These include Stack Overflow, Reddit, and the Playwright Gitter chat.&lt;/p&gt;

&lt;h3&gt;
  
  
  Selenium:
&lt;/h3&gt;

&lt;p&gt;There are several ways that community members can get support and help with Selenium:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Selenium documentation:&lt;/strong&gt; It is a comprehensive resource that covers all aspects of using Selenium. It includes tutorials, a reference guide, and information on installing and configuring Selenium.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Selenium forums: The Selenium forums are a good place to ask questions and get help with Selenium. There are separate forums for different programming languages, as well as a general discussion forum.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Selenium Slack channel: The Selenium Slack channel is an active community of Selenium users and developers who are available to answer questions and provide support. To join the Selenium Slack channel, you will need to request an invite by filling out a form on the Selenium website.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Stack Overflow: Stack Overflow is a popular question-and-answer website for programmers, and it has a large number of questions and answers related to Selenium. You can search for answers to your questions or ask a new question and get help from the community.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Cypress:
&lt;/h3&gt;

&lt;p&gt;Cypress has a growing Community, and their documentation is excellent. In addition, there are numerous unofficial forums and communities where Cypress users can connect and share their experiences with the tool.&lt;/p&gt;

&lt;p&gt;In addition to online forums, the Cypress community also provides support through various resources and documentation. The Cypress website features detailed documentation on installing and using the tool, a comprehensive API reference, and a library of example projects. There are also many blog posts, tutorials, and video resources available online that guide on using Cypress for various testing tasks.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Check this out: An &lt;a href="https://www.lambdatest.com/free-online-tools/sha1-hash-calculator?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jan18_sd&amp;amp;utm_term=sd&amp;amp;utm_content=free_tools" rel="noopener noreferrer"&gt;SHA-1 Hash calculator&lt;/a&gt; is a tool that creates a 160-bit (20-byte) hash value for a specified input, generally referred to as a “message” or “data.”&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Comparison Table: Playwright vs Selenium vs Cypress
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
    &lt;tr&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;PLAYWRIGHT&lt;/td&gt;
        &lt;td&gt;SELENIUM&lt;/td&gt;
        &lt;td&gt;CYPRESS &lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
        &lt;td&gt;Language Support&lt;/td&gt;
        &lt;td&gt;JavaScript Java, C#, Python, Ruby&lt;/td&gt;
        &lt;td&gt;JavaScript Java, C#, Python, Ruby&lt;/td&gt;
        &lt;td&gt;JavaScript/TypeScript &lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
        &lt;td&gt;Browser Support&lt;/td&gt;
        &lt;td&gt;Chrome, Edge, Firefox, Safari&lt;/td&gt;
        &lt;td&gt;Chrome, Edge, Firefox, Safari&lt;/td&gt;
        &lt;td&gt;Chrome, Edge, Firefox, Safari &lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
        &lt;td&gt;Framework Support&lt;/td&gt;
        &lt;td&gt;Jest/Jasmine, AVA, Mocha, and Vitest&lt;/td&gt;
        &lt;td&gt;Mocha, Jest/Jasmine,, TestNG, JUnit, Cucumber and NUnit&lt;/td&gt;
        &lt;td&gt;Supports Mocha, Jest/Jasmine, Cucumber &lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
        &lt;td&gt;Continuous Integration&lt;/td&gt;
        &lt;td&gt;Can be easily integrated with continuous integration tools like Jenkins&lt;/td&gt;
        &lt;td&gt;Can be easily integrated with continuous integration tools like Jenkins&lt;/td&gt;
        &lt;td&gt;Can be easily integrated with continuous integration tools like Jenkins &lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
        &lt;td&gt;Ease of use&lt;/td&gt;
        &lt;td&gt;Playwright has a user-friendly interface and requires minimal setup&lt;/td&gt;
        &lt;td&gt;Selenium requires more setup and has a steeper learning curve&lt;/td&gt;
        &lt;td&gt;Cypress has a user-friendly interface and requires minimal setup &lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
        &lt;td&gt;Test Writing Experience&lt;/td&gt;
        &lt;td&gt;Intuitive&lt;/td&gt;
        &lt;td&gt;Moderate&lt;/td&gt;
        &lt;td&gt;Intuitive &lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
        &lt;td&gt;DOM manipulation&lt;/td&gt;
        &lt;td&gt;Easy&lt;/td&gt;
        &lt;td&gt;Moderate&lt;/td&gt;
        &lt;td&gt;Easy &lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
        &lt;td&gt;Community Support&lt;/td&gt;
        &lt;td&gt;Growing community&lt;/td&gt;
        &lt;td&gt;Large and active community with good documentation and support resources&lt;/td&gt;
        &lt;td&gt;Active community with good documentation and support resources &lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
        &lt;td&gt;Support for headless mode&lt;/td&gt;
        &lt;td&gt;YES&lt;/td&gt;
        &lt;td&gt;YES&lt;/td&gt;
        &lt;td&gt;YES &lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
        &lt;td&gt;Parallel Execution&lt;/td&gt;
        &lt;td&gt;Supports parallel execution&lt;/td&gt;
        &lt;td&gt;Supports parallel execution&lt;/td&gt;
        &lt;td&gt;Supports parallel execution using CI/CD tool &lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
        &lt;td&gt;Built-in network traffic control&lt;/td&gt;
        &lt;td&gt;YES&lt;/td&gt;
        &lt;td&gt;NO&lt;/td&gt;
        &lt;td&gt;YES &lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
        &lt;td&gt;Setup complexity&lt;/td&gt;
        &lt;td&gt;Easy Setup&lt;/td&gt;
        &lt;td&gt;Requires some effort to build the framework&lt;/td&gt;
        &lt;td&gt;Easy Setup &lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
        &lt;td&gt;Iframe Support&lt;/td&gt;
        &lt;td&gt;YES&lt;/td&gt;
        &lt;td&gt;YES&lt;/td&gt;
        &lt;td&gt;Iframe support through plugin e.g. cypress-iframe &lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
        &lt;td&gt;Driver&lt;/td&gt;
        &lt;td&gt;No driver required&lt;/td&gt;
        &lt;td&gt;Each browser requires its driver&lt;/td&gt;
        &lt;td&gt;No need of driver bindings &lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
        &lt;td&gt;Multi Tab Support&lt;/td&gt;
        &lt;td&gt;YES&lt;/td&gt;
        &lt;td&gt;NO&lt;/td&gt;
        &lt;td&gt;YES &lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
        &lt;td&gt;Drag &amp;amp; Drop Support&lt;/td&gt;
        &lt;td&gt;YES&lt;/td&gt;
        &lt;td&gt;YES&lt;/td&gt;
        &lt;td&gt;YES &lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
        &lt;td&gt;Test Assertions Libraries&lt;/td&gt;
        &lt;td&gt;Mocha, Chai&lt;/td&gt;
        &lt;td&gt;PyUnit, JUnit, TestNG almost any language-specific test framework can be adapted.&lt;/td&gt;
        &lt;td&gt;Mocha, Chai &lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
        &lt;td&gt;Inbuilt reports&lt;/td&gt;
        &lt;td&gt;YES&lt;/td&gt;
        &lt;td&gt;NO&lt;/td&gt;
        &lt;td&gt;Default Reporter is Spec, Customizable for other supported reporters &lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
        &lt;td&gt;Cross-Domain Support&lt;/td&gt;
        &lt;td&gt;YES&lt;/td&gt;
        &lt;td&gt;YES&lt;/td&gt;
        &lt;td&gt;YES &lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
        &lt;td&gt;Debug features&lt;/td&gt;
        &lt;td&gt;Playwright has built-in debugging tools and a time-traveling feature for easy debugging&lt;/td&gt;
        &lt;td&gt;Selenium does not have built-in debugging tools&lt;/td&gt;
        &lt;td&gt;Cypress has built-in debugging tools and a time-traveling feature for easy debugging &lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
        &lt;td&gt;Automatic Waiting&lt;/td&gt;
        &lt;td&gt;YES&lt;/td&gt;
        &lt;td&gt;NO&lt;/td&gt;
        &lt;td&gt;YES &lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
        &lt;td&gt;Dashboard&lt;/td&gt;
        &lt;td&gt;NO&lt;/td&gt;
        &lt;td&gt;NO&lt;/td&gt;
        &lt;td&gt;Provided as Premium/Paid Feature &lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
        &lt;td&gt;Community Support&lt;/td&gt;
        &lt;td&gt;Good&lt;/td&gt;
        &lt;td&gt;Very Good as the user base is more.&lt;/td&gt;
        &lt;td&gt;Good &lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
        &lt;td&gt;Built-in Screenshot, VIDEO feature&lt;/td&gt;
        &lt;td&gt;YES&lt;/td&gt;
        &lt;td&gt;No built-in screenshot feature. Customization is required to add this feature.&lt;/td&gt;
        &lt;td&gt;YES &lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
        &lt;td&gt;Pricing&lt;/td&gt;
        &lt;td&gt;Free for open-source projects, paid for commercial use&lt;/td&gt;
        &lt;td&gt;Free for all use cases&lt;/td&gt;
        &lt;td&gt;Free for open-source projects, paid for commercial use &lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
    &lt;/tr&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F6op7kh9t95wewbm49h4t.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F6op7kh9t95wewbm49h4t.jpg" width="800" height="154"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Obtain certifications in &lt;a href="https://www.lambdatest.com/automation-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jan18_sd&amp;amp;utm_term=sd&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;test automation&lt;/a&gt; frameworks like Playwright, Selenium, and Cypress that enhance your resume and increase your chances of obtaining a highly sought-after position. Obtain this certification as tangible proof of your expertise in test automation on LambdaTest’s cloud infrastructure, displaying mastery of advanced knowledge and skills.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Check this out: The &lt;a href="https://www.lambdatest.com/free-online-tools/sha512-hash-calculator?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jan18_sd&amp;amp;utm_term=sd&amp;amp;utm_content=free_tools" rel="noopener noreferrer"&gt;SHA512 Hash Calculator&lt;/a&gt; lets you generate the SHA512 hash of any string.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Wrapping up
&lt;/h2&gt;

&lt;p&gt;In this blog on Playwright vs Selenium vs Cypress, we have learned how tools like Playwright, Selenium, and Cypress are designed to automate web browsers for testing. While they each have distinct architectures, user bases, and objectives, it is up to testing teams to decide which tool is the most appropriate for their project and skill set. With the varying features and capabilities when comparing Playwright vs Selenium vs Cypress, it is essential to carefully consider the needs of the project and the team’s strengths before making a decision.&lt;/p&gt;

</description>
      <category>community</category>
      <category>beginners</category>
    </item>
    <item>
      <title>How To Run Cypress Tests In Azure DevOps Pipeline</title>
      <dc:creator>Kailash Pathak</dc:creator>
      <pubDate>Wed, 28 Dec 2022 14:58:08 +0000</pubDate>
      <link>https://dev.to/testmuai/how-to-run-cypress-tests-in-azure-devops-pipeline-1k5g</link>
      <guid>https://dev.to/testmuai/how-to-run-cypress-tests-in-azure-devops-pipeline-1k5g</guid>
      <description>&lt;p&gt;When software developers took years to create and introduce new products to the market is long gone. Users (or consumers) today are more eager to use their favorite applications with the latest bells and whistles. However, users today don’t have the patience to work around bugs, errors, and design flaws. People have less self-control, and if your product or application doesn’t make life easier for users, they’ll leave for a better solution.&lt;/p&gt;

&lt;p&gt;Before the advent of &lt;a href="https://www.lambdatest.com/blog/getting-started-with-devops/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=dec29_sd&amp;amp;utm_term=sd&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;DevOps&lt;/a&gt;, software companies used the conventional &lt;a href="https://www.lambdatest.com/blog/agile-vs-waterfall-methodology/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=dec29_sd&amp;amp;utm_term=sd&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;Waterfall model&lt;/a&gt;, which was effective for many projects like CRM and inventory management. However, it had several shortcomings. DevOps completely overpowered the traditional waterfall model.&lt;/p&gt;

&lt;p&gt;Development teams in product organizations are constantly releasing updates, patches, bug fixes, and new features. Before rolling out the updates to all end users, operations teams have their hands full to ensure the new code functions properly. Users dislike downtime and additional errors, which can occur if the rollout process isn’t managed effectively.&lt;/p&gt;

&lt;p&gt;In DevOps, code is reviewed and deployed much more quickly due to the collaboration between the development and operations teams. As a result, suggestions for new features and bug fixes based on user data get continuously incorporated into the development cycle. The journey each new piece of code takes, from planning to deployment to monitoring, is known as the DevOps pipeline. Every software development company needs a strong DevOps pipeline to meet customer demands and specifications.&lt;/p&gt;

&lt;p&gt;Azure, AWS, GCP, Oracle Cloud Services, and many other cloud service providers have integrations with several open-source and enterprise &lt;a href="https://www.lambdatest.com/blog/automation-testing-tools/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=dec29_sd&amp;amp;utm_term=sd&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;automated testing tools&lt;/a&gt;. Cypress is the most commonly used framework that has integrations with all major cloud platforms. There are also testing platforms like LambdaTest, a cloud SaaS platform for &lt;a href="https://www.lambdatest.com/support/docs/vsts-integration/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=dec29_sd&amp;amp;utm_term=sd&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;Cypress testing&lt;/a&gt; that we can integrate with &lt;a href="https://www.lambdatest.com/support/docs/vsts-integration/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=dec29_sd&amp;amp;utm_term=sd&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;Azure DevOps&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Cypress Trends on GitHub&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;As per the Cypress GitHub repository, Cypress continues to gain popularity with:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Stars: 39.5k&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Forks: 2.5k&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Used By: 599k&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Releases: 282&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Contributors: 400&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This &lt;a href="https://www.lambdatest.com/learning-hub/cypress-tutorial?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=dec29_sd&amp;amp;utm_term=sd&amp;amp;utm_content=learning_hub" rel="noopener noreferrer"&gt;Cypress tutorial&lt;/a&gt; on how to run Cypress tests in Azure DevOps aims at getting people started with running &lt;a href="https://www.lambdatest.com/automation-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=dec29_sd&amp;amp;utm_term=sd&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;automation testing&lt;/a&gt; on Microsoft’s Azure. We will deep dive into the essentials of Azure DevOps along with &lt;a href="https://www.lambdatest.com/blog/cypress-test-automation-framework/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=dec29_sd&amp;amp;utm_term=sd&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;running Cypress automated tests&lt;/a&gt; with &lt;a href="https://www.lambdatest.com/support/docs/integrate-azure-pipelines-with-lambdatest/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=dec29_sd&amp;amp;utm_term=sd&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;Azure Pipeline&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/jX3v3N6oN5M"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;To make this tutorial more interesting, I have broken it down into different parts. First, I will explain DevOps, the Components/Stages of DevOps then how we Can Set Up Cypress and run Cypress tests in Azure DevOps pipeline. Finally, integrate Azure pipelines with LambdaTest and run Cypress test cases.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Check this out: &lt;a href="https://www.lambdatest.com/selenium?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=dec29_sd&amp;amp;utm_term=sd&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;Selenium&lt;/a&gt; Tutorial: A Complete Guide on Selenium Automation Testing&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  What is DevOps Pipeline?
&lt;/h2&gt;

&lt;p&gt;DevOps is a software development methodology that connects the Development and Operations sides of an application. It bridges the gap between developers and maintainers by introducing collective responsibility practices. Traditionally, there was a barrier between these teams, and software packages were metaphorically pushed past the wall. But with DevOps processes, that barrier no longer exists.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2400%2F0%2AjSETt-lHbMRdS8vw.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2400%2F0%2AjSETt-lHbMRdS8vw.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;A &lt;strong&gt;pipeline&lt;/strong&gt; in software development consists of a set of tools, flows, and automated processes that enable the team to leverage technologies to build and deploy the application/software.&lt;/p&gt;

&lt;p&gt;The process of building, testing, and deploying code is known as continuous integration &amp;amp; continuous deployment, or CI/CD. Automating this process can minimize human error and maintain a consistent process for how software is released.&lt;/p&gt;

&lt;p&gt;You can develop, test, and continuously deploy new code by creating an effective &lt;strong&gt;DevOps pipeline&lt;/strong&gt;. Building an efficient DevOps pipeline enables organizations to develop, test, and continuously deploy new code rapidly.&lt;/p&gt;

&lt;p&gt;One of the main goals of a DevOps pipeline is to automate the software delivery process, thus eliminating the need for manual changes at every step of the pipeline.&lt;/p&gt;

&lt;p&gt;Manual work is time-consuming and risks human error, which often delays deployments. Switching from manual to automated changes results in fewer errors and allows developers to release higher-quality code faster than ever.&lt;/p&gt;

&lt;p&gt;LambdaTest lets you integrate and run Cypress tests in Azure DevOps Pipelines using an extension that connects the CI server to LambdaTest’s cloud Cypress Grid.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2000%2F0%2AGJsvdJUSdMiFdabK.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2000%2F0%2AGJsvdJUSdMiFdabK.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Components of a DevOps Pipeline
&lt;/h2&gt;

&lt;p&gt;In order to run Cypress tests in Azure DevOps Pipeline, let’s discuss the components of a DevOps pipeline.&lt;/p&gt;

&lt;p&gt;There are several different approaches and tools that organizations normally use to create a customized DevOps pipeline. Common pipeline components enable continuous delivery by ensuring that code flows smoothly from one stage to the next, automating the entire process and reducing manual work.&lt;/p&gt;

&lt;p&gt;A well-constructed pipeline comprises tools that automate processes and permit continuous iteration. Which are:&lt;/p&gt;

&lt;h2&gt;
  
  
  Continuous Integration
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://www.lambdatest.com/blog/what-is-continuous-integration-and-continuous-delivery/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=dec29_sd&amp;amp;utm_term=sd&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;Continuous Integration (CI)&lt;/a&gt; means multiple integrations every day. In the past, when the team didn’t have the continuous integration concept, we had to wait for a long time to reflect the actual code into production. Since code is integrated very late, the chance of code conflict is increased due to this delay.&lt;/p&gt;

&lt;p&gt;Contrary to the previous methodology, CI encourages developers to submit their code regularly. As a result, they can identify bugs more quickly and spend less time fixing them.&lt;/p&gt;

&lt;p&gt;Continuous Integration (CI) is a development practice requiring developers and quality assurance personnel to commit code changes to a shared repository (e.g., GIT repository) several times a day. When we push the code, the CI tool pulls the code from the shared repository and makes the build.&lt;/p&gt;

&lt;p&gt;The CI tool builds the code in addition to performing other background tasks like code review, &lt;a href="https://www.lambdatest.com/learning-hub/system-integration-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=dec29_sd&amp;amp;utm_term=sd&amp;amp;utm_content=learning_hub" rel="noopener noreferrer"&gt;integration testing&lt;/a&gt;, and running unit test cases. CI has some best practices in modern DevOps — which detects and notifies developers what has happened. GitHub users can implement CI through GitHub Actions. Azure DevOps users can use Azure Pipelines.&lt;/p&gt;

&lt;h2&gt;
  
  
  Continuous Delivery
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://www.lambdatest.com/blog/what-is-continuous-integration-and-continuous-delivery/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=dec29_sd&amp;amp;utm_term=sd&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;Continuous Delivery (CD)&lt;/a&gt; is nothing more than the evolution /or next step of CI. It is about speeding up the release process by encouraging developers to release code for &lt;a href="https://www.lambdatest.com/learning-hub/user-acceptance-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=dec29_sd&amp;amp;utm_term=sd&amp;amp;utm_content=learning_hub" rel="noopener noreferrer"&gt;user acceptance testing&lt;/a&gt; in the test environment. Once the build is successful, the code is deployed to the test server for user acceptance or end-user testing.&lt;/p&gt;

&lt;p&gt;Continuous Delivery (CD) has great advantages. Let’s look at some of the benefits offered by CD. Before CD, developers used to take much longer to locate the issue if there was an error in the build. With CD in place, it became easy to track which particular commit is causing the failure.&lt;/p&gt;

&lt;p&gt;The more frequently you can deploy code updates, the better off you’ll be able to use continuous deployment. The workflow determines the release frequency, typically daily, weekly, or monthly. Compared to releasing all changes at once, releasing code in smaller chunks makes it simpler to fix bugs. By doing this, bottlenecks and merge conflicts are prevented, and the integration pipeline continues to flow steadily and continuously.&lt;/p&gt;

&lt;h2&gt;
  
  
  Continuous Deployment
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Continuous Deployment&lt;/strong&gt; is the next step in automating the software development lifecycle after continuous delivery. Continuous Delivery and Continuous Deployment are similar in many ways, yet there are subtle differences. In continuous delivery, code is periodically committed to the staging branch for user acceptance testing. While continuous deployment allows development teams to deploy software, features, and code updates manually, continuous deployment is about automating the entire release cycle.&lt;/p&gt;

&lt;p&gt;In the continuous deployment phase, code updates are automatically released to the targeted users without manual intervention. If something goes wrong, you can roll back the changes without causing the application to stop working. To fully realize the potential of continuous deployment, robust &lt;a href="https://www.lambdatest.com/blog/best-test-automation-frameworks-2021/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=dec29_sd&amp;amp;utm_term=sd&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;automation testing frameworks&lt;/a&gt; like &lt;a href="https://www.lambdatest.com/selenium?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=dec29_sd&amp;amp;utm_term=sd&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;Selenium&lt;/a&gt;, Cypress, etc., must be in place to ensure that the new code is truly bug-free and can be deployed to production without delays.&lt;/p&gt;

&lt;h2&gt;
  
  
  Continuous Testing
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://www.lambdatest.com/learning-hub/continuous-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=dec29_sd&amp;amp;utm_term=sd&amp;amp;utm_content=learning_hub?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=dec29_sd&amp;amp;utm_term=sd&amp;amp;utm_content=learning_hub" rel="noopener noreferrer"&gt;Continuous testing&lt;/a&gt; is another part of the DevOps pipeline. Using continuous testing, you can run automated tests for the code integrations gathered during the continuous integration phase. To find problems before they affect the production environment, continuous testing involves running tests as frequently as possible at each stage of the development process. Rapid evaluation of the business risks associated with particular release candidates in the delivery pipeline is made possible by implementing a &lt;a href="https://www.lambdatest.com/blog/continuous-testing-strategy/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=dec29_sd&amp;amp;utm_term=sd&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;continuous testing strategy&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Functional and &lt;a href="https://www.lambdatest.com/learning-hub/non-functional-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=dec29_sd&amp;amp;utm_term=sd&amp;amp;utm_content=learning_hub" rel="noopener noreferrer"&gt;non-functional testing&lt;/a&gt; should both be included in the testing scope. This entails carrying out the unit, system, and integration tests as well as tests that focus on an application’s security and performance along with the server infrastructure.&lt;/p&gt;

&lt;p&gt;Continuous testing encompasses a broader understanding of quality control, including risk assessment and internal policy compliance. Some types of testing that can be automated include &lt;a href="https://www.lambdatest.com/blog/cypress-end-to-end-testing/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=dec29_sd&amp;amp;utm_term=sd&amp;amp;utm_content=blog?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=dec29_sd&amp;amp;utm_term=sd&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;end-to-end testing&lt;/a&gt;, &lt;a href="https://www.lambdatest.com/blog/regression-testing-what-is-and-how-to-do-it/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=dec29_sd&amp;amp;utm_term=sd&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;regression testing&lt;/a&gt;, functional tests, integration tests, and performance tests that run automatically as soon as the code is integrated.&lt;/p&gt;

&lt;p&gt;Every DevOps cloud platform has some stages. Below are some stages that DevOps pipelines normally have.&lt;/p&gt;

&lt;p&gt;Run End-to-End Cypress tests on the cloud grid. &lt;a href="https://accounts.lambdatest.com/register?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=dec29_sd&amp;amp;utm_term=sd&amp;amp;utm_content=register" rel="noopener noreferrer"&gt;Try LambdaTest Now!&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Check this out: 30 Top &lt;a href="https://www.lambdatest.com/blog/automation-testing-tools/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=dec29_sd&amp;amp;utm_term=sd&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;tools for Automation Testing&lt;/a&gt; In 2022&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Stages of a DevOps Pipeline
&lt;/h2&gt;

&lt;p&gt;There are no strict guidelines for how you should structure the pipeline. DevOps teams add or remove certain phases depending on their specific workflows. Almost all pipelines consist of four core phases: Development, Build, Test, and Deploy.&lt;/p&gt;

&lt;p&gt;You can extend the setup by adding two more stages — &lt;strong&gt;&lt;em&gt;plan&lt;/em&gt;&lt;/strong&gt; and &lt;strong&gt;&lt;em&gt;monitor&lt;/em&gt;&lt;/strong&gt; — as they are also ubiquitous in professional DevOps environments.&lt;/p&gt;

&lt;h2&gt;
  
  
  Plan
&lt;/h2&gt;

&lt;p&gt;Planning your project, technology, environment, structure, and architecture creates a roadmap for successfully achieving your project goals. In the planning phase, the entire workflow is planned before developers start coding. Product managers and project managers are crucial during this stage. It is their responsibility to develop a development roadmap that will serve as a guide for the entire team.&lt;/p&gt;

&lt;p&gt;The work is further broken down into a list of tasks after gathering feedback and relevant information from stakeholders and users. Teams can produce results more quickly, address issues immediately, and adjust to unforeseen changes more readily by breaking the project into smaller, more manageable pieces. In a DevOps environment, teams work in sprints — a shorter time (usually two weeks) during which individual team members work on their assigned tasks.&lt;/p&gt;

&lt;h2&gt;
  
  
  Develop
&lt;/h2&gt;

&lt;p&gt;Development phase is when developers start writing code. Developers install the appropriate IDEs, code editors, and other technologies on their local computers depending on the programming language to achieve maximum productivity.&lt;/p&gt;

&lt;p&gt;Developers submit a pull request to the shared source repository when they are prepared to submit their code. Once the initial pull request has been approved, team members can manually review the recently submitted code and merge it with the branch.&lt;/p&gt;

&lt;h2&gt;
  
  
  Build
&lt;/h2&gt;

&lt;p&gt;A compilation process is used to extract the source code from the repository, link it to libraries, modules, and dependencies, and create an executable. A DevOps pipeline’s build phase is crucial because it enables developers to find code errors before they get into the pipeline, resulting in a major catastrophe.&lt;/p&gt;

&lt;p&gt;Newly written code is merged with the shared repository, and developers run a series of automated tests. The pull request typically starts an automated process that builds the code into an executable or deployable package. Some programming languages do not need to be compiled.&lt;/p&gt;

&lt;p&gt;For example, applications written in Java and C must be compiled to run, while PHP and Python do not. Build fails if there are issues with the code and the developer is informed of the issues. To ensure that only bug-free code gets into the pipeline, developers repeat this procedure each time they push code to the shared repository.&lt;/p&gt;

&lt;h2&gt;
  
  
  Test
&lt;/h2&gt;

&lt;p&gt;The testing stage begins after a successful build. Once ready, the build is then deployed to the &lt;a href="https://www.lambdatest.com/blog/what-is-test-environment/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=dec29_sd&amp;amp;utm_term=sd&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;test environment&lt;/a&gt; where you can perform several types of testing like user acceptance test, security test, integration testing, &lt;a href="https://www.lambdatest.com/blog/how-to-get-started-with-load-testing/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=dec29_sd&amp;amp;utm_term=sd&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;performance testing&lt;/a&gt;, end-to-end testing, and &lt;a href="https://www.lambdatest.com/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=dec29_sd&amp;amp;utm_term=sd&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;cross browser testing.&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Deploy
&lt;/h2&gt;

&lt;p&gt;When the build reaches the deployment stage, the software is ready to be moved to production. When only minor changes to the code are required, an automated deployment method is used. To see how the newly added code functions, the build is first deployed to a production-like environment if the application has been significantly reworked.&lt;/p&gt;

&lt;p&gt;Blue/green deployment is a common method of deployment for continuous delivery, where two environments are configured identically — one environment serves end users, while the other is ready for new code to deploy and undergo testing, such as performance testing, end to end testing, and cross browser testing&lt;/p&gt;

&lt;h2&gt;
  
  
  Monitor
&lt;/h2&gt;

&lt;p&gt;Operations teams put in a lot of effort to monitor infrastructure, systems continuously, and applications during this last stage of the DevOps pipeline to make sure everything is operating as it should. To find performance problems, they gather important data from logs, analytics, monitoring systems, and user feedback.&lt;/p&gt;

&lt;p&gt;The DevOps pipeline is more effective using the feedback gathered during the Monitor phase. After each release cycle, optimizing the pipeline is a good idea to eliminate any potential bottlenecks or other problems that might reduce productivity.&lt;/p&gt;

&lt;p&gt;Now we know what scenario we will cover in this blog on how to run Cypress tests in Azure DevOps. But before running our scenario, we need to set up and create Cypress code using the below-mentioned steps.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Check this out: Online Automation Testing Platform- Accelerate your release velocity with blazing fast &lt;a href="https://www.lambdatest.com/automation-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=dec29_sd&amp;amp;utm_term=sd&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;test automation cloud&lt;/a&gt;&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Demonstration: Setup Cypress tests in Azure DevOps pipeline
&lt;/h2&gt;

&lt;p&gt;To explain how we can set up the Azure pipeline for Cypress test cases, I will be testing a typical e-commerce site &lt;a href="https://ecommerce-playground.lambdatest.io/" rel="noopener noreferrer"&gt;https://ecommerce-playground.lambdatest.io/&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Project Setup
&lt;/h2&gt;

&lt;p&gt;You can follow the steps mentioned below to create a new Cypress project:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 1:&lt;/strong&gt; Create a folder and generate package.json.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Create a project by the name &lt;strong&gt;Cypress_Lambdatest&lt;/strong&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Create a &lt;strong&gt;package.json&lt;/strong&gt; file using the &lt;strong&gt;npm init&lt;/strong&gt; command in the terminal.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;**Step 2: **Install Cypress.&lt;/p&gt;

&lt;p&gt;Run this command in the newly created folder to install Cypress.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm install cypress —save-dev
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;OR&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;yarn add cypress --dev
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;​​This will install Cypress locally as a dev dependency for your project.&lt;/p&gt;

&lt;p&gt;Cypress version 9.2.0 is reflected once this is installed, as seen below. The most recent version of Cypress is 10.11.0&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;      {
       "name": "cypress_lambdatest",
       "version": "1.0.0",
       "description": "",
       "main": "index.js",
       "scripts": {
         "cy:report": "cypress run"
       },
       "author": "Kailash Pathak",
       "license": "ISC",
       "devDependencies": {
         "cypress": "^9.2.0"
       }
      }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Shown below is the default folder structure of Cypress. You can create test cases under the folder “integration”&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2000%2F0%2AhxJtLENuqUpmNt_c.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2000%2F0%2AhxJtLENuqUpmNt_c.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Under the integration folder named “cypress_lambdatest,” let’s create a new folder.&lt;/p&gt;

&lt;p&gt;Under the folder lambdatest, create the first spec with the name &lt;strong&gt;&lt;em&gt;login_searchproduct.spec.js.&lt;/em&gt;&lt;/strong&gt; Second spec with the name &lt;strong&gt;&lt;em&gt;ScrollAnd_ClickProduct.spec.js&lt;/em&gt;&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2000%2F0%2Aj1fbcKQpIiytd0Ln.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2000%2F0%2Aj1fbcKQpIiytd0Ln.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Implementation (Test Scenario — 1)
&lt;/h2&gt;

&lt;p&gt;To demonstrate the usage of Cypress, we will first demonstrate the following test scenario.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Test Scenario:&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Open the URL &lt;a href="https://ecommerce-playground.lambdatest.io/index.php?route=account/login" rel="noopener noreferrer"&gt;https://ecommerce-playground.lambdatest.io/index.php?route=account/login&lt;/a&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Enter your email address.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Enter the password.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Click on the Login button.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Search for the product “VAIO.”&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Verify the correct product is searched.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Logs out from the application.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Create a &lt;strong&gt;&lt;em&gt;login_searchproduct.spec.js&lt;/em&gt;&lt;/strong&gt; file with the script below. This covers login into the application and searching for the product. After the search, verify the correct product should be displayed.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    /// &amp;lt;reference types="cypress" /&amp;gt;
    it("Open the Url", () =&amp;gt; {
     cy.visit(
       "https://ecommerce-playground.lambdatest.io/index.php?route=account/login"
     );
    });
    it("Login into the application", () =&amp;gt; {
     cy.get('[id="input-email"]').type("lambdatest@yopmail.com");
     cy.get('[id="input-password"]').type("lambdatest");
     cy.get('[type="submit"]').eq(0).click();
    });
    it("Search the Product", () =&amp;gt; {
     cy.get('[name="search"]').eq(0).type("VAIO");
     cy.get('[type="submit"]').eq(0).click();
    });
    it("Verify Product after search ", () =&amp;gt; {
     cy.contains("Sony VAIO");
    });
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2000%2F0%2A8IccivnkKGZHJihR.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2000%2F0%2A8IccivnkKGZHJihR.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Code Walkthrough:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;In the above code snippet, we have opened the target URL using &lt;em&gt;cy.visit&lt;/em&gt;(), and Second, &lt;em&gt;it&lt;/em&gt;() block is used to log in to the application by entering email and password.&lt;/p&gt;

&lt;p&gt;In the third, &lt;strong&gt;&lt;em&gt;it()&lt;/em&gt;&lt;/strong&gt; block is used for searching for the product, and the last it() block is used for searching for the product.&lt;/p&gt;

&lt;p&gt;In the below screenshot, we can see how we can inspect the element. We have located element by &lt;strong&gt;&lt;em&gt;id&lt;/em&gt;&lt;/strong&gt; for the email field&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;   cy.get(‘[id=”input-email”]’).type(“lambdatest@yopmail.com”);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3200%2F0%2AgfLZZ_epf8LbI1SR.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3200%2F0%2AgfLZZ_epf8LbI1SR.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Check this out: Online &lt;a href="https://www.lambdatest.com/safari-browser-for-windows?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=dec29_sd&amp;amp;utm_term=sd&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;Safari For Windows&lt;/a&gt;. Say No To Safari VM! Perform Cross Browser Compatibility Testing On All Safari Browser Versions Across Real Browsers And Operating Systems.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Implementation (Test Scenario — 2)
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Test Scenario:&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Open the URL &lt;a href="https://ecommerce-playground.lambdatest.io/index.php?route=account/login" rel="noopener noreferrer"&gt;https://ecommerce-playground.lambdatest.io/index.php?route=account/login&lt;/a&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Enter your email address.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Enter the password.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Click on the Login button.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Now, Scroll to the bottom of the application.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Click on a particular product.&lt;br&gt;
&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    /// &amp;lt;reference types="cypress" /&amp;gt;
    it("Open the Url", () =&amp;gt; {
     cy.visit(
       "https://ecommerce-playground.lambdatest.io/index.php?route=account/login"
     );
    });
    it("Login into the application", () =&amp;gt; {
     cy.get('[id="input-email"]').type("lambdatest@yopmail.com");
     cy.get('[id="input-password"]').type("lambdatest");
     cy.get('[type="submit"]').eq(0).click();
    });
    it("Click on Lambdatest Logo", () =&amp;gt; {
     cy.get('[title="Poco Electro"]').click();
     cy.wait(5000);
    });
    it("Scroll to the bottom and Click on product 'Nikon D300' ", () =&amp;gt; {
     cy.get('[title="Nikon D300"]').eq(0).scrollIntoView().click();
    });
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Code Walkthrough:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;In the above code snippet, first, we open the e-commerce site URL using cy.visit(). Second, it() block is used for login into the application by entering your email and password.&lt;/p&gt;

&lt;p&gt;In the third, &lt;strong&gt;&lt;em&gt;it()&lt;/em&gt;&lt;/strong&gt; block, you will be redirected to the home page after clicking on LambdaTest Logo.&lt;/p&gt;

&lt;p&gt;And In the Final &lt;strong&gt;&lt;em&gt;it()&lt;/em&gt;&lt;/strong&gt; block, you will scroll to the bottom of the page and click on the particular product.&lt;/p&gt;

&lt;p&gt;The Cypress chain starts with &lt;strong&gt;cy.[command]&lt;/strong&gt;, where what is yielded by the command establishes what other commands can be called next (chained). &lt;em&gt;cy.get() *or *cy.contains()&lt;/em&gt; methods yield a DOM element. This allows further commands to be chained onto them (assuming they expect a DOM subject), like .click() or even cy.contains() again.&lt;/p&gt;

&lt;p&gt;In the below screenshot, we can see how we can inspect the element. We have located elements by &lt;strong&gt;type&lt;/strong&gt; for the Login button.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    cy.get(‘[type=”submit”]’).eq(0).click();
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3998%2F0%2Ar3c1YWnUYBZ_yyiL.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3998%2F0%2Ar3c1YWnUYBZ_yyiL.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Check this out: Online &lt;a href="https://www.lambdatest.com/web-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=dec29_sd&amp;amp;utm_term=sd&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;Web Testing&lt;/a&gt; Platform. Check your websites and web applications in all major browsers with LambdaTest.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  How to run Cypress tests in Azure DevOps pipeline?
&lt;/h2&gt;

&lt;p&gt;Traditionally in the &lt;a href="https://www.lambdatest.com/blog/software-testing-life-cycle/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=dec29_sd&amp;amp;utm_term=sd&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;software testing life cycle&lt;/a&gt;, once QA creates the test cases, the QA has to wait for the build to deploy in the appropriate environment to test the functionality and to give the final sign-off of the build because, at that time, there was no concept of auto-deployment of the code. However, now there are many cloud computing platforms. One of the most popular is the Azure pipeline for building the code and deployment at regular intervals as code is pushed.&lt;/p&gt;

&lt;p&gt;Azure Pipeline helps us to deploy code automatically in prod and test fastly. As the team pushes code within a few seconds pipeline is triggered automatically, and code deployment is started. Azure pipeline helps us ensure consistent and quality code readily available to users.&lt;/p&gt;

&lt;p&gt;We can use the Azure pipeline with Cypress for code deployment and execute the test cases.&lt;/p&gt;

&lt;p&gt;We have created a Cypress spec file for the scenario. The next step is to &lt;strong&gt;set up&lt;/strong&gt; the &lt;strong&gt;Azure pipeline&lt;/strong&gt; to execute our test cases using Cypress.&lt;/p&gt;

&lt;h2&gt;
  
  
  Pre-requisites
&lt;/h2&gt;

&lt;p&gt;Let’s look at the prerequisites to run Cypress tests in Azure DevOps Pipeline.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Cypress code has already been pushed into the GitHub repository.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Azure free account already created through URL.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;User is already logged into Azure DevOps.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Step 1: Create the pipeline.&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Click on Pipelines from the left navigation and then click on New pipeline.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2000%2F0%2Az6OESTvUY0ntfrc4.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2000%2F0%2Az6OESTvUY0ntfrc4.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;2- Click on New pipeline.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2000%2F0%2AlyIgBk7yw_Q4LcSL.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2000%2F0%2AlyIgBk7yw_Q4LcSL.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;3- After clicking on the New pipeline, the below page is open.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2400%2F0%2AXLgYv7hGQTOaftr2.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2400%2F0%2AXLgYv7hGQTOaftr2.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 2: Select Classic editor.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Click on &lt;strong&gt;Use the classic editor&lt;/strong&gt; to create a pipeline without YAML from the above screen. The classic editor walks you through using a wizard-like process that guides you as you create your build.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 3: Select the repository.&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Click on the GitHub icon to select the repository.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2400%2F0%2ALc-6yFAZszw5MrHR.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2400%2F0%2ALc-6yFAZszw5MrHR.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;2- Select the repository and branch name from the existing repository.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2400%2F0%2AM7gmAVhEVBTdMSUK.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2400%2F0%2AM7gmAVhEVBTdMSUK.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;3- Click on &lt;strong&gt;Continue&lt;/strong&gt;, the below page is open.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2400%2F0%2AWOW-HMbNb4rOdyXO.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2400%2F0%2AWOW-HMbNb4rOdyXO.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 4: Select Empty Job.&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Select the template as an Empty job.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2400%2F0%2AMB-IteCw_g0yaHlX.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2400%2F0%2AMB-IteCw_g0yaHlX.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;2- After clicking on “&lt;strong&gt;Empty job&lt;/strong&gt;” on the next screen, we can see under the &lt;strong&gt;Tasks **tab three options: **Pipeline, Get Source&lt;/strong&gt;, and &lt;strong&gt;Agent job&lt;/strong&gt;. By default, the pipeline is selected.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2400%2F0%2AVAmlcjvcOlEAzhrh.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2400%2F0%2AVAmlcjvcOlEAzhrh.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;On the right side:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Enter the &lt;strong&gt;Name **of the pipeline, e.g., **Cypress Lambdatest Project&lt;/strong&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;In the &lt;strong&gt;Agent pool&lt;/strong&gt;: Select ‘&lt;strong&gt;Azure Pipelines&lt;/strong&gt;’ from the drop-down.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;In the &lt;strong&gt;Agent Specification&lt;/strong&gt;: Select OS ‘window-latest’ (Test cases are run in this OS).&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3998%2F0%2AY8Toyl8ovFKdJpqd.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3998%2F0%2AY8Toyl8ovFKdJpqd.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 5: Configure Get Source under the Task tab.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Under &lt;strong&gt;Get sources&lt;/strong&gt;, make sure the correct repository and build are selected.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3998%2F0%2AQAMRM4TdlVAsdExh.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3998%2F0%2AQAMRM4TdlVAsdExh.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 6: Configure Agent Job under the Task tab.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;In the Agent Job section under the **Tasks **tab, enter the following information.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Enter the &lt;strong&gt;Display Name&lt;/strong&gt; of the pipeline, e.g., Cypress Lambdatest.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;In the &lt;strong&gt;Agent pool&lt;/strong&gt;: Select ‘Azure Pipelines’ from the drop-down.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;In the &lt;strong&gt;Agent Specification&lt;/strong&gt;: Select Agent ‘window-latest’ (test cases are run in this agent).&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3998%2F0%2AKx9VLZpC_4n5WVwt.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3998%2F0%2AKx9VLZpC_4n5WVwt.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 7: Add the npm package.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Now Click on the &lt;strong&gt;(+)&lt;/strong&gt; icon against the Project, search for “&lt;strong&gt;npm&lt;/strong&gt;” and click on the Add button.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2284%2F0%2AK9fqYM5KnH5TAC3J.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2284%2F0%2AK9fqYM5KnH5TAC3J.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3998%2F0%2AgCGyfdl2VYSp06Zf.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3998%2F0%2AgCGyfdl2VYSp06Zf.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3998%2F0%2AJUT-cCsBbDdW264V.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3998%2F0%2AJUT-cCsBbDdW264V.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;After adding “&lt;strong&gt;npm&lt;/strong&gt;,” from the left side, click on npm install (See below screenshot). Enter/Select the below data (on the right side) to install the Cypress and other dependencies.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Enter the Display name, e.g., &lt;strong&gt;npm install&lt;/strong&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;In the Command: Enter &lt;strong&gt;‘install’&lt;/strong&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;In the Control Options: Select &lt;strong&gt;Check Box&lt;/strong&gt; ‘Enabled’ and Check Box ‘Continue on error’.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3200%2F0%2AbVPn13qN5mUZzXDr.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3200%2F0%2AbVPn13qN5mUZzXDr.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 8: Add npm package to Run Cypress Tests in Azure DevOps Pipeline.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Now Click on the (+) icon, search for “&lt;strong&gt;npm&lt;/strong&gt;” again, and click on the Add button.&lt;br&gt;
Click on npm install from the left side (See below screenshot). On the Right side, enter /select the below data to install Cypress and other dependencies.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Enter the Display name, e.g., &lt;strong&gt;Run Cypress Lambdatest&lt;/strong&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;In the Command: Enter ‘custom’.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;In the Command and arguments: Enter run &lt;strong&gt;cy:report&lt;/strong&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Step 9: Click Save &amp;amp; queue.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Now Click on ‘Save &amp;amp; queue’.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3200%2F0%2A1LXv5s0hguW0qNw6.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3200%2F0%2A1LXv5s0hguW0qNw6.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;As the user clicks on Save &amp;amp; queue, this will open a dialogue box as below. Select the agent pool, agent, and the branch from which Azure DevOps needs to execute the build&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2000%2F0%2AYZYiQZ9ETe4IWRdr.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2000%2F0%2AYZYiQZ9ETe4IWRdr.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 10: Click Save and run.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;As we click on Save and run, the Job starts executing.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;In the first step, the job is initialized.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2400%2F0%2AGmPqsx1BRSrB3Bbp.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2400%2F0%2AGmPqsx1BRSrB3Bbp.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;2- In the second step, code is pulled from the repository. In this case, the code pulls from .github.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2400%2F0%2AQXrEFF24fCZTFNDB.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2400%2F0%2AQXrEFF24fCZTFNDB.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;3- In the third step, the npm command runs to install the package.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2400%2F0%2AowqWO8yib7EzDyPs.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2400%2F0%2AowqWO8yib7EzDyPs.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;4- In the fourth step, the Cypress test case starts executing. In the below screenshot, we can see using the command &lt;strong&gt;cy:report&lt;/strong&gt; &lt;em&gt;(Which we have given in package.json)&lt;/em&gt; test case starts executing.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2400%2F0%2AkJL67cHLyadgXbZS.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2400%2F0%2AkJL67cHLyadgXbZS.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;5- In the fifth and sixth steps, we have to purge the repository, and the job is finished.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2400%2F0%2AqBI1Ta5SMlVXdrUR.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2400%2F0%2AqBI1Ta5SMlVXdrUR.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Check this out: Accelerate Delivery With &lt;a href="https://www.lambdatest.com/mobile-app-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=dec29_sd&amp;amp;utm_term=sd&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;Mobile App Test&lt;/a&gt; Cloud- Test your native mobile applications using LambdaTest’s online real device cloud and virtual testing platform of emulators and simulators.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  How to run Cypress tests in Azure DevOps pipeline on cloud Cypress Grid?
&lt;/h2&gt;

&lt;p&gt;Azure Pipelines is a CI server that automates the build and deploys process of your native web apps. There is an easy way to integrate LambdaTest to run Cypress tests in Azure DevOps pipelines.&lt;/p&gt;

&lt;p&gt;LambdaTest is a cloud-based &lt;a href="https://www.lambdatest.com/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=dec29_sd&amp;amp;utm_term=sd&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;cross browser testing&lt;/a&gt; platform that lets you test your website on an &lt;a href="https://www.lambdatest.com/online-browser-farm?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=dec29_sd&amp;amp;utm_term=sd&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;online browser farm&lt;/a&gt; of 3,000+ browsers, operating systems, and device emulators. It can be used to perform manual &lt;a href="https://www.lambdatest.com/web-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=dec29_sd&amp;amp;utm_term=sd&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;web testing&lt;/a&gt; and automated browser testing.&lt;/p&gt;

&lt;p&gt;Using &lt;a href="https://www.lambdatest.com/cypress-automation-tool?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=dec29_sd&amp;amp;utm_term=sd&amp;amp;utm_content=webpage?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=dec29_sd&amp;amp;utm_term=sd&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;Cypress automation tools&lt;/a&gt; like LambdaTest, you can execute &amp;amp; analyze Cypress test scripts online as a part of the build process. It enables continuous testing, build, and deployment of iterative code changes. &lt;a href="https://www.lambdatest.com/blog/best-ci-cd-tools/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=dec29_sd&amp;amp;utm_term=sd&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;Best CI/CD tools&lt;/a&gt; help in catching failures ahead of the production stage and mitigate them as they occur. Perform &lt;a href="https://www.lambdatest.com/cypress-ui-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=dec29_sd&amp;amp;utm_term=sd&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;Cypress UI testing&lt;/a&gt; on 40+ browsers and browser versions, including headless ones.&lt;/p&gt;

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/SBY669U14Oo"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Check this out: &lt;a href="https://www.lambdatest.com/selenium-automation?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=dec29_sd&amp;amp;utm_term=sd&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;Selenium Testing&lt;/a&gt; Automation Cloud- Test on Selenium Grid Cloud of 3000+ Desktop &amp;amp; Mobile Browsers.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;You can also Subscribe to the &lt;a href="https://www.youtube.com/channel/UCCymWVaTozpEng_ep0mdUyw?sub_confirmation=1" rel="noopener noreferrer"&gt;LambdaTest YouTube Channel&lt;/a&gt; and stay updated with the latest tutorials around &lt;a href="https://medium.com/r?url=https%3A%2F%2Fwww.lambdatest.com%2Fautomated-browser-testing%3Futm_source%3Dmedium%26utm_medium%3Dorganic%26utm_campaign%3Ddec29_sd%26utm_term%3Dsd%26utm_content%3Dwebpage" rel="noopener noreferrer"&gt;automated browser testing&lt;/a&gt;, &lt;a href="https://www.lambdatest.com/selenium-automation?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=dec29_sd&amp;amp;utm_term=sd&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;Selenium testing&lt;/a&gt;, CI/CD, and more.&lt;/p&gt;

&lt;p&gt;To simplify, we have ported the test scenarios mentioned in the earlier section of this blog on how to run Cypress tests in Azure DevOps pipeline so that tests run parallel on LambdaTest Cypress Grid.&lt;/p&gt;

&lt;p&gt;Cut test execution time with Cypress Parallel testing. &lt;a href="https://accounts.lambdatest.com/register?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=dec29_sd&amp;amp;utm_term=sd&amp;amp;utm_content=register" rel="noopener noreferrer"&gt;Try LambdaTest Now!&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Before &lt;a href="https://www.lambdatest.com/blog/getting-started-with-cypress/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=dec29_sd&amp;amp;utm_term=sd&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;getting started with Cypress&lt;/a&gt; and integrating the Azure pipeline with LambdaTest, we should have the information below information:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;An Azure CI account.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;A Git or GitHub repository.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;LambdaTest Authentication Credentials that can be accessed from the &lt;a href="https://accounts.lambdatest.com/login?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=dec29_sd&amp;amp;utm_term=sd&amp;amp;utm_content=login" rel="noopener noreferrer"&gt;LambdaTest profile&lt;/a&gt; page.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;There are &lt;strong&gt;steps&lt;/strong&gt; to integrate Azure pipelines with LambdaTest and run Cypress tests in Azure DevOps pipeline, as explained below.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 1: Create a project.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The first step is to create the project. Click on “New project” and fill in the required field.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2370%2F0%2ApLolxbLtizha8zLL.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2370%2F0%2ApLolxbLtizha8zLL.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 2: Create the pipeline.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Once the project is created the next step is to create the pipeline by clicking on Create Pipeline.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3200%2F0%2AXfskFXS81Xq8rOZt.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3200%2F0%2AXfskFXS81Xq8rOZt.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 3: Select GitHub.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;If you have your code repository in GitHub, then select the option for GitHub from the values.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3144%2F0%2AkoKqzMYrRxU8pgXY.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3144%2F0%2AkoKqzMYrRxU8pgXY.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 4: Create a YAML file.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Once you choose an option for code repository, you will be asked to log in. Once you log in, you need to choose the specific repository. Here, the repository will pick the &lt;strong&gt;azure-pipelines.yml&lt;/strong&gt; file.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;FileName: azure-pipelines.yml&lt;/em&gt;&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    # Node.js
    # Build a general Node.js project with npm.
    # Add steps that analyze code, save build artifacts, deploy, and more:
    # https://docs.microsoft.com/azure/devops/pipelines/languages/javascript

    trigger:
     - master

    pool:
     vmImage: ubuntu-latest
    variables:
     LT_USERNAME: "&amp;lt;LT_USERNAME&amp;gt;"
     LT_ACCESS_KEY: "&amp;lt;LT_ACCESS_KEY&amp;gt;"

    steps:
     - task: NodeTool@0
       inputs:
         versionSpec: "10.x"
       displayName: "Install Node.js"

     - script: |
         npm install
         npm install -g lambdatest-cypress-cli
         npm run cy:report
       displayName: "npm install and Run Cypress test case in lambdatest cloud"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Yaml file explanation:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;&lt;em&gt;trigger&lt;/em&gt;&lt;/strong&gt;: Under trigger, You can specify the full name of the branch (for example, master).&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;&lt;em&gt;pool&lt;/em&gt;&lt;/strong&gt;: Under the pool, we can mention the name of the agent where we want to run your test case.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;&lt;em&gt;variable&lt;/em&gt;&lt;/strong&gt;: Under variable, you can add LambdaTest credential.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;&lt;em&gt;steps&lt;/em&gt;&lt;/strong&gt;: Under steps, you can add various tasks here. We added a task to install the node with the specific version.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;&lt;em&gt;script&lt;/em&gt;&lt;/strong&gt;: Under the script, you can mention the package you want to install using npm and run the test cases using npm.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;File: lambdatest-config.json:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;In the lambdatest-config file, we can provide the credential, run_setting, and browser with the version in which we want to run our test cases.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;   {
     "lambdatest_auth": {
       "username": "&amp;lt;username&amp;gt;",
       "access_key": "&amp;lt;access_key&amp;gt;"
     },
     "browsers": [
       {
         "browser": "Chrome",
         "platform": "Windows 10",
         "versions": ["latest"]
       },
       {
         "browser": "Chrome",
         "platform": "Windows 10",
         "versions": ["latest-1"]
       },
       {
         "browser": "Firefox",
         "platform": "Windows 10",
         "versions": ["latest"]
       },
       {
         "browser": "Firefox",
         "platform": "Windows 10",
         "versions": ["latest-1"]
       }
     ],
     "run_settings": {
       "cypress_config_file": "cypress.json",
       "build_name": "build-name",
       "parallels": 4,
       "specs": "./cypress/integration/lambdatest/*.spec.js",
       "ignore_files": "",
       "feature_file_suppport": false,
       "network": false,
       "headless": false,
       "reporter_config_file": "",
       "npm_dependencies": {
         "cypress": "9.2.0"
       }
     },
     "tunnel_settings": {
       "tunnel": false,
       "tunnel_name": null
     }
    }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Step 5: Run Test cases.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;We are using Cypress version 9.2.0 for testing our scenarios. At the time of writing this blog on how to run Cypress tests in Azure DevOps pipeline, the latest version of Cypress was 10.11.0 when writing this blog.&lt;/p&gt;

&lt;p&gt;As the build in Azure Pipeline starts, the first step job is initialized.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3200%2F0%2A_zEDg8ePJgsT-aoj.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3200%2F0%2A_zEDg8ePJgsT-aoj.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In the second step, code is pulled from the repository. In this case, code pulled from .github.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3200%2F0%2AKxoVtqkzL37d9oOj.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3200%2F0%2AKxoVtqkzL37d9oOj.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In the third step, the node is installed.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3200%2F0%2AwFvjZRE4zh6_21q6.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3200%2F0%2AwFvjZRE4zh6_21q6.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In the fourth step, &lt;strong&gt;npm&lt;/strong&gt; install various packages, and finally, the cypress test cases start executing.&lt;/p&gt;

&lt;p&gt;In the screenshot below, we can see that the command &lt;strong&gt;cy:report&lt;/strong&gt; (&lt;em&gt;Which we have given in package.json&lt;/em&gt;) test case starts executing in the LambdaTest platform.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3200%2F0%2AoW8lfj0LEsEkOSNN.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3200%2F0%2AoW8lfj0LEsEkOSNN.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3200%2F0%2AX5QDmaigAwfyEnb0.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3200%2F0%2AX5QDmaigAwfyEnb0.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Execution:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;In the below screen, you can see test cases start running in &lt;strong&gt;*four browsers **parallelly (Browser details given above **in File: lambdatest-config.json&lt;/strong&gt;)*.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3200%2F0%2AGqQqkk8SNKEIsqVi.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3200%2F0%2AGqQqkk8SNKEIsqVi.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In the below screenshot, we can see the test cases are passed in Firefox and in Chrome browser, test cases are running.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3200%2F0%2Aj1hPUugYnUqTAlWa.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3200%2F0%2Aj1hPUugYnUqTAlWa.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In the below screenshot, we can see that both test cases are passed in different browsers.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3200%2F0%2AqIN4C6h2uzISHdgK.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3200%2F0%2AqIN4C6h2uzISHdgK.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Here are the logs that are generated when the test cases are run successfully.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3200%2F0%2AEUGKl4qfkeE2XZVn.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3200%2F0%2AEUGKl4qfkeE2XZVn.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3200%2F0%2AiErfG48ClWATY8wk.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3200%2F0%2AiErfG48ClWATY8wk.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In the below screenshot, we can see that VIDEO products are &lt;strong&gt;loading&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3200%2F0%2AXDXNsD9SllttrrCr.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3200%2F0%2AXDXNsD9SllttrrCr.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In the below screenshot, we can see after scrolling to the bottom product is clicked.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3200%2F0%2Anwm-5TEQ68vFvoJ7.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3200%2F0%2Anwm-5TEQ68vFvoJ7.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If you’re a developer or a tester, the Cypress 101 certification will help you understand the fundamentals of &lt;a href="https://www.lambdatest.com/cypress-e2e-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=dec29_sd&amp;amp;utm_term=sd&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;Cypress end to end testing&lt;/a&gt; and prepare you to write tests faster, with greater confidence and clarity.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2000%2F0%2ATF7BXBtw5V26RIo_.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2000%2F0%2ATF7BXBtw5V26RIo_.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Check this out: How To Use &lt;a href="https://www.lambdatest.com/blog/iphone-simulators-on-windows/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=dec29_sd&amp;amp;utm_term=sd&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;ios emulators for PC&lt;/a&gt;&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Wrapping Up
&lt;/h2&gt;

&lt;p&gt;I hope this gives you a great starting point for building your first Azure DevOps pipeline. You will understand how we can run &lt;a href="https://www.lambdatest.com/support/docs/running-your-first-cypress-test/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=dec29_sd&amp;amp;utm_term=sd&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;Cypress tests&lt;/a&gt; in Azure DevOps Pipelines on cloud-based platforms like LambdaTest.&lt;/p&gt;

</description>
      <category>devops</category>
      <category>tutorial</category>
      <category>testing</category>
      <category>test</category>
    </item>
    <item>
      <title>Cypress End to End Testing Tutorial: A Detailed Guide</title>
      <dc:creator>Kailash Pathak</dc:creator>
      <pubDate>Tue, 20 Dec 2022 12:01:17 +0000</pubDate>
      <link>https://dev.to/testmuai/cypress-end-to-end-testing-tutorial-a-detailed-guide-25m6</link>
      <guid>https://dev.to/testmuai/cypress-end-to-end-testing-tutorial-a-detailed-guide-25m6</guid>
      <description>&lt;p&gt;Software applications nowadays have become increasingly complex, and maximizing test coverage is one of the key aspects for every testing team. Testers globally rely upon different testing types using testing tools and frameworks. But there is an urgent need to test software systems (along with all their sub-systems) from beginning to end.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.lambdatest.com/blog/guide-to-end-to-end-testing-with-examples/#:~:text=End%20to%20end%20testing%20is,integrated%20with%20the%20external%20interface.?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=dec20_sd&amp;amp;utm_term=sd&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;End to End (E2E) testing&lt;/a&gt; permits testing teams to drive quality throughout the pipeline by replicating critical real-user scenarios. In addition, it enables teams to validate software systems and their sub-systems for data integrity. End to End testing isn’t easy.&lt;/p&gt;

&lt;p&gt;Cypress makes setting up, writing, running, and debugging tests easy. We usually neglect End to End testing because it requires a large part of the effort to implement. Performing End to End tests using the manual approach can be a tedious and error-prone task. With &lt;a href="https://www.lambdatest.com/cypress-visual-regression?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=dec20_sd&amp;amp;utm_term=sd&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;Cypress visual regression testing&lt;/a&gt;, you can verify the graphical component of a web application.&lt;/p&gt;

&lt;p&gt;Cypress is one of the options when it comes to End to End testing. With Cypress, you don’t need to install ten different things to set up your test suite. In minutes, you can start writing your test cases with the help of Cypress API. Cypress runs test cases inside the browser, which makes it different from other frameworks (e.g., Selenium). Cypress uses Chai, which is a popular assertion library. It also uses Mocha, a framework that provides the syntax for testing in a &lt;a href="https://www.lambdatest.com/blog/behaviour-driven-development-by-selenium-testing-with-gherkin/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=dec20_sd&amp;amp;utm_term=sd&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;Behavior-Driven Development (BDD)&lt;/a&gt; style.&lt;/p&gt;

&lt;p&gt;In this &lt;a href="https://www.lambdatest.com/learning-hub/cypress-tutorial?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=dec20_sd&amp;amp;utm_term=sd&amp;amp;utm_content=learning_hub" rel="noopener noreferrer"&gt;Cypress tutorial&lt;/a&gt; on End to End testing, we will deep dive into performing &lt;a href="https://www.lambdatest.com/cypress-e2e-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=dec20_sd&amp;amp;utm_term=sd&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;Cypress End to End testing&lt;/a&gt; on a local Cypress grid and over a cloud Cypress grid like LambdaTest.&lt;/p&gt;

&lt;p&gt;So, let’s get started!&lt;/p&gt;

&lt;h2&gt;
  
  
  Why End to End Testing?
&lt;/h2&gt;

&lt;p&gt;Most of the End to End application testing used to be performed manually, with a QA team understanding the requirements, making test cases, executing the test cases, and recording the results. In modern software development, automation has become the foundational part of testing.&lt;/p&gt;

&lt;p&gt;The software can and must be tested on many tiers. When you design a system, you begin with a small piece of software, for which unit testing is sufficient. However, testing software at the unit level isn’t enough, and it does not guarantee that these small units should work perfectly when combined.&lt;/p&gt;

&lt;p&gt;This is where &lt;strong&gt;integration testing&lt;/strong&gt; comes into the picture. In integration tests, two or more components are used together in a test, and the result is validated. Though all these tests run perfectly fine, integration testing can’t guarantee that the system will work as expected. This is where End to End testing comes into the picture.&lt;/p&gt;

&lt;p&gt;End to End testing is closest to real user testing. &lt;a href="https://www.lambdatest.com/learning-hub/cypress-tutorial?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=dec20_sd&amp;amp;utm_term=sd&amp;amp;utm_content=learning_hub" rel="noopener noreferrer"&gt;Cypress&lt;/a&gt; is one of the &lt;a href="https://www.lambdatest.com/blog/best-test-automation-frameworks-2021/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=dec20_sd&amp;amp;utm_term=sd&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;best automation testing frameworks&lt;/a&gt; for E2E testing because Cypress runs the application in the browser, thereby providing the experience as if the application is running inside the actual browser. The closer the test is to mimic the user, the more likely it will locate issues that the user(s) might experience.&lt;/p&gt;

&lt;p&gt;To understand End to End testing, let’s deep dive into the &lt;a href="https://www.lambdatest.com/blog/how-agile-teams-use-test-automation-pyramid/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=dec20_sd&amp;amp;utm_term=sd&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;test automation pyramid&lt;/a&gt; introduced by Mike Cohn. It makes testing efficient. All levels of testing mentioned in this pyramid we usually do when running automated &lt;a href="https://www.lambdatest.com/blog/getting-started-with-cypress/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=dec20_sd&amp;amp;utm_term=sd&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;Cypress testing&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;In automation, we start by automation of lower units; once they are ready, we write our integration automation scripts. Finally, once the integration test is done, we do End to End testing to ensure our script works correctly together, including third-party code.&lt;/p&gt;

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/jX3v3N6oN5M"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;h2&gt;
  
  
  Layers of the Testing Pyramid
&lt;/h2&gt;

&lt;p&gt;Test pyramid is an empirical concept formulated by Mike Cohn and was introduced in his book, ‘Agile Estimating and Planning’. The test suite is organized into three layers — Unit, Integration, and E2E testing. Let’s learn more about them.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2000%2F0%2A1-XKx95dODEQeovm.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2000%2F0%2A1-XKx95dODEQeovm.png" width="512" height="464"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Unit Tests&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Unit testing is a technique where individual modules are tested to determine whether they are suitable for use. The main aim of unit testing includes segregating each part of the system and ensuring that the individual components are working efficiently.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Integration Tests&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Integration testing specializes in the interaction between two or more components used together in a test, and the result is validated. They are generally slower to run because it involves a complex setup.&lt;/p&gt;

&lt;p&gt;Finding the problem could be a bit more complicated if integration tests fail because the failure range is greater. They’re also harder to code and maintain because they have more advanced mocking and increased testing scope. You can refer to this &lt;a href="https://www.lambdatest.com/blog/junit5-mockito-tutorial/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=dec20_sd&amp;amp;utm_term=sd&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;JUnit 5 Mockito tutorial&lt;/a&gt; to learn more about mocking.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;End to End Tests&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;End to End testing is a technique used to test whether the flow of an application right from start to end is behaving as expected.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2000%2F0%2AuaL20-G1KRrvg0J6.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2000%2F0%2AuaL20-G1KRrvg0J6.png" width="800" height="154"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Benefits of End to End Testing
&lt;/h2&gt;

&lt;p&gt;There are several benefits of End to End testing. When discussing the worth of End to End testing for a business, the benefits are often boiled down to some key points.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Testing from an end-user’s perspective&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In unit tests, you verify each component in isolation, and end to end testing examines the application from the perspective of the end-users.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Health of the application&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In End to End testing, the application is tested at all the layers — the business, data, integration, and presentation. This helps ensure the application being tested is free from bugs and works seamlessly across the lifecycle.&lt;/p&gt;

&lt;p&gt;Since End to End testing validates the health of your application at every level, it keeps the health and well-being of your application at all times. Testing applications at the unit level rather than at the integration level provides a much-needed perspective on software overall performance throughout different levels and environments.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Increased test coverage&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;End to End tests can verify that each one of an application’s dependencies works correctly together, including third-party code.&lt;/p&gt;

&lt;p&gt;End to End testing helps us to test the entire application, both at the API and UI layers, from start to finish. Using &lt;a href="https://www.lambdatest.com/automated-ui-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=dec20_sd&amp;amp;utm_term=sd&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;automated UI testing&lt;/a&gt; and &lt;a href="https://www.lambdatest.com/learning-hub/manual-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=dec20_sd&amp;amp;utm_term=sd&amp;amp;utm_content=learning_hub" rel="noopener noreferrer"&gt;manual testing&lt;/a&gt; practices aids in maximizing test coverage. You can learn more about it through this blog on &lt;a href="https://www.lambdatest.com/blog/starting-automation-testing-from-scratch-here-is-what-you-need-to-know/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=dec20_sd&amp;amp;utm_term=sd&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;how to move from manual testing to automation&lt;/a&gt;.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Decrease future risks&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In End to End testing, the application is tested in-depth after every sprint and iteration. This helps testers locate defects faster and earlier in the life cycle. The chances of application failure in the testing (or production) process are prominently decreased.&lt;/p&gt;

&lt;p&gt;Detection of bugs and issues sooner within the application development lifecycle minimizes testing efforts and costs. Extensive testing at every step ensures fewer bugs in the system and earlier identification of breakdowns in the software. This will reduce the repetition of tests and, therefore, ultimately, the associated effort, time, and costs.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Increases Confidence in product quality&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;End to End testing additionally increases the confidence in the functioning and performance of the application as the application is tested across multiple devices, browsers, and operating systems comprehensively.&lt;/p&gt;

&lt;h2&gt;
  
  
  End to End web application testing frameworks
&lt;/h2&gt;

&lt;p&gt;Let’s look at some of the popular web frameworks for End to End testing.&lt;/p&gt;

&lt;h2&gt;
  
  
  Cypress
&lt;/h2&gt;

&lt;p&gt;Cypress is a next-generation front-end testing framework built with modern JavaScript frameworks. Cypress comes with a bundle of test runners and a dashboard service that records and displays test results.&lt;/p&gt;

&lt;p&gt;Cypress is most often compared to Selenium; however, Cypress is both fundamentally and architecturally different. Cypress is not coercible by the same restrictions as Selenium. Cypress allows us to write several types of tests: end-to-end, integration, and even unit tests. You can learn more about the differences with this &lt;a href="https://www.lambdatest.com/blog/cypress-vs-selenium-comparison/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=dec20_sd&amp;amp;utm_term=sd&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;Cypress vs Selenium&lt;/a&gt; comparison.&lt;/p&gt;

&lt;p&gt;Cypress runs tests inside the browser, giving results almost identical to what the users would experience when using the application.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Cypress Trends on GitHub&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The data below is gathered from the official site of Cypress GitHub repository:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Stars: 39.5k&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Forks: 2.5k&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Used By: 490k&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Releases: 273&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Contributors: 368&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2000%2F0%2AT97VZf9hH8E9c4vx.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2000%2F0%2AT97VZf9hH8E9c4vx.png" width="800" height="154"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If you’re a developer or a tester, the Cypress 101 certification will prepare you to write tests faster and with greater confidence by giving you a clear understanding of the fundamentals of Cypress End to End testing.&lt;/p&gt;

&lt;h2&gt;
  
  
  WebdriverIO
&lt;/h2&gt;

&lt;p&gt;WebdriverIO is a progressive automation framework built to automate modern web and mobile applications.&lt;/p&gt;

&lt;p&gt;It simplifies the interaction with the app and provides a set of plugins that help you create a scalable, robust, and stable test suite.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;WebdriverIO Trends on GitHub&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The data below is gathered from the official site of WebdriverIO GitHub repository:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Stars: 7.6k&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Forks: 2.1k&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Used By: 43.1k&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Releases: 209&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Contributors: 424&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Nightwatch.js
&lt;/h2&gt;

&lt;p&gt;Nightwatch.js is an integrated, easy-to-use End to End testing solution for web applications and websites, written in Node.js. It uses the W3C WebDriver API to drive browsers and perform commands and assertions on DOM elements.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Nightwatch.js Trends on GitHub&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The data below is gathered from the official site of Nightwatch.js GitHub repository:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Stars: 11.1k&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Forks: 1.1k&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Used By: 135k&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Releases: 182&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Contributors: 94&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Protractor
&lt;/h2&gt;

&lt;p&gt;Protractor is an End to End test framework for Angular and AngularJS applications. Protractor runs tests against your application running in a real browser, interacting with it as a user would.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Protractor Trends on GitHub&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The data below is gathered from the official site of Protractor GitHub repository:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Stars: 8.8k&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Forks: 2.4k&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Used By: 1.8m&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Contributors: 260&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  TestCafe
&lt;/h2&gt;

&lt;p&gt;​​TestCafe framework is an open-source automation framework built with NodeJS. It supports JavaScript, TypeScript, and CoffeeScript out of the box, which means zero configuration is needed. TestCafe is distributed under an open-source MIT license and is managed by DevExpress.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;TestCafe Trends on GitHub&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The data below is gathered from the official site of TestCafe GitHub repository:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Stars: 9.4k&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Forks: 655&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Used By: 10.6k&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Releases: 351&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Contributors: 112&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Benefits of Cypress End to End Testing
&lt;/h2&gt;

&lt;p&gt;Before we look at the benefits of performing Cypress End to End testing, let’s look at a simple Cypress End to End testing scenario:&lt;/p&gt;

&lt;p&gt;Suppose you have to login into the application, and search for some product on the site &lt;a href="https://ecommerce-playground.lambdatest.io/" rel="noopener noreferrer"&gt;https://ecommerce-playground.lambdatest.io/ &lt;/a&gt;and then log out from the application. Here are the steps for the above scenario, which cover End to End flow from Log-in to → Product search → Logout.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Test Scenario&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Open the URL &lt;a href="https://ecommerce-playground.lambdatest.io/index.php?route=account/login" rel="noopener noreferrer"&gt;https://ecommerce-playground.lambdatest.io/index.php?route=account/login&lt;/a&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Enter email “&lt;a href="mailto:lambdatest@yourmail.com"&gt;lambdatest@yourmail.com&lt;/a&gt;”.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Enter password “lambdatest”.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Click on Login.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Search for the product “VAIO”.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Verify the correct product is searched.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Click on My Account.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Click on the “Logout” link.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;User logs out from the application.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Now let us look at the benefits of Cypress End to End testing. Cypress is a fast, easy, and reliable End to End testing framework. Cypress tests anything that runs on a web browser.&lt;/p&gt;

&lt;p&gt;Traditionally, End to End tests are slower and more expensive. With Cypress version 9.2.0, there is a significant improvement in the End to End testing experience. Now we can automate the whole testing process from unit level testing to system testing. Using the dashboard feature of Cypress, we can track our test results easily.&lt;/p&gt;

&lt;p&gt;Cypress is very easy to set up. Just install and start writing the test cases. You can integrate custom reporters with Cypress to view the results.&lt;/p&gt;

&lt;p&gt;It has a dashboard feature for CI integration. You can record test results in Dashboard when running Cypress tests from your CI provider.&lt;/p&gt;

&lt;p&gt;As per my experience, here are some of the awesome features of Cypress End to End testing:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Easy to set up&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;You can install Cypress using NPM or their desktop application too. Also, you don’t need to install any additional libraries, dependencies, drivers, servers, etc., as you have to do in the case of Selenium. Cypress is very easy to set up compared to other &lt;a href="https://www.lambdatest.com/automation-testing-tool?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=dec20_sd&amp;amp;utm_term=sd&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;automation testing tools&lt;/a&gt; (or frameworks).&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Write test case faster&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Cypress is faster, and within a few min, you can start to write the test case. Cypress runs tests inside the browser, giving results almost identical to what the users will experience. It also has access to the network layer over the application, which allows us to control all the network requests.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Automatic waiting&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In Cypress, we don’t need to add waits or sleeps to your tests. Cypress automatically waits for commands and assertions before moving on to the next step. Cypress not only waits for elements to be visible or AJAX to load but also for different requests to be sent or returned. You can go through this tutorial on the &lt;a href="https://www.lambdatest.com/blog/types-of-waits-in-selenium/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=dec20_sd&amp;amp;utm_term=sd&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;types of Waits in Selenium&lt;/a&gt; to learn more about waits.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Real-time reloads&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In Cypress, you don’t need to reload the test case. As you make changes to your test case, it is intelligent enough to automatically trigger and run the test. This saves a lot of time in other tools we have to save and rerun the test case&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Screenshots and videos&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Screenshots are captured automatically on failure, or videos of your entire test suite&lt;br&gt;
when run headlessly, and this is extremely useful when tests are failed. Since we can watch what happens when a series of test steps are running, it becomes very easy to track down the exact step when some test case fails.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Informative Dashboard&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Using the Cypress dashboard, we can run our test cases in &lt;a href="https://www.lambdatest.com/blog/what-is-continuous-integration-and-continuous-delivery/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=dec20_sd&amp;amp;utm_term=sd&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;CI/CD&lt;/a&gt; providers and record test results. The Dashboard provides you insight into what happened when your tests ran. The dashboard lets you see the number of failed, passing, pending, skipped tests and the entire stack trace of failed tests. The screenshot captures itself when any test case fails, and by running the video, we can see the step of failure.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Integration with cloud testing platform&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;We can integrate Cypress with the various cloud-providing testing platforms. One of them is LambdaTest. Using &lt;a href="https://www.lambdatest.com/cypress-automation-tool?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=dec20_sd&amp;amp;utm_term=sd&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;Cypress automation tools&lt;/a&gt; like LambdaTest, you can execute &amp;amp; analyze &lt;a href="https://www.lambdatest.com/support/docs/running-your-first-cypress-test/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=dec20_sd&amp;amp;utm_term=sd&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;Cypress test scripts online&lt;/a&gt;. You can run End to End tests on a blazing-fast Cypress test execution cloud. LambdaTest is a reliable, scalable, secure, and high-performing test execution platform built for scale. Perform &lt;a href="https://www.lambdatest.com/cypress-ui-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=dec20_sd&amp;amp;utm_term=sd&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;Cypress UI testing&lt;/a&gt; on 40+ different browsers and browser versions, including headless versions.&lt;/p&gt;

&lt;p&gt;Run End-to-End Cypress tests on cloud grid. &lt;a href="https://accounts.lambdatest.com/register?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=dec20_sd&amp;amp;utm_term=sd&amp;amp;utm_content=register" rel="noopener noreferrer"&gt;Try LambdaTest Now!&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  Getting Started with Cypress End to End Testing
&lt;/h2&gt;

&lt;p&gt;Follow the below-mentioned steps to create a new project for &lt;a href="https://www.lambdatest.com/blog/cypress-test-automation-framework/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=dec20_sd&amp;amp;utm_term=sd&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;Cypress automation&lt;/a&gt; testing.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 1&lt;/strong&gt;: Create a folder and generate package.json.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Create a project, here naming it as &lt;strong&gt;Cypress_Lambdatest&lt;/strong&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Use the &lt;strong&gt;npm init&lt;/strong&gt; command in the terminal to create a &lt;strong&gt;package.json&lt;/strong&gt; file&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Step 2&lt;/strong&gt;: Install Cypress.&lt;/p&gt;

&lt;p&gt;To install Cypress, run this command in the newly created folder:&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm install cypress — save-dev
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;p&gt;This command will install Cypress locally as a dev dependency for your project.&lt;/p&gt;

&lt;p&gt;OR&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;yarn add cypress — dev
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;p&gt;​​This command will install Cypress locally as a dev dependency for your project.&lt;/p&gt;

&lt;p&gt;Once installed, Cypress version 9.2.0 is reflected, as seen below. The latest version of Cypress is 10.3.0&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2272%2F0%2A0NTOxWaLkQ4DybVW.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2272%2F0%2A0NTOxWaLkQ4DybVW.png" width="800" height="585"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The default folder structure of Cypress is shown below. You can create test cases under the folder “integration”.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2000%2F0%2AVwn_lAyE7YuJ5-C2.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2000%2F0%2AVwn_lAyE7YuJ5-C2.png" width="800" height="469"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  Project structure of Cypress
&lt;/h2&gt;

&lt;p&gt;From the screenshots, you can see that Cypress has created a default folder hierarchy when it opens the first time. Below are the details for each of these folders/files created by Cypress.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2560%2F0%2AM3vnGLbA_6SFlw40.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2560%2F0%2AM3vnGLbA_6SFlw40.png" width="800" height="556"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;**Fixtures: **Fixtures are external pieces of static data that your tests can use. It is recommended not to complex code data in the test case. It should be driven from an external source like CSV, HTML, or JSON.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Integration:&lt;/strong&gt; This is the main folder to store all your tests. We add the Basic, End to End Test, Visual or Cucumber test here. All your spec files will be here.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Plugins:&lt;/strong&gt; The Plugin folder contains the plugins or listeners. Cypress will automatically include the plugins file “cypress/plugins/index.js”.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Support:&lt;/strong&gt; There are two files inside the support folder: commands.js and index.js&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;command.js:&lt;/strong&gt; is the file where you add your commonly used functions and custom commands. It includes functions you may call to use in different tests, such as the login function. Cypress created some functions for you, and you can override them here if you want.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;index.js:&lt;/strong&gt; This file runs before every single spec file. This file is a great place to put global configuration and behavior that modifies Cypress like before or before. By default, it imports only commands.js, but you can import or require other files to keep things organized.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Node_Modules:&lt;/strong&gt; All the node packages will be installed in the node_modules directory and available in all the test files. So, in a nutshell, this is the folder where NPM installs all the project dependencies.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Cypress.json:&lt;/strong&gt; It is used to store different configurations. e.g., timeout, base URL, test files, or any other configurations we want to override for tweaking the behavior of Cypress. We can also manage the customized folder structure because it is part of, by default, Cypress Configurations.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Apart from the above four folders, we have some more folders like Screenshot, Download, and Video to store different related files, which we will discuss later.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Check this out: Run Automated &lt;a href="https://www.lambdatest.com/puppeteer-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=dec20_sd&amp;amp;utm_term=sd&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;Puppeteer Testing&lt;/a&gt; Online- Test your Puppeteer test scripts online.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  Basic constructs of Cypress
&lt;/h2&gt;

&lt;p&gt;Cypress has adopted Mocha’s syntax for developing test cases. Below are a few main constructs that are majorly used in Cypress test development:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;describe()&lt;/strong&gt;: It is used to group our tests. It takes two arguments, the first is the name of the test group, and the second is a callback function.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;it()&lt;/strong&gt;: It is used for individual test cases. It takes two arguments, a string explaining what the test should do and a callback function that contains our actual test.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;before()&lt;/strong&gt;: It runs once before all tests in the block.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;after()&lt;/strong&gt;: It runs once after all tests in the block.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;beforeEach()&lt;/strong&gt;: It runs before each test in the block.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;afterEach()&lt;/strong&gt;: It runs after each test in the block.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;.only()&lt;/strong&gt;: It is used to run a specified suite or test; append “.only” against the .it() block.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;.skip()&lt;/strong&gt;: It is used to skip a specified suite or test; append “.skip()” against the .it() block.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;
  
  
  Demonstration: Cypress End to End Testing
&lt;/h2&gt;

&lt;p&gt;Let’s create a new folder under the integration folder named “cypress_lambdatest” to perform Cypress End to End testing.&lt;/p&gt;
&lt;h2&gt;
  
  
  Cypress End to End Testing: Case Example 1
&lt;/h2&gt;

&lt;p&gt;Create the first spec with the name login_searchproduct.spec.js under the folder LambdaTest.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2000%2F0%2Aiff19YZSRa418ejc.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2000%2F0%2Aiff19YZSRa418ejc.png" width="736" height="592"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Write the script below in the &lt;em&gt;login_searchproduct.spec.js&lt;/em&gt; file, which covers login into the application and searching for the product. After the search, verify the correct product should be displayed.&lt;/p&gt;

&lt;p&gt;In the code snippet below:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;First, we open the site URL using cy.visit().&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Second, it() block is used for log-in into the application by entering email and password.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Third, it() block is used for searching the product, and the last it() block is used for searching the product.&lt;br&gt;
&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;   /// &amp;lt;reference types="cypress" /&amp;gt;
    it("Open the Url", () =&amp;gt; {
     cy.visit(
       "https://ecommerce-playground.lambdatest.io/index.php?route=account/login"
     );
    });
    it("Login into the application", () =&amp;gt; {
     cy.get('[id="input-email"]').type("lambdatest@yopmail.com");
     cy.get('[id="input-password"]').type("lambdatest");
     cy.get('[type="submit"]').eq(0).click();
    });
    it("Search the Product", () =&amp;gt; {
     cy.get('[name="search"]').eq(0).type("VAIO");
     cy.get('[type="submit"]').eq(0).click();
    });
    it("Verify Product after search ", () =&amp;gt; {
     cy.contains("Sony VAIO");
    });
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;&lt;strong&gt;Code Walkthrough&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;A new Cypress chain always starts with &lt;strong&gt;cy.[command]&lt;/strong&gt;, where what is yielded by the command establishes what other commands can be called next (chained).&lt;/p&gt;

&lt;p&gt;Some methods, such as &lt;strong&gt;cy.get()&lt;/strong&gt; or &lt;strong&gt;cy.contains()&lt;/strong&gt;, yield a DOM element, allowing further commands to be chained onto them (assuming they expect a DOM subject) like .click() or even cy.contains() again&lt;/p&gt;
&lt;h2&gt;
  
  
  Cypress End to End Testing: Case Example 2
&lt;/h2&gt;

&lt;p&gt;Create the second spec with the name *ScrollAnd_ClickProduct.spec.js *under the folder LambdaTest. Log in to → scroll to the bottom → and click on the product.&lt;/p&gt;

&lt;p&gt;In the code snippet below:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;First, we open the site URL using cy.visit().&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Second, it() block is used for log-in into the application by entering email and password.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Third, it() block will click on the logo of LambdaTest.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Fourth, it() block will scroll to the particular product and click on it.&lt;br&gt;
&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;   /// &amp;lt;reference types="cypress" /&amp;gt;
    it("Open the Url", () =&amp;gt; {
     cy.visit(
       "https://ecommerce-playground.lambdatest.io/index.php?route=account/login"
     );
    });
    it("Login into the application", () =&amp;gt; {
     cy.get('[id="input-email"]').type("lambdatest@yopmail.com");
     cy.get('[id="input-password"]').type("lambdatest");
     cy.get('[type="submit"]').eq(0).click();
    });
    it("Click on Lambdatest Logo", () =&amp;gt; {
     cy.get('[title="Poco Electro"]').click();
    });
    it("Scroll to bottom and Click on Product 'iPod Touch' ", () =&amp;gt; {
     cy.get('[title="iPod Touch"]').eq(0).scrollIntoView().click();
    });
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;&lt;strong&gt;&lt;em&gt;Check this out: Mobile &lt;a href="https://www.lambdatest.com/mobile-emulator-online?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=dec20_sd&amp;amp;utm_term=sd&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;Emulator Online&lt;/a&gt;- Test your mobile websites and smartphone apps using our scalable on cloud mobile emulator.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  How to perform Cypress End to End Testing on local Cypress Grid?
&lt;/h2&gt;

&lt;p&gt;You can run the test case from the command line or use Cypress runner. Let’s run test cases using Cypress runner. ​​To open the Cypress test runner, run the following command.&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;yarn run cypress open
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;p&gt;The above command will open the Cypress test runner with the existing test cases. You can select the browser on which you want to run the test case.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3200%2F0%2AA5PwFHgUEcVICXaX.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3200%2F0%2AA5PwFHgUEcVICXaX.png" width="800" height="442"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h3&gt;
  
  
  Performing first Cypress End to End Testing on local Cypress Grid
&lt;/h3&gt;

&lt;p&gt;Clicking on the first .spec, the first test case starts executing. Below is a screenshot of when the test case ran successfully.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3200%2F0%2AFbGbmDnwPKR_Y7xA.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3200%2F0%2AFbGbmDnwPKR_Y7xA.png" width="800" height="370"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h3&gt;
  
  
  Performing second Cypress End to End Testing on local Cypress Grid
&lt;/h3&gt;

&lt;p&gt;Clicking on the second .spec, the second test case starts executing. In the below screenshot, we can see products are loading.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3200%2F0%2ALOInt0fevqqxmDPJ.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3200%2F0%2ALOInt0fevqqxmDPJ.png" width="800" height="444"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In the below screenshot the test case ran successfully.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3200%2F0%2AgzO8DVL30Fo7EDxH.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3200%2F0%2AgzO8DVL30Fo7EDxH.png" width="800" height="408"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Check this out: &lt;a href="https://www.lambdatest.com/blog/regression-testing-what-is-and-how-to-do-it/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=dec20_sd&amp;amp;utm_term=sd&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;Regression test&lt;/a&gt;ing: Complete Guide With Best Practices&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  How to perform Cypress End to End Testing on cloud Cypress Grid?
&lt;/h2&gt;

&lt;p&gt;We have performed Cypress End to End testing on the local Cypress Grid. We can perform &lt;a href="https://www.lambdatest.com/cypress-parallel-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=dec20_sd&amp;amp;utm_term=sd&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;Cypress parallel testing&lt;/a&gt; on multiple browsers, versions, and operating systems using the cloud platform. Cloud-based &lt;a href="https://www.lambdatest.com/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=dec20_sd&amp;amp;utm_term=sd&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;cross browser testing&lt;/a&gt; platforms like LambdaTest allows you to automate &lt;a href="https://www.lambdatest.com/web-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=dec20_sd&amp;amp;utm_term=sd&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;web testing&lt;/a&gt; with Cypress on an &lt;a href="https://www.lambdatest.com/online-browser-farm?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=dec20_sd&amp;amp;utm_term=sd&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;online browser farm&lt;/a&gt; of real browsers and OS. We can perform Cypress End to End testing on a blazing fast test execution cloud.&lt;/p&gt;

&lt;p&gt;LambdaTest offers high-scale parallelization with easy integration with CI/CD pipeline. Cypress test results will appear in real-time through the lambdatest-Cypress CLI. Once all test cases are executed, you can see the Cypress test results on the &lt;a href="https://accounts.lambdatest.com/register?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=dec20_sd&amp;amp;utm_term=sd&amp;amp;utm_content=register" rel="noopener noreferrer"&gt;LambdaTest Dashboard&lt;/a&gt;. On LambdaTest, we can also see screenshots, videos, and logs for all test cases.&lt;/p&gt;

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/SBY669U14Oo"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;You can also Subscribe to the &lt;a href="https://www.youtube.com/channel/UCCymWVaTozpEng_ep0mdUyw?sub_confirmation=1" rel="noopener noreferrer"&gt;LambdaTest YouTube Channel &lt;/a&gt;and stay updated with the latest tutorials around &lt;a href="https://www.lambdatest.com/automated-browser-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=dec20_sd&amp;amp;utm_term=sd&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;automated browser testing&lt;/a&gt;, &lt;a href="https://www.lambdatest.com/selenium-automation?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=dec20_sd&amp;amp;utm_term=sd&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;Selenium testing&lt;/a&gt;, CI/CD, and more.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Check this out: 30 Top &lt;a href="https://www.lambdatest.com/blog/automation-testing-tools/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=dec20_sd&amp;amp;utm_term=sd&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;tools for Automation Testing&lt;/a&gt; In 2022&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Step-up lambdatest for Cypress test case execution
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Step 1&lt;/strong&gt;: Install the CLI.&lt;/p&gt;

&lt;p&gt;Install the LambdaTest using Cypress CLI command via npm. LambdaTest’s command-line interface allows us to run your Cypress tests on LambdaTest.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm install -g lambdatest-cypress-cli
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;Step 2:&lt;/strong&gt; Generate lambdatest-config.json.&lt;/p&gt;

&lt;p&gt;Under the root folder, configure the browsers that we want to run the tests. Use the &lt;strong&gt;init&lt;/strong&gt; command to generate a sample &lt;strong&gt;lambdatest-config.json&lt;/strong&gt; file or create one from scratch. Use the below command.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;lambdatest-cypress init
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;In the generated lambdatest-config.json file, pass the below information.&lt;/p&gt;

&lt;p&gt;Fill required values in the section &lt;strong&gt;lambdatest_auth, browsers&lt;/strong&gt;, and &lt;strong&gt;run_settings&lt;/strong&gt; to run your tests.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{
 "lambdatest_auth": {
   "username": "username",
   "access_key": "access_key"
 },
 "browsers": [
   {
     "browser": "Chrome",
     "platform": "Windows 10",
     "versions": ["latest-1"]
   },
   {
     "browser": "Firefox",
     "platform": "Windows 10",
     "versions": ["latest-1"]
   }
 ],
 "run_settings": {
   "cypress_config_file": "cypress.json",
   "build_name": "build-name",
   "parallels": 2,
   "specs": "./cypress/integration/lambdatest/*.spec.js",
   "ignore_files": "",
   "feature_file_suppport": false,
   "network": false,
   "headless": false,
   "reporter_config_file": "",
   "npm_dependencies": {
     "cypress": "9.2.0"
   }
 },
 "tunnel_settings": {
   "tunnel": false,
   "tunnel_name": null
 }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Cut test execution time with Cypress Parallel testing. &lt;a href="https://accounts.lambdatest.com/register?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=dec20_sd&amp;amp;utm_term=sd&amp;amp;utm_content=register" rel="noopener noreferrer"&gt;Try LambdaTest Now!&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;How to perform Cypress End to End Testing in Parallel on cloud Cypress Grid?&lt;br&gt;
Run the below command to perform &lt;a href="https://www.lambdatest.com/cypress-ui-automation?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=dec20_sd&amp;amp;utm_term=sd&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;Cypress UI automation&lt;/a&gt; on LambdaTest.&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;lambdatest-cypress run
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;p&gt;As we run the above command, test case execution starts on your local and parallelly on the LambdaTest platform.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Check this out: Online Automation Testing Platform- Accelerate your release velocity with blazing fast &lt;a href="https://www.lambdatest.com/automation-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=dec20_sd&amp;amp;utm_term=sd&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;test automation cloud &lt;/a&gt;&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;h3&gt;
  
  
  Cypress End to End Testing Report on local environment
&lt;/h3&gt;

&lt;p&gt;Below report is generated when we run the command lambdatest-cypress run in the local terminal.&lt;/p&gt;

&lt;p&gt;In the below report, we can see test case &lt;strong&gt;login_searchproduct.spec.js&lt;/strong&gt; and &lt;strong&gt;ScrollAnd_ClickProduct.spec.js&lt;/strong&gt; successfully run on Firefox and Chrome.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3064%2F0%2A9639fghGlRMdRa4H.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3064%2F0%2A9639fghGlRMdRa4H.png" width="800" height="636"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h3&gt;
  
  
  Cypress End to End Testing Report on LambdaTest
&lt;/h3&gt;

&lt;p&gt;In the below screen, you can see test cases start running on the Firefox browser.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3998%2F0%2AGOQMusk51q8pJ1TN.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3998%2F0%2AGOQMusk51q8pJ1TN.png" width="800" height="383"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You can see in the below console that log test cases are passed on the Firefox browser.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3998%2F0%2ACQwKrflkVM3DZ2oY.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3998%2F0%2ACQwKrflkVM3DZ2oY.png" width="800" height="392"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In the below screen, you can see test cases start running on the Chrome browser as well.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3998%2F0%2AnsQ7TQtwCt_y_jqs.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3998%2F0%2AnsQ7TQtwCt_y_jqs.png" width="800" height="350"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You can see in the below console that log test cases are passed on the Chrome browser.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3998%2F0%2A_gIJf2MMjLYngWDN.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3998%2F0%2A_gIJf2MMjLYngWDN.png" width="800" height="392"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;For more detail, you can read through this blog on &lt;a href="https://www.lambdatest.com/blog/how-to-perform-cypress-testing-at-scale-with-lambdatest/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=dec20_sd&amp;amp;utm_term=sd&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;How To Perform Cypress Testing At Scale With LambdaTest&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2000%2F0%2AuVUn9JWnEJNeEGxE.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2000%2F0%2AuVUn9JWnEJNeEGxE.png" width="800" height="154"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Here’s quick video if you have doubts regarding how to handle iframes in Cypress.&lt;/p&gt;

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/D3jw8-eRzjs"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Check this out: &lt;a href="https://www.lambdatest.com/learning-hub/ad-hoc-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=dec20_sd&amp;amp;utm_term=sd&amp;amp;utm_content=learning_hub" rel="noopener noreferrer"&gt;Ad Hoc Testing&lt;/a&gt;: A Comprehensive Guide With Examples and Best Practices&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Summary
&lt;/h2&gt;

&lt;p&gt;There are pros and cons to each testing method. Cypress End to End testing is the closest to real user testing, which is one of its main advantages. The closer the test is to mimic the user, the more likely it will catch issues the user might experience.&lt;/p&gt;

&lt;p&gt;Overall, Cypress is a solid choice if you want to take your testing to the next level with some End to End tests&lt;/p&gt;

</description>
      <category>css</category>
      <category>testing</category>
      <category>webdev</category>
    </item>
  </channel>
</rss>
