<?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>Forem: enriquee20</title>
    <description>The latest articles on Forem by enriquee20 (@enriquee20).</description>
    <link>https://forem.com/enriquee20</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%2F937011%2F3078550c-f620-4563-bb72-6c7c639a28ac.jpeg</url>
      <title>Forem: enriquee20</title>
      <link>https://forem.com/enriquee20</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/enriquee20"/>
    <language>en</language>
    <item>
      <title>Cypress Testing Library: Getting Started Tutorial</title>
      <dc:creator>enriquee20</dc:creator>
      <pubDate>Tue, 20 Jun 2023 06:29:58 +0000</pubDate>
      <link>https://forem.com/testmuai/cypress-testing-library-getting-started-tutorial-202a</link>
      <guid>https://forem.com/testmuai/cypress-testing-library-getting-started-tutorial-202a</guid>
      <description>&lt;p&gt;Writing maintainable tests for web user interfaces is critical for ensuring the reliability and stability of applications. As the software evolves and changes, it’s vital to have tests that can be easily maintained and updated to reflect the latest changes in the code.&lt;/p&gt;

&lt;p&gt;As part of &lt;a href="https://www.lambdatest.com/learning-hub/ui-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jun20_kj&amp;amp;utm_term=kj&amp;amp;utm_content=learning_hub" rel="noopener noreferrer"&gt;UI testing&lt;/a&gt;, it is necessary to focus on the application’s behavior rather than its implementation details. This is because implementation details can undergo frequent changes, and testing them can result in fragile tests that easily break when the implementation is modified.&lt;/p&gt;

&lt;p&gt;On the other hand, focusing on the application’s behavior allows for more resilient tests that are less prone to breaking as the code changes. Remember that this approach also helps catch regressions and ensure the application continues functioning as intended, even if new features are added and others are modified.&lt;/p&gt;

&lt;p&gt;To maintain the long-term viability of a &lt;a href="https://www.lambdatest.com/automation-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jun20_kj&amp;amp;utm_term=kj&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;test automation&lt;/a&gt; suite, it’s also vital to ensure it can handle components’ refactors without breaking. Refactors can involve changes to implementing components but not necessarily their functionality; also, those could be related to technical debt. Therefore, tests that rely on implementation details may fail when a refactor occurs, even though the component’s functionality remains unchanged.&lt;/p&gt;

&lt;p&gt;In this blog on Cypress Testing Library, we will delve deeper into the concept of removing implementation details from our tests and instead focusing on behavior. By adopting this approach, your test scripts can remain robust and effective even when there are changes in the implementation of components.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Check out this blog on the &lt;a href="https://www.lambdatest.com/blog/best-mobile-automation-testing-tools/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jun20_kj&amp;amp;utm_term=kj&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;mobile automation testing tools&lt;/a&gt;, we list the best 11 mobile automation testing tools with their advantages and business-friendly features.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Why Cypress for test automation?
&lt;/h2&gt;

&lt;p&gt;The big question for you at this moment is why &lt;a href="https://www.lambdatest.com/learning-hub/cypress-tutorial?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jun20_kj&amp;amp;utm_term=kj&amp;amp;utm_content=learning_hub" rel="noopener noreferrer"&gt;Cypress&lt;/a&gt; is still relevant compared to other tools like Playwright, &lt;a href="https://www.lambdatest.com/learning-hub/webdriverio?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jun20_kj&amp;amp;utm_term=kj&amp;amp;utm_content=learning_hub" rel="noopener noreferrer"&gt;WebdriverIO&lt;/a&gt;, or &lt;a href="https://www.lambdatest.com/testcafe?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jun20_kj&amp;amp;utm_term=kj&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;TestCafe&lt;/a&gt; in terms of UI test automation. At the time of writing this blog on Cypress Testing Library, Cypress had just announced the 12.12.0 release, which supports Angular 16 and updates the Debug page as part of the significant features. But for those still waiting on Safari as part of &lt;a href="https://www.lambdatest.com/online-browser-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jun20_kj&amp;amp;utm_term=kj&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;cross browser testing&lt;/a&gt;, sadly, you will be waiting a bit longer.&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%2F2876%2F0%2AtByvY5MMSCr26KJH.png" class="article-body-image-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%2F2876%2F0%2AtByvY5MMSCr26KJH.png" width="800" height="542"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If you are looking at Safari or Multi-tabs Testing for your UI testing, you know Cypress is not your first option; perhaps you have already switched to &lt;a href="https://www.lambdatest.com/playwright?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jun20_kj&amp;amp;utm_term=kj&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;Playwright&lt;/a&gt; or keeping your &lt;a href="https://www.lambdatest.com/selenium?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jun20_kj&amp;amp;utm_term=kj&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;Selenium&lt;/a&gt; test suite. The question is still there, and it looks like Cypress is not relevant anymore, but Cypress is still relevant (Let’s rephrase it, tools like Cypress are more appropriate to these new Modern times), but why is this true, let’s dig in a bit more. You can learn more about it through this blog on &lt;a href="https://www.lambdatest.com/blog/playwright-vs-selenium-vs-cypress/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jun20_kj&amp;amp;utm_term=kj&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;Playwright vs Selenium vs Cypress&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Cypress and similar tools want to simplify writing tests; imagine Developers coding all day and following the &lt;a href="https://www.lambdatest.com/learning-hub/test-driven-development?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jun20_kj&amp;amp;utm_term=kj&amp;amp;utm_content=learning_hub" rel="noopener noreferrer"&gt;Test Driven Development&lt;/a&gt; (TDD) methodology; it could be more challenging for them; now, what about the new QAs, in the past (Or present situation)? Installing Selenium and maintaining your WebDriver version or adding extra complexity to test a single component with more code doesn’t sound efficient.&lt;/p&gt;

&lt;p&gt;Cypress wants to simplify that by providing easy solutions and making test automation an enjoyable experience for Developers, Testers, DevOps Engineers, and others.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;This article will walk you through the best &lt;a href="https://www.lambdatest.com/blog/best-software-testing-certifications/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jun20_kj&amp;amp;utm_term=kj&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;software testing certifications&lt;/a&gt; that will help boost your career as a test automation engineer.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Understanding the Problematic DOM-Testing
&lt;/h2&gt;

&lt;p&gt;When writing tests for your web UI, prioritizing maintainability is essential. It means writing tests that avoid relying on the implementation details of your components. Instead, you should focus on testing the functionality of your application in a way that gives you confidence that it works as expected. By decoupling your tests from implementation details, you can ensure that your test scripts remain resilient to coding changes.&lt;/p&gt;

&lt;p&gt;To achieve maintainable tests, you should focus on testing the external behavior of your components. It means testing what your users will see and interact with rather than how your components are implemented under the hood. You can achieve this by combining &lt;a href="https://www.lambdatest.com/learning-hub/functional-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jun20_kj&amp;amp;utm_term=kj&amp;amp;utm_content=learning_hub" rel="noopener noreferrer"&gt;functional tests&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=jun20_kj&amp;amp;utm_term=kj&amp;amp;utm_content=learning_hub" rel="noopener noreferrer"&gt;integration tests&lt;/a&gt;, which help ensure our application works as intended from an &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=jun20_kj&amp;amp;utm_term=kj&amp;amp;utm_content=learning_hub" rel="noopener noreferrer"&gt;end-to-end testing&lt;/a&gt; perspective.&lt;/p&gt;

&lt;p&gt;If you want to prioritize maintainability, you must avoid the typical pitfall of tests that break after minor UI changes to our coding. In addition, it can help us and the team to save time and effort in the long run, as you won’t need to spend as much time fixing broken tests or updating them after every refactor. Finally, writing maintainable tests can help you build a more reliable and robust web UI that meets the needs of your users.&lt;/p&gt;

&lt;p&gt;It sounds hard to write highly maintainable test scripts and avoid breaking changes; I know the solution could be more apparent, but believe me, the utilities this library provides facilitate querying the &lt;a href="https://www.lambdatest.com/blog/document-object-model/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jun20_kj&amp;amp;utm_term=kj&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;DOM&lt;/a&gt; as the user would. For example, it found form elements by their label text (just like a user would), links and buttons from their text (Similar like a user would), and more. In addition, it exposes a suggested way to find elements by a data-testid as an “escape hatch” for elements where the text content and label do not make sense or are impractical.&lt;/p&gt;

&lt;p&gt;The DOM-Testing library encourages your applications to be more accessible. It allows you to get our tests closer to using your components the way a user will, which allows your tests to give you more confidence that your application will work when a real user uses it.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;In this article on the top 9 &lt;a href="https://www.lambdatest.com/blog/challenges-in-automation-testing/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jun20_kj&amp;amp;utm_term=kj&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;challenges in automation testing&lt;/a&gt;, we look at the various obstacles and how to deal with them.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  What is the Cypress Testing Library?
&lt;/h2&gt;

&lt;p&gt;Cypress Testing Library is a JavaScript library that provides utilities and best practices for testing web applications using the Cypress testing framework. It is built on top of the popular testing library family of libraries, which promotes a user-centric approach to testing by emphasizing real-world user interactions and behavior. &lt;a href="https://www.lambdatest.com/cypress-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jun20_kj&amp;amp;utm_term=kj&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;Cypress Testing&lt;/a&gt; Library extends the capabilities of Cypress and enables developers to write more maintainable and reliable &lt;a href="https://www.lambdatest.com/cypress-ui-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jun20_kj&amp;amp;utm_term=kj&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;Cypress UI tests&lt;/a&gt; for their web applications.&lt;/p&gt;

&lt;p&gt;With Cypress Testing Library, you can write tests that closely resemble how users interact with your application. It encourages testing the application from the user’s perspective, focusing on the rendered output and the expected behavior. This approach helps to decouple the tests from implementation details, making them more resilient to changes in the application code.&lt;/p&gt;

&lt;p&gt;The library provides a set of intuitive query methods to select and interact with elements on the page, just like a user would. It also offers various utility functions for common testing scenarios, such as checking for the presence of elements, interacting with form inputs, and making assertions on the rendered content. Cypress Testing Library promotes accessible and inclusive testing practices, ensuring that your application can be tested for a wide range of users.&lt;/p&gt;

&lt;p&gt;Overall, Cypress Testing Library simplifies the process of writing effective and maintainable tests for web applications using Cypress, making it a valuable tool for developers seeking to enhance the quality and reliability of their &lt;a href="https://www.lambdatest.com/cypress-e2e-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jun20_kj&amp;amp;utm_term=kj&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;Cypress e2e testing&lt;/a&gt; efforts.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Learn why Python is the top choice for automation testing. This comprehensive tutorial provides a step-by-step guide to &lt;a href="https://www.lambdatest.com/blog/python-automation-testing/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jun20_kj&amp;amp;utm_term=kj&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;Python automation testing&lt;/a&gt; to help you streamline your testing process.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Installing Cypress Testing Library
&lt;/h2&gt;

&lt;p&gt;Now, it’s time to install the Cypress Testing Library in your Cypress project. Please type the following command:&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 --save-dev @testing-library/cypress
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



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

&lt;p&gt;If the installation is successful, you will see the Cypress Testing Library in our package.json 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%2AoXQvxGy0EcLQgOwx.png" class="article-body-image-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%2AoXQvxGy0EcLQgOwx.png" width="800" height="406"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Cypress Testing Library extends Cypress’s cy commands. You must add the following line to our project’s &lt;em&gt;cypress/support/commands.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;    import '@testing-library/cypress/add-commands'

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can now use the DOM Testing Library’s &lt;em&gt;findBy, findAllBy, queryBy, and queryAllBy&lt;/em&gt; commands off the global cy object.&lt;/p&gt;

&lt;p&gt;Let’s start with a simple test, FindAllByTitle; we will use the following URL -&amp;gt; “&lt;a href="https://ecommerce-playground.lambdatest.io/" rel="noopener noreferrer"&gt;https://ecommerce-playground.lambdatest.io/&lt;/a&gt;” as this is a good Automation playground from LambdaTest.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; it.only('findAllByText', () =&amp;gt; {
            cy.findAllByText('Search')
                .should('have.length', 1)
        })
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;For this test, we are trying to find all the elements having the text “Search” in the current webpage as part of the DOM page; you should see only one.&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%2AQa-wyQ4XEnXABVbJ.png" class="article-body-image-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%2AQa-wyQ4XEnXABVbJ.png" width="800" height="424"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;As you can see in the image above, our webpage only has one element; that’s why it says “length of 1” But what about if the requirements mention two elements with Search’s Text? Let’s update our code and rerun it.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  it.only('findAllByText', () =&amp;gt; {
            cy.findAllByText('Search')
                .should('have.length', 2)
        })
&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%2F1%2AdRM7teyZwQCYv05jcPJLbA.png" class="article-body-image-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%2F1%2AdRM7teyZwQCYv05jcPJLbA.png" width="800" height="430"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;As you noticed, the &lt;a href="https://www.lambdatest.com/learning-hub/cypress-assertions?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jun20_kj&amp;amp;utm_term=kj&amp;amp;utm_content=learning_hub" rel="noopener noreferrer"&gt;Cypress assertion&lt;/a&gt; failed; we were expecting two elements with the Search text, but our web page’s current state displays only one; as the first part of our approach, it worked smoothly; we validated the behavior, let’s try another 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%2F3200%2F0%2A9dJlFFKZWwZrROv9.png" class="article-body-image-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%2A9dJlFFKZWwZrROv9.png" width="800" height="400"&gt;&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; it.only('findAllByText', () =&amp;gt; {
           cy.findAllByText('SHOP NOW')
           .should('have.length', 3)
       })

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;For the following example, we will find all the elements with the text “SHOP NOW”; I did a quick search, and it’s displaying 3, let’s go with that approach.&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%2ABxv6i3C7cb9di-ky.png" class="article-body-image-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%2ABxv6i3C7cb9di-ky.png" width="800" height="434"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We got a failure; it looks like our test only found two elements; let’s see the Cypress highlight page; this is a good option if you are debugging your 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%2A_TtQJf7Xj8sgnGBx.png" class="article-body-image-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_TtQJf7Xj8sgnGBx.png" width="695" height="1600"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;After debugging, we found the problem; we were looking for “SHOP NOW” in all Upper cases, but the other button contains the text “Shop Now” in Lower and Upper cases; let’s see if this is correct, rerun it with “Shop Now” text.&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%2AVk16XTb4Jb7oDJmk.png" class="article-body-image-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%2AVk16XTb4Jb7oDJmk.png" width="800" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now, let’s create our first UX bug per UX web design guidelines; you should have a standard design applicable to buttons, labels, titles, etc. Just kidding, but now you can witness the potential of DOM testing with Cypress.&lt;/p&gt;

&lt;p&gt;It’s addictive; let’s use the &lt;em&gt;Placeholder&lt;/em&gt; attribute, which is relevant for web Inputs; inputs are the gates nearly all eCommerce has to pass. Regardless of your feelings about empathy in design, unusable inputs leave money on the table. In this case, we will use &lt;em&gt;findByPlaceholderText&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;  it.only('findPlaceholders', () =&amp;gt; {
           cy.get(`li:nth-of-type(6) &amp;gt; a[role='button']`).click()
           //
           cy.findByText('Continue').click()
           //
           cy.findByPlaceholderText('First Name').click().type('Hello Placeholder')
       })

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;As you can notice from the code above, we are using “&lt;em&gt;findByText&lt;/em&gt;” and “&lt;em&gt;cy.get&lt;/em&gt;“; the “&lt;em&gt;get&lt;/em&gt;” we are using to find a specific element without any particular identifier; the rest is straightforward; let’s run it our 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%2AX6YZRTIXwwABQHbh.png" class="article-body-image-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%2AX6YZRTIXwwABQHbh.png" width="800" height="432"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Last but not least, here you can find the list of queries you can perform using Cypress Testing Library&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;em&gt;‘findByLabelText’,&lt;/em&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;em&gt;‘findByPlaceholderText’,&lt;/em&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;em&gt;‘findByText’,&lt;/em&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;em&gt;‘findByDisplayValue’,&lt;/em&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;em&gt;‘findByAltText’,&lt;/em&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;em&gt;‘findByTitle’,&lt;/em&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;em&gt;‘findByRole’,&lt;/em&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;em&gt;‘findByTestId’&lt;/em&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

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

&lt;p&gt;Till now, you have understood the importance of the Cypress Testing Library. So, with the Cypress project already set, let’s look at how the code works using Cypress. For starters, please look at the link to set up Cypress; as mentioned before, Cypress enables you to write faster, easier, and more reliable tests.&lt;/p&gt;

&lt;p&gt;Let’s start defining our config.json file; here, you can include some data and URLs.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;   {
       "URL1": "https://www.lambdatest.com/blog/",
       "URL2": "https://ecommerce-playground.lambdatest.io"
    }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Next, you need to establish our structure. As demonstrated in the following line of code, import MainPage from ‘../../page-objects/components/MainPage’; we aim to separate our &lt;a href="https://www.lambdatest.com/blog/finding-html-elements-using-cypress-locators/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jun20_kj&amp;amp;utm_term=kj&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;Cypress locators&lt;/a&gt; from our tests using the &lt;a href="https://www.lambdatest.com/learning-hub/cypress-page-object-model?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jun20_kj&amp;amp;utm_term=kj&amp;amp;utm_content=learning_hub" rel="noopener noreferrer"&gt;Page Object Model&lt;/a&gt; (POM) approach. This structure is located under the “page-objects” folder.&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%2AOH2t0xHrqR61GwQD.png" class="article-body-image-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%2AOH2t0xHrqR61GwQD.png" width="640" height="496"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Let’s start defining a hook for our tests; with a couple of tests, things might get repetitive. For this case, you might instead use a &lt;em&gt;beforeEach()&lt;/em&gt; hook that will open up your page before all of your tests; remember that Cypress clears out the state of the browser in between tests.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; describe('Testing Cypress Library', () =&amp;gt; {
       beforeEach(() =&amp;gt; {
           cy.visit(`${config.URL2}`)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now, you probably noticed the following line of code -&amp;gt; “cy.visit(${config.URL2}) “; as I mentioned before, I like to put my URLs in a different file, “config.json” in this case you are wondering why not using the baseUrl inside of the cypress.config.js file, being honest, this is because switching URLs can be tricky, in my case, I use around four to five web pages to validate.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;![](https://cdn-images-1.medium.com/max/2000/0*hwKOPbHwiCodcG-O.png)

    // Test each of the types of queries: LabelText, PlaceholderText, Text, DisplayValue, AltText, Title, Role, TestId

       it('findAllByText', () =&amp;gt; {

           MainPage.FindByTextAll('Search', 1)
       })

       it('findAllByText', () =&amp;gt; {

           MainPage.FindByTextAll('Shop Now', 1)
       })

       it('findAllByText Second', () =&amp;gt; {

           MainPage.FindByTextAll('SHOP NOW', 2)
       })

       it('findPlaceholders', () =&amp;gt; {

           MainPage.GoToCreateAccount()
           //
           MainPage.findPlaceholders()
       })

    })

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Our methods and locators can be found in the “components/MainPage”. You can see that our tests look cleaner and easy to follow; currently, we have four tests; let’s explore the methods one by one.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; export default class MainPage {

       static GoToCreateAccount(){

           cy.get(`li:nth-of-type(6) &amp;gt; a[role='button']`).click()
           //
           cy.findByText('Continue').click()

       }

       static FindByTextAll(El1, qty){

           cy.findAllByText(El1)
               .should('have.length', qty)

       }

       static findPlaceholders(){

           //cy.findByPlaceholderText(El1).click().type(PlaceText)

           cy.findByPlaceholderText('First Name').click().type('Hello Placeholder')
           cy.findByPlaceholderText('Last Name').click().type('Hello Last Name')
           cy.findByPlaceholderText('E-Mail').click().type('Hello E-Mail')
           cy.findByPlaceholderText('Telephone').click().type('Hello Telephone')
           cy.findByPlaceholderText('Password').click().type('Hello Password')
           cy.findByPlaceholderText('Password Confirm').click().type('Hello Password Confirm')

       }

    }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;As you can see from the code above, we have three methods, one for registering a new customer, in this case, “&lt;em&gt;GoToCreateAccount&lt;/em&gt;“, another one for the “&lt;em&gt;FindByTextAll&lt;/em&gt;” receiving two parameters, text, and the length, finally the “&lt;em&gt;findPlaceholders&lt;/em&gt;” method, basically looking for all the Placeholders in the registering page, as this is a one-time method, no need to encapsulate more the repeatable &lt;em&gt;FindByTextAll&lt;/em&gt; sentence.&lt;/p&gt;

&lt;p&gt;Here is the result of our tests, which indicates that our Cypress Testing Library testing approach is working smoothly.&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%2AiXRGp99lNVfPV7Jh.png" class="article-body-image-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%2AiXRGp99lNVfPV7Jh.png" width="800" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Run your &lt;a href="https://www.lambdatest.com/selenium-automation?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jun20_kj&amp;amp;utm_term=kj&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;Selenium Automation&lt;/a&gt; Testing scripts on the LambdaTest cloud grid. Test on 3000+ desktop &amp;amp; mobile environments. Try it for free!&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  When to use the Cypress Testing Library?
&lt;/h2&gt;

&lt;p&gt;We try only to expose methods and utilities that encourage you to write tests that closely resemble how web pages are used.&lt;/p&gt;

&lt;p&gt;Utilities are included in the Cypress Testing Library, and we encourage the following principles about when to use this library:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;If it relates to rendering components, it should deal with DOM nodes rather than component instances and not encourage dealing with them.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;It should generally test the application components and how the user would use them. We are making some trade-offs here because we’re using a computer and often a simulated browser environment, but in general, utilities should encourage tests that use the components how they’re intended to be used.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Utility implementations and APIs should be simple and flexible.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;You must resemble how users interact with your code (component, page, etc.); for Cypress Testing Library, we recommend the following priority:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Semantic Queries HTML5&lt;/strong&gt;. Remember that the user experience of interacting with these attributes varies greatly across browsers and assistive technology.&lt;/li&gt;
&lt;/ol&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;em&gt;findByRole&lt;/em&gt;: It can be used to find every element exposed in the accessibility tree. With the name option, you can filter the returned elements by their accessible name. It should be your top preference for just about everything. There’s not much you can’t get with this (if you can’t, your UI may be inaccessible). Most often, this will be used with the name option like so: getByRole(‘button,’ {name: /submit/i}).&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;em&gt;findByLabelText&lt;/em&gt;: This method is perfect for form fields. Users find elements using label text when navigating through a web page form. This method emulates that behavior, so it should be your top preference.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;em&gt;findByPlaceholderText&lt;/em&gt;: A placeholder is not a substitute for a label. But if that’s all you have, it’s better than alternatives.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;em&gt;findByText&lt;/em&gt;: Text content is the primary way users find elements outside forms. This method can find non-interactive elements (like divs, spans, and paragraphs).&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;em&gt;findByDisplayValue&lt;/em&gt;: The current value of a form element can be helpful when navigating a page with filled-in values.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;em&gt;findByAltText&lt;/em&gt;: If your element supports alt text (img, area, input, and any custom element), you can use this to find that element.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;em&gt;findByTitle&lt;/em&gt;: The title attribute is not consistently read by screen readers and is not visible by default for sighted users&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;2. Test IDs&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;em&gt;findByTestId&lt;/em&gt;: This approach is advisable only in situations where matching by role, or text is not feasible or meaningful (such as when the text is dynamic) since these attributes are not visible or audible to the user.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Cypress Testing Library supports both jQuery elements and DOM nodes. It is necessary because Cypress uses jQuery elements, while DOM Testing Library expects DOM nodes.&lt;/p&gt;

&lt;p&gt;In addition to supporting both jQuery elements and DOM nodes, Cypress Testing Library’s true capabilities can be harnessed on &lt;a href="https://www.lambdatest.com/cypress-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jun20_kj&amp;amp;utm_term=kj&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;Cypress cloud&lt;/a&gt; grid. Digital experience testing platforms like LambdaTest allow devs and QA to perform &lt;a href="https://www.lambdatest.com/automation-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jun20_kj&amp;amp;utm_term=kj&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;automation testing&lt;/a&gt; with Cypress on over 50+ real browsers and OS, including Chrome, Firefox, Edge, Electron, and WebKit.&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;strong&gt;&lt;em&gt;&lt;a href="https://www.lambdatest.com/learning-hub/jenkins?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jun20_kj&amp;amp;utm_term=kj&amp;amp;utm_content=learning_hub" rel="noopener noreferrer"&gt;Jenkins&lt;/a&gt; is an open-source automation server that is written entirely in Java. Learn how to do continuous integration with Jenkins with this comprehensive guide to Jenkins Tutorial.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  It’s a Wrap
&lt;/h2&gt;

&lt;p&gt;Writing maintainable tests for web user interfaces is essential to guarantee that applications are reliable and stable. Tests ensure the code works as expected and catch potential issues before production. However, as software evolves and changes over time, it’s essential to have tests that are easy to maintain and update. Maintaining tests that are tightly coupled to the implementation details of the code can take time and effort to manage, leading to test code that is complex and brittle.&lt;/p&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=jun20_kj&amp;amp;utm_term=kj&amp;amp;utm_content=learning_hub" rel="noopener noreferrer"&gt;Cypress tutorial&lt;/a&gt; will help you create modular and flexible tests using Cypress Testing Library, making them current and focusing on business behavior. In addition, it helps to ensure that tests remain an effective tool for verifying the quality and correctness of the code.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;“We must guarantee what we deliver works for everyone.” — Enrique A Decoss.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;I hope the Cypress Testing Library works for your team; in the meantime, let’s continue exploring it and adapting it to our current testing needs. Feel free to leave any comments or suggestions.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Happy Bug Hunting!&lt;/strong&gt;&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>cypress</category>
      <category>tutorial</category>
      <category>testing</category>
    </item>
    <item>
      <title>How To Handle iFrames In Cypress</title>
      <dc:creator>enriquee20</dc:creator>
      <pubDate>Thu, 09 Feb 2023 08:27:39 +0000</pubDate>
      <link>https://forem.com/testmuai/how-to-handle-iframes-in-cypress-54nk</link>
      <guid>https://forem.com/testmuai/how-to-handle-iframes-in-cypress-54nk</guid>
      <description>&lt;p&gt;In today’s web development world, finding standalone web apps is challenging. However, we can find most of these web apps work with each other where the integrations happen either from the Front-end or Back-end. One of the oldest yet simple integration strategies is using iFrames when examining these integrations.&lt;/p&gt;

&lt;p&gt;The &amp;lt; iframe &amp;gt; element has a somewhat convoluted history; introduced by Microsoft around 1997 and supported in early versions of Internet Explorer, it was incorporated into HTML 4.0, banished from XHTML, and reintroduced in HTML5.&lt;/p&gt;

&lt;p&gt;Using iFrames is a good idea from the modern web development perspective. Still, it decreases the app’s testability from the UI perspective. Each iFrame is treated as a separate document via the browser, adding extra steps in our &lt;a href="https://www.lambdatest.com/automation-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=feb09_kj&amp;amp;utm_term=kj&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;automation testing&lt;/a&gt; code as we need to map our elements inside those iFrames; imagine the complexity of handling nested iFrames. In addition, it could create flake test scripts if we don’t operate them correctly.&lt;/p&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=feb09_kj&amp;amp;utm_term=kj&amp;amp;utm_content=learning_hub" rel="noopener noreferrer"&gt;Cypress&lt;/a&gt; is an excellent framework for testing the front-end and back-end, but interacting with iFrames could be tricky. Testing iFrames with &lt;a href="https://www.lambdatest.com/blog/automation-testing-tools/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=feb09_kj&amp;amp;utm_term=kj&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;automated testing tools&lt;/a&gt; is necessary for many web apps. In this tutorial on how to handle iFrames in Cypress, you will learn how to write reliable tests for web applications that use iFrames and run them on the cloud Cypress grid.&lt;/p&gt;

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

&lt;h2&gt;
  
  
  What are iFrames?
&lt;/h2&gt;

&lt;p&gt;An iFrame in plain English is considered a window onto another document or site; the element’s purpose is to place content from one HTML document in the context of another (Basically embedded things).&lt;/p&gt;

&lt;p&gt;When we add an iFrame to a page, we look through a window from that page into another site, with full interactivity within that space. It is why Google Maps, YouTube, and others encourage users to embed their content using an iFrame element; rather than hosting any portion of the complex web app ourselves, our page views the web service through an integrated window.&lt;/p&gt;

&lt;p&gt;iFrame usage was much more popular before the explosion of JavaScript on the web (Resuscitated with HTML5). However, it remains vital in today’s web world (Especially with React and Flutter webs). Therefore, if we use iFrames to display external content on our website, we must ensure they work correctly.&lt;/p&gt;

&lt;p&gt;Why is it essential to test the iFrames on our web pages? The logical answer is to guarantee everything is working as desired. Therefore, we test iFrames during the &lt;a href="https://www.lambdatest.com/learning-hub/functional-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=feb09_kj&amp;amp;utm_term=kj&amp;amp;utm_content=learning_hub" rel="noopener noreferrer"&gt;functional testing&lt;/a&gt; phase. Also, we validate the E2E flows to determine if the entire application is working at the point where the end-user interacts with 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%2Fcdn-images-1.medium.com%2Fmax%2F3200%2F0%2AXujwjq-dr4xZk1eL.png" class="article-body-image-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%2AXujwjq-dr4xZk1eL.png" width="800" height="492"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;For a website, it means testing the website as it appears in a real browser. You’ll be loading up the website, serving accurate content, and then writing scripts to ensure you see what you expect. So let’s stop giving more context and start doing something worthwhile. Working with iFrames and Cypress.io is possible, and let’s demonstrate &lt;a href="https://www.lambdatest.com/blog/cypress-test-automation-framework/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=feb09_kj&amp;amp;utm_term=kj&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;Cypress test automation&lt;/a&gt; with some functional code.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Also, get started with this complete &lt;a href="https://www.lambdatest.com/selenium?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=feb09_kj&amp;amp;utm_term=kj&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;Selenium&lt;/a&gt; automation testing tutorial. Learn what Selenium is, its architecture, advantages and more for automated cross browser testing. Read more.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Is it possible to automate iFrames with Cypress?
&lt;/h2&gt;

&lt;p&gt;Cypress has some difficulties working with iFrames primarily because for all built-in “cy” DOM traversal commands, there is an open Issue #136 about the iFrame support, saying that we can still use iFrames in Cypress. In this blog on how to handle iFrames in Cypress, we will share how to interact with DOM elements inside an iFrame.&lt;/p&gt;

&lt;p&gt;For version purposes, we will use Cypress version 10.7; as a personal recommendation, always try stable versions before going directly to the latest version (Currently Cypress v12.5.1) as Cypress v11 has some changes related to Experimental features (cy.session errors), related Cypress v12, still evaluating the chrome web security configuration. Still using an older version of Cypress? or want to migrate to Cypress 10? Check out this blog on &lt;a href="https://www.lambdatest.com/blog/cypress-10-migration/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=feb09_kj&amp;amp;utm_term=kj&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;migrating your test automation suite to Cypress 10&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;npm install cypress@10.7 &lt;br&gt;
&lt;/code&gt;&lt;br&gt;
Cypress v10.7 was released on 08/30/2022.&lt;/p&gt;

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

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;The experimental feature of Cypress Studio has been brought back. It offers a visual method to create tests within Cypress by recording actions against the Application Under Test (AUT). This feature is only accessible for &lt;a href="https://www.lambdatest.com/blog/guide-to-end-to-end-testing-with-examples/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=feb09_kj&amp;amp;utm_term=kj&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;end-to-end tests&lt;/a&gt; and must be turned on through the e2e.experimentalStudio flag.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Support for Svelte &lt;a href="https://www.lambdatest.com/learning-hub/component-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=feb09_kj&amp;amp;utm_term=kj&amp;amp;utm_content=learning_hub" rel="noopener noreferrer"&gt;component testing&lt;/a&gt; has been introduced. This feature has been released as an Alpha version, indicating the possibility of changes that could cause breaking in future Cypress releases. The issue #23037 has been resolved with this feature.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The “Latest Runs” and “Average Duration” columns in the specifications list now have hover-activated actions to help connect the project to the Cypress Dashboard. This resolves issue #22932.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Instructions for connecting projects to the Cypress Dashboard and recording a first test run have been added as informational banners. Users who do not plan to use the Cypress Dashboard can dismiss the banners to avoid seeing them in the future, resolving issues #22933, #22934, #22798, and #22935.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The “Create Spec from Component” feature, introduced in v10.5.0, is now available for Vue.js projects with a custom specification pattern configuration. This resolves issue #23071.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Custom configuration for the Webpack dev server in Angular component testing projects can now be provided through the “projectConfig” key. This enables support for projects that do not follow Angular CLI conventions, addressing issue #23161.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The setSystemTime function has been introduced, allowing the Cypress clock to be set to a new time. This resolves issue #15424.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

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

&lt;ul&gt;
&lt;li&gt;The behavior of the cy.session() command has been improved such that it no longer clears the DOM after a validation function runs. As a result, the need for a cy.visit() command after running cy.session() when using a validation function has been eliminated, addressing issue &lt;a href="https://github.com/cypress-io/cypress/issues/22368" rel="noopener noreferrer"&gt;#22368&lt;/a&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Now, let’s focus on the iFrame test part.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 1:&lt;/strong&gt; First, we need to identify our iFrame inside the DOM and perform any action inside 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%2Fcdn-images-1.medium.com%2Fmax%2F3200%2F0%2A7nd7Cl-hDcFyc-vU.png" class="article-body-image-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%2A7nd7Cl-hDcFyc-vU.png" width="800" height="478"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 2:&lt;/strong&gt; Write spec file cypress/e2e/e2e_tests/test-iframe-cypress.cy.js that visit our web page and identifies the iFrame; we will use “iframetester.”&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;cy.visit('https://iframetester.com/?url=https://www.lambdatest.com/blog')
    //let's test iframe
    cy.get('#iframe-window')
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Our test looks good, and we can see the loaded 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%2Fcdn-images-1.medium.com%2Fmax%2F3200%2F0%2A4JZWWOyokAOxJyF2.png" class="article-body-image-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%2A4JZWWOyokAOxJyF2.png" width="800" height="419"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 3:&lt;/strong&gt; Let’s update our spec file to type something and click on search input for the &lt;a href="https://www.lambdatest.com/blog/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=feb09_kj&amp;amp;utm_term=kj&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;LambdaTest blog&lt;/a&gt; web page. Those elements are located inside the document’s body iFrame element.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;cy.visit('https://iframetester.com/?url=https://www.lambdatest.com/blog')
           //let's test iframe
           cy.get('#iframe-window')
               .should('be.visible')
               .should('not.be.empty')
               .then(($iframe) =&amp;gt; {
                   const $body = $iframe.contents().find('body')

           cy.wrap($body)
               .find(`input[name='s']`)
               .type('Cypress{enter}')

           })
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Unfortunately, the test fails; Browsers adhere to a strict same-origin policy. It means that browsers restrict access between &amp;lt; iframes &amp;gt; when their origin policies do not match.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 4:&lt;/strong&gt; To enable cross-domain iFrame access, we must set the property &lt;em&gt;chromeWebSecurity&lt;/em&gt; to false in the file &lt;em&gt;cypress.config.js&lt;/em&gt; and re-run the 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%2AM35Xq7rGOfrbg-7b.png" class="article-body-image-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%2AM35Xq7rGOfrbg-7b.png" width="800" height="419"&gt;&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; module.exports = defineConfig({
      chromeWebSecurity: false,
      e2e: {
        setupNodeEvents(on, config) {
          // implement node event listeners here
        },
      },
    })
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;After that, our test looks ok!&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%2A7wgMXmkf5nN5OEno.png" class="article-body-image-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%2A7wgMXmkf5nN5OEno.png" width="800" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;However, what about nested iFrames accessing an iFrame into an iFrame?&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 5:&lt;/strong&gt; We will use the iFrames web page for testing purposes. In this case, we will click the “iFrame 2” button, “Click Me 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%2Fcdn-images-1.medium.com%2Fmax%2F3200%2F0%2Ay3EJra7NycpFBrg5.png" class="article-body-image-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%2Ay3EJra7NycpFBrg5.png" width="800" height="472"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We will use the “contentDocument” property; if the iFrame and the iFrame’s parent document are the Same Origins. It returns a Document that is the active document in the inline Frame’s nested browsing context.&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("#frame1")
               .its('0.contentDocument')
               .its('body')
               .find('#frame3')
               .its('0.contentDocument')
               .its('body')
               .find('#frame4')
               .its('0.contentDocument')
               .its('body')
               .find("#click_me_4").click()
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Let’s run our spec file and see if the button is clicked 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%2AhnXfpmQSdSRCJnoz.png" class="article-body-image-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%2AhnXfpmQSdSRCJnoz.png" width="800" height="429"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Now, run your &lt;a href="https://www.lambdatest.com/playwright?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=feb09_kj&amp;amp;utm_term=kj&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;Playwright&lt;/a&gt; test scripts instantly on 50+ browser and OS combinations using the LambdaTest cloud. Read more.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  How to perform iFrames testing with Cypress?
&lt;/h2&gt;

&lt;p&gt;Now, let’s focus on Cypress and iFrame and understand the code step by step. We are using Cypress v10.7 for testing iFrames with 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;Subscribe to the &lt;a href="https://www.youtube.com/c/LambdaTest?sub_confirmation=1" rel="noopener noreferrer"&gt;LambdaTest YouTube channel&lt;/a&gt; for tutorials around &lt;a href="https://www.lambdatest.com/selenium-automation?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=feb09_kj&amp;amp;utm_term=kj&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;Selenium testing&lt;/a&gt;, &lt;a href="https://www.lambdatest.com/blog/playwright-framework/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=feb09_kj&amp;amp;utm_term=kj&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;Playwright browser 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=feb09_kj&amp;amp;utm_term=kj&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;Appium&lt;/a&gt;, and more.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Code Walkthrough:&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; import config from './config.json'
    import MainPage from '../../page-objects/components/MainPage'

    describe('iFrame Testing Cypress', () =&amp;gt; {
       before(function(){
           cy.visit(`${config.URL3}`)
       })

       it('Verify iframe working', () =&amp;gt;{

           //let's test iframe
           MainPage.iframeInput("#iframe-window",`input[name='s']`)
       })
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Let’s start defining our config.json file; here, we can include some data and URLs.&lt;/p&gt;

&lt;p&gt;Next, we need to establish our structure. As demonstrated in the following line of code, import MainPage from ‘../../page-objects/components/MainPage’, we aim to separate our &lt;a href="https://www.lambdatest.com/blog/finding-html-elements-using-cypress-locators/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=feb09_kj&amp;amp;utm_term=kj&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;Cypress locators&lt;/a&gt; from our tests using the &lt;a href="https://www.lambdatest.com/learning-hub/cypress-page-object-model?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=feb09_kj&amp;amp;utm_term=kj&amp;amp;utm_content=learning_hub" rel="noopener noreferrer"&gt;Page Object Model (POM)&lt;/a&gt; approach. This structure can be found within the “page-objects” folder.&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%2AtGAYL-KfR7iev-bJ_hWUQA.png" class="article-body-image-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%2AtGAYL-KfR7iev-bJ_hWUQA.png" width="526" height="528"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;As mentioned above, our methods and locators can be found there; in our example, we try to search on Google using an iFrame webpage (embedded Google search).&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; describe('iFrame Testing Cypress', () =&amp;gt; {
       before(function(){
           cy.visit(`${config.URL3}`)
       })
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;For this case, we are using a before() hook that will open up our page before all of our tests, and after that, we can test, keeping in mind if we need to switch URLs, we must use “cy.origin” as we will mention below.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;it('Verify iframe working', () =&amp;gt;{

           //let's test iframe
           MainPage.iframeInput("#iframe-window",`input[name='s']`)
       })


    export default class MainPage {

       static iframeInput(iframe_el,ele1){
           cy.get(iframe_el)
               .should('be.visible')
               .should('not.be.empty')
               .then(($iframe) =&amp;gt; {
                   const $body = $iframe.contents().find('body')
           //
           cy.wrap($body)
               .find(ele1)
               .type('Cypress{enter}')
           })
       }
    }

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;&lt;em&gt;Here’s this tutorial, learn what is &lt;a href="https://www.lambdatest.com/learning-hub/regression-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=feb09_kj&amp;amp;utm_term=kj&amp;amp;utm_content=learning_hub" rel="noopener noreferrer"&gt;Regression testing&lt;/a&gt;, its importance, types, and how to perform it.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Slow loading and empty iFrames validation
&lt;/h2&gt;

&lt;p&gt;Let’s understand the code below; first it is vital to get the iFrame locator. Since, as we know, many iFrames are a bit slower to load, or sometimes iFrames are broken, for those cases, we must implement some assertions “be.visible” or “not.be.empty” can do the work. Second, assign an alias, and then we can navigate inside the elements of the iFrame.&lt;/p&gt;

&lt;h2&gt;
  
  
  Reusing our Code
&lt;/h2&gt;

&lt;p&gt;We will probably access the iFrame’s elements in multiple tests; as we can see, we are using a static method and a class. The other approach is using Cypress custom commands inside the cypress/support/index.js. Not a big fan of using custom commands, but you can reuse the same code and create a custom command.&lt;/p&gt;

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

&lt;p&gt;We can now see that after it went through all those steps, it was able to grab the body of the iFrame. So then we can wrap it with Cypress, using that .find() to navigate inside the iFrame body.&lt;/p&gt;

&lt;p&gt;Cypress wrap command is used to yield objects placed in it and their resolved value, meaning that when you want to use Cypress commands like should, type, or click on an object or jQuery element, you should wrap.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Here's a complete &lt;a href="https://www.lambdatest.com/learning-hub/webdriver?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=feb09_kj&amp;amp;utm_term=kj&amp;amp;utm_content=learning_hub" rel="noopener noreferrer"&gt;Selenium WebDriver&lt;/a&gt; tutorial that covers what WebDriver is, its features, architecture and best practices.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Nested iFrames
&lt;/h2&gt;

&lt;p&gt;What about dealing with nested iFrames? It could be a nightmare and happens very often on multiple web pages. In those cases, we can use the “contentDocument” approach, which is relevant when navigating with various iFrames, as we can see from the image.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;it("Using 'contentDocument' - Nested iframes", () =&amp;gt; {

           cy.origin(`${config.URL4}`, () =&amp;gt; {
               cy.visit('/frames.html')
               cy.get("#frame1")
                   .its('0.contentDocument')
                   .its('body')
                   .find('#frame3')
                   .its('0.contentDocument')
                   .its('body')
                   .find('#frame4')
                   .its('0.contentDocument')
                   .its('body')
                   .find("#click_me_4").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%2F3200%2F1%2Apy9GxEDgsRakm-XjV6a47g.png" class="article-body-image-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%2F1%2Apy9GxEDgsRakm-XjV6a47g.png" width="800" height="472"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Cross-origin E2E
&lt;/h2&gt;

&lt;p&gt;One last part I would like to discuss is the “cy.origin”, as we are using version 10.7. This feature is not fully available if we don’t activate the experimental feature -&amp;gt; “experimentalSessionAndOrigin: true.” As you probably noticed, we used a new domain -&amp;gt; “&lt;a href="https://www.play1.automationcamp.ir%E2%80%9D" rel="noopener noreferrer"&gt;https://www.play1.automationcamp.ir”&lt;/a&gt; but also we need to visit the specific web page.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;`cy.origin(`${config.URL4}`, () =&amp;gt; {
           cy.visit('/frames.html')`
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Here is the &lt;a href="https://www.lambdatest.com/learning-hub/test-execution?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=feb09_kj&amp;amp;utm_term=kj&amp;amp;utm_content=learning_hub" rel="noopener noreferrer"&gt;test execution&lt;/a&gt;, which indicates that our Cypress iFrame testing approach is working:&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%2AuHRuX1LXB4v6k2kl.png" class="article-body-image-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%2AuHRuX1LXB4v6k2kl.png" width="800" height="393"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In the next section of this tutorial on how to handle iFrames in Cypress, we will learn how to run our tests in the Cypress cloud grid.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;LT Browser is a live &lt;a href="https://www.lambdatest.com/mobile-friendly-test?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=feb09_kj&amp;amp;utm_term=kj&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;mobile friendly test&lt;/a&gt; tool. It helps you to perform live mobile friendly test on multiple screen resolutions while surfing your website.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  How to handle iFrames in Cypress on the cloud grid?
&lt;/h2&gt;

&lt;p&gt;We can utilize a Cypress cloud grid such as LambdaTest, which offers automated &lt;a href="https://www.lambdatest.com/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=feb09_kj&amp;amp;utm_term=kj&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;cross-browser testing&lt;/a&gt; on over 40 browsers and operating systems, and &lt;a href="https://www.lambdatest.com/cypress-parallel-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=feb09_kj&amp;amp;utm_term=kj&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;Cypress parallel testing&lt;/a&gt; to speed up test execution and facilitate large-scale &lt;a href="https://www.lambdatest.com/cypress-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=feb09_kj&amp;amp;utm_term=kj&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;Cypress testing&lt;/a&gt;. This will result in enhanced overall test coverage, leading to a better quality product, as we can test various combinations using the same test scripts.&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 get started with &lt;a href="https://www.lambdatest.com/cypress-e2e-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=feb09_kj&amp;amp;utm_term=kj&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;Cypress e2e testing&lt;/a&gt;, follow the below-mentioned steps:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Install &lt;a href="https://www.lambdatest.com/blog/cypress-cli-on-lambdatest/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=feb09_kj&amp;amp;utm_term=kj&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;LambdaTest Cypress CLI&lt;/a&gt; on your machine. Trigger the following command to install the same:&lt;/li&gt;
&lt;/ol&gt;

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

&lt;ol&gt;
&lt;li&gt;After installation is completed, set up the configuration using the below command:&lt;/li&gt;
&lt;/ol&gt;

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

&lt;ol&gt;
&lt;li&gt;Once the command is completed, lambdatest-config.json is created in the project folder. Next, enter the LambdaTest credentials from the &lt;a href="https://accounts.lambdatest.com/detail/profile?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=feb09_kj&amp;amp;utm_term=kj&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;LambdaTest Profile Section&lt;/a&gt;.
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; "lambdatest_auth": {
          "username": "&amp;lt;Your LambdaTest username&amp;gt;",
          "access_key": "&amp;lt;Your LambdaTest access key&amp;gt;"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;Here is how you can configure the required browser &amp;amp; OS combinations in lambdatest-config.json:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; {
      "lambdatest_auth": {
         "username": "",
         "access_key": ""
      },
      "browsers": [
         {
            "browser": "MicrosoftEdge",
            "platform": "Windows 10",
            "versions": [
               "latest"
            ]
         },
         {
            "browser": "Chrome",
            "platform": "Windows 11",
            "versions": [
               "latest"
            ]
         },
         {
            "browser": "Chrome",
            "platform": "MacOS Monterey",
            "versions": [
               "latest"
            ]
         }
      ],
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;The run_settings section in the JSON file contains the desired Cypress test suite capabilities, including Cypress_version, build_name (Cypress-iframe), number of parallel sessions, etc.
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;"run_settings": {
         "cypress_config_file": "cypress.config.js",
         "build_name": "build-Cypress-iframes",
         "parallels": 5,
         "specs": "./cypress/e2e/e2e_tests/*.cy.js",
         "pluginsFile": true,
         "ignore_files": "",
         "npm_dependencies": {
            "cypress": "10.7.0"
         },
         "feature_file_suppport": true
      },
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;The “tunnel_settings” in the JSON file allows you to establish a connection between your local system and the LambdaTest servers through an SSH-based integration tunnel. With this tunnel in place, you can test &lt;a href="https://accounts.lambdatest.com/detail/profile?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=feb09_kj&amp;amp;utm_term=kj&amp;amp;utm_content=webpage?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=feb09_kj&amp;amp;utm_term=kj&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;locally hosted pages&lt;/a&gt; on all browsers supported by Cypress on LambdaTest.
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  "tunnel_settings": {
        "tunnel": false,
        "tunnelName": null
    }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;With the setup complete, it’s time to run the tests. Keep in mind that the “parallels” field in the “run_settings” file is set to five, meaning the tests will run in parallel without additional parameters. Note that the code used in previous tests remains unchanged when utilizing the cloud grid.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;code&gt;lambdatest-cypress run&lt;br&gt;
&lt;/code&gt;&lt;br&gt;
Shown below is the test execution status from the &lt;a href="https://automation.lambdatest.com/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=feb09_kj&amp;amp;utm_term=kj&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;LambdaTest Automation Dashboard&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%2AH-ZNDmI9jqeHmaA7.png" class="article-body-image-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%2AH-ZNDmI9jqeHmaA7.png" width="800" height="479"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If we click on any of the tests, we can see the details of our Cypress test scripts video of the execution and the actual code executed in Cypress Grid; pretty neat.&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%2AjBEiZAd4W9iUzro3.png" class="article-body-image-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%2AjBEiZAd4W9iUzro3.png" width="800" height="477"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now, let’s see more details about our test code, click on the button next to our test title. It will open a page, and we can explore our code or identify some issues in case of failure.&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-nWDiiYx3ix8lpok.png" class="article-body-image-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-nWDiiYx3ix8lpok.png" width="800" height="474"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;To view test performance metrics, go to the &lt;a href="https://analytics.lambdatest.com/test-overview?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=feb09_kj&amp;amp;utm_term=kj&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;LambdaTest Analytics Dashboard&lt;/a&gt;. The Test Overview provides an overview of tests with stable behavior, while the Test Summary shows the total number of passed or failed tests and any completed or pending 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%2F3200%2F0%2A1bLKeADWUL7SLI88.png" class="article-body-image-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%2A1bLKeADWUL7SLI88.png" width="800" height="402"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If you are a developer or a tester and have a basic understanding of Cypress and want to take your knowledge to the next level, then this Cypress 101 certification course is for you.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;In this tutorial, learn what is &lt;a href="https://www.lambdatest.com/learning-hub/regression-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=feb09_kj&amp;amp;utm_term=kj&amp;amp;utm_content=learning_hub" rel="noopener noreferrer"&gt;Regression testing&lt;/a&gt;, its importance, types, and how to perform it.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Wrapping Up
&lt;/h2&gt;

&lt;p&gt;Working with iFrames could be a big deal with Cypress, but I hope this blog on how to handle iFrames in Cypress helps you overcome common issues I ran into with them. Even though Cypress has limitations with iFrames, there are ways to work around them.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;“We must guarantee what we deliver works for everyone.” — Enrique A Decoss.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;I hope the Cypress team addresses the native way to use “switchToFrame” soon; in the meantime, let’s continue using the workarounds available. Feel free to leave any comments or suggestions.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Happy Bug Hunting!&lt;/strong&gt;&lt;/p&gt;

</description>
      <category>dicsuss</category>
      <category>cypresss</category>
      <category>iframes</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>How To Write End-To-End Tests Using Cypress App Actions</title>
      <dc:creator>enriquee20</dc:creator>
      <pubDate>Wed, 08 Feb 2023 10:43:46 +0000</pubDate>
      <link>https://forem.com/testmuai/how-to-write-end-to-end-tests-using-cypress-app-actions-ic4</link>
      <guid>https://forem.com/testmuai/how-to-write-end-to-end-tests-using-cypress-app-actions-ic4</guid>
      <description>&lt;p&gt;When I started writing tests with &lt;a href="https://www.lambdatest.com/learning-hub/cypress-tutorial?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=feb08_kj&amp;amp;utm_term=kj&amp;amp;utm_content=learning_hub" rel="noopener noreferrer"&gt;Cypress&lt;/a&gt;, I was always going to use the user interface to interact and change the application’s state when running tests.&lt;/p&gt;

&lt;p&gt;This could be beneficial since it gives you the same behavior as an end-user interacting with the application.&lt;/p&gt;

&lt;p&gt;But this is only sometimes the case. Sometimes, you only need to manipulate the state in your application without using the UI.&lt;/p&gt;

&lt;p&gt;You might have already tested it in a different test case and only need the state to test the next feature. In this case, using the UI to interact with the application could be redundant and time-consuming.&lt;/p&gt;

&lt;p&gt;However, there is another way to bypass the UI and manipulate the state of your application to get the results you want without using the user interface, giving you a fast and instant result.&lt;/p&gt;

&lt;p&gt;If some of your tests require the actual state to be available inside your application, you no longer need to use the UI. Instead, you can use &lt;strong&gt;App Actions&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;In this blog on Cypress App Actions, you will learn how Cypress App Actions differs from Page Object Model and how you will run tests with Cypress App Actions in a cloud grid like LambdaTest.&lt;/p&gt;

&lt;h2&gt;
  
  
  What are App Actions?
&lt;/h2&gt;

&lt;p&gt;App Actions are shortcuts or actions inside your application that will help you change and manipulate your application’s state without using the graphical user interface (GUI).&lt;/p&gt;

&lt;p&gt;Actions are one of the most exciting new features of &lt;a href="https://www.lambdatest.com/cypress-automation-tool?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=feb08_kj&amp;amp;utm_term=kj&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;Cypress automation&lt;/a&gt; tool. They enable you to extend your app’s functionality by adding an unlimited number of custom commands. They are the equivalent of writing a Cypress module but with much higher developer velocity.&lt;/p&gt;

&lt;p&gt;Each action has its state, so any time the state changes, the test will be re-run automatically. With Cypress App actions, you can automatically log users, fill out forms, click buttons, and much more with little or no effort.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Now, perform manual or automated cross browser &lt;a href="https://www.lambdatest.com/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=feb08_kj&amp;amp;utm_term=kj&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;testing web&lt;/a&gt; on 3000+ browsers online. Deploy and scale faster with the most powerful cross browser testing tool online.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Cypress App Actions vs. Page Object Model
&lt;/h2&gt;

&lt;p&gt;The page object model is a popular design pattern when it comes to &lt;a href="https://www.lambdatest.com/cypress-e2e-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=feb08_kj&amp;amp;utm_term=kj&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;Cypress E2E testing&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;The &lt;a href="https://www.lambdatest.com/learning-hub/cypress-page-object-model?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=feb08_kj&amp;amp;utm_term=kj&amp;amp;utm_content=learning_hub" rel="noopener noreferrer"&gt;Cypress page object model&lt;/a&gt; serves some good purposes, like preventing code duplication, but like anything else, the page object model design pattern has its pros and cons.&lt;/p&gt;

&lt;h2&gt;
  
  
  Page Object Model (POM)
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Page objects&lt;/strong&gt; help to keep tests organized and maintainable by encapsulating DOM interactions into reusable functions. This way, if the UI changes, you only need to update the page object methods rather than doing changes in your entire &lt;a href="https://www.lambdatest.com/learning-hub/test-suite?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=feb08_kj&amp;amp;utm_term=kj&amp;amp;utm_content=learning_hub" rel="noopener noreferrer"&gt;test suite&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;However, page objects can easily become too long to read or understand when your project grows larger and larger, making it challenging to find the relevant code for a particular test.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;App actions&lt;/strong&gt;, on the other hand, are written as general-purpose functions that can be reused across multiple tests. The most important benefit to Cypress App Actions is that it completely bypasses the user interface, making your test suites much more performant.&lt;/p&gt;

&lt;p&gt;This makes them more flexible since you can create many custom actions, but also more difficult to debug since there is no clear structure. When deciding which approach to take, it’s essential to weigh the tradeoffs and decide what will work best for your specific needs.&lt;/p&gt;

&lt;h2&gt;
  
  
  Shortcomings of Page Object Model?
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Page objects can be tricky to work with because they introduce an additional state level into your tests that is separate from the application’s initial state.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Page objects make it difficult for you to debug and may lead you astray when trying to understand exactly what went wrong with a test case since the tests depend on the previous state instead of the initial state of the application.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Page objects could make your test cases extremely slow and inefficient since they always have to use the user interface to interact with the application.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;It’s crucial to debug websites for Safari before pushing them live. In this article, we look at how to debug websites using &lt;a href="https://www.lambdatest.com/blog/debug-websites-using-safari-developer-tools/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=feb08_kj&amp;amp;utm_term=kj&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;Dev tool in Safari&lt;/a&gt;.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Why Cypress App Actions?
&lt;/h2&gt;

&lt;p&gt;Let’s say we have a sample to-do application in which a user can add and delete to-do items, and there are also featureful to-dos at once.&lt;/p&gt;

&lt;p&gt;Let’s say we want to test the button which deletes all to-dos. To perform &lt;a href="https://www.lambdatest.com/cypress-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=feb08_kj&amp;amp;utm_term=kj&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;Cypress testing&lt;/a&gt; of this feature, we first visit the page with Cypress, add the to-dos, and then press the delete button to see if this new feature works.&lt;/p&gt;

&lt;p&gt;If we have done this the regular way (using the graphical user interface) and not by using Cypress App Actions, it will take some time for Cypress to type some to-dos in a text input and add them one by one. Therefore the application needs more time to be thoroughly tested.&lt;/p&gt;

&lt;p&gt;However, this amount of time looks insignificant in this basic example. What if you had an extensive application and your tests needed the application to run some actions for them to run?&lt;/p&gt;

&lt;p&gt;If you decide to use the GUI, it will significantly lower your application’s performance and make your test suites run for hours.&lt;/p&gt;

&lt;p&gt;That’s when Cypress App Actions come in, with app actions, you no longer need to interact with the user interface.&lt;/p&gt;

&lt;p&gt;If you want some to-dos to be added to the list, you can easily write an action inside of your application (app action), which will do that for you without interacting with the graphical user interface, making it work instantly, cutting out all the time required for the user interface to respond.&lt;/p&gt;

&lt;h2&gt;
  
  
  How to run tests using Cypress App Actions?
&lt;/h2&gt;

&lt;p&gt;I will create a simple one-page front-end-only to-do list application where users can add, check, uncheck, and delete to-dos.&lt;/p&gt;

&lt;p&gt;The application is written in React with the help of TailwindCSS to make it look better. Here is the code of the application.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// App.jsx
    import React, { useState } from 'react'

    const App = () =&amp;gt; {
      const [todos, setTodos] = useState([])
      const [input, setInput] = useState('')

      const addTodoHandler = e =&amp;gt; {
        e.preventDefault()
        if (!input) return
        setTodos([...todos, { title: input, done: false }])
        setInput('')
      }

      const updateTodoHandler = (index, done) =&amp;gt; {
        const newTodos = [...todos]
        newTodos[index].done = done
        setTodos(newTodos)
      }

      const deleteHandler = index =&amp;gt; {
        const newTodos = todos.filter((todo, i) =&amp;gt; i !== index)
        setTodos(newTodos)
      }

      const deleteAll = () =&amp;gt; {
        setTodos([])
      }

      return (
        &amp;lt;div className='w-full p-10 max-w-md mx-auto flex flex-col gap-5'&amp;gt;
          &amp;lt;h2 className='text-center font-bold text-3xl mb-4'&amp;gt;To do APP&amp;lt;/h2&amp;gt;

          &amp;lt;form className='flex flex-col gap-1' onSubmit={addTodoHandler}&amp;gt;
            &amp;lt;input
              className='outline-none px-5 py-2 rounded-lg border'
              placeholder='Add new todo'
              type='text'
              data-cy='new-todo-input'
              value={input}
              onChange={e =&amp;gt; setInput(e.target.value)}
            /&amp;gt;
            &amp;lt;button
              data-cy='submit-button'
              className='py-2 px-5 rounded-lg bg-gray-100 hover:bg-gray-200 active:bg-gray-100'
            &amp;gt;
              Submit
            &amp;lt;/button&amp;gt;
            &amp;lt;button
              onClick={deleteAll}
              type='button'
              data-cy='delete-all-button'
              className='py-2 px-5 rounded-lg bg-red-100 hover:bg-red-200 text-red-500'
            &amp;gt;
              Delete All
            &amp;lt;/button&amp;gt;
          &amp;lt;/form&amp;gt;
          &amp;lt;div className='flex flex-col gap-5'&amp;gt;
            {todos?.map((todo, _idx) =&amp;gt; (
              &amp;lt;div
                key={_idx}
                data-cy='todo-item'
                className='flex justify-between items-center select-none gap-5 p-2 border rounded-lg cursor-pointer hover:bg-gray-100'
              &amp;gt;
                &amp;lt;div className='flex items-center gap-2 w-full'&amp;gt;
                  &amp;lt;input
                    onChange={e =&amp;gt; updateTodoHandler(_idx, e.target.checked)}
                    checked={todo.done}
                    type='checkbox'
                    data-cy='todo-checkbox'
                  /&amp;gt;
                  &amp;lt;p data-cy='todo-title'&amp;gt;{todo.title}&amp;lt;/p&amp;gt;
                &amp;lt;/div&amp;gt;

                &amp;lt;button
                  onClick={() =&amp;gt; deleteHandler(_idx)}
                  className='text-sm text-red-500  hover:bg-red-100 rounded-sm p-2 z-50'
                  data-cy='todo-delete-button'
                &amp;gt;
                  Delete
                &amp;lt;/button&amp;gt;
              &amp;lt;/div&amp;gt;
            ))}
          &amp;lt;/div&amp;gt;
        &amp;lt;/div&amp;gt;
      )
    }

    export default App
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;As you might have noticed, I have added a new attribute for specific HTML tags, for example, the submit button has a new attribute of data-cy='submit-button’ this will be useful as a selector in our spec files to get access to the element, this is also one of the best practices of writing tests 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=feb08_kj&amp;amp;utm_term=kj&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;Cypress test automation&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;We can also create a new custom command in our cypress/support/commands.js file for this selector and re-use it later on.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Cypress.Commands.add('getBySel', (selector, ...args) =&amp;gt; {
      return cy.get(`[data-cy=${selector}]`, ...args)
    })
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Example usage:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    cy.getBySel('submit-button').should(...)

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This is what the application looks like:&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%2ASJrIoeJU5mQVtd5g.png" class="article-body-image-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%2ASJrIoeJU5mQVtd5g.png" width="456" height="255"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now that it is set up and works perfectly, it is time to install Cypress and write some tests.&lt;/p&gt;

&lt;h2&gt;
  
  
  Installing Cypress
&lt;/h2&gt;

&lt;p&gt;Installing Cypress is quite easy and straightforward.&lt;/p&gt;

&lt;p&gt;1- Run the following command 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;yarn add -D cypress
&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%2F1%2ATil0_dsSdk45mPqWYWfTXg.png" class="article-body-image-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%2ATil0_dsSdk45mPqWYWfTXg.png" width="557" height="273"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;2- Add the following scripts to your &lt;code&gt;package.json&lt;/code&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:open": "cypress open",
        "cypress:run": "cypress run"
    }

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;3- Now that Cypress has been installed, run the following command to launch Cypress.&lt;br&gt;
&lt;/p&gt;

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

&lt;/div&gt;



&lt;p&gt;4- Select E2E testing after Cypress launches.&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%2F2350%2F1%2AgxtN0ZNlV7E3u6PmNSEmag.png" class="article-body-image-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%2F2350%2F1%2AgxtN0ZNlV7E3u6PmNSEmag.png" width="800" height="367"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;5- Click Continue.&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%2Agj3Oe1c8pRht-llGnb9DcA.png" class="article-body-image-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%2Agj3Oe1c8pRht-llGnb9DcA.png" width="800" height="519"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;6- Choose your preferred browser (I will use 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%2F2000%2F1%2At8EuTbB-PwgdcTmtpPOrRg.png" class="article-body-image-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%2At8EuTbB-PwgdcTmtpPOrRg.png" width="800" height="488"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;7- After your browser opens up, click on “Create new empty spec”.&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%2AUKGKZqByiAmg0-lJ9gIzqA.png" class="article-body-image-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%2AUKGKZqByiAmg0-lJ9gIzqA.png" width="800" height="489"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;8- This will create a new spec file in which we can write our 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%2F1%2AMwpBBKMnF8WbNowMfjK3eQ.png" class="article-body-image-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%2AMwpBBKMnF8WbNowMfjK3eQ.png" width="756" height="380"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;9- Now, our spec has been added to the cypress/e2e folder, and we can run it with 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%2F2000%2F1%2A29QT54lLkkKVUiSdMUxmHA.png" class="article-body-image-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%2A29QT54lLkkKVUiSdMUxmHA.png" width="329" height="343"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;This article explains the &lt;a href="https://www.lambdatest.com/blog/emulator-vs-simulator-vs-real-device/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=feb08_kj&amp;amp;utm_term=kj&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;emulator vs simulator&lt;/a&gt; vs real device differences, the learning of which can help you select the right mobile testing solution for your business.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Editing the Cypress configurations
&lt;/h2&gt;

&lt;p&gt;Since we are running a React application, I will set the baseURL of the Cypress configurations so that we can access our app easily.&lt;/p&gt;

&lt;p&gt;Here is my Cypress config file in &lt;code&gt;./cypress.config.js&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  // cypress.config.js
    const { defineConfig } = require('cypress')

    module.exports = defineConfig({
      e2e: {
        setupNodeEvents (on, config) {
          // implement node event listeners here
        },
        // setting up the base URL of our application
        baseUrl: '&amp;lt;http://localhost:3000&amp;gt;'
      }
    })
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;As I mentioned above, our goal here is to do some tests that require the application to at least have two or three to-do entries inside of it.&lt;/p&gt;

&lt;p&gt;If we had to use the old approach to run these tests, we’d have to use the user interface to type the todo titles and add them to the list, and after that, run the tests on them.&lt;/p&gt;

&lt;p&gt;So let’s try it and see why it’s &lt;strong&gt;not the right choice&lt;/strong&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Running tests without Cypress App Actions (regular approach)
&lt;/h2&gt;

&lt;p&gt;This is how the tests are written &lt;strong&gt;without Cypress App Actions (using the UI).&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;describe('Todo application', () =&amp;gt; {
      beforeEach(() =&amp;gt; {
        cy.visit('/')

        todos.forEach(todo =&amp;gt; {
          cy.getBySel('new-todo-input').type(todo)
          cy.getBySel('submit-button').click()
        })
      })

      it('should delete all todos', () =&amp;gt; {
        cy.getBySel('delete-all-button').click()
        cy.getBySel('todo-item').should('not.exist')
      })

      it('should delete one entry', () =&amp;gt; {
        cy.getBySel('todo-delete-button')
          .first()
          .click()
        cy.getBySel('todo-item').should('have.length', todos.length - 1)
      })

      it('should delete multiple entries', () =&amp;gt; {
        // deletes two items
        for (let i = 0; i &amp;lt; 2; i++) {
          cy.getBySel('todo-delete-button')
            .first()
            .click()
        }

        cy.getBySel('todo-item').should('have.length', todos.length - 2)
      })

      it('should check one item', () =&amp;gt; {
        cy.getBySel('todo-checkbox')
          .first()
          .click()

        cy.getBySel('todo-checkbox').should('be.checked')
      })

      it('should check multiple items', () =&amp;gt; {
        cy.getBySel('todo-checkbox')
          .first()
          .click()

        cy.getBySel('todo-checkbox')
          .eq(1)
          .click()

        cy.getBySel('todo-checkbox')
          .first()
          .should('be.checked')
        cy.getBySel('todo-checkbox')
          .eq(1)
          .should('be.checked')
      })
    })
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;As you can see in the beforeEach hook, we are inserting some data into the application, this happens before each of the tests or it blocks.&lt;/p&gt;

&lt;p&gt;Now, let’s run the tests and see why this method of testing applications is actually not optimal or efficient.&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%2AhXE1zV6x2YsLYo1QtrKxxA.gif" class="article-body-image-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%2AhXE1zV6x2YsLYo1QtrKxxA.gif" width="600" height="338"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The total time required for the tests to complete was 9 seconds, for such a small application like this, it is considered a very low performant test 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%2Fcdn-images-1.medium.com%2Fmax%2F2000%2F1%2AcYxbxb3Xwd_upIMR1wMn2g.png" class="article-body-image-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%2AcYxbxb3Xwd_upIMR1wMn2g.png" width="722" height="538"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Also, this depends heavily on the user interface and element selectors, if one of the selectors of your application changes in future updates, your code will not be able to locate the elements and your tests will easily fail.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Need a great solution for cross browser testing on Safari? Forget about emulators or simulators — use real online browsers. Try LambdaTest to test on &lt;a href="https://www.lambdatest.com/test-on-safari-browsers?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=feb08_kj&amp;amp;utm_term=kj&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;safari browser online&lt;/a&gt;.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Using Cypress App Actions
&lt;/h2&gt;

&lt;p&gt;Now it’s time to run the same &lt;a href="https://www.lambdatest.com/cypress-ui-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=feb08_kj&amp;amp;utm_term=kj&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;Cypress UI tests&lt;/a&gt; using app actions and see why they are a better choice and how they can improve the test performance.&lt;/p&gt;

&lt;p&gt;In order to use certain functions inside of our application, we have to set it as a property of the window object and re-use those functions inside our spec files.&lt;/p&gt;

&lt;p&gt;So, let’s add the functions that we want to the window object&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; useEffect(() =&amp;gt; {
        if (window.Cypress) {
          // the "todos" argument will be an array of todos
          // example: [{ title: "Run some tests", done: false }]
          window.addTodos = todos =&amp;gt; setTodos(todos)
        }
    }, [])

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;With the use of the useEffect lifecycle hook, we’ll be able to use the window object inside of a React application, read more about &lt;a href="https://reactjs.org/docs/hooks-reference.html#useeffect" rel="noopener noreferrer"&gt;React useEffect hook&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;The addTodos function will enable us to send an array of to-dos to the application without using the user interface.&lt;/p&gt;

&lt;p&gt;Now we can use the addTodos function inside of our spec files.&lt;/p&gt;

&lt;p&gt;To access the window object, Cypress has provided us with the window() function, which we can call anywhere in our tests. We chain the invoke() function to it and pass the method’s name on the window object and the arguments it requires.&lt;/p&gt;

&lt;p&gt;The spec file for app actions &lt;code&gt;./cypress/e2e/spec.cy.js&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; let todos = ['Buy milk', 'Buy eggs', 'Buy bread', 'Buy butter', 'Buy cheese']

    describe('Todo application', () =&amp;gt; {
      beforeEach(() =&amp;gt; {
        cy.visit('/')

        cy.window().invoke(
          // name of the method
          'addTodos',
          // ...args (in this case we only have one argument "todos")
          todos.map(todo =&amp;gt; ({ title: todo, done: false }))
        )
      })

      it('should delete all todos', () =&amp;gt; {
        cy.getBySel('delete-all-button').click()
        cy.getBySel('todo-item').should('not.exist')
      })

      it('should delete one entry', () =&amp;gt; {
        cy.getBySel('todo-delete-button')
          .first()
          .click()
        cy.getBySel('todo-item').should('have.length', todos.length - 1)
      })

      it('should delete multiple entries', () =&amp;gt; {
        cy.getBySel('todo-delete-button')
          .first()
          .click()

        cy.getBySel('todo-delete-button')
          .first()
          .click()

        cy.getBySel('todo-item').should('have.length', todos.length - 2)
      })

      it('should check one item', () =&amp;gt; {
        cy.getBySel('todo-checkbox')
          .first()
          .click()

        cy.getBySel('todo-checkbox').should('be.checked')
      })

      it('should check multiple items', () =&amp;gt; {
        cy.getBySel('todo-checkbox')
          .first()
          .click()

        cy.getBySel('todo-checkbox')
          .eq(1)
          .click()

        cy.getBySel('todo-checkbox')
          .first()
          .should('be.checked')
        cy.getBySel('todo-checkbox')
          .eq(1)
          .should('be.checked')
      })
    })
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now, let’s run the tests and see the performance of the test 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%2Fcdn-images-1.medium.com%2Fmax%2F2000%2F0%2ARDzGK0Wtk4zbwTBN.gif" class="article-body-image-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%2ARDzGK0Wtk4zbwTBN.gif" width="600" height="338"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;As you can see, we are running exactly the same tests that we did before, but now we are getting a total time of tests of only &lt;strong&gt;1 second&lt;/strong&gt; which is almost &lt;strong&gt;800%&lt;/strong&gt; more efficient than the previous test.&lt;/p&gt;

&lt;p&gt;This will make your application much more performant in the long run, which would have been very difficult to run if we’d had to interact with the UI.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Check this article, and look at some aspects of &lt;a href="https://www.lambdatest.com/blog/iphone-simulators-on-windows/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=feb08_kj&amp;amp;utm_term=kj&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;ios emulator for pc&lt;/a&gt; and discuss some ways through which we can use iPhone Simulator on Windows.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Bonus: Running Cypress App Actions in the cloud with LambdaTest
&lt;/h2&gt;

&lt;p&gt;LambdaTest’s latest feature (&lt;a href="https://www.lambdatest.com/hyperexecute?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=feb08_kj&amp;amp;utm_term=kj&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;HyperExecute&lt;/a&gt;) now allows developers to run their &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=feb08_kj&amp;amp;utm_term=kj&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;end to end tests&lt;/a&gt; with the latest Cypress version available (Version 10.0).&lt;/p&gt;

&lt;p&gt;In this short tutorial on Cypress App Actions, I will show you how to run the same tests we wrote in the &lt;a href="https://www.lambdatest.com/cypress-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=feb08_kj&amp;amp;utm_term=kj&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;Cypress cloud&lt;/a&gt; on LambdaTest.&lt;/p&gt;

&lt;p&gt;LambdaTest provides an &lt;a href="https://www.lambdatest.com/online-device-farm?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=feb08_kj&amp;amp;utm_term=kj&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;online device farm&lt;/a&gt; that allows you to run your &lt;a href="https://www.lambdatest.com/blog/cypress-test-automation-framework/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=feb08_kj&amp;amp;utm_term=kj&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;Cypress automation&lt;/a&gt; tests on over 50 different real browsers and operating systems to increase the overall &lt;a href="https://www.lambdatest.com/learning-hub/test-coverage?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=feb08_kj&amp;amp;utm_term=kj&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;test coverage&lt;/a&gt; of your web application. This is achieved by running the same test scripts on various combinations of browsers and operating systems.&lt;/p&gt;

&lt;p&gt;Check out the &lt;a href="https://www.lambdatest.com/learning-hub/cypress-tutorial?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=feb08_kj&amp;amp;utm_term=kj&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;Cypress tutorial&lt;/a&gt; below to dive deep into the basics of the Cypress framework.&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;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=feb08_kj&amp;amp;utm_term=kj&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;LambdaTest YouTube channel&lt;/a&gt; for tutorials around &lt;a href="https://www.lambdatest.com/selenium-automation?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=feb08_kj&amp;amp;utm_term=kj&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;Selenium testing&lt;/a&gt;, &lt;a href="https://www.lambdatest.com/blog/playwright-framework/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=feb08_kj&amp;amp;utm_term=kj&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;Playwright browser 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=feb08_kj&amp;amp;utm_term=kj&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;Appium&lt;/a&gt;, and more.&lt;/p&gt;

&lt;h2&gt;
  
  
  Changing the configurations
&lt;/h2&gt;

&lt;p&gt;Before starting configuring our tests for LambdaTest, let’s make our application available on a public URL.&lt;/p&gt;

&lt;p&gt;I have deployed the to-do application on Vercel, which is public and available for LambdaTest to run tests on.&lt;/p&gt;

&lt;p&gt;Updating the &lt;code&gt;cypress.config.js&lt;/code&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: {
        setupNodeEvents (on, config) {
          // implement node event listeners here
        },
        // changed
        baseUrl: 'https://app-actions-cypress.vercel.app'
      }
    })
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now our application is ready to be tested on LambdaTest.&lt;/p&gt;

&lt;h2&gt;
  
  
  Downloading the HyperExecute CLI
&lt;/h2&gt;

&lt;p&gt;Go to &lt;a href="https://www.lambdatest.com/support/docs/cypressv10-on-hyperexecute/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=feb08_kj&amp;amp;utm_term=kj&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;this page&lt;/a&gt; and scroll until you see the table for the HyperExecute CLI executable files and download the one for your operating system.&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%2AQx7DopZ23EAfTA9Y.png" class="article-body-image-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%2AQx7DopZ23EAfTA9Y.png" width="800" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;After you do that, move the file to the root directory of your application &lt;code&gt;./hyperexecute.exe&lt;/code&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  HyperExecute YAML file
&lt;/h2&gt;

&lt;p&gt;All the test configurations that we need relating to LambdaTest will be specified inside this file.&lt;/p&gt;

&lt;p&gt;Now, create a &lt;code&gt;.yml&lt;/code&gt;with a name of your choice; I have named it &lt;code&gt;LambdaTest.yml&lt;/code&gt;. This is what my YAML file looks like for this specific test.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; version: 0.1
    runson: win
    cypress: true
    concurrency: 2
    autosplit: true

    pre:
      - npm install
      - npm install cypress --save-dev
    cacheKey: '{{ checksum "package.json" }}'
    cacheDirectories:
      - node_modules
    testDiscovery:
      mode: static
      type: raw
      command: ls cypress/e2e
    testRunnerCommand: npx cypress run  --spec ./cypress/e2e/$test --browser=chrome-95.0 --headed --config video=false
    cypressOps:
      Build: "Hyperexecute Cypress Sample Build"
      Tags: ["Hyperexecute", "Cypress", "Windows", "Autosplit"]
      BuildTags: ["Hyperexecute-Cypress"]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The &lt;code&gt;testDiscovery&lt;/code&gt; key is very important, with this, you can tell LambaTest where to look for your test files, and you can specify your directory inside of the command property.&lt;/p&gt;

&lt;p&gt;In my case, I have only one spec file, which is inside the &lt;code&gt;./cypress/e2e/&lt;/code&gt; directory. The ls &lt;code&gt;cypress/e2e&lt;/code&gt; command ensures that every file inside that directory will be picked up and tested.&lt;/p&gt;

&lt;p&gt;With the &lt;code&gt;testRunnerCommand&lt;/code&gt; key, you can run a regular Cypress command. You can also configure it by specifying arguments and flags. In this case, we are specifying it to run on a chrome browser version 95.0, and the browser is headed, etc.&lt;/p&gt;

&lt;p&gt;After this, we can perform &lt;a href="https://www.lambdatest.com/cypress-ui-automation?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=feb08_kj&amp;amp;utm_term=kj&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;Cypress UI automation&lt;/a&gt; on LambdaTest by uploading the tests using the &lt;code&gt;HyperExecute CLI&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;In your terminal, run the following command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    ./hyperexecute.exe --user &amp;lt;your-lambda-test-username&amp;gt; --key &amp;lt;your-lambda-test-access-key&amp;gt; --config &amp;lt;your-.yml-file&amp;gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;After replacing the user, access key, and config flags with your actual LambdaTest username and access key, and the YAML configuration file, in this case, LambdaTest.yml, run the command.&lt;/p&gt;

&lt;p&gt;You can get your access key through the HyperExecute tab in the LambdaTest dashboard.&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%2F3808%2F0%2AcnQZNSqD52ruYbmm.png" class="article-body-image-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%2F3808%2F0%2AcnQZNSqD52ruYbmm.png" width="800" height="239"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;HyperExecute will pick up the configurations and upload your test files to 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%2Aw2UZMwd_DCnIY13S.png" class="article-body-image-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%2Aw2UZMwd_DCnIY13S.png" width="680" height="305"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You will also see your tests running on the HyperExecute tab on 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%2F3812%2F0%2AkkVdHNVHWRGrLX4O.png" class="article-body-image-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%2F3812%2F0%2AkkVdHNVHWRGrLX4O.png" width="800" height="303"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You can see the status of your tests either by looking up the test on the LambdaTest dashboard or the HyperExecute 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%2F2000%2F1%2Ag4EJCOplfg8r_LBfICHIyA.png" class="article-body-image-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%2Ag4EJCOplfg8r_LBfICHIyA.png" width="719" height="410"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The Cypress 101 certification is intended for those who have already acquired some familiarity with Cypress and wish to improve their understanding and end-to-end testing skills. It is suitable for developers and testers who want to take their Cypress knowledge to the next level.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Here’s 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=feb08_kj&amp;amp;utm_term=kj&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;Appium Automation&lt;/a&gt; testing of your mobile applications.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

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

&lt;p&gt;App Actions and Page Object Model are two different ways to test an application, but they have their use cases.&lt;br&gt;
App actions, as the name suggests, are about writing down actions in the application code, which can change the state of your application and re-using them inside your test suites.&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>endtoendtesting</category>
      <category>cypress</category>
      <category>testing</category>
    </item>
    <item>
      <title>A Step-By-Step Guide To Cypress API Testing</title>
      <dc:creator>enriquee20</dc:creator>
      <pubDate>Tue, 07 Feb 2023 08:57:26 +0000</pubDate>
      <link>https://forem.com/testmuai/a-step-by-step-guide-to-cypress-api-testing-1460</link>
      <guid>https://forem.com/testmuai/a-step-by-step-guide-to-cypress-api-testing-1460</guid>
      <description>&lt;h2&gt;
  
  
  A Step-By-Step Guide To Cypress API Testing
&lt;/h2&gt;

&lt;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%2F2izbvnf9oxamvuu8v081.png" class="article-body-image-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%2F2izbvnf9oxamvuu8v081.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;API (Application Programming Interface) is a set of definitions and protocols for building and integrating applications. It’s occasionally referred to as a contract between an information provider and an information user establishing the content required from the consumer and the content needed by the producer.&lt;/p&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=feb07_kj&amp;amp;utm_term=kj&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;Cypress&lt;/a&gt; is a popular and user-friendly testing framework 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=feb07_kj&amp;amp;utm_term=kj&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;end-to-end (E2E) testing&lt;/a&gt; of web applications. It is particularly popular among developers and testers familiar with JavaScript, as it does not require additional libraries, dependencies, or drivers to install. Cypress can be easily installed using the Node Package Manager (NPM) and does not require additional setup or configuration. This makes it a good choice for those looking to quickly and easily set up E2E testing for their applications.&lt;/p&gt;

&lt;p&gt;Why Cypress 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=feb07_kj&amp;amp;utm_term=kj&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;API testing?&lt;/a&gt; Can we have a &lt;a href="https://www.lambdatest.com/automation-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=feb07_kj&amp;amp;utm_term=kj&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;test automation&lt;/a&gt; tool for everything? It could sound like a utopian dream for every company and testing team, but we can cover almost all possibilities with &lt;a href="https://www.lambdatest.com/cypress-automation-tool?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=feb07_kj&amp;amp;utm_term=kj&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;Cypress automation tool&lt;/a&gt;. It is a next-generation &lt;a href="https://www.lambdatest.com/learning-hub/front-end-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=feb07_kj&amp;amp;utm_term=kj&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;front-end testing&lt;/a&gt; framework; it constructs HTTP requests on behalf of the web applications as it is running. Although it might seem that Cypress is making these requests from the browser, it utilizes Node.js as the motor to create the HTTP requests to the API server.&lt;/p&gt;

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

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Test your &lt;a href="https://www.lambdatest.com/puppeteer-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=feb07_kj&amp;amp;utm_term=kj&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;Puppeteer testing&lt;/a&gt; scripts online. Deploy a quality build faster by running automated checks across over 3000+ browsers and OS combinations with the LambdaTest cloud.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;In this blog on &lt;a href="https://www.lambdatest.com/blog/how-to-test-api-with-cypress/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=feb07_kj&amp;amp;utm_term=kj&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;Cypress API Testing&lt;/a&gt;, you will learn how to use Cypress to write cleaner and more efficient code for API test automation.&lt;/p&gt;

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

&lt;h2&gt;
  
  
  Introduction to API Testing
&lt;/h2&gt;

&lt;p&gt;API testing is a form of software testing accomplished as a part of &lt;a href="https://www.lambdatest.com/learning-hub/integration-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=feb07_kj&amp;amp;utm_term=kj&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;integration testing&lt;/a&gt; to determine if they satisfy functionality, reliability, performance, and security expectations. API testing has recently been considered critical to the software testing process as it is faster and more reliable than UI-based tests.&lt;/p&gt;

&lt;p&gt;In addition, API testing allows the testers to find bugs earlier in the development process, usually before the UI is created. Finally, API testing allows requests that might not be allowed through the UI (Sometimes, the UI is not ready during API development).&lt;/p&gt;

&lt;p&gt;Understanding the flow of our APIs is necessary before starting to test them, and we need to understand a few essential technical requirements of the APIs.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;API Endpoints&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;An API endpoint is the entry point in a communication channel where two software mediators interact. The endpoint can be seen as how the APIs can access the resources they require from a server to fulfill their tasks. An API endpoint is a fancy word for a server or service URL. For example, &lt;a href="https://api.linkedin.com/v2/simpleJobPostings" rel="noopener noreferrer"&gt;https://api.linkedin.com/v2/simpleJobPostings&lt;/a&gt; is the endpoint for LinkedIn’s job posting API, or we can use &lt;a href="https://api.lambdatest.com/automation/api/v1" rel="noopener noreferrer"&gt;https://api.lambdatest.com/automation/api/v1&lt;/a&gt; endpoint for getting data from the LambdaTest platform.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Methods Supported&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;We need to understand the methods (POST, GET, PUT, DELETE, PATCH) supported by the API. Keep in mind those as we need to test them.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Input-Output Schema&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;It is essential to comprehend the type of input required and the response body content for the API (JSON, plain text, XML, or other).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Response Codes&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The response or status code is the most crucial API output that must be verified. The API response status codes are included in five classes or types. The first digit of the response code represents the response class, while the last two digits do not have any classification or categorization roles. The standard defines five types:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;&lt;em&gt;1xx Informational response&lt;/em&gt;&lt;/strong&gt; — the request was received, resuming the process.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;&lt;em&gt;2xx Successful&lt;/em&gt;&lt;/strong&gt; — the request was received, comprehended, and accepted.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;&lt;em&gt;3xx Redirection&lt;/em&gt;&lt;/strong&gt; — further action must be taken to complete the request.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;&lt;em&gt;4xx Client error&lt;/em&gt;&lt;/strong&gt; — the request contains the wrong syntax or cannot be fulfilled.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;&lt;em&gt;5xx Server error&lt;/em&gt;&lt;/strong&gt; — the server failed to fulfill a valid request.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;You can read through our earlier blog that deep dives into the &lt;a href="https://www.lambdatest.com/blog/how-to-get-response-status-code-using-apache-httpclient/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=feb07_kj&amp;amp;utm_term=kj&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;HTTP Status request&lt;/a&gt; to learn more about it.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Headers and Auth Requirements&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;API calls demand a variety of header fields. Headers include a wealth of information that can help track down issues when they occur.&lt;/p&gt;

&lt;p&gt;Typically, headers contain information regarding &lt;em&gt;the request, response body,&lt;/em&gt; and &lt;em&gt;request authorization&lt;/em&gt;. In addition, authentication is essential to confirm the credentials of a connection attempt. Therefore, most commercial APIs require API Key-based Authentication for their services (&lt;a href="https://www.lambdatest.com/support/api-doc/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=feb07_kj&amp;amp;utm_term=kj&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;LambdaTest API Documentation&lt;/a&gt;).&lt;/p&gt;

&lt;p&gt;Are you interested in learning more about API testing? Check out the TestuConf 2022 &lt;a href="https://www.lambdatest.com/testuconf-2022/phase-angle-of-api-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=feb07_kj&amp;amp;utm_term=kj&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;Phase Angle of API&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;In this &lt;a href="https://www.lambdatest.com/xcuitest?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=feb07_kj&amp;amp;utm_term=kj&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;XCUITest tutorial&lt;/a&gt;, learn about XCUITest framework and its benefits for mobile automation testing. Take a look at how XCUITest works and see how to use it to test your mobile applications.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Rest and GraphQL API Testing using Cypress
&lt;/h2&gt;

&lt;p&gt;In REST, an API endpoint is requested using the HTTP protocol to serve the data that the client needs, and the server returns the response based on the requested query. REST is a set of architectural practices, not a protocol or a standard. Therefore, API developers can implement REST in a variety of ways.&lt;/p&gt;

&lt;p&gt;GraphQL, as a query language, defines specifications of how a client application can ask for the required data from a remote server. As a result, the server application produces a response to the requested client query. The exciting thing to notice in GraphQL is that the client application can also query what it requires without relying on the server-side application to determine a query.&lt;/p&gt;

&lt;p&gt;Now we can start using Cypress for API testing, as Cypress is a standalone frontend &lt;a href="https://www.lambdatest.com/blog/automation-testing-tools/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=feb07_kj&amp;amp;utm_term=kj&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;automation testing tool&lt;/a&gt;; it creates HTTP requests on behalf of the web applications as it is executing. Cypress might appear to make these requests from the browser; it uses Node.js as an engine to make the HTTP requests to the API server.&lt;/p&gt;

&lt;p&gt;For &lt;a href="https://www.lambdatest.com/cypress-ui-automation?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=feb07_kj&amp;amp;utm_term=kj&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;Cypress UI automation&lt;/a&gt;, I’m currently using version 9.7.0; at this point, we don’t require any cool new experimental features for our Cypress API testing project. Regarding API testing Rest and GraphQL, we will use the &lt;a href="https://gorest.co.in/" rel="noopener noreferrer"&gt;Go REST&lt;/a&gt; website; let’s start with some basic test scripts to get familiar with automated Cypress API 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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fkfot3hq0wj694g131f4y.png" class="article-body-image-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%2Fkfot3hq0wj694g131f4y.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Let’s code our first test and get all the users from our API user’s endpoint; we will use an HTTP request with the syntax &lt;em&gt;cy.request&lt;/em&gt; (options):&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%2Frjldfd0xrjgzp5y56261.png" class="article-body-image-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%2Frjldfd0xrjgzp5y56261.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;For the code above, we make a ‘&lt;strong&gt;GET&lt;/strong&gt;‘ request to our users in the ‘gorest’ API route. We assert that the response returns a &lt;strong&gt;200&lt;/strong&gt; status code and prints the body response for that request. Now let’s run it and see the Cypress Test Runner result:&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%2F3hr0ahn4a19cam06b29u.png" class="article-body-image-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%2F3hr0ahn4a19cam06b29u.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Let’s understand the code above; we are using &lt;em&gt;cy.request&lt;/em&gt; with some parameters, first is the method &lt;em&gt;cy.request&lt;/em&gt; supports the following methods -&amp;gt; GET, POST, PUT, DELETE, PATCH, HEAD, OPTIONS, among others.&lt;/p&gt;

&lt;p&gt;Then the URL to request, and finally, the failOnStatusCode equal to false, avoiding our tests failing with other status codes different to 2xx and 3xx. One crucial part is creating an alias for our request to use for the assertions to validate the status code and JSON body or other necessary validations.&lt;/p&gt;

&lt;p&gt;Now, let’s create more requests using different methods with &lt;em&gt;cy.request&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%2Fb1v0ojn1x0y617hhyx7a.png" class="article-body-image-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%2Fb1v0ojn1x0y617hhyx7a.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Get started with this complete &lt;a href="https://www.lambdatest.com/selenium?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=feb07_kj&amp;amp;utm_term=kj&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;Selenium&lt;/a&gt; automation testing tutorial. Learn what Selenium is, its architecture, advantages and more for automated cross browser testing.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Cypress API Testing POST — Code
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; cy.request({
                method: 'POST',
                url: `${config.URL}`,
                failOnStatusCode: false,
                'auth': {
                    'bearer':`${config.Bearer_Rest}`
                },
                body: {'name':'Test6 API6', 
                'gender':'male', 
                'email':'test_api6@test.com', 
                'status':'active'}
            }).as('details')
            //Validate status code
            cy.get('@details').its('status').should('eq', 201)
            cy.get('@details').then((response) =&amp;gt; {
                let res = response.body
                att1 = res.id
                cy.log(att1)
            })
            cy.get('@details').then((response) =&amp;gt; {
                cy.log(JSON.stringify(response.body))
            })
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;For the code above, we send a ‘POST’ request to create a new user in the ‘gorest’ API route. We assert that the response returns a 201 (Success and a New resource have been created) status code and saves the id for future purposes (UPDATE, DELETE, PATCH). Besides that, we added a few fields for Bearer Authentication and body request to send the data required for the new user.&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%2Fp9mifgltji7xzha7rqex.png" class="article-body-image-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%2Fp9mifgltji7xzha7rqex.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Cypress API Testing Put and Delete — Code
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; cy.request({
               method: 'PUT',
               url: `${config.URL}`+att1,
               failOnStatusCode: false,
               'auth': {
                   'bearer': `${config.Bearer_Rest}`
               },
               body: {'name':'Test API_Update',
               'gender':'female',
               'email':'test_update@test.com',
               'status':'active'}
           }).as('details')
           //Validate status code
           cy.get('@details').its('status').should('eq', 200)
           cy.get('@details').then((response) =&amp;gt; {
               cy.log(JSON.stringify(response.body))
           })



    cy.request({
               method: 'DELETE',
               url: `${config.URL}`+att1,
               failOnStatusCode: false,
               'auth': {
                   'bearer': `${config.Bearer_Rest}`
               },
           }).as('details')
           //Validate response code
           cy.get('@details').its('status').should('eq', 204)
           cy.get('@details').then((response) =&amp;gt; {
               cy.log(JSON.stringify(response.body))
           })
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We can notice from the code above that the att1 global variable is part of the URL; as mentioned above, we need previous data to Update or Delete. Also, there is a new status code for our DELETE request; the response returns a 204 (there is no content to send in the response payload body.) Let’s see the execution results for those 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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Frff8zwk2o58wf47xekwy.png" class="article-body-image-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%2Frff8zwk2o58wf47xekwy.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;As QAs validate a status code 204, we should ask if this is the proper response; a successful response should be 200 (OK) if the response includes an entity describing the status or a 202 (Accepted). But, again, it is up to your current needs.&lt;/p&gt;

&lt;p&gt;It’s time to explore the GraphQL part; unlike a REST API, GraphQL requests are all sent to a single endpoint. We can easily use Cypress to fetch all the uses in our GraphQL endpoint. It will look like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; cy.request({
                method: 'POST',
                url: `${config.URL4}`,
                failOnStatusCode: false,
                header: {
                    'Accept-Encoding': 'application/json', 
                    'Content-Type' : 'application/json',
                    'bearer': `${config.Bearer_Graph}`
                },
                body: { query: 'query{users {pageInfo {endCursor startCursor hasNextPage hasPreviousPage} totalCount nodes {id name email gender status}}}' }
            }).as('details')
            //Validate status code
            cy.get('@details').its('status').should('eq', 200)
            cy.get('@details').then((response) =&amp;gt; {
                cy.log(JSON.stringify(response.body))
            })
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;As we can notice from the code above, the body request is a query; that’s the essential part; GraphQL is a query language for APIs; if we understand our GraphQL schema, we can query and get the desired response.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Run your &lt;a href="https://www.lambdatest.com/playwright?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=feb07_kj&amp;amp;utm_term=kj&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;Playwright&lt;/a&gt; test scripts instantly on 50+ browser and OS combinations using the LambdaTest cloud.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Cypress plugin API
&lt;/h2&gt;

&lt;p&gt;In this section of our Cypress API testing guide, we will discuss one API plugin, and probably, one of the most useful, related to APIs, &lt;a href="https://github.com/filiphric/cypress-plugin-api#requestmode---enable-ui-for-cyrequest-command" rel="noopener noreferrer"&gt;cypress-plugin-api&lt;/a&gt;; the creator of this plugin mentions that if we merge Postman with Cypress, we obtain the cypress-plugin-api. First, we need to install it.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; 'npm i cypress-plugin-api'.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;As we are using the 9.7.0 version, we need to add it to our /support/index.js file:&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-plugin-api'
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We can now use the cy.api() command. It works precisely like cy.request() command, but in addition to calling the API, it will print our information about the API call in your Cypress runner, as you can see 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%2F56l6tc2eg7adfzx4sag2.png" class="article-body-image-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%2F56l6tc2eg7adfzx4sag2.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;As we can see, the information printed looks useful, including response, headers, and cookies; besides that, we can see the body request and authentication.&lt;/p&gt;

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

&lt;p&gt;&lt;strong&gt;Code Walkthrough:&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;import config from './config.json'
    import { faker } from '@faker-js/faker'
    describe('API Testing ', function () {
       let att1
       let att2  

       it('API - GET details', () =&amp;gt; {
           cy.request({
               method: 'GET',
               url: `${config.URL}`,
               failOnStatusCode: false,
           }).as('details')
           //Validate status code
           cy.get('@details').its('status').should('eq', 200)
           cy.get('@details').then((response) =&amp;gt; {
               cy.log(JSON.stringify(response.body))
           })
       })

       it('API - POST Request', () =&amp;gt; {
           cy.request({
               method: 'POST',
               url: `${config.URL}`,
               failOnStatusCode: false,
               'auth': {
                   'bearer': `${config.Bearer_Rest}`
               },
               body: {'name':faker.internet.userName(),
               'gender':'male',
               'email':faker.internet.email(),
               'status':'active'}
           }).as('details')
           //Validate status code
           cy.get('@details').its('status').should('eq', 201)
           cy.get('@details').then((response) =&amp;gt; {
               let res = response.body
               att1 = res.id
               att2 = res.user
               cy.log(att1)
           })
           cy.get('@details').then((response) =&amp;gt; {
               cy.log(JSON.stringify(response.body))
           })

       })

       it('API Post - POST Request', () =&amp;gt; {
           cy.request({
               method: 'POST',
               url: `${config.URL2}`,
               failOnStatusCode: false,
               'auth': {
                   'bearer': `${config.Bearer_Rest}`
               },
               body: {'user':att2,
               'user_id': att1,
               'email':faker.internet.email(),
               'title':'This is a title',
               'body': 'This is a message'}
           }).as('details')
           //Validate status code
           cy.get('@details').its('status').should('eq', 201)
           cy.get('@details').then((response) =&amp;gt; {
               let res = response.body
               let post_id = res.id
               cy.log(post_id)
           })
           cy.get('@details').then((response) =&amp;gt; {
               cy.log(JSON.stringify(response.body))
           })

       })

       it('API - PUT Request', () =&amp;gt; {
           cy.request({
               method: 'PUT',
               url: `${config.URL}`+att1,
               failOnStatusCode: false,
               'auth': {
                   'bearer': `${config.Bearer_Rest}`
               },
               body: {'name':faker.internet.userName(),
               'gender':'female',
               'email':faker.internet.email(),
               'status':'active'}
           }).as('details')
           //Validate status code
           cy.get('@details').its('status').should('eq', 200)
           cy.get('@details').then((response) =&amp;gt; {
               cy.log(JSON.stringify(response.body))
           })

       })

       it('API - DELETE Request', () =&amp;gt; {
           cy.request({
               method: 'DELETE',
               url: `${config.URL}`+att1,
               failOnStatusCode: false,
               'auth': {
                   'bearer': `${config.Bearer_Rest}`
               },
           }).as('details')
           //Validate response code
           cy.get('@details').its('status').should('eq', 204)
           cy.get('@details').then((response) =&amp;gt; {
               cy.log(JSON.stringify(response.body))
           })


       })

    })
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Let’s start defining our config.json file; here, we can include some data and URLs:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{
       "URL": "https://gorest.co.in/public/v2/users/",
       "URL2": "https://gorest.co.in/public/v2/posts/",
       "URL3": "https://pokeapi.co/api/v2/pokemon/",
       "URL4": "https://gorest.co.in/public/v2/graphql",
       "Bearer_Rest": "e2360bb230c2fc83af7451f8346d9fcdb699879e3a8f14462a2187f9d670675e",
       "Bearer_Graph": "3df84f0ba9a2028aa6efe7519e3d73466cb301501858acabaad74119082f3b02"
    }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then, we use ‘faker’ for our random data related to our POST and PUT methods; we can install it using the following:&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 --save-dev @faker-js/faker
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;After that, we use a global variable for our user-id field; it’s up to you if you want to use Cypress env variables or global variables, in my particular case, as this will be used for API. There is no need to use it outside this file; I prefer that variable.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;it('API Post - POST Request', () =&amp;gt; {
           cy.request({
               method: 'POST',
               url: `${config.URL2}`,
               failOnStatusCode: false,
               'auth': {
                   'bearer': `${config.Bearer_Rest}`
               },
               body: {'user':att2,
               'user_id': att1,
               'email':faker.internet.email(),
               'title':'This is a title',
               'body': 'This is a message'}
           }).as('details')
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Regarding the API tests, we added one more test about Post using a user previously created; as we can notice, the &lt;strong&gt;API Post — POST Request&lt;/strong&gt;‘. The structure is similar to our previous request, only changing the body. Testers must understand the API definition to send requests and adequately create Negative tests based on API schema.&lt;/p&gt;

&lt;p&gt;It’s time to run our tests; as we saw above, we can run using the UI Runner or terminal mode; let’s try both.&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%2Frfvltv0ewinx5abw8y02.png" class="article-body-image-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%2Frfvltv0ewinx5abw8y02.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We are going to use the following command to run one specific test spec:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  npx cypress run --spec cypress/integration/test.api.spec.js
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;As we can see above, the specific test case is executed on the CLI using the “–spec” option.&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%2Fkiez2ruh9xmtci0hj3ll.png" class="article-body-image-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%2Fkiez2ruh9xmtci0hj3ll.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Mochawesome is also available if we want to take a look:&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%2Fj6jh9trlvsspbjp2x7ym.png" class="article-body-image-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%2Fj6jh9trlvsspbjp2x7ym.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If you want to know more about Mochawesome, please visit the blog on &lt;a href="https://www.lambdatest.com/blog/how-to-generate-mocha-reports-with-mochawesome/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=feb07_kj&amp;amp;utm_term=kj&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;generating Mocha Reports with Mochawesome&lt;/a&gt;. Also, please download the &lt;a href="https://github.com/enriquedcs/cypress-gen-api-lmbtest" rel="noopener noreferrer"&gt;GitHub repo &lt;/a&gt;and provide some feedback.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;In this tutorial, learn what is &lt;a href="https://www.lambdatest.com/learning-hub/regression-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=feb07_kj&amp;amp;utm_term=kj&amp;amp;utm_content=learning_hub" rel="noopener noreferrer"&gt;Regression testing&lt;/a&gt;, its importance, types, and how to perform it.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Cleaner Methods for our Cypress API Testing
&lt;/h2&gt;

&lt;p&gt;As we can see in our code, we are repeating our code multiple times, especially for the POSTs and PUT, GET and DELETE; what about using some methods to encapsulate our “cy.requests” calls:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;export default class MainMethods {

       static GetDelMethod(url,method){
           cy.request({
               method: method,
               url: url,
               failOnStatusCode: false,
               'auth': {
                   'bearer': `${config.Bearer_Rest}`
               },
           }).as('details')

       }

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now, let’s reuse the methods inside of our Test code:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;it('API - GET details', () =&amp;gt; {

           MainMethod.GetDelMethod(`${config.URL}`,'GET')
           //Validate status code
           cy.get('@details').its('status').should('eq', 200)
           cy.get('@details').then((response) =&amp;gt; {
               cy.log(JSON.stringify(response.body))
           })
       })

    it('API - POST Request', () =&amp;gt; {
           const body = {'name':faker.internet.userName(),
                   'gender':'male',
                   'email':faker.internet.email(),
                   'status':'active'}
           //Method
           MainMethod.PostMethod(`${config.URL}`, JSON.parse(JSON.stringify(body)))
           //Validate status code
           cy.get('@details').its('status').should('eq', 201)
           cy.get('@details').then((response) =&amp;gt; {
               let res = response.body
               att1 = res.id
               att2 = res.user
               cy.log(att1)
           })
           cy.get('@details').then((response) =&amp;gt; {
               cy.log(JSON.stringify(response.body))
           })

       })

    it('API - DELETE Request', () =&amp;gt; {
           MainMethod.GetDelMethod(`${config.URL}`+att1,'DELETE')
           cy.get('@details').its('status').should('eq', 204)
           cy.get('@details').then((response) =&amp;gt; {
               cy.log(JSON.stringify(response.body))
           })    
       })

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;What we tried above was a crude attempt to use the Builder pattern, as the focus here is that the instance is returned from every method (every computation) and is then used to build up the complex object. The builder pattern can help us to reuse and maintain different API test scenarios. You can learn more about it through this blog on &lt;a href="https://www.lambdatest.com/blog/fluent-interface-design-pattern/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=feb07_kj&amp;amp;utm_term=kj&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;Fluent Interface Design Pattern&lt;/a&gt; blog.&lt;/p&gt;

&lt;h2&gt;
  
  
  Using LambdaTest Rest API to validate data
&lt;/h2&gt;

&lt;p&gt;In this section of our blog on Cypress API testing, we will use &lt;a href="https://www.lambdatest.com/support/api-doc/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=feb07_kj&amp;amp;utm_term=kj&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;LambdaTest REST APIs&lt;/a&gt; for related APIs to validate the data already uploaded in our previous tests to LambdaTest.&lt;/p&gt;

&lt;p&gt;LambdaTest &lt;a href="https://www.lambdatest.com/cypress-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=feb07_kj&amp;amp;utm_term=kj&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;Cypress cloud&lt;/a&gt; grid offers an online device farm with 3000+ real devices and browsers to help you get the job done. This can help improve the overall &lt;a href="https://www.lambdatest.com/learning-hub/test-coverage?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=feb07_kj&amp;amp;utm_term=kj&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;test coverage&lt;/a&gt; of an application by enabling tests to be run on different combinations of browsers and operating systems using the same test scripts.&lt;/p&gt;

&lt;p&gt;With &lt;a href="https://www.lambdatest.com/cypress-parallel-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=feb07_kj&amp;amp;utm_term=kj&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;Cypress parallel testing&lt;/a&gt;, run multiple tests concurrently to expedite the testing process and enable &lt;a href="https://www.lambdatest.com/blog/cypress-test-automation-framework/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=feb07_kj&amp;amp;utm_term=kj&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;Cypress test automation&lt;/a&gt; at scale. By leveraging cloud grids and parallel testing, it is possible to significantly improve the quality of a product by thoroughly testing it across a wide range of environments.&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;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=feb07_kj&amp;amp;utm_term=kj&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;LambdaTest YouTube channel&lt;/a&gt; for tutorials around &lt;a href="https://www.lambdatest.com/selenium-automation?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=feb07_kj&amp;amp;utm_term=kj&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;Selenium testing&lt;/a&gt;, &lt;a href="https://www.lambdatest.com/blog/playwright-framework/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=feb07_kj&amp;amp;utm_term=kj&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;Playwright browser 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=feb07_kj&amp;amp;utm_term=kj&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;Appium&lt;/a&gt;, and more.&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%2Frck00pe0fj50bwmb8grx.png" class="article-body-image-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%2Frck00pe0fj50bwmb8grx.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;For this example, we will use the Cypress level GET request for execution on the LambdaTest platform. Let’s code one test and get the Cypress console logs from the LambdaTest API endpoint:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; static GetDelMethodLam(url,method){
           cy.request({
               method: method,
               url: url,
               failOnStatusCode: false,
               'headers' : {
                   'accept': 'application/octet-stream',
                   'content-type': 'application/x-gzip',
                   'Authorization': "Basic &amp;lt;code&amp;gt;
               },

           }).as('details')
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Let’s dig into the code; we are reusing one of our Methods for ‘GET’ and ‘DELETE,’ just updating the headers part as we need that to authenticate into LambdaTest API.&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%2Fv3jekgrlm5v79m2bajcv.png" class="article-body-image-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%2Fv3jekgrlm5v79m2bajcv.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Once in our test, we use our config.json file for the URL endpoint and testID, passing the Method name and running it to see the data. It is essential to get the test_Id from our 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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F348zczvlrisv6ob1yxke.png" class="article-body-image-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%2F348zczvlrisv6ob1yxke.png"&gt;&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; import config from './config.json'
    import MainMethod from '../builder/components/Mainmethods'
    describe('API Testing LambdaTest ', function () {

       it.only('API - GET details', () =&amp;gt; {

           MainMethod.GetDelMethodLam(`${config.URLL}`+`${config.testId}`+'/console','GET')
           //Validate status code
           cy.get('@details').its('status').should('eq', 200)
           cy.get('@details').then((response) =&amp;gt; {
               cy.log(JSON.stringify(response.body))
           })
       })
    })

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;As we can see in the response, there are some logs for the past execution of &lt;a href="https://www.lambdatest.com/cypress-ui-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=feb07_kj&amp;amp;utm_term=kj&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;Cypress UI testing&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%2Fc7s4snnhnj9qmpdzmm15.png" class="article-body-image-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%2Fc7s4snnhnj9qmpdzmm15.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Another Test example using API for Network logs:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; it('API - GET Network', () =&amp;gt; {

           MainMethod.GetDelMethodLam(`${config.URLL}`+`${config.testId}`+'/network','GET')
           //Validate status code
           cy.get('@details').its('status').should('eq', 200)
           cy.get('@details').then((response) =&amp;gt; {
               cy.log(JSON.stringify(response.body))
           })
       })
&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%2Fmi6uz0eher4mpb959kjm.png" class="article-body-image-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%2Fmi6uz0eher4mpb959kjm.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Last but not least, a PATCH method to change the build name:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; static PatchMethodLam(url){
           cy.request({
               method: 'PATCH',
               url: url,
               failOnStatusCode: false,
               'headers' : {
                   'accept': 'application/json',
                   'Authorization': "Basic &amp;lt;&amp;gt;
               },
               body: { 'name': 'cypress - api mod2 cypress' }

           }).as('details')
       }

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Shown below is the test runner results:&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%2Fpr9w263hk2pdg6ljr50b.png" class="article-body-image-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%2Fpr9w263hk2pdg6ljr50b.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Hopefully, this will give you an idea of how to take advantage of the LambdaTest APIs and build your Cypress requests.&lt;/p&gt;

&lt;p&gt;If you want to deepen your understanding of Cypress and become proficient in using it to test web applications, this course could be a good fit. It covers the fundamentals of Cypress and provides a solid foundation for building more advanced testing skills.&lt;/p&gt;

&lt;p&gt;The Cypress 101 certification course is designed for developers and testers who already have a basic understanding of Cypress and want to advance their knowledge and &lt;a href="https://www.lambdatest.com/cypress-e2e-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=feb07_kj&amp;amp;utm_term=kj&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;Cypress e2e testing&lt;/a&gt; skills.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;A complete &lt;a href="https://www.lambdatest.com/learning-hub/webdriver?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=feb07_kj&amp;amp;utm_term=kj&amp;amp;utm_content=learning_hub" rel="noopener noreferrer"&gt;Selenium WebDriver&lt;/a&gt; tutorial that covers what WebDriver is, its features, architecture and best practices.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Wrapping Up
&lt;/h2&gt;

&lt;p&gt;API testing is a process that involves three steps:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;em&gt;Sending the request with the necessary input data&lt;/em&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;em&gt;Getting the response’s output data&lt;/em&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;em&gt;Validating the response against the expected outcome&lt;/em&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;These steps seem very easy and quick to follow for any tester and are, in fact, truly easy for low functionality levels, but tests get more and more complex as you start testing APIs on a deeper level.&lt;/p&gt;

&lt;p&gt;It is strongly advised to consider Cypress API testing as a core requirement of your project development process and make it as extendable, reusable, and maintainable as possible. With this blog post on Cypress API Testing, we’ve covered a lot, but we’ve only scratched the surface of API Test Automation. The Cypress site has much more detailed documentation and examples of the power of Cypress.&lt;/p&gt;

&lt;p&gt;If there are any questions or ideas about improving our Cypress API Testing, please let me know or reach me directly.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Happy Bug Hunting!&lt;/strong&gt;&lt;/p&gt;

</description>
      <category>announcement</category>
      <category>devto</category>
      <category>offers</category>
    </item>
    <item>
      <title>How To Run Cypress Tests In Jenkins Pipeline [Jenkins and Cypress Tutorial]</title>
      <dc:creator>enriquee20</dc:creator>
      <pubDate>Wed, 12 Oct 2022 11:07:39 +0000</pubDate>
      <link>https://forem.com/testmuai/how-to-run-cypress-tests-in-jenkins-pipeline-jenkins-and-cypress-tutorial-2aok</link>
      <guid>https://forem.com/testmuai/how-to-run-cypress-tests-in-jenkins-pipeline-jenkins-and-cypress-tutorial-2aok</guid>
      <description>&lt;p&gt;Cypress is one of the fast-growing &lt;a href="https://www.lambdatest.com/blog/best-test-automation-frameworks-2021/?utm_source=devto&amp;amp;utm_medium=group&amp;amp;utm_campaign=oct12_kj&amp;amp;utm_term=kj&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;test automation framework&lt;/a&gt;s. As you learn Cypress, you will probably come across the need to integrate your Cypress tests with your CI environment. Jenkins is an open-source &lt;a href="https://www.lambdatest.com/blog/what-is-continuous-integration-and-continuous-delivery/?utm_source=devto&amp;amp;utm_medium=group&amp;amp;utm_campaign=oct12_kj&amp;amp;utm_term=kj&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;Continuous Integration (CI)&lt;/a&gt; server that automates your web applications’ build and deploys process. By running your Cypress test suite in Jenkins, you also automate testing as part of the build process.&lt;/p&gt;

&lt;p&gt;Adding LambdaTest to the formula, you can run your apps across different OS and browser combinations. In this Jenkins and Cypress tutorial, we will dive deep into integrating the Jenkins pipeline with LambdaTest’s &lt;a href="https://www.lambdatest.com/cypress-testing?utm_source=devto&amp;amp;utm_medium=group&amp;amp;utm_campaign=oct12_kj&amp;amp;utm_term=kj&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;Cypress Cloud&lt;/a&gt;.&lt;/p&gt;

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

&lt;h2&gt;
  
  
  Advantages of Jenkins
&lt;/h2&gt;

&lt;p&gt;Jenkins is a widely popular Continuous Integration (CI) tool. It is free-to-use, open-source software written in Java. Jenkins allows boosting your release agility by providing Continuous Integration services. You can trigger these services by a web application server or simply using a command line to hasten the deployment pipeline &amp;amp; release migration activities. In addition, Jenkins’s popularity offers thousands of plugins to fast-track your productivity.&lt;/p&gt;

&lt;p&gt;Detailed down are some of the significant advantages of using Jenkins:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Jenkins is open-source and free to use. It is a preferred CI tool by early-stage startups and large corporations since it has been under development for a long time.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;It is a rich plugin ecosystem. At the time of this blog post, there were close to 1500+ plugins available for use.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Jenkins can be integrated with popular cloud platforms such as Amazon EC2, Google Cloud, VMWare vSphere, Digital Ocean, and more.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Anyone can write the tests to detect the errors in their code as soon as possible. So the developers don’t waste time on large-scale error-ridden integrations.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Issues are detected and resolved almost immediately, which keeps the software in a state where it can be safely released at any time.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Most of the integration work is automated. Hence fewer integration issues. It saves both time and money over the lifespan of a project.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If you are new to Jenkins and wish to learn more about it, you can go through this &lt;a href="https://www.lambdatest.com/learning-hub/jenkins?utm_source=devto&amp;amp;utm_medium=group&amp;amp;utm_campaign=oct12_kj&amp;amp;utm_term=kj&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;Jenkins tutorial&lt;/a&gt; that covers &lt;a href="https://www.lambdatest.com/blog/what-is-jenkins/?utm_source=devto&amp;amp;utm_medium=group&amp;amp;utm_campaign=oct12_kj&amp;amp;utm_term=kj&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;what is Jenkins&lt;/a&gt; and how &amp;amp; why to use it.&lt;/p&gt;

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

&lt;p&gt;In the next section of this Jenkins and Cypress tutorial, we will look into why Cypress Jenkins is the right option for your team.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Automate &lt;a href="https://www.lambdatest.com/cypress-testing?utm_source=devto&amp;amp;utm_medium=group&amp;amp;utm_campaign=oct12_kj&amp;amp;utm_term=kj&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;Cypress cloud&lt;/a&gt; tests and perform browser automation testing with LambdaTest. Our cloud infrastructure has 3000+ desktop &amp;amp; mobile environments. Try for free!&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Why Cypress and Jenkins?
&lt;/h2&gt;

&lt;p&gt;Cypress is an open-source, full-featured, and easy-to-use testing framework for &lt;a href="https://www.lambdatest.com/learning-hub/end-to-end-testing?utm_source=devto&amp;amp;utm_medium=group&amp;amp;utm_campaign=oct12_kj&amp;amp;utm_term=kj&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;end to end testing&lt;/a&gt;. Currently, Cypress is preferred by front-end developers and automation testers who know JavaScript. We can install Cypress using NPM. Also, we don’t need to install any additional libraries, dependencies, drivers, servers, etc., as we have to do in the case of Selenium.&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%2Fp6h76k4jd3jjnbkb59t3.png" class="article-body-image-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%2Fp6h76k4jd3jjnbkb59t3.png" width="800" height="432"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;As mentioned above, Jenkins is the predicted option of many startups and large companies trying to accomplish Continuous Integration. It offers a significant plugin ecosystem plus easy configuration with Jenkins; if you are looking for an open-source CI tool that is easy to configure with Cypress, then Jenkins is the right option for your team.&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%2Fwj38jnpoywprax7swzc6.png" class="article-body-image-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%2Fwj38jnpoywprax7swzc6.png" width="800" height="404"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In the next section of this tutorial Jenkins and Cypress tutorial , we will learn how to configure Jenkins to run Cypress tests.&lt;/p&gt;

&lt;h2&gt;
  
  
  Configuring Jenkins to run Cypress tests
&lt;/h2&gt;

&lt;p&gt;We are going to need NodeJS to execute Cypress. In this section of this Jenkins and Cypress tutorial, we will learn how to install NodeJS in our Jenkins environment. However, before this, you must install Cypress. You can go through this blog on &lt;a href="https://www.lambdatest.com/blog/getting-started-with-cypress/#D?utm_source=devto&amp;amp;utm_medium=group&amp;amp;utm_campaign=oct12_kj&amp;amp;utm_term=kj&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;getting started with Cypress&lt;/a&gt; to install Cypress on the local machine.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;In Jenkins, go to Manage Jenkins &amp;gt; Manage Plugins &amp;gt; Available Plugins and search for NodeJS Plugin and install it.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;After you successfully install the NodeJs Plugin, we need to add NodeJs to it. Go to Manage Jenkins &amp;gt; Global Tool Configuration and click Add NodeJS. Then,&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Provide a name for your NodeJS installation Eg: Node14.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Hit the Install automatically.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Choose a cypress-compatible NodeJS version.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Add Cypress for Global npm packages to install.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;We can keep the other configurations as it is.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Now we need to create your Cypress Jenkins project. First, we must keep things simple; let’s use a freestyle project; as a freestyle, we can break down our build job into several smaller build steps, making it more comfortable to manage builds in separate stages. E.g., in one step, a build might run a suite of functional tests and then tag the build in a second step if all available tests are successful.&lt;/p&gt;

&lt;p&gt;A &lt;a href="https://www.lambdatest.com/blog/jenkins-freestyle-project/?utm_source=devto&amp;amp;utm_medium=group&amp;amp;utm_campaign=oct12_kj&amp;amp;utm_term=kj&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;Jenkins freestyle project&lt;/a&gt; can be as powerful and complicated as any build job built with a &lt;a href="https://www.lambdatest.com/blog/jenkins-pipeline-tutorial/?utm_source=devto&amp;amp;utm_medium=group&amp;amp;utm_campaign=oct12_kj&amp;amp;utm_term=kj&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;Jenkins pipeline&lt;/a&gt; or a Groovy DSL. The drawback to freestyle projects is that the user must know how to script all these actions, and developers must learn how to manage these scripts.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;In Jenkins, click New Item, provide a project name, and choose Freestyle project.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;As we have our Git project in Source Code Management, add your Git URL and credentials for this Jenkins and Cypress tutorial. If you do not use Git, I encourage you to try it. Git is lightning fast; we’re talking about only a few seconds per command; it quickly adds to your work day. Remember that a large community often is an advantage because an ecosystem revolves around the system.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Now we need to switch to the build environment section. Here we will find and select the option, Provide Node &amp;amp; npm bin/ folder to PATH.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;If you remember, we added a NodeJS installation before. We will see the name we provided in the NodeJS Installation dropdown. Choose it, and then we can keep the other configurations.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;We are all set; don’t forget to add our Cypress command to execute the script.&lt;/p&gt;

&lt;h2&gt;
  
  
  Configuring the Jenkins Pipeline
&lt;/h2&gt;

&lt;p&gt;A pipeline is a series of events or tasks interconnected in a particular order. In plain English, a Jenkins pipeline is a set of modules or plugins which enable the implementation and integration of Continuous Delivery pipelines within Jenkins.&lt;/p&gt;

&lt;p&gt;The Jenkins pipeline has an expandable automation system for building basic or complex “template” distribution pipelines via the Domain-specific language (DSL) used in the Pipeline. For example, stages in the &lt;a href="https://www.lambdatest.com/blog/jenkins-declarative-pipeline-examples/?utm_source=devto&amp;amp;utm_medium=group&amp;amp;utm_campaign=oct12_kj&amp;amp;utm_term=kj&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;Declarative Pipeline&lt;/a&gt; may have a stages section containing a list of nested stages to be run in sequential order.&lt;/p&gt;

&lt;p&gt;The concepts in Jenkins pipelines are as follows:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;*&lt;em&gt;Pipeline *&lt;/em&gt;— It is code executed for the build, test, and delivery of the applications and is a set of instructions in the state of code for continuous delivery.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Node&lt;/strong&gt; — It is a machine or system on which Jenkins runs. A node block is a pipeline syntax scripted.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Stage&lt;/strong&gt; — Here, we can picture the process of Jenkins pipelines. It consists of a series of steps: build, test, and deploy. In earlier versions of Declarative Pipeline, the only way to run chunks of Pipeline code in parallel was to use the parallel step inside the steps block for a stage).&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Step&lt;/strong&gt; — It is a single step in the stage; for example, either build or test or deploy from a single step.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The Jenkins pipeline’s main advantages are automating many tasks and making the CI/CD pipeline tasks reliable, efficient, repeatable, and high in quality.&lt;/p&gt;

&lt;p&gt;We can find the Jenkins file for the Pipeline as follows for this Jenkins and Cypress tutorial:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;pipeline {
   agent any

   tools {nodejs "Node12"}

   environment {
       CHROME_BIN = '/bin/google-chrome'

   }

   stages {
       stage('Dependencies') {
           steps {
               sh 'npm i'
           }
       }
       stage('e2e Tests') {
         Parallel{
             stage('Test 1') {
                  steps {
                sh 'npm run cypress:ci'
                  }
               }

             stage('Test 2') {
                  steps {
                sh 'npm run cypress2:ci'
                  }
               }

       }
       stage('Deploy') {
           steps {
               echo 'Deploying....'
           }
       }
   }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;1- Create a new project for Pipeline by going to Jenkins –&amp;gt; New Item. Jenkins -&amp;gt; Select the 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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fjqh4ylldd3rsfgy4ae2j.png" class="article-body-image-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%2Fjqh4ylldd3rsfgy4ae2j.png" width="800" height="326"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;2- Scroll down to Pipeline Options. And update according to your Git repo.&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%2F1%2AROWeyY3w_khvszsBHhUTKQ.png" class="article-body-image-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%2F1%2AROWeyY3w_khvszsBHhUTKQ.png" width="800" height="552"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;3- Our Jenkins file will contain our configuration, and then we can see our results.&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%2F1%2AQxEV7dZxoXw8PyPZsVNYlw.png" class="article-body-image-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%2F1%2AQxEV7dZxoXw8PyPZsVNYlw.png" width="800" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;So far, we have seen how to configure the Jenkins pipeline. In the next section of this Jenkins and Cypress tutorial, we will deep-dive into integrating your Cypress Jenkins pipeline with the Cypress cloud grid.&lt;/p&gt;

&lt;h2&gt;
  
  
  How to integrate your Cypress Jenkins Pipeline with Cypress cloud grid?
&lt;/h2&gt;

&lt;p&gt;Jenkins Pipeline, also called “Pipeline,” presents a suite of plugins to assist in integrating our continuous delivery pipeline into Jenkins. Jenkins Pipeline does so with the help of Pipeline DSL (Domain Specific Language) syntax that facilitates easy modeling of even the most complex delivery pipeline.&lt;/p&gt;

&lt;h2&gt;
  
  
  Configuring your Jenkins Pipeline with LambdaTest
&lt;/h2&gt;

&lt;p&gt;Follow these steps to configure LambdaTest with Jenkins:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Jenkins 2.X or the latest version.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;A Jenkins User with root access.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;LambdaTest Authentication Credentials.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Keep an eye on your LambdaTest authentication credentials, i.e., your LambdaTest username and access key. You need to set them up as your environment variables. You can retrieve them from your &lt;a href="https://accounts.lambdatest.com/dashboard?utm_source=devto&amp;amp;utm_medium=group&amp;amp;utm_campaign=oct12_kj&amp;amp;utm_term=kj&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;LambdaTest Automation Dashboard&lt;/a&gt; by clicking on the key icon around the help button.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;This &lt;a href="https://www.lambdatest.com/blog/cypress-test-automation-framework/?utm_source=devto&amp;amp;utm_medium=group&amp;amp;utm_campaign=oct12_kj&amp;amp;utm_term=kj&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;Cypress test automation&lt;/a&gt; tutorial will help you learn the benefits of Cypress automation, and how to install Cypress and execute Cypress automation testing over scores of browsers and operating systems online.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

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

&lt;p&gt;In this section of this Jenkins and Cypress tutorial, we will look into the steps to set up Jenkins.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;pipeline {
   agent any

   tools {nodejs "Node12"}

   stages {
       stage('Dependencies') {
           steps {
               sh 'npm i'
               sh 'npm install lambdatest-cypress-cli'
           }
       }
       stage('e2e Tests') {
           steps {
               sh 'npm run cypress:lambda'
           }
       }
       stage('Deploy') {
           steps {
               echo 'Deploying....'
           }
       }
   }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;1- Create a new project for Pipeline by going to Jenkins –&amp;gt; New Item. Jenkins -&amp;gt; Select the 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%2F3976%2F1%2AnaVX1bJfBUIjO7DwQwzWog.png" class="article-body-image-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%2F3976%2F1%2AnaVX1bJfBUIjO7DwQwzWog.png" width="800" height="511"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;2- Scroll down to Pipeline Options. And update according to your Git repo.&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%2F1%2AROHIBEO_VuHye-DchmCTAA.png" class="article-body-image-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%2F1%2AROHIBEO_VuHye-DchmCTAA.png" width="800" height="552"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;3- Our Jenkinsfile will contain our configuration:&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%2F3756%2F1%2AAmJbpStMGhqHqjlLNui_Iw.png" class="article-body-image-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%2F3756%2F1%2AAmJbpStMGhqHqjlLNui_Iw.png" width="800" height="545"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;4- The “cypress:lambda” task will be executed by the “e2e Tests” step in the Jenkins pipeline. So now we can press the “Build Now” button in Jenkins and get the following result:&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%2F1%2AkaNB0DWQcNavrEHS3chC7w.png" class="article-body-image-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%2F1%2AkaNB0DWQcNavrEHS3chC7w.png" width="800" height="457"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;5- When checking the console output of the build, we can verify that the Cypress tests ran.&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%2F3436%2F1%2A_sR5GjN7eEwNumNqFHk9JA.png" class="article-body-image-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%2F3436%2F1%2A_sR5GjN7eEwNumNqFHk9JA.png" width="800" height="645"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;As we can notice from the image above, our build was successfully executed, and the tests were uploaded to our LambdaTest Dashboard.&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%2AjCeqKySRV6MUCi9c.png" class="article-body-image-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%2AjCeqKySRV6MUCi9c.png" width="800" height="331"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In the following section of this Jenkins and Cypress tutorial, we will learn how to perform parallel testing on Cypress cloud.&lt;/p&gt;

&lt;h2&gt;
  
  
  How to perform Cypress parallel testing on a cloud grid?
&lt;/h2&gt;

&lt;p&gt;We can use a Cypress cloud grid like LambdaTest, which provides automated &lt;a href="https://www.lambdatest.com/?utm_source=devto&amp;amp;utm_medium=group&amp;amp;utm_campaign=oct12_kj&amp;amp;utm_term=kj&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;cross browser testing&lt;/a&gt; on 40+ browsers and operating systems, and &lt;a href="https://www.lambdatest.com/cypress-parallel-testing?utm_source=devto&amp;amp;utm_medium=group&amp;amp;utm_campaign=oct12_kj&amp;amp;utm_term=kj&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;Cypress parallel testing&lt;/a&gt; to expedite the test execution and help perform our Jenkin pipelines. In addition, it will help improve our overall test coverage by resulting in better product quality, as we can cover different combinations using the same test scripts.&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?utm_source=devto&amp;amp;utm_medium=group&amp;amp;utm_campaign=oct12_kj&amp;amp;utm_term=kj&amp;amp;utm_content=blog" 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=group&amp;amp;utm_campaign=oct12_kj&amp;amp;utm_term=kj&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;automated browser testing&lt;/a&gt;, &lt;a href="https://www.lambdatest.com/cypress-testing?utm_source=devto&amp;amp;utm_medium=group&amp;amp;utm_campaign=oct12_kj&amp;amp;utm_term=kj&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;Cypress testing&lt;/a&gt;, CI/CD, and more.&lt;/p&gt;

&lt;p&gt;To get started with &lt;a href="https://www.lambdatest.com/cypress-e2e-testing?utm_source=devto&amp;amp;utm_medium=group&amp;amp;utm_campaign=oct12_kj&amp;amp;utm_term=kj&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;Cypress e2e testing&lt;/a&gt;, follow the below-mentioned steps:&lt;/p&gt;

&lt;p&gt;2- &lt;a href="https://www.lambdatest.com/blog/cypress-cli-on-lambdatest/?utm_source=devto&amp;amp;utm_medium=group&amp;amp;utm_campaign=oct12_kj&amp;amp;utm_term=kj&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;Install LambdaTest Cypress CLI&lt;/a&gt; on your machine. Trigger the following command to install the same:&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;2- After installation is completed, set up the configuration using 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;3- Once the command is completed, lambdatest-config.json is created in the project folder. Next, enter the LambdaTest credentials from the &lt;a href="https://accounts.lambdatest.com/detail/profile?utm_source=devto&amp;amp;utm_medium=group&amp;amp;utm_campaign=oct12_kj&amp;amp;utm_term=kj&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;LambdaTest Profile Section&lt;/a&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;Your LambdaTest username&amp;gt;",
      "access_key": "&amp;lt;Your LambdaTest access key&amp;gt;"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;4- Here is how you can configure the required browser &amp;amp; OS combinations in lambdatest-config.json:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{
  "lambdatest_auth": {
     "username": "",
     "access_key": ""
  },
  "browsers": [
     {
        "browser": "MicrosoftEdge",
        "platform": "Windows 10",
        "versions": [
           "latest"
        ]
     },
     {
        "browser": "Chrome",
        "platform": "Windows 10",
        "versions": [
           "latest"
        ]
     },
     {
        "browser": "Firefox",
        "platform": "Windows 10",
        "versions": [
           "latest"
        ]
     }
  ],
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;5- The run_settings section in the JSON file contains the desired Cypress test suite capabilities, including Cypress_version, build_name, number of parallel sessions, etc.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;"run_settings": {
     "cypress_config_file": "cypress.json",
     "build_name": "build-Cypress-test",
     "parallels": 5,
     "specs": "./cypress/integration/e2e_tests/*.spec.js",
     "pluginsFile": true,
     "ignore_files": "",
     "npm_dependencies": {
        "cypress": "9.0.0",
        "[@cypress](http://twitter.com/cypress)-audit/pa11y": "^1.3.0",
        "cypress-plugin-snapshots": "^1.4.4",
        "cypress-visual-regression": "^1.6.2"
     },
     "feature_file_suppport": true
  },
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;6- Tunnel_settings in the JSON file lets you connect your local system with LambdaTest servers via an SSH-based integration tunnel. Once this tunnel is established, you can &lt;a href="https://www.lambdatest.com/support/docs/testing-locally-hosted-pages/?utm_source=devto&amp;amp;utm_medium=group&amp;amp;utm_campaign=oct12_kj&amp;amp;utm_term=kj&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;test locally hosted pages&lt;/a&gt; on all the browsers currently supported by Cypress on LambdaTest.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;"tunnel_settings": {
    "tunnel": false,
    "tunnelName": null
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Using LambdaTest, we can run our tests in parallel and reduce execution time. Instead of running tests one by one in sequence, parallel testing allows for running multiple tests simultaneously. In addition, this approach executes tests on various browsers, devices, and operating systems parallelly.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Without Cypress Cloud Grid (Compare e2e Tests timing):&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%2ASO74VNJkFsuJRYot.png" class="article-body-image-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%2ASO74VNJkFsuJRYot.png" width="800" height="305"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Using Cypress Cloud Grid and running multiple OS and Browsers (Compare e2e Tests timing):&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%2AQgwh2a_z9Pm_5IM4.png" class="article-body-image-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%2AQgwh2a_z9Pm_5IM4.png" width="800" height="336"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;To view test performance metrics, navigate to the &lt;a href="https://analytics.lambdatest.com/test-overview?utm_source=devto&amp;amp;utm_medium=group&amp;amp;utm_campaign=oct12_kj&amp;amp;utm_term=kj&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;LambdaTest Analytics Dashboard&lt;/a&gt;. The Test Overview will provide a snapshot of tests consistent with stable behavior. You can see all test results, their status, and the overall number of tests passed or failed in both failures and failures’ breakdowns areas.&lt;/p&gt;

&lt;p&gt;If you’re a developer or a tester, Cypress 101 certification will prepare you to write tests faster and with greater confidence. You’ll learn the fundamentals of &lt;a href="https://www.lambdatest.com/blog/cypress-end-to-end-testing/?utm_source=devto&amp;amp;utm_medium=group&amp;amp;utm_campaign=oct12_kj&amp;amp;utm_term=kj&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;Cypress end to end testing&lt;/a&gt; and walk away with a clear understanding of how to write better tests with this Jenkins and Cypress Tutorial.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;This &lt;a href="https://www.lambdatest.com/blog/cypress-test-automation-framework/?utm_source=devto&amp;amp;utm_medium=group&amp;amp;utm_campaign=oct12_kj&amp;amp;utm_term=kj&amp;amp;utm_content=blog[](url)" rel="noopener noreferrer"&gt;Cypress automation&lt;/a&gt; testing tutorial will help you learn the benefits of Cypress automation, and how to install Cypress and execute Cypress automation testing over scores of browsers and operating systems online.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Jenkins and Cypress Tutorial: Final Thoughts
&lt;/h2&gt;

&lt;p&gt;Lastly, in this Jenkins and Cypress Tutorial we have covered Jenkins’s importance and how it can be integrated with our Cypress projects to run our tests efficiently and achieve the goal of continuous integration. Using Jenkins to run our tests is time effective, and the results can be visualized with complete logs. It helps fulfill the entire software development life cycle, from development, deployment, testing, monitoring, and releasing.&lt;/p&gt;

&lt;p&gt;Jenkins supports various plugins for achieving the project requirements. It also keeps alerting the user via emails regarding the build’s stability. Thanks for reading through this Jenkins and Cypress tutorial.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Happy Bug Hunting!&lt;/strong&gt;&lt;/p&gt;

</description>
      <category>testing</category>
      <category>cypress</category>
      <category>jenkins</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>How To Perform Cypress Accessibility Testing</title>
      <dc:creator>enriquee20</dc:creator>
      <pubDate>Tue, 11 Oct 2022 13:12:53 +0000</pubDate>
      <link>https://forem.com/testmuai/how-to-perform-cypress-accessibility-testing-1bbd</link>
      <guid>https://forem.com/testmuai/how-to-perform-cypress-accessibility-testing-1bbd</guid>
      <description>&lt;p&gt;Accessibility means designing products, devices, services, vehicles, or environments so that they’re accessible to specially-abled people. A big part of the concept is to enable people with disabilities through assistive technologies (screen readers, keyboard detection, and other assistive technology).&lt;/p&gt;

&lt;p&gt;To create accessible things means to create something that is accessible to all (whether they have a disability or not). Users can use an application to achieve established goals with effectiveness, efficiency, and convenience and not be confused with accessibility, which is how users can use an application in a specified context.&lt;/p&gt;

&lt;p&gt;The legal argument can be used as the main reason to care about accessibility. In many countries, lack of accessibility has been seen as discrimination against those unable to access the applications. Therefore, it is essential to take the legal aspects seriously and make the application accessible to all users. And this is why &lt;a href="https://www.lambdatest.com/accessibility-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=oct11_kj&amp;amp;utm_term=kj&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;accessibility testing&lt;/a&gt; is important.&lt;/p&gt;

&lt;p&gt;Testers can leverage &lt;a href="https://www.lambdatest.com/blog/curated-tools-for-accessibility-testing-of-websites/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=oct11_kj&amp;amp;utm_term=kj&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;accessibility testing tools&lt;/a&gt; to test a variety of websites and web applications. Automating Accessibility tests allows testers to save time and effort and ship products with quality and confidence. Among all 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=oct11_kj&amp;amp;utm_term=kj&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;automation testing frameworks&lt;/a&gt; available, &lt;a href="https://www.lambdatest.com/blog/cypress-test-automation-framework/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=oct11_kj&amp;amp;utm_term=kj&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;Cypress automation&lt;/a&gt; framework reduces complexity by offering an all-inclusive testing platform (FrontEnd, BackEnd, Accessibility, Performance Testing) rather than requiring you to select and piece together individual libraries for &lt;a href="https://www.lambdatest.com/blog/all-you-need-to-know-about-end-to-end-testing/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=oct11_kj&amp;amp;utm_term=kj&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;end-to-end testing&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;In this &lt;a href="https://www.lambdatest.com/blog/accessibility-testing/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=oct11_kj&amp;amp;utm_term=kj&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;accessibility testing tutorial&lt;/a&gt;, we will learn the importance of accessibility testing and how to perform Cypess accessibility testing on a cloud grid.&lt;/p&gt;

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

&lt;h2&gt;
  
  
  The importance of Accessibility Testing
&lt;/h2&gt;

&lt;p&gt;The success of an application depends on whether everyone can achieve their goals through their chosen technologies.&lt;/p&gt;

&lt;p&gt;We must test an interface against a set of guidelines if we want to be considered for accessibility testing. Common issues that the WCAG doesn’t cover may be considered as well. If you have an accessibility policy, it is good to test your site against its criteria. There are a lot of broad use cases that are covered by the WCAG 2.1 criteria.&lt;/p&gt;

&lt;p&gt;Accessibility testing should be focused on the application’s actual use. There are a lot of reasons why a product might not be accessible. It can be a problem with the software itself or how it was designed. Testing for accessibility is about the user and what they want to do. If you create a feature that does not help a user accomplish a task, you need to ask yourself: “Why not?”. Accessibility testing is about making sure a product works for everyone.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;In this article, we take a look at some aspects of simulation and discuss some ways through which we can 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=oct11_kj&amp;amp;utm_term=kj&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;ios emulator for pc&lt;/a&gt;.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Is it possible to automate Accessibility Testing?
&lt;/h2&gt;

&lt;p&gt;Accessibility testing is an essential part of quality assurance, and there are many different ways of conducting it. Unfortunately, &lt;a href="https://www.lambdatest.com/blog/exploratory-testing-all-about-discovery/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=oct11_kj&amp;amp;utm_term=kj&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;exploratory testing&lt;/a&gt; for people with impairments is only one of many options, and sometimes it’s necessary to use other accessibility testing tools.&lt;/p&gt;

&lt;p&gt;Test websites against criteria; many modern testing tools help companies like ours. For example, you can use a keyboard or screen reader that people with disabilities commonly use. Axe or &lt;a href="https://www.lambdatest.com/blog/using-cypress-google-lighthouse-performance-testing/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=oct11_kj&amp;amp;utm_term=kj&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;Google Lighthouse&lt;/a&gt; are browser extensions that can run accessibility checks.&lt;/p&gt;

&lt;p&gt;Axe-Core is the most common tool for automated accessibility testing in your software development process. Numerous projects are built on top of the Axe-Core; if you use Selenium, WebdriverIO, Cypress, or another automated testing framework, you can implement Axe in your tests.&lt;/p&gt;

&lt;p&gt;We want to try new things in this article on Cypress accessibility testing, so I would like to share my new finding, pa11y, a powerful tool for accessibility testing.&lt;/p&gt;

&lt;h2&gt;
  
  
  Pally and Cypress Accessibility Testing
&lt;/h2&gt;

&lt;p&gt;Firstly, let’s talk about Pally, a command-line interface that loads web pages and highlights any accessibility issues it finds. Second, Pa11y is an automated accessibility testing tool. It runs accessibility tests on your pages via the command line so that you can automate your testing process(Pa11y is licensed under the Lesser General Public License (LGPL-3.0-only).&lt;/p&gt;

&lt;p&gt;Now, let’s focus on Cypress and Pally and follow the below-mentioned steps for performing Cypress accessibility testing:&lt;/p&gt;

&lt;p&gt;1- Install the dependency in our local project using 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](http://twitter.com/cypress)-audit/pa11y
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

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

&lt;p&gt;2- The following configuration allows Lighthouse and Cypress to make their verifications inside the same browser (controlled by Cypress) instead of creating a new one. In the cypress/plugins/index.js file, let’s add the following:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const { pa11y, prepareAudit } = require("[@cypress](http://twitter.com/cypress)-audit/pa11y");

module.exports = (on, config) =&amp;gt; {
  on("before:browser:launch", (browser = {}, launchOptions) =&amp;gt; {
    prepareAudit(launchOptions)
  })

on("task", {
    pa11y: pa11y(), // calling the function must be important
  })
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;3- Once we add the following line in the &lt;em&gt;cypress/support/commands.js&lt;/em&gt; file, you will be able to use cy.pa11y inside your Cypress tests:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import "[@cypress](http://twitter.com/cypress)-audit/pa11y/commands"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;4- Now, we are ready to evaluate some web pages for accessibility; let’s use the following example:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;describe('Accessibility Testing Cypress', () =&amp;gt; {
   before(function(){
       cy.visit(`${config.URL2}`)
   })

   it('verify full Home Page is displayed correctly', () =&amp;gt;{

       cy.pa11y()   
   })
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;5- And then let’s run it using npx cypress 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%2F3200%2F1%2AiIdjsLTDmD1dx06qC4hNNQ.png" class="article-body-image-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%2F1%2AiIdjsLTDmD1dx06qC4hNNQ.png" width="800" height="360"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;As we identified from the image above, it displays some errors; more specifically, 36 accessibility violations were found.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;As we identified from the image above, it displays some errors/violations; more specifically, 33 accessibility violations were found. We can see more details related to all the rules here.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The only violation is color contrast; text elements must have sufficient color contrast against the background; as we can see, 33 elements are not following that rule.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import config from './config.json'
import MainPage from '../../page-objects/components/MainPage'

describe('Accessibility Testing Cypress', () =&amp;gt; {
   before(function(){
       cy.visit(`${config.URL2}`)
   })

   it('verify full Home Page is displayed correctly', () =&amp;gt;{

       //Using Pally as our tool for Accessibility Testing
       cy.pa11y()
   })

it('Verify a search in Google', () =&amp;gt; {

cy.origin(`${config.URL3}`, () =&amp;gt; {
           cy.visit('/')
       })   
       MainPage.searchGoogle('Accessibility Testing')
       cy.pa11y()

})

})
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Let’s start defining our config.json file; here, we can include some data and URLs:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{
   "URL1": "[https://www.lambdatest.com/blog/](https://www.lambdatest.com/blog/)",
   "URL2": "[https://www.scope.org.uk](https://www.scope.org.uk)",
   "URL3": "[http://www.google.com](http://www.google.com)"
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;After that, we need to define our structure; as we can see on the following line of code -&amp;gt; **&lt;em&gt;import **MainPage **from *&lt;/em&gt;‘../../page-objects/components/MainPage’*, we want to separate our &lt;a href="https://www.lambdatest.com/blog/finding-html-elements-using-cypress-locators/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=oct11_kj&amp;amp;utm_term=kj&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;Cypress locators&lt;/a&gt; from our tests, saying that this is the Page Object Model structure. We can find that under the “page-objects” folder:&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%2AmwlB6ZPIEpOLfVyO.png" class="article-body-image-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%2AmwlB6ZPIEpOLfVyO.png" width="294" height="130"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;export default class MainPage {

static searchGoogle(text){
       cy.get(`input[role='combobox']`).type(`${text} {enter}`)
   }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;As we mentioned above, our methods and locators can be found here; in our example, we try to do a simple search on Google.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;describe('Accessibility Testing Cypress', () =&amp;gt; {
   before(function(){
       cy.visit(`${config.URL2}`)
   })
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;For this case, we are using a before() hook that will open up our page before all of our tests, and after that, we can notice two tests, one related to a full-page home validation and the second one for the google search validation.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;it('verify full Home Page is displayed correctly', () =&amp;gt;{

       //Using Pally as our tool for Accessibility Testing
       cy.pa11y()
   })

it('Verify a search in Google', () =&amp;gt; {

cy.origin(`${config.URL3}`, () =&amp;gt; {
           cy.visit('/')
       })   
       MainPage.searchGoogle('Accessibility Testing')
       cy.pa11y()

})
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;You can go through the following video from 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=oct11_kj&amp;amp;utm_term=kj&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;LambdaTest YouTube channel&lt;/a&gt; to learn more about Cypress hooks:&lt;/p&gt;

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

&lt;p&gt;You can subscribe to the channel and get the latest tutorials around &lt;a href="https://www.lambdatest.com/blog/getting-started-with-cypress/" rel="noopener noreferrer"&gt;Cypress testing&lt;/a&gt;, &lt;a href="https://www.lambdatest.com/automated-browser-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=oct11_kj&amp;amp;utm_term=kj&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;automated browser testing&lt;/a&gt;, CI/CD, and more!&lt;/p&gt;

&lt;p&gt;And here is the test execution, which indicates that our Cypress accessibility testing approach is working:&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%2AuuvgvnV6AqxDUyXV.png" class="article-body-image-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%2AuuvgvnV6AqxDUyXV.png" width="800" height="379"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;One thing I forgot to mention during our test using “cy.origin” to use this experimental command, we must enable it from our cypress configuration file; our file must be as follows:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;"e2e": {
    "experimentalSessionAndOrigin": true
  },
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;If we don’t enable it, Cypress will throw an error:&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%2F2824%2F0%2AuliLIS6X2_YNf5So.png" class="article-body-image-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%2F2824%2F0%2AuliLIS6X2_YNf5So.png" width="800" height="213"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We must upgrade to Cypress 9.6.0, then we can try out the new functionality by setting the new experimentalSessionAndOrigin configuration option to true.&lt;/p&gt;

&lt;p&gt;In the next section of this tutorial on Cypress accessibility testing, we will learn how to perform accessibility testing on the Cypress cloud grid.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Online mobile &lt;a href="https://www.lambdatest.com/mobile-emulator-online?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=oct11_kj&amp;amp;utm_term=kj&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;emulators online&lt;/a&gt; from LambdaTest allows you to seamlessly test your mobile applications, websites,and web apps on mobile browsers and mobile devices.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  How to perform Cypress Accessibility Testing on the cloud grid?
&lt;/h2&gt;

&lt;p&gt;We can use a &lt;a href="https://www.lambdatest.com/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=oct11_kj&amp;amp;utm_term=kj&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;Cypress cloud grid&lt;/a&gt; like LambdaTest, which provides automated &lt;a href="https://www.lambdatest.com/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=oct11_kj&amp;amp;utm_term=kj&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;cross browser testing&lt;/a&gt; on 40+ browsers and operating systems, and &lt;a href="https://www.lambdatest.com/cypress-parallel-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=oct11_kj&amp;amp;utm_term=kj&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;Cypress parallel testing&lt;/a&gt; to expedite the test execution and help perform &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=oct11_kj&amp;amp;utm_term=kj&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;Cypress testing at scale&lt;/a&gt;. In addition, it will help improve our overall test coverage by resulting in better product quality as we can cover different combinations using the same test scripts.&lt;/p&gt;

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

&lt;p&gt;To get started with &lt;a href="https://www.lambdatest.com/cypress-e2e-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=oct11_kj&amp;amp;utm_term=kj&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;Cypress e2e testing&lt;/a&gt;, follow the below-mentioned steps:&lt;/p&gt;

&lt;p&gt;1- Install &lt;a href="https://www.lambdatest.com/blog/cypress-cli-on-lambdatest/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=oct11_kj&amp;amp;utm_term=kj&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;LambdaTest Cypress CLI&lt;/a&gt; on your machine. Trigger the following command to install the same:&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;2- After installation is completed, set up the configuration using 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;3- Once the command is completed, lambdatest-config.json is created in the project folder. Next, enter the LambdaTest credentials from the &lt;a href="https://accounts.lambdatest.com/detail/profile?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=oct11_kj&amp;amp;utm_term=kj&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;LambdaTest Profile Section&lt;/a&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;Your LambdaTest username&amp;gt;",
      "access_key": "&amp;lt;Your LambdaTest access key&amp;gt;"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;4- Here is how you can configure the required browser &amp;amp; OS combinations in lambdatest-config.json:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{
  "lambdatest_auth": {
     "username": "",
     "access_key": ""
  },
  "browsers": [
     {
        "browser": "MicrosoftEdge",
        "platform": "Windows 10",
        "versions": [
           "latest"
        ]
     },
     {
        "browser": "Chrome",
        "platform": "Windows 10",
        "versions": [
           "latest"
        ]
     },
     {
        "browser": "Firefox",
        "platform": "Windows 10",
        "versions": [
           "latest"
        ]
     }
  ],
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;5- The run_settings section in the JSON file contains the desired Cypress test suite capabilities, including Cypress_version, build_name, number of parallel sessions, etc.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;"run_settings": {
     "cypress_config_file": "cypress.json",
     "build_name": "build-Cypress-test",
     "parallels": 5,
     "specs": "./cypress/integration/e2e_tests/*.spec.js",
     "pluginsFile": true,
     "ignore_files": "",
     "npm_dependencies": {
        "cypress": "9.0.0",
        "[@cypress](http://twitter.com/cypress)-audit/pa11y": "^1.3.0",
        "cypress-plugin-snapshots": "^1.4.4",
        "cypress-visual-regression": "^1.6.2"
     },
     "feature_file_suppport": true
  },
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;6- Tunnel_settings in the JSON file lets you connect your local system with LambdaTest servers via an SSH-based integration tunnel. Once this tunnel is established, you can &lt;a href="https://www.lambdatest.com/support/docs/testing-locally-hosted-pages/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=oct11_kj&amp;amp;utm_term=kj&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;test locally hosted pages&lt;/a&gt; on all the browsers currently supported by Cypress on LambdaTest.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;"tunnel_settings": {
    "tunnel": false,
    "tunnelName": null
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;7- Now that the setup is ready, it’s time to run the tests; remember that our run_settings file displays the parallels field as five once we trigger our execution in parallel without any extra parameter. We must consider that the code used in the earlier test remains unchanged when we use the Cloud Grid.&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;Shown below is the test execution status from the &lt;a href="https://automation.lambdatest.com/?utm_source=medium&amp;amp;utm_medium=organic&amp;amp;utm_campaign=oct11_kj&amp;amp;utm_term=kj&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;LambdaTest Automation Dashboard&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%2A3hsixmBdbVJPLluY.png" class="article-body-image-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%2A3hsixmBdbVJPLluY.png" width="800" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;To view test performance metrics, navigate to the &lt;a href="https://analytics.lambdatest.com/test-overview?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=oct11_kj&amp;amp;utm_term=kj&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;LambdaTest Analytics Dashboard&lt;/a&gt;. The Test Overview will provide a snapshot of tests consistent with stable behavior. Meanwhile, the Test Summary will display the total number of tests passed or failed and any completed and pending 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%2F3200%2F0%2AWs1kOp5FbLYooe_R.png" class="article-body-image-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%2AWs1kOp5FbLYooe_R.png" width="800" height="402"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If you are a developer or a tester and have a basic understanding of Cypress and want to take your knowledge to the next level, then this Cypress 101 certification course is for you.&lt;/p&gt;

&lt;p&gt;Here’s a short glimpse of the Cypress 101 certification from LambdaTest:&lt;/p&gt;

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

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Automate &lt;a href="https://www.lambdatest.com/cypress-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=oct11_kj&amp;amp;utm_term=kj&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;Cypress testing&lt;/a&gt; and perform browser automation testing with LambdaTest. Our cloud infrastructure has 3000+ desktop &amp;amp; mobile environments. Try for free!&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Final Thoughts
&lt;/h2&gt;

&lt;p&gt;It’s important to ensure your website is accessible to all visitors, including those who have disabilities. 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=oct11_kj&amp;amp;utm_term=kj&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;Cypress tutorial&lt;/a&gt;, we learned the importance of accessibility testing and how to perform Cypress accessibility testing on a cloud grid.&lt;/p&gt;

&lt;p&gt;Let’s include Accessibility Testing in our projects; Accessibility is easy to consider once you start caring about it. The importance here is to embrace accessibility as part of our Automation testing. Let’s keep applications accessible to as many people as possible.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;“We must guarantee what we deliver works for everyone.” — Enrique A Decoss&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;My suggestion to all Testers is to consider accessibility in your test automation projects; we should work together and keep applications available to all. &lt;strong&gt;Accessibility can help us to generate a real impact.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Happy Bug Hunting!&lt;/strong&gt;&lt;/p&gt;

</description>
      <category>testing</category>
      <category>techtalks</category>
      <category>cypress</category>
      <category>performance</category>
    </item>
    <item>
      <title>How To Avoid Anti-Patterns In Cypress</title>
      <dc:creator>enriquee20</dc:creator>
      <pubDate>Mon, 10 Oct 2022 12:36:49 +0000</pubDate>
      <link>https://forem.com/testmuai/how-to-avoid-anti-patterns-in-cypress-13bg</link>
      <guid>https://forem.com/testmuai/how-to-avoid-anti-patterns-in-cypress-13bg</guid>
      <description>&lt;p&gt;No matter how advanced your automation technology is, anti-patterns represent standard bad practices, code smells, and pitfalls. In this case, when creating automated tests, teams can experience a range of difficulties that compound to create inefficient, incomplete, and hard-to-maintain 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%2AqmSJHy0sqWhbCn8_.gif" class="article-body-image-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%2AqmSJHy0sqWhbCn8_.gif" width="480" height="202"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In addition, to provide high-quality, cost efficiency, and on-time delivery, it’s essential to recognize the signs that your tests aren’t performing optimally. 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=oct10_kj&amp;amp;utm_term=kj&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;Cypress tutorial&lt;/a&gt; on avoiding anti-patterns in Cypress, we will discuss some anti-patterns that we believe should be avoided using &lt;a href="https://www.lambdatest.com/blog/cypress-test-automation-framework/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=oct10_kj&amp;amp;utm_term=kj&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;Cypress test automation framework&lt;/a&gt; for the most relevant testing experience and end product.&lt;/p&gt;

&lt;p&gt;Let’s get started!&lt;/p&gt;

&lt;p&gt;Get the best out of your Cypress tests with LambdaTest’s online &lt;a href="https://www.lambdatest.com/cypress-automation-tool?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=oct10_kj&amp;amp;utm_term=kj&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;Cypress automation tool&lt;/a&gt;. Check out how you can test your &lt;a href="https://www.lambdatest.com/blog/getting-started-with-cypress/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=oct10_kj&amp;amp;utm_term=kj&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;Cypress testing&lt;/a&gt; scripts using LambdaTest’s online cloud.&lt;/p&gt;

&lt;h2&gt;
  
  
  Fragile Locators
&lt;/h2&gt;

&lt;p&gt;Have you experienced fragile locators in your test scripts? Any slight change on the UI would fail the tests, and it will require some maintenance work to update the specific locator.&lt;/p&gt;

&lt;p&gt;Imagine a &lt;a href="https://www.lambdatest.com/blog/dynamic-rendering-using-html-and-css/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=oct10_kj&amp;amp;utm_term=kj&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;dynamic CSS&lt;/a&gt;, XPath, Id, Class, Tag selectors; it could be tough to target elements changing every time the web page loads.&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%2AngZ__J_DHCDoEQbM.png" class="article-body-image-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%2AngZ__J_DHCDoEQbM.png" width="800" height="390"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Let’s imagine an input field&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;input class="gLFyf gsfi" jsaction="paste:puy29d;" maxlength="2048" name="q" type="text" aria-autocomplete="both" aria-haspopup="false" autocapitalize="off" autocomplete="off" autocorrect="off" autofocus="" role="combobox" spellcheck="false" title="Search" value="" aria-label="Search" data-ved="0ahUKEwjj1t2JiY32AhVQkmoFHTMfD48Q39UDCAQ"&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;The easiest way to approach could be using:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;cy.get('.a4bIc')
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;But, that wouldn’t be the best approach as this is a fragile selector; instead, we should add test attributes to our elements, and the example above it should be like the following:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;input class="gLFyf gsfi" jsaction="paste:puy29d;" maxlength="2048" name="q" type="text" aria-autocomplete="both" aria-haspopup="false" autocapitalize="off" autocomplete="off" autocorrect="off" autofocus="" role="combobox" spellcheck="false" title="Search" value="" aria-label="Search" data-ved="0ahUKEwjj1t2JiY32AhVQkmoFHTMfD48Q39UDCAQ" data-test="submit"&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Now, we can use our locator in a better way:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;cy.get('[data-test=submit]')
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;The test-cy attribute will not change from CSS style or JS behavioral changes; additionally, it clarifies to everyone that this element is used directly by the test code.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;&lt;a href="https://www.lambdatest.com/android-emulator-online?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=oct10_kj&amp;amp;utm_term=kj&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;Online Android Emulator&lt;/a&gt; for testing your native Android apps and testing web apps over android browsers. Test your native, hybrid, and webapps across all legacy and latest mobile operating systems on most powerful Andoird emulator online.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Overcomplexity, chains in Cypress
&lt;/h2&gt;

&lt;p&gt;We always want to use elegant solutions and apply a better approach in our &lt;a href="https://www.lambdatest.com/automation-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=oct10_kj&amp;amp;utm_term=kj&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;test automation&lt;/a&gt; code, but always remember the KISS principle; if you are not aware, KISS is an acronym for Keep It Simple, Stupid. This principle says about making your code simple. It will help if you avoid unnecessary complexity. A simple code is easier to maintain and easier to understand.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;cy.get(nice.selector-unique').type('This is a great blog post.')
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Chaining the .type() onto the cy.get(), telling it to type into the subject yielded from the cy.get() command, which will be a DOM element.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;it('Another example of Command chains', () =&amp;gt; {
  cy.visit('[https://www.awesomesite.com'](https://www.awesomesite.com'))

cy
  // Find the element with id any-link'
  .get('#any-link')
  .as('myElement') // sets the alias
  .click()

cy.get('[@myElement](http://twitter.com/myElement)') // re-queries the DOM as before (only if necessary)
  .click()

})
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Using Aliases, let us reuse our DOM queries for faster tests when the element is still in the DOM. Furthermore, it automatically handles re-querying the DOM when it is not immediately found in the DOM. It is beneficial when dealing with front-end frameworks that do a lot of re-rendering.&lt;/p&gt;

&lt;p&gt;Another cool thing about Cypress is the built-in retry function available in too many commands; there is a default timeout set to 4000 milliseconds, which you can modify in your cypress.json file. If you come from &lt;a href="https://www.lambdatest.com/automation-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=oct10_kj&amp;amp;utm_term=kj&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;Selenium&lt;/a&gt;, you probably know it as a fluent &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=oct10_kj&amp;amp;utm_term=kj&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;wait&lt;/a&gt;. In this case, nothing extra needs to be added to our tests to make them wait fluently.&lt;/p&gt;

&lt;h2&gt;
  
  
  Inefficient waits, avoiding waits in Cypress
&lt;/h2&gt;

&lt;p&gt;Perhaps, you want to debug your tests, or you need to halt your tests for a couple of seconds to see the desired state. But, in Cypress, when you use .wait() and do nothing for a couple of seconds, how long do we need to wait? We understand sometimes our test scripts are going so fast that we need to consider hard waits and tell Cypress to reduce speed. But remember using waits in our code is regarded as an anti-pattern in Cypress.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;cy.get('#any-link')
    .wait(5000) 
    .click()
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Instead, we can use timeout per command; the timeouts can be modified per command, which will affect all default assertions and any assertions chained after that command.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;cy.get('#any-link', {timeout: 5000})
    .should('be.visible')
    .click()
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Also, you can wait for basically anything by passing a callback function into the &lt;strong&gt;.should()&lt;/strong&gt; command. It will use the built-in retry logic and wait for the procedure to pass. As a recap in our example above, Cypress will wait 5 seconds for the element to exist in the DOM and wait another 5 seconds for the same element to be visible.&lt;/p&gt;

&lt;h2&gt;
  
  
  Optimizing DRY, custom commands in Cypress
&lt;/h2&gt;

&lt;p&gt;If you are not aware of custom commands in Cypress, it is an excellent time to avoid reinventing the wheel and reuse those available custom commands. Cypress comes with its API for creating custom commands and overwriting existing commands, for example, cypress-downloadfile:&lt;/p&gt;

&lt;p&gt;You can install the module:&lt;/p&gt;

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

&lt;/div&gt;

&lt;p&gt;Then, add the following line to 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;Add the following lines to cypress/plugins/index.js&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const {downloadFile} = require('cypress-downloadfile/lib/addPlugin')
module.exports = (on, config) =&amp;gt; {
  on('task', {downloadFile})
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;After we can start using the custom command the following way:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;cy.downloadFile('[https://my_blog.pdf'](https://my_blog.pdf'), 'downloads', 'blogpost.pdf')
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;As mentioned before, we can reuse most of the custom commands, but Cypress allows us to modify the behavior of these custom commands; this is really useful to optimize our code and use the DRY principle.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Cypress.Commands.overwrite('download', (url, directory) =&amp;gt; {})
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Let’s try not to overcomplicate things and reuse custom commands in our tests.&lt;/p&gt;

&lt;p&gt;In the below &lt;a href="https://www.youtube.com/playlist?list=PLZMWkkQEwOPnxrxi544nL1vdC1noooXPx?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=oct10_kj&amp;amp;utm_term=kj&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;Cypress testing tutorial&lt;/a&gt; video, you’ll understand how to create custom commands in Cypress.&lt;/p&gt;

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/4AKKlLqsov4"&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?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=oct10_kj&amp;amp;utm_term=kj&amp;amp;utm_content=blog" 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=oct10_kj&amp;amp;utm_term=kj&amp;amp;utm_content=blog" 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=oct10_kj&amp;amp;utm_term=kj&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;Selenium testing&lt;/a&gt;, CI/CD, and more.&lt;/p&gt;

&lt;h2&gt;
  
  
  Behavior Driven Development in Cypress
&lt;/h2&gt;

&lt;p&gt;&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=oct10_kj&amp;amp;utm_term=kj&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;Behavior-driven development&lt;/a&gt; is a software engineering practice developed to deliver high-quality products by focusing on the business value or behavior of the system. The main difference is BDD focuses on the behavior/ business value. In contrast, TDD focuses on tests which sometimes leads developers to become too detail-focused compared to the business focus/value. However, it’s important to understand the &lt;a href="https://www.lambdatest.com/blog/tdd-vs-bdd/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=oct10_kj&amp;amp;utm_term=kj&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;TDD vs BDD difference&lt;/a&gt; before choosing a suitable framework.&lt;/p&gt;

&lt;p&gt;Cucumber is a tool that supports BDD; anyone can write specifications in plain English using Gherkin. It is as simple as adding a test from the business value point of view, as I like to call business-centric test automation.&lt;/p&gt;

&lt;p&gt;Let’s start adding the cucumber plugin using npm to our current Cypress project. Please follow the below video for Cypress installation:&lt;/p&gt;

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

&lt;p&gt;Please install the plugin.&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-cucumber-preprocessor
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;The following dependency with the latest version will be added to your package.json of the project. At the time of writing this recipe, the version of cypress-cucumber-preprocessor is 4.1.4&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;devDependencies": { "cypress-cucumber-preprocessor": "^4.1.4" }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;To make it work, we would need to add it to cypress plugins as part of Cypress Configuration under cypress/plugins/index.js&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const cucumber = required('cypress-cucumber-preprocessor').default

module.exports = (on, config) =&amp;gt; {
  on('file:preprocessor', cucumber())

}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Next, we need to add cosmiconfig configuration to the package.json. Cosmiconfig searches and loads the required configuration of the project. In this case, we are defining to locate the step definitions by setting up the below property.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;"cypress-cucumber-preprocessor": {
    "nonGlobalStepDefinitions": true
  }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Let’s create a new folder under Cypress -&amp;gt; Integration directory as ‘cucumber-test’ and then create a new feature, “Home.feature.”&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Feature: Home / Landing Page

Scenario: Navigating to E-commerce Store
           Given I open home page
           Then I should see Homepage
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;For step definition location, let’s create a folder named “home.”&lt;/p&gt;

&lt;p&gt;Let’s create a step definition file ‘homeSteps.js.”&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import { Given } from "cypress-cucumber-preprocessor/steps";

Given('I open home page', () =&amp;gt; {
    cy.visit('[https://ecommerce-playground.lambdatest.io/'](https://ecommerce-playground.lambdatest.io/'))
}) 

Then('I should see Homepage', () =&amp;gt; {    
    cy.get('#search').should('be.visible')
})
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;The folder structure should be as the following:&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%2AmE7p4Ii-a10DNXR1J3K06Q.png" class="article-body-image-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%2AmE7p4Ii-a10DNXR1J3K06Q.png" width="514" height="352"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now, let’s run using the following command in the terminal or command console to execute the test:&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;On Cypress Test Runner, select ‘home.feature’&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%2F3176%2F1%2AMMfNIfcSa6mNzoQFlqSvxA.png" class="article-body-image-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%2F3176%2F1%2AMMfNIfcSa6mNzoQFlqSvxA.png" width="800" height="524"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;And you should see the results correctly:&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%2AxOyA07ClFjgaC3dr.png" class="article-body-image-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%2AxOyA07ClFjgaC3dr.png" width="800" height="426"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Cucumber Expressions
&lt;/h2&gt;

&lt;p&gt;In the “.feature” file, cypress-cucumber-pre-processor uses the same expression as the cucumber expressions to link Gherkin to step definition. This can be achieved either by Cucumber expressions or regular expressions. The advantage of these is that they are more humanly readable than regular expressions. The following is how a Gherkin Step is translated in Step Definition.&lt;/p&gt;

&lt;h2&gt;
  
  
  Gherkin Step
&lt;/h2&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Given I open home page
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;h2&gt;
  
  
  Step Definition translation
&lt;/h2&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Given('I open home page', () =&amp;gt; { 
cy.visit(url) 
})
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;*** Test your native, hybrid, and webapps across all legacy and latest mobile operating systems on most powerful &lt;a href="https://www.lambdatest.com/android-emulator-online?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=oct10_kj&amp;amp;utm_term=kj&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;Andoird emulator online&lt;/a&gt;.***&lt;/p&gt;

&lt;h2&gt;
  
  
  Gherkin Keywords
&lt;/h2&gt;

&lt;p&gt;Keywords are used to give structure &amp;amp; meaning to the executable specifications. For example, every specification or a feature file starts one of the keywords as:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;FEATURE&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;SCENARIO&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;SCENARIO OUTLINE&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;BACKGROUND&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Examples:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Feature: Background Example

Background: Given greeting has been set

Scenario: example #1        
  When name is "John"        
 Then greetings equals "Hello John"

Scenario: example #2        
 When name is "Mary"        
 Then greetings equals "Hello Mary"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Step definition will look like the following:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;let myName, greeting, finalString;

Given("greeting has been set", () =&amp;gt; {    
greeting = 'Hello '
})

When("name is {string}", setName =&amp;gt; {    
myName = setName    
finalString = greeting.concat(myName) 
})

Then("greetings equals {string}", expectedValue =&amp;gt; {    expect(finalString).to.equal(expectedValue) 
})
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Take this certification to showcase your expertise with end-to-end testing using &lt;a href="https://www.lambdatest.com/blog/cypress-test-automation-framework/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=oct10_kj&amp;amp;utm_term=kj&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;Cypress automation&lt;/a&gt; framework and stay one step ahead.&lt;/p&gt;

&lt;p&gt;Here’s a short glimpse of the Cypress 101 certification from LambdaTest:&lt;/p&gt;

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

&lt;h2&gt;
  
  
  Gherkin Functions
&lt;/h2&gt;

&lt;p&gt;Gherkin uses functions to execute the specifications/ features files. These functions are used to translate the specification to executable tasks with the help of expressions or regular expressions.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;**GIVEN **represents pre-conditions in the executable specification. It is a pre-step to the specification or test.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;WHEN&lt;/strong&gt; represents the condition in the executable specification. It is a condition to the specification or test.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;**THEN **represents post-condition in the executable specification. It is the post-condition to the specification or test. There could be single or multiple steps as part of Then (post-condition).&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;**AND **step is to extend pre-step, conditions, and post-condition (s). It can be used with all the functions (Given, When &amp;amp; Then).&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;**BUT **is helpful to define the negative step in the scenario. Same like AND step, BUT also supports the Given/When/Then step.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  How do you write a feature statement?
&lt;/h2&gt;

&lt;p&gt;Follow the following principles to build greatness in features.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Keep it short and to the point.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Make your benefits measurable.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Emphasize the advantages.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The principles are not mandatory like Gherkin Keywords or Function, but they communicate the vision or goal of the feature.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Test your &lt;a href="https://www.lambdatest.com/mobile-emulator-for-app-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=oct10_kj&amp;amp;utm_term=kj&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;Android Emulator for iOS&lt;/a&gt; apps on an official mobile emulators for app testing hosted on cloud. No need to buy every new and expensive mobile devices for native app testing.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Feature and Steps Definition
&lt;/h2&gt;

&lt;p&gt;Here, we can find our Feature File and our Step Definition file.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;File: search.feature&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%2F2500%2F1%2A5qYIU8ZQbySGT8lGBbcBCA.png" class="article-body-image-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%2F2500%2F1%2A5qYIU8ZQbySGT8lGBbcBCA.png" width="800" height="601"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;File: searchSteps.js&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%2F2676%2F1%2A6L7tImqQa-emnZEFh235xg.png" class="article-body-image-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%2F2676%2F1%2A6L7tImqQa-emnZEFh235xg.png" width="800" height="626"&gt;&lt;/a&gt;&lt;/p&gt;

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

&lt;p&gt;Let’s start defining our Page file, here we can include our locators and URLs:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;searchPage.js&lt;/strong&gt;&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const URL = "[https://ecommerce-playground.lambdatest.io/](https://ecommerce-playground.lambdatest.io/)"
const search = "#search"

class SearchPage{
    static visitPage(){
        cy.visit(URL)
    }

static searchPrd(name){
        cy.get(search)
        .type(name+'{enter}')
    }

}

export default SearchPage
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;We defined the URL, in this case, &lt;a href="https://www.lambdatest.com/selenium-playground/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=oct10_kj&amp;amp;utm_term=kj&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;LambdaTest Playground&lt;/a&gt;, and our search locator, as we can see in the following two methods:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class SearchPage{
    static visitPage(){
        cy.visit(URL)
    }

static searchPrd(name){
        cy.get(search)
        .type(name+'{enter}')
    }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Now, let’s take a look into our Step Definition file searchSteps.js.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import { Given, When, Then } from "cypress-cucumber-preprocessor/steps"
import SearchPage from './searchPage'
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;First, we need to import our Cucumber plugin previously installed and our SearchPage file; this file includes our selectors and methods.&lt;/p&gt;

&lt;p&gt;Now we need to define our Given, When, and Then steps; let’s start with the “Given” one:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Given('I open home page', () =&amp;gt; {
    SearchPage.visitPage()
})
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;As we can notice, we are calling our SearchPage method to perform a “cy.visit”.&lt;/p&gt;

&lt;p&gt;Related to our “When” definition, we take advantage of dynamic parameters coming from our feature file. Therefore, it is helpful to get the actual search value from the feature file.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Scenario: Navigating to E-commerce and Search Mac Devices
        Given I open home page
        When I search for "Mac"
        Then I should see Product Available



When('I search for {string}', Mac =&amp;gt; {    
    SearchPage.searchPrd(Mac)

})
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;As we notice, we are distinguishing from a search returning any Product vs. a search returning no Products; it is helpful as our feature can include negative scenarios.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Then('I should see Product Available', () =&amp;gt; {    
    cy.get(`div:nth-of-type(1) &amp;gt; .product-thumb`)
        .should('be.visible')
})

Then('I should Not see Product Available', () =&amp;gt; {    
    cy.get(`div:nth-of-type(1) &amp;gt; .product-thumb`)
        .should('not.exist')
})



Scenario: Navigating to E-commerce and Search Mac Devices
        Given I open home page
        When I search for "Mac"
        Then I should see Product Available

Scenario: Navigating to E-commerce and Search Monitor Devices
        Given I open home page
        When I search for "Printers"
        Then I should Not see Product Available

    Scenario: Navigating to E-commerce and Search Samsung Devices
        Given I open home page
        When I search for "Samsung"
        Then I should see Product Available
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;And here is the test execution, which indicates that our BDD approach is working:&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%2AtgTkZ-C77H4p3Q-a.png" class="article-body-image-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%2AtgTkZ-C77H4p3Q-a.png" width="800" height="443"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  How to run Regression on Cypress Cloud Grid
&lt;/h2&gt;

&lt;p&gt;We can use a &lt;a href="https://www.lambdatest.com/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=oct10_kj&amp;amp;utm_term=kj&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;Cloud Cypress Grid&lt;/a&gt; like LambdaTest, which provides automated &lt;a href="https://www.lambdatest.com/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=oct10_kj&amp;amp;utm_term=kj&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;cross browser testing&lt;/a&gt; on 40+ browsers and operating systems, and &lt;a href="https://www.lambdatest.com/cypress-parallel-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=oct10_kj&amp;amp;utm_term=kj&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;Cypress parallel testing&lt;/a&gt; to expedite the test execution in a scalable way. In addition, it will help improve our overall test coverage by resulting in better product quality as we can cover different combinations using the same test scripts.&lt;/p&gt;

&lt;p&gt;To get started with &lt;a href="https://www.lambdatest.com/cypress-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=oct10_kj&amp;amp;utm_term=kj&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;Cypress testing&lt;/a&gt;, you have to install &lt;a href="https://www.lambdatest.com/blog/cypress-cli-on-lambdatest/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=oct10_kj&amp;amp;utm_term=kj&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;LambdaTest Cypress CLI&lt;/a&gt; on your machine. Trigger the following command to install the same:&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;After installation is completed, set up the configuration using 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;Once the command is completed, lambdatest-config.json is created in the project folder. Next, enter the LambdaTest credentials from the &lt;a href="https://accounts.lambdatest.com/detail/profile?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=oct10_kj&amp;amp;utm_term=kj&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;LambdaTest Profile Section&lt;/a&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;Your LambdaTest username&amp;gt;",
      "access_key": "&amp;lt;Your LambdaTest access key&amp;gt;"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Here is how you can configure the required browser &amp;amp; OS combinations in lambdatest-config.json:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{
  "lambdatest_auth": {
     "username": "",
     "access_key": ""
  },
  "browsers": [
     {
        "browser": "MicrosoftEdge",
        "platform": "Windows 10",
        "versions": [
           "latest"
        ]
     },
     {
        "browser": "Chrome",
        "platform": "Windows 10",
        "versions": [
           "latest"
        ]
     },
     {
        "browser": "Firefox",
        "platform": "macOS Big Sur",
        "versions": [
           "latest"
        ]
     },
     {
        "browser": "Firefox",
        "platform": "Windows 10",
        "versions": [
           "latest"
        ]
     }
  ],
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;The run_settings section in the JSON file contains the desired Cypress test suite capabilities, including Cypress_version, build_name, number of parallel sessions, etc.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;"run_settings": {
      "Cypress_config_file": "Cypress.json",
      "build_name": "build-cucumber-testing",
      "parallels": 5,
      "specs": "./Cypress/integration/cucumber-tests/*.feature",
      "ignore_files": "",
      "feature_file_suppport": false
   },
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Tunnel_settings in the JSON file lets you connect your local system with LambdaTest servers via an SSH-based integration tunnel. Once this tunnel is established, you can &lt;a href="https://www.lambdatest.com/support/docs/testing-locally-hosted-pages/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=oct10_kj&amp;amp;utm_term=kj&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;test locally hosted pages&lt;/a&gt; on all the browsers currently supported by Cypress on LambdaTest.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;"tunnel_settings": {
    "tunnel": false,
    "tunnelName": null
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Now that the setup is ready, it’s time to run the tests; remember that our run_settings file displays the parallels field as five once we trigger our execution in parallel without any extra parameter.&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;Shown below is the test execution status from the &lt;a href="https://automation.lambdatest.com/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=oct10_kj&amp;amp;utm_term=kj&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;LambdaTest Automation Dashboard&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%2AKusYtMylE1PSp7oc.png" class="article-body-image-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%2AKusYtMylE1PSp7oc.png" width="800" height="340"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;To view test performance metrics, navigate to the &lt;a href="https://analytics.lambdatest.com/test-overview?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=oct10_kj&amp;amp;utm_term=kj&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;LambdaTest Analytics Dashboard&lt;/a&gt;. The Test Overview will provide a snapshot of tests consistent with stable behavior. Meanwhile, the Test Summary will display the total number of tests passed or failed, as well as any completed tests and pending 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%2F3200%2F0%2AApBma72uBtp9FVl4.png" class="article-body-image-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%2AApBma72uBtp9FVl4.png" width="800" height="402"&gt;&lt;/a&gt;&lt;/p&gt;

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

&lt;h2&gt;
  
  
  Final Thoughts
&lt;/h2&gt;

&lt;p&gt;The presented list was not supposed to be exhaustive since there are good resources and smells/patterns in Parts II and III of xUnit Test Patterns. In this &lt;a href="https://www.lambdatest.com/cypress-e2e-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=oct10_kj&amp;amp;utm_term=kj&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;Cypress e2e testing&lt;/a&gt; tutorial on avoiding anti-patterns in Cypress, I focused on the BDD approach as our Test Automation must be customer-centric and easy to follow from our non-technical stakeholders.&lt;/p&gt;

&lt;p&gt;Happy Bug Hunting with Cypress!&lt;/p&gt;

</description>
      <category>tutorial</category>
      <category>cypress</category>
      <category>automation</category>
      <category>testing</category>
    </item>
    <item>
      <title>TDD vs BDD: Choosing The Suitable Framework</title>
      <dc:creator>enriquee20</dc:creator>
      <pubDate>Fri, 07 Oct 2022 11:28:47 +0000</pubDate>
      <link>https://forem.com/testmuai/tdd-vs-bdd-choosing-the-suitable-framework-3ih6</link>
      <guid>https://forem.com/testmuai/tdd-vs-bdd-choosing-the-suitable-framework-3ih6</guid>
      <description>&lt;p&gt;Most Software Developers in Test are familiar with Test-Driven Development, or TDD, but Behavior-Driven Development, or BDD, is often misunderstood. The truth is that both of these approaches have advantages and disadvantages to consider.&lt;/p&gt;

&lt;p&gt;This blog deep dives into TDD vs BDD comparison by looking at both these approaches individually. Later, we would compare them on functionalities, supported frameworks, and more. I could say BDD is merely the evolution of TDD.&lt;/p&gt;

&lt;h2&gt;
  
  
  What is Test-Driven Development (TDD)?
&lt;/h2&gt;

&lt;p&gt;Test-Driven Development is a programming practice implemented from a developer’s perspective. In this process, a QA engineer begins designing and writing test cases for every small functionality of an application.&lt;/p&gt;

&lt;p&gt;This technique tries to answer a simple question — Is the code valid? The primary purpose of this practice is to modify or write a new code only when the tests fail. Consequently, it results in lesser duplication of test scripts. This technique is mainly popular in agile development ecosystems. In a TDD approach, automated test scripts are written before functional pieces of code.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Check this &lt;a href="https://www.lambdatest.com/blog/cypress-test-automation-framework/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=oct07_kj&amp;amp;utm_term=kj&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;Cypress automation&lt;/a&gt; testing tutorial that will help you learn the benefits of Cypress automation, and how to install Cypress and execute Cypress automation testing over scores of browsers and operating systems online.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  How to Implement Test-Driven Development (TDD)
&lt;/h2&gt;

&lt;p&gt;Test-driven development gives preference to testing instead of the implementation phase. As all the tests pass, it signals the end of the first iteration. However, if more features have to be implemented, all the phases must be repeated with new feature tests. The figure below summarizes the flow of TDD:&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%2ABtPDG8epPdpNudar.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%2Fcdn-images-1.medium.com%2Fmax%2F2000%2F0%2ABtPDG8epPdpNudar.jpg" width="452" height="700"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Pros and Cons of Test-Driven Development (TDD)
&lt;/h2&gt;

&lt;p&gt;TDD is a test-first approach, where automated test scripts are typically written before implementing the product’s actual features. However, TDD has its own share of advantages (or pros) and disadvantages(or cons)&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Advantages of Test-Driven Development (TDD)&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Reduced cost of Development:&lt;/strong&gt; The development process in TDD is divided into smaller chunks to simplify the detection of issues at the early stages of design and development.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Focus on design and architecture:&lt;/strong&gt; Writing tests before the implementation makes the development process more seamless and efficient.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Improved Code Coverage:&lt;/strong&gt; Through TDD, a well-designed system can achieve 100 percent code coverage.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Code visibility:&lt;/strong&gt; Tests are written to verify smaller functionalities, making it easy to refactor and maintain the code.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Detailed Documentation:&lt;/strong&gt; Since tests are written for verifying micro-level functionalities, writing documentation becomes an easy task.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Disadvantages of Test-Driven Development (TDD)&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Bugs leading to faulty code:&lt;/strong&gt;  Tests could contain bugs which in turn results in faulty implementation. This can be averted by using the right BDD framework, performing detailed code review, and more.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Costly Architectural mistakes:&lt;/strong&gt; If the generated test code is not in line with the desired architecture, it could result in huge losses.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Slowness in development:&lt;/strong&gt; Creating test cases before code development slows product development. In addition, framing test cases may take a huge time as the actual implementation is not available at that time.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Requires prior experience:&lt;/strong&gt; Prior experience with TDD is a must since many teams commit the mistake of not running tests at the Red Stage.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  What is Test-Driven Development (TDD)?
&lt;/h2&gt;

&lt;p&gt;Test-Driven Development is a programming practice implemented from a developer’s perspective. In this process, a QA engineer begins designing and writing test cases for every small functionality of an application.&lt;/p&gt;

&lt;p&gt;This technique tries to answer a simple question — Is the code valid? The primary purpose of this practice is to modify or write a new code only when the tests fail. Consequently, it results in lesser duplication of test scripts. This technique is mainly popular in agile development ecosystems. In a TDD approach, automated test scripts are written before functional pieces of code.&lt;/p&gt;

&lt;h2&gt;
  
  
  How to Implement Test-Driven Development (TDD)
&lt;/h2&gt;

&lt;p&gt;Test-driven development gives preference to testing instead of the implementation phase. As all the tests pass, it signals the end of the first iteration. However, if more features have to be implemented, all the phases must be repeated with new feature tests. The figure below summarizes the flow of TDD:&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%2A2KX8-kIBiz31Yagx.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%2Fcdn-images-1.medium.com%2Fmax%2F2000%2F0%2A2KX8-kIBiz31Yagx.jpg" width="452" height="700"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Pros and Cons of Test-Driven Development (TDD)
&lt;/h2&gt;

&lt;p&gt;TDD is a test-first approach, where automated test scripts are typically written before implementing the product’s actual features. However, TDD has its own share of advantages (or pros) and disadvantages(or cons)&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Advantages of Test-Driven Development (TDD)&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Reduced cost of Development:&lt;/strong&gt; The development process in TDD is divided into smaller chunks to simplify the detection of issues at the early stages of design and development.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Focus on design and architecture:&lt;/strong&gt; Writing tests before the implementation makes the development process more seamless and efficient.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Improved Code Coverage:&lt;/strong&gt; Through TDD, a well-designed system can achieve 100 percent code coverage.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Code visibility:&lt;/strong&gt; Tests are written to verify smaller functionalities, making it easy to refactor and maintain the code.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Detailed Documentation:&lt;/strong&gt; Since tests are written for verifying micro-level functionalities, writing documentation becomes an easy task.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Disadvantages of Test-Driven Development (TDD)&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;**Bugs leading to faulty code: **Tests could contain bugs which in turn results in faulty implementation. This can be averted by using the right BDD framework, performing detailed code review, and more.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Costly Architectural mistakes:&lt;/strong&gt; If the generated test code is not in line with the desired architecture, it could result in huge losses.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Slowness in development:&lt;/strong&gt; Creating test cases before code development slows product development. In addition, framing test cases may take a huge time as the actual implementation is not available at that time.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Requires prior experience:&lt;/strong&gt; Prior experience with TDD is a must since many teams commit the mistake of not running tests at the Red Stage.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;In this article on what is TDD vs BDD, we have covered what is TDD, including its advantages and disadvantages. In the next section, we will look into BDD.&lt;/p&gt;

&lt;h2&gt;
  
  
  What is Behavior-Driven Development (BDD)
&lt;/h2&gt;

&lt;p&gt;Behavioral-Driven Development (BDD) is derived from the Test-Driven Development (TDD) methodology. In BDD, tests are based on systems behavior. BDD approach describes different ways to develop a feature based on its behavior. In most cases, the Given-When-Then approach is used for writing test cases. You can learn more about Gherkin by reading the article on &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=oct07_kj&amp;amp;utm_term=kj&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;Behavior Driven Development By Selenium Testing With Gherkin&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%2F2048%2F0%2AHYpBbNAIsJhesFZv.png" class="article-body-image-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%2F2048%2F0%2AHYpBbNAIsJhesFZv.png" width="800" height="600"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Let’s take an example for better understanding:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Scenario: User can sign in&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Given a valid user with username “lambdatest1.”&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;When I login as “lambdatest1.”&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Then I should see a message “Welcome, lambdatest1”&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Here is the overall approach to BDD:&lt;/p&gt;

&lt;p&gt;Debugging the errors in the latter stages of the development life cycle often proves to be very expensive. In most cases, ambiguity in understanding the requirements is the root cause behind this. Therefore, one must ensure that all the development efforts remain aligned towards fulfilling pre-determined requirements. BDD allows developers to do the above by:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Allowing the requirements to be defined in a standard approach using simple English.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Providing several ways to illustrate real-world scenarios for understanding requirements.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Providing a platform that enables the tech and non-tech teams to collaborate and understand the requirements&lt;/p&gt;&lt;/li&gt;
&lt;/ol&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=oct07_kj&amp;amp;utm_term=kj&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. Sign up for free!&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  How to Implement Behavior-Driven Development (BDD)
&lt;/h2&gt;

&lt;p&gt;As we know, BDD is an extension of TDD. BDD plays a crucial role in cutting back the bugs and errors you would encounter at later stages of product development. &lt;a href="https://www.lambdatest.com/blog/effective-test-automation-strategy/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=oct07_kj&amp;amp;utm_term=kj&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;Effective test automation strategy&lt;/a&gt;, including scenarios, can be developed by involving different teams (e.g., engineering, product management, marketing, etc.).&lt;/p&gt;

&lt;p&gt;The BDD approach accords technical and non-technical teams for the collaboration of knowledge and ideas. It’s time for some action.&lt;/p&gt;

&lt;p&gt;Cucumber is a tool that supports BDD; anyone can write specifications in plain English using Gherkin. It is as simple as adding a test from the business value point of view, as I like to call business-centric Test Automation. If you are new to Cucumber, you can also check out the step-by-step tutorial on &lt;a href="https://www.lambdatest.com/learning-hub/selenium-cucumber?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=oct07_kj&amp;amp;utm_term=kj&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;Selenium Cucumber&lt;/a&gt; with examples.&lt;/p&gt;

&lt;p&gt;Let’s start by adding the Cucumber plugin using npm to our current &lt;a href="https://www.lambdatest.com/learning-hub/cypress-tutorial?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=oct07_kj&amp;amp;utm_term=kj&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;Cypress Testing&lt;/a&gt; project.&lt;/p&gt;

&lt;p&gt;1- Please install the plugin.&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 --save-dev cypress-cucumber-preprocessor
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;2- The following dependency with the latest version will be added to your package.json of the project. At the time of writing this recipe, the version of cypress-cucumber-preprocessor is 4.1.4&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;devDependencies": { "cypress-cucumber-preprocessor": "^4.1.4" }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;3- To make it work, we would need to add it to cypress plugins as part of Cypress Configuration under cypress/plugins/index.js&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    const cucumber = required('cypress-cucumber-preprocessor').default

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; module.exports = (on, config) =&amp;amp;gt; {
      on('file:preprocessor', cucumber())
    }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;4- Next, we need to add cosmiconfig configuration to the package.json. Cosmiconfig searches and loads the required configuration of the project. In this case, we are defining to locate the step definitions by setting up the below property.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;"cypress-cucumber-preprocessor": {
        "nonGlobalStepDefinitions": true
      }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;5- Let’s create a new folder under Cypress -&amp;gt; Integration directory as ‘cucumber-test’ and then create a new feature, “Home.feature.”&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Feature: Home / Landing Page

    Scenario: Navigating to E-commerce Store
               Given I open home page
               Then I should see Homepage
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;6- For step definition location, let’s create a folder named “home.” Let’s create a step definition file ‘homeSteps.js.”&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; import { Given } from "cypress-cucumber-preprocessor/steps";

    Given('I open home page', () =&amp;amp;gt; {
        cy.visit('[https://ecommerce-playground.lambdatest.io/'](https://ecommerce-playground.lambdatest.io/'))
    }) 

    Then('I should see Homepage', () =&amp;amp;gt; {    
        cy.get('#search').should('be.visible')
    })
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The folder structure should be as the following:&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%2AM_FKUFWXJfJYvj7J_MJo7A.png" class="article-body-image-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%2AM_FKUFWXJfJYvj7J_MJo7A.png" width="514" height="352"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;7- Now, let’s run using the following command in the Terminal or command console to execute the test:&lt;br&gt;
&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;8- On Cypress Test runner, select ‘home.feature.’&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%2AYoHIjwImsyduEK3sZq7fPQ.png" class="article-body-image-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%2AYoHIjwImsyduEK3sZq7fPQ.png" width="768" height="504"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;And you should see the results correctly:&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%2AeL9BqvtpXhOIdSzl.png" class="article-body-image-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%2AeL9BqvtpXhOIdSzl.png" width="800" height="426"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Note:&lt;/em&gt;&lt;/strong&gt;  You can download the code from the GitHub Repository.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Gherkin Keywords&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Keywords are used to give structure &amp;amp; meaning to the executable specifications. Every specification or a feature file starts one of the keywords as:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Feature&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Scenario&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Scenario Outline&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Background&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Feature&lt;/strong&gt; — It is the primary key in the Gherkin; it is used to describe the specification name.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Feature: Hello     
    In order to start a conversation with someone     
    chat bot needs to start with greetings     
    so the user gets the interactive feel.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Scenario&lt;/strong&gt; — It is the collection of actions or steps which need to be performed to fulfill a test objective.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Feature: Greetings     
    In order to start the conversation with someone   
    chat bot needs to start with greetings     
    so the user gets the interactive feel.

    Scenario: example     
    Given greeting has been set to "hello"     
    When name is "Frank"     
    Then greetings equals "Hello Frank"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Scenario Outline&lt;/strong&gt; — is used when the same scenario needs to be executed with multiple data sets. Scenario Outline is always defined with Examples keyword that’s where data sets can be defined to execute the same scenario multiple times. Scenario Outline is used for Data-driven tests.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Feature: Greetings  
    In order to start the conversation with someone
    chat bot needs to start with greetings   
    so the user gets the interactive feel.

    Scenario Outline: example    
    Given greeting has been set to""    
    When name is ""    
    Then greetings equals "" 
    Examples: 
    | greeting | name | conversation |  
    | Hello      | Frank   | Hello Frank   |  
    | Hi         | Maria   | Hi Maria      |
    | Hey        | Johnny  | Hey Johnny    |
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Implementation example:&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; let myName, greeting, finalword
    Given("greeting has been set to {string}", setGreeting =&amp;amp;gt; {    
    greeting = setGreeting + ' ' 
    })

    When("name is {string}", setName =&amp;amp;gt; {    
    myName = setName    
    finalString = greeting.concat(myName) 
    })

    Then("greetings equals {string}", expectedValue =&amp;amp;gt; {    expect(finalword).to.equal(expectedValue)
    })
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Background&lt;/strong&gt; — It is used to define a step or series of steps common to all the tests included in the feature file. The steps defined as part of the background get executed before each scenario. Adding the Background section is helpful to avoid duplication of feature steps.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Feature: Background Example 
    Background: 
    Given greeting has been set 
    Scenario: example1        
    When name is "Frank"        
    Then greetings equals "Hello Frank" 
    Scenario: example2        
    When name is "Maria"        
    Then greetings equals "Hello Maria"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Pros and Cons of Behavior-Driven Development (BDD)
&lt;/h2&gt;

&lt;p&gt;BDD is an approach that involves managers, testers, developers, etc., in the whole process. As a result, BDD offers a huge number of benefits. Let’s look at some of the major ones in this section.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Advantages of Behavior-Driven Development (BDD)&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Improved Communication:&lt;/strong&gt; Creating scenarios requires close coordination between clients, managers, developers, testers, etc. This unifies the team in understanding the product behavior.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Reduced cost of Quality Control:&lt;/strong&gt; Automated acceptance tests are used to depict the scenarios, which in turn helps in reducing the costs involved in inspecting the product quality.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Accurate task estimation:&lt;/strong&gt; Since the expected behavior is predicted before, there are few chances to change the software application’s architecture.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Better user experience:&lt;/strong&gt; The scenarios and tests written before development take the user’s perspective into account. The focus is on the desired behavior rather than on implementing features.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Excellent documentation:&lt;/strong&gt; When a certain test fails, the specification is updated, resulting in the detailed documentation.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Challenges of Behavior-Driven Development (BDD)&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Requires more involvement from all the stakeholders:&lt;/strong&gt; Putting all the people together becomes difficult for teams. Is it the three amigos sitting down together, talking, collaborating, and leaving with a common language around the system requirements?&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;BDD tools struggle with parallelization:&lt;/strong&gt; Cucumber and SpecFlow do parallelization or support &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=oct07_kj&amp;amp;utm_term=kj&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;parallel testing&lt;/a&gt; in a sub-optimal manner. They parallelize at the feature file level. It implies that if you want to run 50 tests in parallel, you need to have 50 feature files. That’s a lot of feature files.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Writing incorrect Gherkin syntax:&lt;/strong&gt; The issue is that most of us do not follow the correct Gherkin syntax as prescribed by the BDD creators. Just remember Given-When-Then steps must appear in order and cannot repeat.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;You can go through this webinar if you are intrigued to know more about using the BDD and &lt;a href="https://www.lambdatest.com/selenium-grid-online?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=oct07_kj&amp;amp;utm_term=kj&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;Online Selenium Grid&lt;/a&gt; together.&lt;/p&gt;

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/_w-lf4VwXxY"&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?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=oct07_kj&amp;amp;utm_term=kj&amp;amp;utm_content=blog" 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/selenium-automation?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=oct07_kj&amp;amp;utm_term=kj&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;Selenium testing&lt;/a&gt;, &lt;a href="https://www.lambdatest.com/cypress-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=oct07_kj&amp;amp;utm_term=kj&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;Cypress testing&lt;/a&gt;, CI/CD, and more.&lt;/p&gt;

&lt;h2&gt;
  
  
  TDD vs BDD — The Final Showdown
&lt;/h2&gt;

&lt;p&gt;TDD vs BDD is a quest for some developers. Even experienced developers find it difficult to differentiate between these approaches. Now that we have touched upon the working and implementation of TDD and BDD, let’s deep dive into the major differences in this epic TDD vs BDD clash:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
    &lt;tr&gt;
        &lt;td&gt;Criteria&lt;/td&gt;
        &lt;td&gt;Test-Driven Development (TDD)&lt;/td&gt;
        &lt;td&gt;Behavior-Driven Development
(BDD)&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
        &lt;td&gt;Language&lt;/td&gt;
        &lt;td&gt;Test cases designed in TDD are Technical. These are similar to the test cases that are normally written during the testing phase.&lt;/td&gt;
        &lt;td&gt;The test scenarios designed in BDD are written in simple English language.&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
        &lt;td&gt;Implementation Level&lt;/td&gt;
        &lt;td&gt;There is a low-level implementation in TDD.&lt;/td&gt;
        &lt;td&gt;The scenarios are easy to understand and implement, making BDD a high-level implementation with regard to test case development.&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
        &lt;td&gt;Key Stages&lt;/td&gt;
        &lt;td&gt;Test case development is the major phase in TDD.&lt;/td&gt;
        &lt;td&gt;Discussion and creation of scenarios are the major stages in BDD.&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
        &lt;td&gt;Stages involved in Development&lt;/td&gt;
        &lt;td&gt;TDD involves three main stages, Test creation, implementation, and code refactoring are the major stages in TDD.&lt;/td&gt;
        &lt;td&gt;BDD involves a number of stages like feature discussion, scenario creation, testing, implementation, and code refactoring.&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
        &lt;td&gt;Participants&lt;/td&gt;
        &lt;td&gt;Only technical teams like development teams take part in TDD processes.&lt;/td&gt;
        &lt;td&gt;BDD involves many teams, right from client to business analysts, testers, developers, etc.&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
        &lt;td&gt;Primary Focus&lt;/td&gt;
        &lt;td&gt;Development of required functionality based on test cases is the primary focus in TDD.&lt;/td&gt;
        &lt;td&gt;BDD focuses on the correspondence between implemented features and expected behavior.&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
        &lt;td&gt;Documentation&lt;/td&gt;
        &lt;td&gt;TDD requires documentation for the creation of accurate test cases.&lt;/td&gt;
        &lt;td&gt;Thrust is laid on documentation created during the scenario creation process.&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
        &lt;td&gt;Tools&lt;/td&gt;
        &lt;td&gt;The tools (or frameworks) used in TDD involve JUnit, TestNG, NUnit, etc. These are used to run test cases.&lt;/td&gt;
        &lt;td&gt;Gherkin is used for writing scenarios in BDD. Cucumber, SpecFlow, etc., are some of the widely used test automation frameworks.&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
        &lt;td&gt;Applicable Domain&lt;/td&gt;
        &lt;td&gt;The main focus in TDD is to get appropriate functionality through implementation.&lt;/td&gt;
        &lt;td&gt;BDD has the defined domain as “Behavior.” This focuses on the product’s behavior at the end of implementing the product functionality.&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
        &lt;td&gt;Bug Tracking&lt;/td&gt;
        &lt;td&gt;Bug tracking is easier in TDD, as the tests indicate whether they have passed or failed.&lt;/td&gt;
        &lt;td&gt;Bug tracking in BDD requires integration between multiple tools across the organization.&lt;/td&gt;
    &lt;/tr&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;So, these were the key differences as far as TDD vs BDD is concerned. So, make sure to look upon these differences when you have to decide between TDD vs BDD.&lt;/p&gt;

&lt;h2&gt;
  
  
  Can TDD and BDD work together?
&lt;/h2&gt;

&lt;p&gt;So far, we have seen what is different as far as TDD vs BDD is concerned. The best part is that these processes are not mutually exclusive. While it’s not unusual for Agile teams to use one without the other, making these two work together can ensure a higher degree of efficiency in testing use cases, thereby bringing confidence in the performance.&lt;/p&gt;

&lt;p&gt;TDD, when used alongside BDD, gives importance to &lt;a href="https://www.lambdatest.com/web-testing?utm_source=medium&amp;amp;utm_medium=organic&amp;amp;utm_campaign=oct07_kj&amp;amp;utm_term=kj&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;web testing&lt;/a&gt; from the developer’s perspective, with greater emphasis laid on the application’s behavior. To implement the specifics, developers can create separate testing units to get robust components. This is beneficial since the same component can be used in different places across the software development process.&lt;/p&gt;

&lt;p&gt;You can use cloud tools like LambdaTest to leverage the capabilities of both TDD and BDD frameworks and perform &lt;a href="https://www.lambdatest.com/live-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=oct07_kj&amp;amp;utm_term=kj&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;live testing&lt;/a&gt;. LambdaTest is a &lt;a href="https://www.lambdatest.com/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=oct07_kj&amp;amp;utm_term=kj&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;cross browser testing&lt;/a&gt; platform that enables you to run your test scripts on an &lt;a href="https://www.lambdatest.com/online-device-farm?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=oct07_kj&amp;amp;utm_term=kj&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;online device farm&lt;/a&gt; of 3000+ real browsers and real operating systems.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.lambdatest.com/integrations/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=oct07_kj&amp;amp;utm_term=kj&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;LambdaTest integration&lt;/a&gt; with tools like Slack, Microsoft Teams, etc., makes discussions between the teams efficient and easy. TDD or BDD, the choice is governed by the individual needs of an application or the enterprise.&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%2F2048%2F0%2A6vQKqaXwNkytNf1N.png" class="article-body-image-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%2F2048%2F0%2A6vQKqaXwNkytNf1N.png" width="800" height="362"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The combination of TDD and BDD frameworks can add more value to the software development process. This is where automation testing tools like LambdaTest can be beneficial since they can be integrated with major TDD and BDD frameworks.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;This &lt;a href="https://www.lambdatest.com/blog/playwright-framework?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=oct07_kj&amp;amp;utm_term=kj&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;Playwright Automation&lt;/a&gt; tutorial will guide you through the setup of the Playwright framework, which will enable you to write end-to-end tests for your future projects.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  TDD vs BDD — Which approach is best for your project?
&lt;/h2&gt;

&lt;p&gt;BDD and TDD have differences and similarities. Although, at the same time, it’s not unusual for Agile teams to use one without the other, making the two work together can guarantee a higher degree of efficiency in testing application use cases, thus obtaining greater confidence in their performance.&lt;/p&gt;

&lt;p&gt;TDD vs BDD, an Agile team, alongside TDD, can use the BDD approach to put in place a higher level of testing that takes care of technical nuances from the Agile team’s point of view and assesses the application’s behavior.&lt;/p&gt;

&lt;p&gt;To implement the specifics, we can create separate testing units to maintain the robustness of different components. It can be beneficial considering that the same component can be used in other places across an application.&lt;/p&gt;

&lt;p&gt;The testing process is based on specifying test scenarios in simple language. Then, Automation Engineers add TDD parts for testing certain specific components. Whether to choose BDD over TDD or use a combination of the two methods is a choice ruled by the needs of an application or organization.&lt;/p&gt;

&lt;p&gt;Experimenting with BDD if you’re already doing TDD testing can add value to the Agile process. Using the two together is more accessible, and you don’t need to change or rework the existing approach. All it takes is updating the testing framework to adjust the other.&lt;/p&gt;

&lt;p&gt;Selenium 101 certification from LambdaTest is a great way to validate your expertise in &lt;a href="https://www.lambdatest.com/selenium-automation?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=oct07_kj&amp;amp;utm_term=kj&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;Selenium automation testing&lt;/a&gt;. There are plenty of good reasons to get Selenium certified. You can use it to prove that you’re on top of things, or you can use it as a way to help yourself learn.&lt;/p&gt;

&lt;h2&gt;
  
  
  Final Thoughts
&lt;/h2&gt;

&lt;p&gt;In this TDD vs BDD article, you can always view the big picture and decide which approach is best for your software requirements. However, whether you choose to implement test-driven or behavior-driven development, you will require strong QA and testing skills and tools.&lt;/p&gt;

&lt;p&gt;Understanding TDD vs BDD approaches work can help Agile teams and other stakeholders improve the development process by zeroing in on the best test strategy for their needs. Then, depending on the nature of the project and the desired result, you can choose between a mix of the two techniques to &lt;a href="https://www.lambdatest.com/webinar/how-to-get-true-cross-browser-test-coverage-with-testCafe-and-lambdatest-webinar?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=oct07_kj&amp;amp;utm_term=kj&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;enhance test coverage efficiency&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Thus, till then, Happy Testing!&lt;/p&gt;

</description>
      <category>bdd</category>
      <category>tdd</category>
      <category>framework</category>
      <category>beginners</category>
    </item>
    <item>
      <title>Complete Guide To Cypress Visual Regression Testing</title>
      <dc:creator>enriquee20</dc:creator>
      <pubDate>Thu, 06 Oct 2022 10:26:43 +0000</pubDate>
      <link>https://forem.com/testmuai/complete-guide-to-cypress-visual-regression-testing-5eab</link>
      <guid>https://forem.com/testmuai/complete-guide-to-cypress-visual-regression-testing-5eab</guid>
      <description>&lt;p&gt;Sometimes referred to as automated UI testing or &lt;a href="https://www.lambdatest.com/smart-visual-ui-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=oct06_kj&amp;amp;utm_term=kj&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;visual regression testing&lt;/a&gt;, VRT checks software from a purely visual standpoint (taking a screenshot and comparing it against another approved screenshot). Cypress is an emerging test automation framework that enables teams to ship high-quality products faster.&lt;/p&gt;

&lt;p&gt;Cypress utilizes a modern architectural approach and is fully equipped with built-in screenshot functionality and also video recording capabilities, making it 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=oct06_kj&amp;amp;utm_term=kj&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;best test automation frameworks&lt;/a&gt; for Cypress visual regression testing.&lt;/p&gt;

&lt;p&gt;For those Automation Engineers validating a UI or performing an HTML canvas test, the UI look and feel of the application is vital for our end-users. Companies spend a lot on strategies to acquire more customers through advertisements, campaigns, and more. A missing visual error in production can jeopardize their reputation. My recommendation is to start learning some &lt;a href="https://www.lambdatest.com/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=oct06_kj&amp;amp;utm_term=kj&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;Visual Testing tools&lt;/a&gt;.&lt;/p&gt;

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

&lt;p&gt;Visual Testing is about which parts of your UI are most important to test (Visual Coverage). Perhaps visual or HTML canvas test is similar to functional testing in that it’s designed to be an automated process that runs alongside code reviews. However, unlike functional testing, the HTML canvas test results cannot be considered as Passed or Failed.&lt;/p&gt;

&lt;p&gt;Starting your journey with &lt;a href="https://www.lambdatest.com/cypress-ui-automation?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=oct06_kj&amp;amp;utm_term=kj&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;Cypress UI Automated Testing?&lt;/a&gt; Check out how you can test your &lt;a href="https://www.lambdatest.com/blog/cypress-test-automation-framework/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=oct06_kj&amp;amp;utm_term=kj&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;Cypress automation&lt;/a&gt; test scripts on LambdaTest’s online cloud.&lt;/p&gt;

&lt;p&gt;Now execute test scripts faster than any other automation testing grid on &lt;a href="https://www.lambdatest.com/automated-ui-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=oct06_kj&amp;amp;utm_term=kj&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;LambdaTest’s Automated UI testing cloud&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Let’s deep dive into performing visual regression testing with the &lt;a href="https://www.lambdatest.com/blog/cypress-test-automation-framework/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=oct06_kj&amp;amp;utm_term=kj&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;Cypress test automation framework&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&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=oct06_kj&amp;amp;utm_term=kj&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;automation testing tools&lt;/a&gt; that have climbed the top of the ladder so far? Let’s take a look.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Understanding Visual Regression Testing
&lt;/h2&gt;

&lt;p&gt;Before talking about visual regression testing, we need to understand the current state of visual testing. Functional test scripts can validate the size, position, and color scheme of visual elements.&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%2AAoPgSoOUjtd9gGR6.png" class="article-body-image-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%2AAoPgSoOUjtd9gGR6.png" width="512" height="364"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;As Automation Engineers, we perform ad hoc and &lt;a href="https://www.lambdatest.com/blog/exploratory-testing-all-about-discovery/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=oct06_kj&amp;amp;utm_term=kj&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;exploratory testing&lt;/a&gt; to catch edge cases and visual bugs regarding manual checkpoints. But, to be honest, it could be challenging from a manual standpoint to verify an entire screen or different screens and detect those visual diffs.&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%2A1TtVbqWIg1Vfk5ad.png" class="article-body-image-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%2A1TtVbqWIg1Vfk5ad.png" width="726" height="316"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Some years ago, there was a good approach called pixel matching. It was related to a bitmap of a screen capturing various points, and its pixels were compared to a baseline bitmap. Pixel matching tools can spot pixel differences quickly and consistently and highlight the visual differences based on pixels.&lt;/p&gt;

&lt;p&gt;If we had a great approach, what went wrong? Well, various things were wrong with snapshot or &lt;a href="https://www.lambdatest.com/automated-screenshot?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=oct06_kj&amp;amp;utm_term=kj&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;screenshot testing&lt;/a&gt;; we can enumerate some of the challenges using this approach:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Variation of screen resolutions&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Image hardware rendering bitmaps differently&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Variations in browser font size and other elements&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Flakiness on dynamic content (Capturing screenshots by the element, we can skip flaky visual tests)&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;With this Screenshot Testing Tutorial, you will learn how to perform Automated Screenshot Testing on the LambdaTest platform.&lt;/p&gt;

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

&lt;p&gt;Actual tools currently combine computer vision as the core of visual comparison and visual diffs when discussing visual regression testing. Unlike pixel matching (snapshot testing), VRT tools do not need unique environments that remain static to ensure accuracy. By blending &lt;a href="https://www.lambdatest.com/automation-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=oct06_kj&amp;amp;utm_term=kj&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;test automation&lt;/a&gt; and image processing, visual regression testing checks that our application looks as it should. With functional checks alone, multiple of the challenges of frontend testing persists.&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%2F3168%2F0%2AcbMUKagv7CwfV20c.png" class="article-body-image-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%2F3168%2F0%2AcbMUKagv7CwfV20c.png" width="800" height="337"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Cypress Visual Regression Testing
&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=oct06_kj&amp;amp;utm_term=kj&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;cypress tutorial&lt;/a&gt; for &lt;a href="https://www.lambdatest.com/cross-browser-testing-with-cypress?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=oct06_kj&amp;amp;utm_term=kj&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;cross browser testing with Cypress&lt;/a&gt;, we discussed the difference between snapshot testing and visual regression testing; typically, we can find some plugins in Cypress to compare images and follow the same process of performing snapshot testing; for example, we can use the &lt;a href="https://github.com/meinaart/cypress-plugin-snapshots?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=oct06_kj&amp;amp;utm_term=kj&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;cypress-plugin-snapshots&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;This open-source plugin compares the baseline and the side of the current image by the side within the Cypress Test Runner if the pixel difference is above the threshold.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Try this online &lt;a href="https://www.lambdatest.com/selenium-automation?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=oct06_kj&amp;amp;utm_term=kj&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;Selenium Automation&lt;/a&gt; Grid to run your browser automation testing scripts. Our cloud infrastructure has 3000+ desktop &amp;amp; mobile environments. Try for free!&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Cypress Version 9.0.0
&lt;/h2&gt;

&lt;p&gt;Before talking about Cypress plugins, we should consider the new Cypress 9.0.0, as I updated to that version; if you want to update, please consider the following changes below; my recommendation is to check the Release notes before updating any project to the latest version.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;The nodeVersion configuration option now defaults to the system. The behavior of the system option has always changed to use the Node.js binary/version that launched Cypress. If Cypress was not launched via the terminal, Cypress would use the bundled Node.js version. It could change the code behavior within your plugins file since it may be run in your system Node.js version &lt;a href="https://github.com/cypress-io/cypress/issues/18684" rel="noopener noreferrer"&gt;#18684&lt;/a&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Windows 32-bit is not supported in Cypress &lt;a href="https://github.com/cypress-io/cypress/issues/17962" rel="noopener noreferrer"&gt;#17962&lt;/a&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;cy.contains() no longer yields the &lt;/p&gt; element when it matches the content of  or &amp;lt;style&amp;gt; tags &amp;lt;a href="https://github.com/cypress-io/cypress/issues/14861"&amp;gt;#14861&amp;lt;/a&amp;gt;.&amp;lt;/p&amp;gt;&amp;lt;/li&amp;gt;
&amp;lt;li&amp;gt;&amp;lt;p&amp;gt;Attempting to add an existing built-in Cypress command using Cypress.Commands.add() will now throw an error, indicating that Cypress.Commands.overwrite() should be used instead to overwrite the behavior of existing commands &amp;lt;a href="https://github.com/cypress-io/cypress/issues/18572"&amp;gt;#18572&amp;lt;/a&amp;gt;.&amp;lt;/p&amp;gt;&amp;lt;/li&amp;gt;
&amp;lt;li&amp;gt;&amp;lt;p&amp;gt;Custom command implementations are now typed based on the declared custom chainable &amp;lt;a href="https://github.com/cypress-io/cypress/issues/17496"&amp;gt;#17496&amp;lt;/a&amp;gt;.&amp;lt;/p&amp;gt;&amp;lt;/li&amp;gt;
&amp;lt;li&amp;gt;&amp;lt;p&amp;gt;The bundled Node.js version was upgraded from 14.17.0 to 16.5.0. This could change the code behavior within the plugins file when using the bundled Node.js version of Cypress &amp;lt;a href="https://github.com/cypress-io/cypress/pull/18317"&amp;gt;#18317&amp;lt;/a&amp;gt;.&amp;lt;/p&amp;gt;&amp;lt;/li&amp;gt;
&amp;lt;li&amp;gt;&amp;lt;p&amp;gt;When null is passed as the encoding to cy.readFile() or cy.fixture(), the file is treated as binary and read as a Buffer. Similarly, null passed as the encoding to cy.writeFile() allows direct writing of buffers. If the encoding is unspecified, the default remains utf8, matching the current behavior &amp;lt;a href="https://github.com/cypress-io/cypress/issues/18534"&amp;gt;#18534&amp;lt;/a&amp;gt;.&amp;lt;/p&amp;gt;&amp;lt;/li&amp;gt;
&amp;lt;li&amp;gt;&amp;lt;p&amp;gt;Sticky elements within a fixed container will now be adequately scrolled to during action commands &amp;lt;a href="https://github.com/cypress-io/cypress/issues/4233"&amp;gt;#4233&amp;lt;/a&amp;gt;.&amp;lt;/p&amp;gt;&amp;lt;/li&amp;gt;
&amp;lt;li&amp;gt;&amp;lt;p&amp;gt;document.referrer will now correctly reflect the correct value from the application under test after cy.visit() &amp;lt;a href="https://github.com/cypress-io/cypress/issues/4295"&amp;gt;#4295&amp;lt;/a&amp;gt;.&amp;lt;/p&amp;gt;&amp;lt;/li&amp;gt;
&amp;lt;/ul&amp;gt;

&amp;lt;p&amp;gt;If you are new to the world of Cypress or don’t know &amp;lt;a href="https://www.lambdatest.com/blog/cypress-test-automation-framework/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=oct06_kj&amp;amp;utm_term=kj&amp;amp;utm_content=blog"&amp;gt;what is Cypress&amp;lt;/a&amp;gt; in detail, you can go through this complete &amp;lt;a href="https://www.youtube.com/playlist?list=PLZMWkkQEwOPnxrxi544nL1vdC1noooXPx?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=oct06_kj&amp;amp;utm_term=kj&amp;amp;utm_content=blog"&amp;gt;Cypress Tutorial for Beginners&amp;lt;/a&amp;gt;, which will walk you through the basics of what is Cypress, including the Cypress Installation &amp;amp;amp; Project Setup, and help you create your first test script using Cypress.&amp;lt;/p&amp;gt;

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

&amp;lt;p&amp;gt;However, you can visit the &amp;lt;a href="https://www.youtube.com/c/LambdaTest?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=oct06_kj&amp;amp;utm_term=kj&amp;amp;utm_content=blog"&amp;gt;LambdaTest YouTube channel&amp;lt;/a&amp;gt; for more videos on &amp;lt;a href="https://www.lambdatest.com/blog/cypress-test-automation-framework/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=oct06_kj&amp;amp;utm_term=kj&amp;amp;utm_content=blog"&amp;gt;Cypress Testing&amp;lt;/a&amp;gt;, &amp;lt;a href="https://www.lambdatest.com/selenium-automation?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=oct06_kj&amp;amp;utm_term=kj&amp;amp;utm_content=blog"&amp;gt;Selenium testing&amp;lt;/a&amp;gt;, etc., so there’s never a shortage of learning opportunities.&amp;lt;/p&amp;gt;
&amp;lt;h2&amp;gt;
  &amp;lt;a name="cypress-visual-regression-plugin" href="#cypress-visual-regression-plugin" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  Cypress Visual Regression Plugin
&amp;lt;/h2&amp;gt;

&amp;lt;p&amp;gt;I recommend one plugin (&amp;lt;a href="https://github.com/mjhea0/cypress-visual-regression?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=oct06_kj&amp;amp;utm_term=kj&amp;amp;utm_content=blog"&amp;gt;cypress-visual-regression&amp;lt;/a&amp;gt;) for Cypress visual regression testing, which is really easy to install within Cypress.&amp;lt;/p&amp;gt;
&amp;lt;h3&amp;gt;
  &amp;lt;a name="setting-up-our-cypress-project" href="#setting-up-our-cypress-project" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  Setting up our Cypress Project
&amp;lt;/h3&amp;gt;

&amp;lt;p&amp;gt;&amp;lt;strong&amp;gt;Step 1&amp;lt;/strong&amp;gt;: Installation&amp;lt;/p&amp;gt;
&amp;lt;div class="highlight"&amp;gt;&amp;lt;pre class="highlight plaintext"&amp;gt;&amp;lt;code&amp;gt;$ npm install cypress-visual-regression
&amp;lt;/code&amp;gt;&amp;lt;/pre&amp;gt;&amp;lt;/div&amp;gt;
&amp;lt;p&amp;gt;We should add the following to your cypress.json file:&amp;lt;/p&amp;gt;
&amp;lt;div class="highlight"&amp;gt;&amp;lt;pre class="highlight plaintext"&amp;gt;&amp;lt;code&amp;gt;const getCompareSnapshotsPlugin = require('cypress-visual-regression/dist/plugin');

module.exports = (on, config) =&amp;amp;amp;gt; {
  getCompareSnapshotsPlugin(on, config);
};
&amp;lt;/code&amp;gt;&amp;lt;/pre&amp;gt;&amp;lt;/div&amp;gt;
&amp;lt;p&amp;gt;And add the command to cypress/support/commands.js:&amp;lt;/p&amp;gt;
&amp;lt;div class="highlight"&amp;gt;&amp;lt;pre class="highlight plaintext"&amp;gt;&amp;lt;code&amp;gt;const compareSnapshotCommand = require('cypress-visual-regression/dist/command');

compareSnapshotCommand();
&amp;lt;/code&amp;gt;&amp;lt;/pre&amp;gt;&amp;lt;/div&amp;gt;
&amp;lt;p&amp;gt;&amp;lt;strong&amp;gt;Note&amp;lt;/strong&amp;gt;: Please ensure import commands.js in cypress/support/index.js&amp;lt;/p&amp;gt;

&amp;lt;p&amp;gt;Once the configuration is ready, we can add our visual testing checkpoints into our existing cypress tests, let’s see an example:&amp;lt;/p&amp;gt;
&amp;lt;div class="highlight"&amp;gt;&amp;lt;pre class="highlight plaintext"&amp;gt;&amp;lt;code&amp;gt;describe('Visual Testing Regression', () =&amp;amp;amp;gt; {

    it('verify UI across the pages', () =&amp;amp;amp;gt;{

        cy.visit(`${config.URL2}`)
        cy.compareSnapshot('Home Page', {
            capture: 'fullPage',
            errorThreshold: 0.0
          });

    })

})
&amp;lt;/code&amp;gt;&amp;lt;/pre&amp;gt;&amp;lt;/div&amp;gt;
&amp;lt;p&amp;gt;The code above will visit a web page, take a &amp;lt;a href="https://www.lambdatest.com/full-page-screen-capture?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=oct06_kj&amp;amp;utm_term=kj&amp;amp;utm_content=blog"&amp;gt;full page screenshot&amp;lt;/a&amp;gt;, and validate zero difference between the base and the actual image comparison. You will wonder about the image baseline, as we don’t have anything in our code. To run basic comparisons, we need to have a baseline image; let’s explore that.&amp;lt;/p&amp;gt;

&amp;lt;p&amp;gt;Let’s run the following command:&amp;lt;/p&amp;gt;
&amp;lt;div class="highlight"&amp;gt;&amp;lt;pre class="highlight plaintext"&amp;gt;&amp;lt;code&amp;gt;npx cypress run --env type=base
&amp;lt;/code&amp;gt;&amp;lt;/pre&amp;gt;&amp;lt;/div&amp;gt;
&amp;lt;p&amp;gt;Once the command is completed, we should see a new couple of folders like the following:&amp;lt;/p&amp;gt;

&amp;lt;p&amp;gt;&amp;lt;img src="https://cdn-images-1.medium.com/max/2000/0*Ug6ZgEOMtnHC4zNB.png"/&amp;gt;&amp;lt;/p&amp;gt;

&amp;lt;p&amp;gt;Once the baseline is created, we’re ready to compare and run a test; first, we need to run the following command:&amp;lt;/p&amp;gt;
&amp;lt;div class="highlight"&amp;gt;&amp;lt;pre class="highlight plaintext"&amp;gt;&amp;lt;code&amp;gt;npx cypress run --env type=actual
&amp;lt;/code&amp;gt;&amp;lt;/pre&amp;gt;&amp;lt;/div&amp;gt;
&amp;lt;p&amp;gt;After the command runs successfully, we will see the folder structure like the following.&amp;lt;/p&amp;gt;

&amp;lt;p&amp;gt;&amp;lt;img src="https://cdn-images-1.medium.com/max/2000/0*YJZ0DWrhaDw05FEW.png"/&amp;gt;&amp;lt;/p&amp;gt;

&amp;lt;p&amp;gt;As we can see from the image above, we have three folders created, one for the actual result, one for the base image, and another for spotting the difference between the images. So basically, we are done with our basic configuration; next time we run, we can spot any discrepancies in our command line.&amp;lt;/p&amp;gt;

&amp;lt;p&amp;gt;&amp;lt;img src="https://cdn-images-1.medium.com/max/2912/0*-jOy4Ay7RrRCLG_b.png"/&amp;gt;&amp;lt;/p&amp;gt;
&amp;lt;h3&amp;gt;
  &amp;lt;a name="implementing-cypress-plugin-snapshots" href="#implementing-cypress-plugin-snapshots" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  Implementing Cypress Plugin Snapshots
&amp;lt;/h3&amp;gt;

&amp;lt;p&amp;gt;There is another exciting plugin for snapshot tests in Cypress. Same API as Jest that we can use with the Cypress GUI. To install the plugin, we need to run:&amp;lt;/p&amp;gt;
&amp;lt;div class="highlight"&amp;gt;&amp;lt;pre class="highlight plaintext"&amp;gt;&amp;lt;code&amp;gt;npm i cypress cypress-plugin-snapshots
&amp;lt;/code&amp;gt;&amp;lt;/pre&amp;gt;&amp;lt;/div&amp;gt;
&amp;lt;p&amp;gt;If you are using Cypress 9.0.0, which in my case, then you need to add an extra parameter like this:&amp;lt;/p&amp;gt;
&amp;lt;div class="highlight"&amp;gt;&amp;lt;pre class="highlight plaintext"&amp;gt;&amp;lt;code&amp;gt;npm i cypress --legacy-peer-deps cypress-plugin-snapshots
&amp;lt;/code&amp;gt;&amp;lt;/pre&amp;gt;&amp;lt;/div&amp;gt;
&amp;lt;p&amp;gt;Just avoid version conflicts and, in many cases, break the installation process. The –legacy-peer-deps flag was introduced with v7 to bypass peerDependency auto-installation; it tells NPM to ignore peer deps and proceed with the installation anyway. It is how things used to be with NPM v4 thru v6.&amp;lt;/p&amp;gt;

&amp;lt;p&amp;gt;As we did for the previous plugin, we need to do the same for cypress-plugin-snapshot; add this to your cypress.json configuration file:&amp;lt;/p&amp;gt;
&amp;lt;div class="highlight"&amp;gt;&amp;lt;pre class="highlight plaintext"&amp;gt;&amp;lt;code&amp;gt;"ignoreTestFiles": [
       "**/__snapshots__/*",
       "**/__image_snapshots__/*"
     ],
   "env": {
       "cypress-plugin-snapshots": {
         "imageConfig": {
           "threshold": 0.01
         }
       }
   }
&amp;lt;/code&amp;gt;&amp;lt;/pre&amp;gt;&amp;lt;/div&amp;gt;
&amp;lt;p&amp;gt;Then add to your cypress/plugins/index.js file and change it to look like this:&amp;lt;/p&amp;gt;
&amp;lt;div class="highlight"&amp;gt;&amp;lt;pre class="highlight plaintext"&amp;gt;&amp;lt;code&amp;gt;const { initPlugin } = require('cypress-plugin-snapshots/plugin');

module.exports = (on, config) =&amp;amp;amp;gt; {
  initPlugin(on, config);
  return config;
};
&amp;lt;/code&amp;gt;&amp;lt;/pre&amp;gt;&amp;lt;/div&amp;gt;
&amp;lt;p&amp;gt;Similar to your cypress/support/index.js file and add the following line:&amp;lt;/p&amp;gt;
&amp;lt;div class="highlight"&amp;gt;&amp;lt;pre class="highlight plaintext"&amp;gt;&amp;lt;code&amp;gt;import 'cypress-plugin-snapshots/commands';
&amp;lt;/code&amp;gt;&amp;lt;/pre&amp;gt;&amp;lt;/div&amp;gt;
&amp;lt;p&amp;gt;After installation is done, we are ready to create some tests; my suggestion is to create a new test spec under your integration folder ‘cypress/integration/.’&amp;lt;/p&amp;gt;
&amp;lt;div class="highlight"&amp;gt;&amp;lt;pre class="highlight plaintext"&amp;gt;&amp;lt;code&amp;gt;import config from './config.json'
import MainPage from '../../page-objects/components/MainPage'

describe('Visual Testing Cypress Snapshots', () =&amp;amp;amp;gt; {
   before(function(){
       cy.visit(`${config.URL1}`)
   })

   it('verify full Page is displayed correctly', () =&amp;amp;amp;gt;{

       cy.document().toMatchImageSnapshot()           
   })

it('verify Multiple elements across the pages', () =&amp;amp;amp;gt;{

//First element Screenshot
       MainPage.elementOne()
       //Second Element Screenshot
       MainPage.elementTwo()

   })

it('Verify blogs related to Cypress', () =&amp;amp;amp;gt; {

MainPage.search('Cypress')
       //Full page plus renaming screenshot
       cy.document().toMatchImageSnapshot({
           name: 'screenshot with Blogs related to Cypress'
       })
   })

})
&amp;lt;/code&amp;gt;&amp;lt;/pre&amp;gt;&amp;lt;/div&amp;gt;
&amp;lt;p&amp;gt;&amp;lt;strong&amp;gt;Code Walkthrough&amp;lt;/strong&amp;gt;&amp;lt;/p&amp;gt;

&amp;lt;p&amp;gt;&amp;lt;strong&amp;gt;Step 1&amp;lt;/strong&amp;gt;: We first import config.json since it contains the test links located in /cypress/integration/e2e_tests/config.json&amp;lt;/p&amp;gt;
&amp;lt;div class="highlight"&amp;gt;&amp;lt;pre class="highlight plaintext"&amp;gt;&amp;lt;code&amp;gt;import config from './config.json'
&amp;lt;/code&amp;gt;&amp;lt;/pre&amp;gt;&amp;lt;/div&amp;gt;
&amp;lt;p&amp;gt;&amp;lt;strong&amp;gt;Step 2&amp;lt;/strong&amp;gt;: We need to import our MainPage component; we use another component to reuse our HTML elements.&amp;lt;/p&amp;gt;
&amp;lt;div class="highlight"&amp;gt;&amp;lt;pre class="highlight plaintext"&amp;gt;&amp;lt;code&amp;gt;import MainPage from '../../page-objects/components/MainPage'
&amp;lt;/code&amp;gt;&amp;lt;/pre&amp;gt;&amp;lt;/div&amp;gt;
&amp;lt;p&amp;gt;&amp;lt;strong&amp;gt;Step 3&amp;lt;/strong&amp;gt;: We visit the URL. The base URL is stored in Cypress.json to ensure better portability and maintainability; also, we use the Before Fixture.&amp;lt;/p&amp;gt;
&amp;lt;div class="highlight"&amp;gt;&amp;lt;pre class="highlight plaintext"&amp;gt;&amp;lt;code&amp;gt;cy.visit(`${config.URL1}`)
&amp;lt;/code&amp;gt;&amp;lt;/pre&amp;gt;&amp;lt;/div&amp;gt;
&amp;lt;p&amp;gt;&amp;lt;strong&amp;gt;Step 4&amp;lt;/strong&amp;gt;: In our first test, we take a full-page screenshot to validate that our web page is displayed correctly and there are no UI errors.&amp;lt;/p&amp;gt;
&amp;lt;div class="highlight"&amp;gt;&amp;lt;pre class="highlight plaintext"&amp;gt;&amp;lt;code&amp;gt;cy.document().toMatchImageSnapshot()
&amp;lt;/code&amp;gt;&amp;lt;/pre&amp;gt;&amp;lt;/div&amp;gt;
&amp;lt;p&amp;gt;&amp;lt;img src="https://cdn-images-1.medium.com/max/3200/1*K7Xz_iT3enrJDNOIihhCkA.png"/&amp;gt;&amp;lt;/p&amp;gt;

&amp;lt;p&amp;gt;&amp;lt;strong&amp;gt;Step 5&amp;lt;/strong&amp;gt;: In our second test, we want to validate multiple elements to make sure they are displayed correctly; this is useful in case of any specific element like a banner or footer on our webpage. For this case, we have our elements inside of our MainPage component located in cypress/page-objects/components/Mainpage.js&amp;lt;/p&amp;gt;
&amp;lt;div class="highlight"&amp;gt;&amp;lt;pre class="highlight plaintext"&amp;gt;&amp;lt;code&amp;gt;//First element Screenshot
       MainPage.elementOne()
       //Second Element Screenshot
       MainPage.elementTwo()
&amp;lt;/code&amp;gt;&amp;lt;/pre&amp;gt;&amp;lt;/div&amp;gt;
&amp;lt;p&amp;gt;&amp;lt;img src="https://cdn-images-1.medium.com/max/3032/1*VRTTUCD6C1w9gr9S1l68cQ.png"/&amp;gt;&amp;lt;/p&amp;gt;

&amp;lt;p&amp;gt;&amp;lt;img src="https://cdn-images-1.medium.com/max/3200/1*zUfJyLVEwDIzjsGtNwMX6g.png"/&amp;gt;&amp;lt;/p&amp;gt;

&amp;lt;p&amp;gt;If we want to avoid flakiness related to dynamic content or other factors, it is better to capture elements to compare discrepancies; we want to ignore full-page screenshots and focus on our web pages’ specific UI instability areas.&amp;lt;/p&amp;gt;

&amp;lt;p&amp;gt;&amp;lt;strong&amp;gt;Step 6&amp;lt;/strong&amp;gt;: For the last test, we want to validate specific search results; in this case, we are searching in our blog for Cypress-related material and taking a full-page screenshot. Last but not least, we are renaming the screenshot to customize our image comparison.&amp;lt;/p&amp;gt;
&amp;lt;div class="highlight"&amp;gt;&amp;lt;pre class="highlight plaintext"&amp;gt;&amp;lt;code&amp;gt;MainPage.search('Cypress')
       //Full page plus renaming screenshot
       cy.document().toMatchImageSnapshot({
           name: 'screenshot with Blogs related to Cypress'
       })
&amp;lt;/code&amp;gt;&amp;lt;/pre&amp;gt;&amp;lt;/div&amp;gt;
&amp;lt;p&amp;gt;A critical aspect of this plugin is the screenshot location, and the plugin saves the actual image in cypress/integration/&amp;lt;strong&amp;gt;image_snapshots&amp;lt;/strong&amp;gt;. The snapshot compares against another picture of the current interface on subsequent runs, and if the tool finds any difference, the test fails. But what if we want to change our current image baseline? Well, in that case, as there is no way to run a baseline command, the easiest way to do that is to remove the previous images saved on cypress/integration/&amp;lt;strong&amp;gt;image_snapshots&amp;lt;/strong&amp;gt; and rerun our tests to get a new baseline.&amp;lt;/p&amp;gt;

&amp;lt;p&amp;gt;&amp;lt;img src="https://cdn-images-1.medium.com/max/2000/0*rMnscJF8oo-qfg5K.png"/&amp;gt;&amp;lt;/p&amp;gt;

&amp;lt;p&amp;gt;Open Cypress test runner and click on the corresponding test to execute the same.&amp;lt;/p&amp;gt;

&amp;lt;p&amp;gt;&amp;lt;img src="https://cdn-images-1.medium.com/max/3200/0*6bGlenAGKy_mIP4W.png"/&amp;gt;&amp;lt;/p&amp;gt;

&amp;lt;p&amp;gt;And here is the test execution, which indicates that we have a new baseline:&amp;lt;/p&amp;gt;

&amp;lt;p&amp;gt;&amp;lt;img src="https://cdn-images-1.medium.com/max/3200/0*65RRx-CSSE9-b7qM.png"/&amp;gt;&amp;lt;/p&amp;gt;

&amp;lt;p&amp;gt;One more time to see that the image is correct:&amp;lt;/p&amp;gt;

&amp;lt;p&amp;gt;&amp;lt;img src="https://cdn-images-1.medium.com/max/3200/0*Z_PcrHj-Nay8pMTH.png"/&amp;gt;&amp;lt;/p&amp;gt;

&amp;lt;p&amp;gt;You can download the code from the GitHub repository.&amp;lt;/p&amp;gt;

&amp;lt;p&amp;gt;Take this certification to showcase your expertise with end-to-end Cypress testing and stay one step ahead.&amp;lt;/p&amp;gt;

&amp;lt;p&amp;gt;Here’s a short glimpse of the Cypress 101 certification from LambdaTest:&amp;lt;/p&amp;gt;

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

&amp;lt;p&amp;gt;&amp;lt;strong&amp;gt;&amp;lt;em&amp;gt;Check our &amp;lt;a href="https://www.lambdatest.com/selenium-automation?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=oct06_kj&amp;amp;utm_term=kj&amp;amp;utm_content=webpage"&amp;gt;selenium automation testing&amp;lt;/a&amp;gt; cloud infrastructure has 3000+ desktop &amp;amp;amp; mobile environments. Try for free!&amp;lt;/em&amp;gt;&amp;lt;/strong&amp;gt;&amp;lt;/p&amp;gt;
&amp;lt;h2&amp;gt;
  &amp;lt;a name="how-to-use-visual-regression-plugin-on-cypress-cloud-grid" href="#how-to-use-visual-regression-plugin-on-cypress-cloud-grid" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  How to use Visual Regression Plugin on Cypress Cloud Grid
&amp;lt;/h2&amp;gt;

&amp;lt;p&amp;gt;We can use a &amp;lt;a href="https://www.lambdatest.com/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=oct06_kj&amp;amp;utm_term=kj&amp;amp;utm_content=blog"&amp;gt;Cloud Cypress Grid&amp;lt;/a&amp;gt; like LambdaTest, which provides automated &amp;lt;a href="https://www.lambdatest.com/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=oct06_kj&amp;amp;utm_term=kj&amp;amp;utm_content=blog"&amp;gt;cross browser testing&amp;lt;/a&amp;gt; on 40+ browsers and operating systems, and &amp;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=oct06_kj&amp;amp;utm_term=kj&amp;amp;utm_content=blog"&amp;gt;Parallel testing&amp;lt;/a&amp;gt; to expedite the test execution in a scalable way. In addition, it will help improve our overall visual test coverage by resulting in better visual standpoint product quality as we can cover different combinations using the same test scripts.&amp;lt;/p&amp;gt;

&amp;lt;p&amp;gt;Starting your journey with &amp;lt;a href="https://www.lambdatest.com/cypress-parallel-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=oct06_kj&amp;amp;utm_term=kj&amp;amp;utm_content=blog"&amp;gt;Cypress Parallel Testing?&amp;lt;/a&amp;gt; Check out how you can test your Cypress test scripts on LambdaTest’s online cloud.&amp;lt;/p&amp;gt;

&amp;lt;p&amp;gt;Now execute test scripts faster than any other automation testing grid on &amp;lt;a href="https://www.lambdatest.com/automated-ui-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=oct06_kj&amp;amp;utm_term=kj&amp;amp;utm_content=blog"&amp;gt;LambdaTest’s Automated UI testing cloud&amp;lt;/a&amp;gt;.&amp;lt;/p&amp;gt;

&amp;lt;p&amp;gt;To get started, you have to install &amp;lt;a href="https://accounts.lambdatest.com/detail/profile?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=oct06_kj&amp;amp;utm_term=kj&amp;amp;utm_content=blog"&amp;gt;LambdaTest Cypress CLI&amp;lt;/a&amp;gt; on your machine. Trigger the following command to install the same:&amp;lt;/p&amp;gt;
&amp;lt;div class="highlight"&amp;gt;&amp;lt;pre class="highlight plaintext"&amp;gt;&amp;lt;code&amp;gt;npm install -g lambdatest-cypress-cli
&amp;lt;/code&amp;gt;&amp;lt;/pre&amp;gt;&amp;lt;/div&amp;gt;
&amp;lt;p&amp;gt;After installation is completed, set up the configuration using the below command:&amp;lt;/p&amp;gt;
&amp;lt;div class="highlight"&amp;gt;&amp;lt;pre class="highlight plaintext"&amp;gt;&amp;lt;code&amp;gt;lambdatest-cypress init
&amp;lt;/code&amp;gt;&amp;lt;/pre&amp;gt;&amp;lt;/div&amp;gt;
&amp;lt;p&amp;gt;Once the command is completed, lambdatest-config.json is created in the project folder. Next, enter the LambdaTest credentials from the &amp;lt;a href="https://www.lambdatest.com/support/docs/testing-locally-hosted-pages/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=oct06_kj&amp;amp;utm_term=kj&amp;amp;utm_content=blog"&amp;gt;LambdaTest Profile Section&amp;lt;/a&amp;gt;.&amp;lt;/p&amp;gt;
&amp;lt;div class="highlight"&amp;gt;&amp;lt;pre class="highlight plaintext"&amp;gt;&amp;lt;code&amp;gt;"lambdatest_auth": {
      "username": "",
      "access_key": ""
&amp;lt;/code&amp;gt;&amp;lt;/pre&amp;gt;&amp;lt;/div&amp;gt;
&amp;lt;p&amp;gt;Here is how you can configure the required browser &amp;amp;amp; OS combinations in lambdatest-config.json:&amp;lt;/p&amp;gt;
&amp;lt;div class="highlight"&amp;gt;&amp;lt;pre class="highlight plaintext"&amp;gt;&amp;lt;code&amp;gt;{
  "lambdatest_auth": {
     "username": "",
     "access_key": ""
  },
  "browsers": [
     {
        "browser": "MicrosoftEdge",
        "platform": "Windows 10",
        "versions": [
           "latest"
        ]
     },
     {
        "browser": "Chrome",
        "platform": "Windows 10",
        "versions": [
           "latest"
        ]
     },
     {
        "browser": "Firefox",
        "platform": "macOS Big Sur",
        "versions": [
           "latest"
        ]
     },
     {
        "browser": "Firefox",
        "platform": "Windows 10",
        "versions": [
           "latest"
        ]
     }
  ],
&amp;lt;/code&amp;gt;&amp;lt;/pre&amp;gt;&amp;lt;/div&amp;gt;
&amp;lt;p&amp;gt;The run_settings section in the JSON file contains the desired Cypress test suite capabilities, including Cypress_version, build_name, visual feedback settings, number of parallel sessions, etc.&amp;lt;/p&amp;gt;
&amp;lt;div class="highlight"&amp;gt;&amp;lt;pre class="highlight plaintext"&amp;gt;&amp;lt;code&amp;gt;"run_settings": {
      "Cypress_config_file": "Cypress.json",
      "build_name": "build-visual-testing",
      "parallels": 5,
      "specs": "./Cypress/integration/e2e_tests/*.spec.js",
      "ignore_files": "",
      "feature_file_suppport": false
   },
&amp;lt;/code&amp;gt;&amp;lt;/pre&amp;gt;&amp;lt;/div&amp;gt;
&amp;lt;p&amp;gt;Tunnel_settings in the JSON file lets you connect your local system with LambdaTest servers via an SSH-based integration tunnel. Once this tunnel is established, you can &amp;lt;a href="https://www.lambdatest.com/support/docs/testing-locally-hosted-pages/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=oct06_kj&amp;amp;utm_term=kj&amp;amp;utm_content=blog"&amp;gt;test locally hosted pages&amp;lt;/a&amp;gt; on all the browsers currently supported by Cypress on LambdaTest.&amp;lt;/p&amp;gt;
&amp;lt;div class="highlight"&amp;gt;&amp;lt;pre class="highlight plaintext"&amp;gt;&amp;lt;code&amp;gt;"tunnel_settings": {
    "tunnel": false,
    "tunnelName": null
}
&amp;lt;/code&amp;gt;&amp;lt;/pre&amp;gt;&amp;lt;/div&amp;gt;
&amp;lt;p&amp;gt;Now that the setup is ready, it’s time to run the tests; remember that our run_settings file displays the parallels field as five once we trigger our execution in parallel without any extra parameter.&amp;lt;/p&amp;gt;
&amp;lt;div class="highlight"&amp;gt;&amp;lt;pre class="highlight plaintext"&amp;gt;&amp;lt;code&amp;gt;lambdatest-cypress run
&amp;lt;/code&amp;gt;&amp;lt;/pre&amp;gt;&amp;lt;/div&amp;gt;
&amp;lt;p&amp;gt;Shown below is the test execution status from the &amp;lt;a href="https://automation.lambdatest.com/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=oct06_kj&amp;amp;utm_term=kj&amp;amp;utm_content=blog"&amp;gt;LambdaTest Automation Dashboard&amp;lt;/a&amp;gt;.&amp;lt;/p&amp;gt;

&amp;lt;p&amp;gt;&amp;lt;img src="https://cdn-images-1.medium.com/max/3200/0*p7qxAVlwUAh02oE5.png"/&amp;gt;&amp;lt;/p&amp;gt;

&amp;lt;p&amp;gt;Here is the execution snapshot, which indicates the progress of test execution:&amp;lt;/p&amp;gt;

&amp;lt;p&amp;gt;&amp;lt;img src="https://cdn-images-1.medium.com/max/3200/0*TGTSabTsn-hRkaLj.png"/&amp;gt;&amp;lt;/p&amp;gt;

&amp;lt;p&amp;gt;To summarize, the significant benefit of Cypress visual regression testing on the cloud is achieving optimal visual test coverage without modifying the core logic of the test code to incorporate multiple OS and Browsers.&amp;lt;/p&amp;gt;

&amp;lt;p&amp;gt;&amp;lt;img src="https://cdn-images-1.medium.com/max/3200/0*Gcd6Rby2vyofT4mT.png"/&amp;gt;&amp;lt;/p&amp;gt;

&amp;lt;p&amp;gt;To view test performance metrics, navigate to the &amp;lt;a href="https://analytics.lambdatest.com/test-overview?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=oct06_kj&amp;amp;utm_term=kj&amp;amp;utm_content=blog"&amp;gt;LambdaTest Analytics Dashboard&amp;lt;/a&amp;gt;. The Test Overview will provide a snapshot of tests consistent with stable behavior. Meanwhile, the Test Summary will display the total number of tests passed or failed, as well as any completed tests and pending tests.&amp;lt;/p&amp;gt;

&amp;lt;p&amp;gt;&amp;lt;img src="https://cdn-images-1.medium.com/max/3200/0*E7Wwm1ZFcKOlXWtj.png"/&amp;gt;&amp;lt;/p&amp;gt;

&amp;lt;p&amp;gt;With this Visual Testing Tutorial, you will learn how to perform Smart Visual UI Testing on the LambdaTest platform.&amp;lt;/p&amp;gt;

&amp;lt;p&amp;gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/sOaQ-ttEBzs"&gt;
&lt;/iframe&gt;
&amp;lt;/p&amp;gt;
&amp;lt;h2&amp;gt;
  &amp;lt;a name="final-thoughts" href="#final-thoughts" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  Final Thoughts
&amp;lt;/h2&amp;gt;

&amp;lt;p&amp;gt;Visual testing does the heavy lifting to contribute to our UI validation; no matter if you use open source tools or paid tools, visual inconsistencies deeply influence the user journey, which means they need to be eliminated. Performing Cypress visual regression testing can help us validate quickly, correctly, and comprehensively, making it indispensable for any enterprise looking to have an online presence.&amp;lt;/p&amp;gt;

&amp;lt;p&amp;gt;&amp;lt;img src="https://cdn-images-1.medium.com/max/2000/0*cEkQvmcpDYfmkWML.png"/&amp;gt;&amp;lt;/p&amp;gt;

&amp;lt;p&amp;gt;“Just because your test automation is working doesn’t mean that it adds value.” — Enrique A Decoss&amp;lt;/p&amp;gt;

&amp;lt;p&amp;gt;Remember, we need to change our test automation landscape positively. If you are not including visual testing in your automation test scripts, this is an excellent opportunity to make your test scripts more robust; at the end of the day, automation testing must add value to our customers.&amp;lt;/p&amp;gt;

&amp;lt;p&amp;gt;Happy Visual Testing!&amp;lt;/p&amp;gt;

&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>cypress</category>
      <category>visual</category>
      <category>regression</category>
    </item>
    <item>
      <title>How To Find Broken Links Using Cypress [With Examples]</title>
      <dc:creator>enriquee20</dc:creator>
      <pubDate>Tue, 04 Oct 2022 11:24:46 +0000</pubDate>
      <link>https://forem.com/testmuai/how-to-find-broken-links-using-cypress-with-examples-2io</link>
      <guid>https://forem.com/testmuai/how-to-find-broken-links-using-cypress-with-examples-2io</guid>
      <description>&lt;p&gt;Have you ever experienced a 404 error? From an end user’s perspective, a 404 error (or broken link) experience can be a complete turn-off. Apart from annoying end-user experience, broken links (or dead links) on a website can dampen the SEO (Search Engine Optimization) activity.&lt;/p&gt;

&lt;p&gt;The more 404 pages you have on your site, the less time users spend on the site. To reduce the bounce rate and build a top-notch online reputation for your website, it is essential to check for broken links using Cypress. It is relatively easy to check broken links on the website by performing &lt;a href="https://www.lambdatest.com/blog/getting-started-with-cypress/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=oct_04kj&amp;amp;utm_term=kj&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;Cypress testing&lt;/a&gt; compared to other test automation frameworks like Selenium.&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%2A7opCnNQ29ji7vLQw.png" class="article-body-image-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%2A7opCnNQ29ji7vLQw.png" width="498" height="306"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In this blog of the &lt;a href="https://www.lambdatest.com/learning-hub/cypress-tutorial?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=oct_04kj&amp;amp;utm_term=kj&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;Cypress tutorial&lt;/a&gt; series, we deep dive into the ‘why’ and ‘how’ of finding broken links on a website. We also demonstrate how to find broken links using Cypress (a test automation framework best suited for modern web applications).&lt;/p&gt;

&lt;h2&gt;
  
  
  Why Find Broken Links On A Website
&lt;/h2&gt;

&lt;p&gt;Search engine algorithms pay special attention to how users behave on your website. As a result, their online behavior has a significant role in the ranking process. HTTP 404 code is one of the most frustrating things your visitors can come across, and the chances are that they might never revisit your website. It is like handing over your customer base to your competition.&lt;/p&gt;

&lt;p&gt;Apart from a negative user experience, high bounce rates due to broken links can negatively affect your SEO. So although Google’s algorithm may not directly consider bounce rate, it can indeed hurt your online rankings.&lt;br&gt;
This is where a broken link checker using Cypress framework can be handy, as it can be regularly triggered to ensure that the website is free from broken links.&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=oct_04kj&amp;amp;utm_term=kj&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;Appium automation&lt;/a&gt; tutorial, learn about Appium and its benefits for mobile automation testing.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  Major Reasons For Broken Links
&lt;/h2&gt;

&lt;p&gt;You can find broken links on a website only when you have clarity about the various conditions that might result in broken links. There are umpteen reasons that result in 404 errors (or broken links/dead links); the major ones are mentioned below:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;The page has been removed from the website&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The page is moved to another URL, and the redirection is done incorrectly&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;You entered the wrong URL address&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Server malfunctions (though it is a rarity)&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;You have entered an expired domain address&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Broken links are often left for long periods after the page has been deleted or moved. This is because websites that link to this page are not informed that the site doesn’t exist anymore or can be found under a new URL. In addition, broken HTML tags, JavaScript errors, and broken embedded elements can also lead to broken (or dead) links on a website.&lt;/p&gt;

&lt;p&gt;Irrespective of the criticality of the ‘page’ from the larger scheme of things (of your website), it is essential to keep a regular check for broken links on the website. Though you can &lt;a href="https://www.lambdatest.com/blog/broken-links-testing-using-selenium/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=oct_04kj&amp;amp;utm_term=kj&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;find broken links using Selenium&lt;/a&gt;, finding broken links on a website using Cypress is recommended due to the simplicity involved in the implementation process.&lt;/p&gt;
&lt;h2&gt;
  
  
  Essential HTTP Status Codes To Detect Broken Links
&lt;/h2&gt;

&lt;p&gt;Whenever a user visits a website, the server responds to the request sent by the browser with a three-digit response code. This code is called ‘HTTP Response Status Code,’ which indicates the status of the HTTP request.&lt;/p&gt;

&lt;p&gt;Here are the five major classes of HTTP status codes:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Informational responses (100–199)&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Successful responses (200–299)&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Redirects (300–399&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Client errors (400–499)&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Server errors (500–599)&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Though it is important to have a top-level understanding of all the HTTP status codes, our interest mainly lies in HTTP 404 status, which indicates whether a particular link on the website is broken. A 404 error means that although the server is reachable, the specific page you are looking for is not present (or available) on the server. Essentially, it’s a page that doesn’t exist, or it’s broken. The 404 error code can appear in any browser, regardless if you’re using Google Chrome or Firefox.&lt;/p&gt;

&lt;p&gt;Here are some of the many ways in which 404 errors are shown to the end user:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;404 Not Found Error&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;404 HTTP 404&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;404 Page Not Found&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Error 404 Not Found&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;HTTP 404 Not Found&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The requested URL was not found on this server&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;404 File or Directory Not Found&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If you want a quick walk-through of the Cypress framework, check out our blog that explains the architecture 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=oct_04kj&amp;amp;utm_term=kj&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;Cypress automation framework&lt;/a&gt;. Alternatively, you can also check out &lt;a href="https://www.youtube.com/channel/UCCymWVaTozpEng_ep0mdUyw?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=oct_04kj&amp;amp;utm_term=kj&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;LambdaTest YouTube Channel&lt;/a&gt;, where we have a video that explains how you can get started with Cypress.&lt;/p&gt;

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

&lt;p&gt;Starting your journey with &lt;a href="https://www.lambdatest.com/cypress-e2e-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=oct_04kj&amp;amp;utm_term=kj&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;Cypress End-to-End Testing?&lt;/a&gt; Check out how you can test your Cypress test scripts on LambdaTest’s online cloud.&lt;/p&gt;

&lt;h2&gt;
  
  
  How To Find Broken Links Using Cypress
&lt;/h2&gt;

&lt;p&gt;Till now, you would have understood the importance of checking broken links on your website? So, with the platform all set, let’s look at how to find broken links using Cypress. For starters, Cypress is a next-generation front-end testing tool built for the modern web; Cypress testing enables you to write faster, easier, and more reliable tests.&lt;/p&gt;

&lt;p&gt;In case you are coming from a Selenium automation background, make sure to check out the differences between Selenium and Cypress from our blog that covers &lt;a href="https://www.lambdatest.com/blog/cypress-vs-selenium-comparison/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=oct_04kj&amp;amp;utm_term=kj&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;Cypress vs Selenium&lt;/a&gt; comparison. Saying that, let’s focus on our problem about broken links and how to build some tests to validate that using Cypress test automation.&lt;/p&gt;

&lt;p&gt;Let’s take a sample HTML page that contains four relative hyperlinks:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;a href="/at-home-coronavirus-testing"&amp;gt;Testing&amp;lt;/a&amp;gt;
    &amp;lt;a href="/paying-for-covid-19-testing/"&amp;gt;Paying for covid Testing&amp;lt;/a&amp;gt;
    &amp;lt;a href="/covid-19-antibody-testing"&amp;gt;Covid19 antibody Testing&amp;lt;/a&amp;gt;
    &amp;lt;a href="/covid-19-testing-statistics"&amp;gt;Testing Statistics&amp;lt;/a&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;As you can see, we have four links, and we need to click on each link, check the redirect URL, and then go back to our main page. So, how do you find broken links using Cypress considering the above HTML page.&lt;/p&gt;

&lt;p&gt;What if we come up with an implementation that is limited to finding which out of the four are broken in nature. If the implementation is hardcoded for four links, it will lead to scalability issues, especially if the checker is used on a different web page.&lt;/p&gt;

&lt;p&gt;Here is the sample code that uses the Cypress framework to find broken links on the website. As mentioned earlier, this is not a scalable approach and should be avoided when finding broken links on large-scale websites.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;describe('Test Navigation', () =&amp;gt; {
  it('can navigate and test the pages', () =&amp;gt; {
    cy.visit('[https://www.testing.com/at-home-coronavirus-testing/'](https://www.testing.com/at-home-coronavirus-testing/'));

    cy.get('main:contains("Testing")');
    cy.go('back');

   cy.visit('[https://www.testing.com/paying-for-covid-19-testing/'](https://www.testing.com/paying-for-covid-19-testing/'));
   cy.get('main:contains("Test")');
   cy.go('back');

   cy.visit('[https://www.testing.com/covid-19-antibody-testing/'](https://www.testing.com/covid-19-antibody-testing/'));
   cy.get('main:contains("Testing")');
   cy.go('back');


   cy.visit('[https://www.testing.com/covid-19-testing-statistics/'](https://www.testing.com/covid-19-testing-statistics/'));
   cy.get('main:contains("Testing")');
   cy.go('back');

  });
});
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;In our example below, we are clicking on every page and checking the specific assertion, it does not follow the design patterns, and we can improve the way we get the links on our website.&lt;/p&gt;

&lt;p&gt;Let’s take a look at the following example.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;it('Navigate through the links using loops', () =&amp;gt; {

  const pages = ['Testing Covid', 'Paying for Covid19 Test', 'Test Antibody Covid19', 'Testing Statistics']

  cy.visit('/')

  pages.forEach(page =&amp;gt; {

    cy.contains(page).click()
    cy.location('pathname').should('eq', `/${page}`)
    cy.go('back')

  })

})
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;As you can deduce from the code above, we are looping against the specific pages and validating the page information. We created a ‘forEach’ loop that will iterate through the array where the entire procedure is repeated. Particularly useful if, for any reason, our navigation bar changes items. We’ll add an item to the array, and our test works.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;“If you are using Cypress to find broken links on your website, it is essential to note that Cypress changes its host URL to match the URL of your AUT (Application Under Test). The basic requirement from Cypress is that the URLs being navigated should have the same superdomain for the entirety of a single test.”&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Navigating to subdomains works fine, but Cypress will throw an error if you visit two different superdomains. Thus, you can see different superdomains in other tests but not in the same test.&lt;/p&gt;

&lt;p&gt;Instead of opening every link on the test website, we can simply check links with the href attribute and check their HTTP status code. If the return code is 404, it means that that particular link is a broken (or dead) link.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Test your native, hybrid, and webapps across all legacy and latest mobile operating systems on most powerful &lt;a href="https://www.lambdatest.com/android-emulator-online?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=oct_04kj&amp;amp;utm_term=kj&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;Andoird emulator&lt;/a&gt; online.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Demonstration: Finding Broken Links With Cypress
&lt;/h2&gt;

&lt;p&gt;In order to demonstrate how to find broken links on your website using Cypress, let’s perform a broken links test on the &lt;a href="https://www.lambdatest.com/blog/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=oct_04kj&amp;amp;utm_term=kj&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;LambdaTest Blog&lt;/a&gt;. There are close to 500+ posts on the LambdaTest blog, and our broken link checker using Cypress will check every link (i.e., under href attribute).&lt;/p&gt;

&lt;p&gt;Here is the test scenario used for finding broken links on a website using Cypress:&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;Go to LambdaTest Blog on Chrome.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Collect all the links present on the page.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Send HTTP requests for each link.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Print whether the link is broken or not on the terminal.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Project Structure&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;It is time to create our test under the integration folder; as you can see below, we have a test called test-example.js. Shown below is the directory structure:&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%2AmEeb6IE7PGsD99hL.png" class="article-body-image-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%2AmEeb6IE7PGsD99hL.png" width="504" height="314"&gt;&lt;/a&gt;&lt;/p&gt;

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

&lt;p&gt;For ensuring that the code is extensible and maintainable to check for broken links on the ’N’ number of websites, we keep the test URL in a separate JSON file (e.g., config.json).&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{
    "URL1": "https://www.lambdatest.com/blog",
    "URL2": "https://www.lambdatest-playground.com"
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;As seen above, we have two test URLs (i.e., URL1 and URL2); however, we would run the test only on URL1. Shown below is the implementation (that uses JavaScript).&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import config from './config.json'

describe('Test Broken Links', () =&amp;gt; {

    it('verify navigation accross the pages', () =&amp;gt;{

        cy.visit(`${config.URL1}`)
        cy.on('window:confirm', cy.stub().as('confirm'))
        Cypress.on('uncaught:exception', (err, runnable) =&amp;gt; {
            // returning false here prevents Cypress from
            // failing the test
        return false
        })

        cy.wrap('passed').as('ctrl')
        cy.get("a:not([href*='mailto:]']").each($el =&amp;gt; {

                if ($el.prop('href').length &amp;gt; 0) {
                    const message = $el.text()
                    expect($el, message).to.have.attr("href").not.contain("undefined")
                    cy.log($el.attr('href'))                       
                }
        })
    })
})
&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;We first import config.json since it contains the test links.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import config from './config.json'
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

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

&lt;p&gt;We now visit a remote URL. The base URL is stored in Cypress.json to ensure better portability and maintainability.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;cy.visit(`${config.URL1}`)
&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;We need to ignore some uncaught exceptions when we are testing some websites. In this case, we can use the following code to turn off uncaught exception handling for specific errors. Cy.on is to catch a single exception or event; in this case, we have used this code to fail a test on purpose, using a small hack.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;cy.on('window:confirm', cy.stub().as('confirm'))
        Cypress.on('uncaught:exception', (err, runnable) =&amp;gt; {
            // returning false here prevents Cypress from
            // failing the test
        return false
   })
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

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

&lt;p&gt;cy.wrap is used for logging purposes in Cypress. In this case, we are using it as a control variable to test or fail the test depending on our parameters.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;cy.wrap('passed').as('ctrl')
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;Step 5:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;We use “each” to get the elements, excluding “mailto:” and empty ones. With this, we will get the URLs that we want to monitor for broken links with Cypress.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;cy.get("a:not([href*='mailto:]']").each($el =&amp;gt; {
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;Step 6:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;We are validating head links, and one of those always presents anchors for the code block shown below. As a part of the process, we validate them all. We combine the selectors wherever possible.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;if ($el.prop('href').length &amp;gt; 0) {
      const message = $el.text()
      expect($el, message).to.have.attr("href").not.contain("undefined")
      cy.log($el.attr('href'))                       
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

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

&lt;p&gt;Now, let’s add to Cypress and run it from there; if you already have an npm project, please open a terminal using VS Code and run the following command:&lt;/p&gt;

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

&lt;/div&gt;

&lt;p&gt;Now that Cypress is installed, let’s run the following command to get the Cypress folder:&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;For configuring Cypress, we open Cypress Test Runner, which creates Cypress.json. This JSON file is used to store any configuration values you supply.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{
    "watchForFilesChanges": false,
    "chromeWebSecurity": false,
    "viewportWidth": 1000,
    "viewportHeight": 600,
    "waitForAnimation": true,
    "defaultCommandTimeout": 6000,
    "execTimeout": 60000,
    "pageLoadTimeout": 60000,
    "requestTimeout": 150000,
    "responseTimeout": 150000,
    "video": true,
    "failOnStatusCode": false
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Open Cypress test runner and click on the corresponding test to execute the same.&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%2AkAOtsqG6GNda42Ah.png" class="article-body-image-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%2AkAOtsqG6GNda42Ah.png" width="512" height="334"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Here is the test execution, which indicates that there are zero broken links on the test 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%2F3200%2F1%2A_2gMirRWFD9SFCSB1H9xFA.png" class="article-body-image-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%2F1%2A_2gMirRWFD9SFCSB1H9xFA.png" width="800" height="366"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Take this certification to showcase your expertise with end-to-end testing using &lt;a href="https://www.lambdatest.com/blog/cypress-test-automation-framework/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=oct_04kj&amp;amp;utm_term=kj&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;Cypress automation&lt;/a&gt; framework and stay one step ahead.&lt;/p&gt;

&lt;p&gt;Here’s a short glimpse of the Cypress 101 certification from LambdaTest:&lt;/p&gt;

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

&lt;p&gt;Perform &lt;a href="https://www.lambdatest.com/cypress-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=oct_04kj&amp;amp;utm_term=kj&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;Cypress Parallel Testing&lt;/a&gt; on LambdaTest and speed up the testing and release process. Check out how you can test your Cypress test scripts on LambdaTest’s online cloud.&lt;/p&gt;

&lt;h2&gt;
  
  
  How to find broken links using Cypress on Cloud Grid
&lt;/h2&gt;

&lt;p&gt;Cypress testing on cloud grid like LambdaTest helps in running tests on a wide range of browser and OS combinations. Parallel execution helps in accelerated test execution as well as achieving optimal browser coverage.&lt;/p&gt;

&lt;p&gt;Cypress on LambdaTest helps you run Cypress tests at scale. You can check out our earlier blog that deep dives into the essentials on how to perform &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=oct_04kj&amp;amp;utm_term=kj&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;Cypress testing at scale with LambdaTest&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;To get started, you have to install LambdaTest Cypress CLI on your machine. Trigger the following command to install the same:&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;After installation is completed, setup the configuration using 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;Once the command is completed, lambdatest-config.json is created in the project folder. Next, enter the LambdaTest credentials from the &lt;a href="https://accounts.lambdatest.com/detail/profile?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=oct_04kj&amp;amp;utm_term=kj&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;LambdaTest profile section&lt;/a&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;Your LambdaTest username&amp;gt;",
      "access_key": "&amp;lt;Your LambdaTest access key&amp;gt;"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Here is how you can configure the required browser &amp;amp; OS combinations in lambdatest-config.json:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;"browsers": [
      {
         "browser": "Chrome",
         "platform": "Windows 10",
         "versions": [
            "latest-2"
         ]
      },
      {
         "browser": "Firefox",
         "platform": "Windows 10",
         "versions": [
            "latest"
         ]
      },
      {
         "browser": "MicrosoftEdge",
         "platform": "Windows 10",
         "versions": [
            "latest"
         ]
      }
   ],
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;run_settings section in the JSON file contains the desired Cypress test suite capabilities, including Cypress_version, build_name, visual feedback settings, number of parallel sessions, etc.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;"run_settings": {
      "Cypress_config_file": "Cypress.json",
      "build_name": "build-broken-links",
      "parallels": 1,
      "specs": "./Cypress/integration/e2e_tests/*.spec.js",
      "ignore_files": "",
      "feature_file_suppport": false
   },
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Tunnel_settings in the JSON file lets you connect your local system with LambdaTest servers via an SSH-based integration tunnel. Once this tunnel is established, you can test your locally hosted pages on all the browsers currently supported by Cypress on LambdaTest.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;"tunnel_settings": {
    "tunnel": false,
    "tunnelName": null
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Now that the setup is ready, it’s time to run the tests by triggering the following command:&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;Shown below is the test execution status from the Automation Dashboard:&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%2Az_t410emg-_pQwRf.png" class="article-body-image-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%2Az_t410emg-_pQwRf.png" width="800" height="217"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;After the test execution, click on the test name to view the automation logs for debugging the respective 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%2AMcFXfVmBzfDbRhdB.png" class="article-body-image-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%2AMcFXfVmBzfDbRhdB.png" width="800" height="427"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You can view the live video feed, screenshots for each test run, view console logs, terminal logs, and do much more using Cypress on LambdaTest.&lt;/p&gt;

&lt;p&gt;One crucial aspect of running the tests using LambdaTest and Cypress is parallel testing. This can be achieved using two methods. The first option is passing the parallelization level from the command line:&lt;/p&gt;

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

&lt;/div&gt;

&lt;p&gt;The other option is to set the parallelization level using the parallels key in lambdatest-config.json.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{
  "run_settings": {
    ...
    "parallels": 5,
    ...
  }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Here is the execution snapshot, which indicates the progress of test execution:&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%2A6HS0XDdfoNNOVs-y.png" class="article-body-image-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%2A6HS0XDdfoNNOVs-y.png" width="512" height="273"&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;To summarize, the major benefit of Cypress testing on the cloud is achieving optimal test coverage without making modifications to the core logic of the test code.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Test your &lt;a href="https://www.lambdatest.com/android-emulator-online?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=oct_04kj&amp;amp;utm_term=kj&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;emulator online&lt;/a&gt; mobile websites and smartphone apps using our scalable on-cloud mobile emulator. LambdaTest is preferred by 600k+ developers across the globe to fulfill their mobile testing needs.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  It’s A Wrap
&lt;/h2&gt;

&lt;p&gt;It’s inevitable 404 errors will appear on your site. Broken links can also impact the rankings on search engines; make sure you proactively monitor the links of your website. Finding broken links on your website or an HTTP 404 is as vital as posting unique and high-quality content.&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%2AEXaktVc4kzutTLjo.png" class="article-body-image-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%2AEXaktVc4kzutTLjo.png" width="478" height="268"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Check your 404s as a part of continuous testing, and you can include Cypress tests as part of your testing tools. Putting time aside to update your website and perform technical testing will help you stay ahead of the competition.&lt;/p&gt;

&lt;p&gt;We know that we must enable, nurture, and foster an ecosystem that includes high-quality success. Every line of test code is an investment in our codebase. Tests will be able to run and work independently always. Lastly, in this Cypress tutorial, we saw how LambdaTest and Cypress integration ensure seamless user experience across different browsers on 40+ browser versions simultaneously.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Happy Bug Hunting with Cypress!!&lt;/strong&gt;&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>cypress</category>
      <category>testing</category>
      <category>beginners</category>
    </item>
  </channel>
</rss>
