<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: BhasinAnshita</title>
    <description>The latest articles on DEV Community by BhasinAnshita (@bhasinanshita).</description>
    <link>https://dev.to/bhasinanshita</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%2F1106890%2F26f758c8-92e5-41a2-884f-50386db3916b.jpeg</url>
      <title>DEV Community: BhasinAnshita</title>
      <link>https://dev.to/bhasinanshita</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/bhasinanshita"/>
    <language>en</language>
    <item>
      <title>Introduction to Shift Left Testing</title>
      <dc:creator>BhasinAnshita</dc:creator>
      <pubDate>Mon, 10 Jul 2023 13:26:17 +0000</pubDate>
      <link>https://dev.to/testmuai/introduction-to-shift-left-testing-1ikc</link>
      <guid>https://dev.to/testmuai/introduction-to-shift-left-testing-1ikc</guid>
      <description>&lt;p&gt;Shift-left testing is a software testing approach where testing is moved to an earlier phase in the development process, closer to the development phase. The goal of shift-left testing is to catch and fix defects as early as possible in the development cycle, which can save time and resources in the long run.&lt;/p&gt;

&lt;p&gt;A real-time example of shift-left testing is in a microservices architecture where each service is developed and tested independently before being integrated with other services.&lt;/p&gt;

&lt;p&gt;For example, My team is developing a payment page for an airline platform that involves new microservice for managing shopping cart and order service. The development team begins by writing unit tests for the cart and order service, which test the individual functions and methods of the service.&lt;/p&gt;

&lt;p&gt;Once these tests pass, the team can proceed to integration testing, where the both services (cart and order) are tested against other services in the platform to ensure that it works as expected.&lt;/p&gt;

&lt;p&gt;Once the development and testing of the both services (cart and order) is completed, it is then deployed to a staging environment where it is tested again. If there are any issues found in staging, they are resolved and the service is deployed to production.&lt;/p&gt;

&lt;p&gt;By performing testing early in the development process, the team can catch and fix defects early on, saving time and resources that would have been spent on later stages of testing.&lt;/p&gt;

&lt;p&gt;It’s also important to note that shift-left testing is not only about testing earlier but also about involving the whole team in the testing process, where developers, QA, and ops collaborate to test, identify and fix issues, which leads to a more streamlined and efficient development process.&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=medium&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jul10_kj&amp;amp;utm_term=kj&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;Selenium automation testing&lt;/a&gt; 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;
  
  
  Adopting Shift left testing in a software development lifecycle
&lt;/h2&gt;

&lt;p&gt;The software development life cycle (SDLC) is a process followed in an organization for a software project. It consists of various stages starting from planning, designing, developing, testing, deploying, and maintaining software. It is a framework that outlines the steps and activities involved in developing software, from the initial planning stages to the final deployment and maintenance of the software.&lt;/p&gt;

&lt;p&gt;Adopting Shift left testing in a software development lifecycle improves the quality of the software and reduces the time and cost required to fix defects later in the process.&lt;/p&gt;

&lt;p&gt;Below are some ways in which you can adopt to shift left testing in your organization:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1.Involve testers earlier in the development process:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Testers should be involved in the development process as early as possible, to provide feedback and help identify defects. This involves working closely with developers, attending daily stand-ups, and participating in design and code reviews.&lt;/p&gt;

&lt;p&gt;To implement shift left testing, organizations often follow Agile Methodology and have sprint ceremonies such as sprint grooming and sprint planning where both QA and Development teams are involved from the beginning.&lt;/p&gt;

&lt;p&gt;During this time, QA can ask clarifying questions about requirements and provide inputs as well.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2.Implement BDD/TDD Approach:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;This approach has several benefits. The test cases prepared by QA can help developers think about scenarios they may not have considered. Additionally, QA may identify cases that were missed by the product owner, business analyst, or the person who is responsible for gathering requirements.&lt;/p&gt;

&lt;p&gt;Identifying potential issues and creating test cases early in the development process can save time and effort later on. Without this early identification, issues may not be discovered until later stages of development or testing, at which point it may be more time-consuming and costly to make changes to address them.&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=jul10_kj&amp;amp;utm_term=kj&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;automation testing Python&lt;/a&gt; to help you streamline your testing process.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3.Encourage developers to write unit testing:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Unit testing involves testing individual units or components of code to ensure that they are working correctly. It is an important shift left testing technique that can be used to identify and fix defects early in the development process. You can provide training on how to write effective unit tests, as well as tools and frameworks that can be used to automate unit testing.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;4.Conducting Internal Demo:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Conducting an internal demo to the sprint team on the sprint closure day is an effective way to implement shift left testing. During this demo, team members can visually see the work completed in the previous sprint, including any changes or updates to the website or product.&lt;/p&gt;

&lt;p&gt;This allows them to provide feedback and identify potential issues early on, rather than waiting for formal testing to be conducted later in the process.&lt;/p&gt;

&lt;p&gt;By involving the entire team in the demo, you can increase the chances of identifying potential issues and gathering valuable feedback. This can help improve the quality and value of the product, as it will not only be tested by a dedicated tester at a later stage but also reviewed and assessed by the entire team. This task ensures all relevant scenarios are considered and necessary changes are made before the product is released.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;In this &lt;a href="https://www.lambdatest.com/blog/flutter-testing/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jul10_kj&amp;amp;utm_term=kj&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;Flutter testing tutorial&lt;/a&gt;, we will discuss how to test flutter apps manually and automation on real device cloud.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;5.Monitor test coverage:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Use tools to monitor test coverage or the percentage of code that is tested, to ensure that you are testing all relevant code. Using code coverage tools can help you in monitor test coverage and also helps in analysing your codebase and reports on the percentage of code that is covered by tests.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;6.Use version control and code review:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Use version control systems, such as Git, to track changes to your codebase and enable collaboration. Use code review to ensure that code is reviewed and tested by multiple team members before it is deployed.&lt;/p&gt;

&lt;p&gt;For example, you might set up a code review process in which all new code is reviewed by at least one other team member before it is merged into the main codebase.&lt;/p&gt;

&lt;p&gt;This can help identify and fix defects early on and improve the overall quality of your software. By incorporating these techniques into your shift left testing strategy, you can effectively identify and fix defects early in the development process, improving the quality and efficiency of your software&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;7.Automation Testing:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Automated testing can be used to test individual units or components of code as they are being developed, allowing you to identify defects early on. This can help reduce the time and effort required for testing later on and improve the quality of your software by identifying and fixing defects early in the development cycle.&lt;/p&gt;

&lt;p&gt;For example, when developing microservices, you can use automated testing to perform component testing early in the development process. By preparing test cases based on the Swagger or Confluence page and calling the service directly from the feature branch, you can verify that the service is working as intended.&lt;/p&gt;

&lt;p&gt;You can also write code in the same branch as the development team and check classes or enumerations that are being used to ensure that they meet the requirements.&lt;/p&gt;

&lt;p&gt;By performing early testing, you can identify bugs and defects at an early stage of software development, improving the quality and efficiency of your development process.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;In this Selenium with Java tutorial, you will learn everything you need to know to kick start your journey in &lt;a href="https://www.lambdatest.com/blog/selenium-with-java/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jul10_kj&amp;amp;utm_term=kj&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;Selenium automation testing&lt;/a&gt; with Java.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;8.Testing every component:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Testing every component is an important aspect of shift left testing. If you are testing an API and not all of the API is developed, you can still test what is available and mock the response for the rest.&lt;/p&gt;

&lt;p&gt;Using concepts such as stubs and drivers, you can focus on testing the ready components without worrying about what is not yet available. This can give you confidence that the developed components are working correctly.&lt;/p&gt;

&lt;p&gt;Later, when the entire API is available for testing, you can quickly verify its functionality without spending a lot of time on testing that has already been covered earlier.&lt;/p&gt;

&lt;p&gt;Additionally, you can concentrate on your API’s functioning in connection to other third-party APIs it communicates with during this testing phase. You can make sure your API is operating properly and consistently by evaluating various third-party API behaviours&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;9.Include security testing:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Security testing should be integrated into the development process as early as possible, to identify and fix security vulnerabilities early on. This can involve using tools such as static analysis tools, dynamic analysis tools, and penetration testing tools to test the security of the software.&lt;/p&gt;

&lt;p&gt;These tools can be used to test the security of the software early in the development process.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Run your &lt;a href="https://www.lambdatest.com/puppeteer?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jul10_kj&amp;amp;utm_term=kj&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;Puppeteer testing&lt;/a&gt; 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 shift left testing is beneficial?
&lt;/h2&gt;

&lt;p&gt;Below are some of the points, in which shift left testing proves to be beneficial: Reduced time and cost: By starting testing earlier in the development process, organizations can catch defects earlier and reduce the time and cost of testing.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Improved quality:&lt;/strong&gt;&lt;br&gt;
By testing early and often, organizations can identify and fix defects before they become more complex and expensive.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Enhanced collaboration:&lt;/strong&gt;&lt;br&gt;
Shift left testing encourages collaboration between development and testing teams, which can improve communication and lead to a better understanding of the requirements and design of the software.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Greater agility:&lt;/strong&gt; Shift left testing can help organizations be more agile and responsive to changes in the market or business requirements, as it allows them to quickly identify and fix defects and make changes to the software.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;This guide explores &lt;a href="https://www.lambdatest.com/learning-hub/digital-transformation?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jul10_kj&amp;amp;utm_term=kj&amp;amp;utm_content=learning_hub" rel="noopener noreferrer"&gt;Digital Transformation&lt;/a&gt;., its benefits, goals, importance and challenges involved in Digital Transformation.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

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

&lt;p&gt;Shift Left testing is not a new approach but it has gained more popularity in recent years as organizations have sought to improve the efficiency and effectiveness of their software development processes.It is a valuable approach that can help organizations improve the quality of their software and reduce the time and cost required to develop it.&lt;/p&gt;

</description>
      <category>discuss</category>
      <category>testing</category>
      <category>shiftleft</category>
      <category>programming</category>
    </item>
    <item>
      <title>Cypress .should() Command: A Detailed Guide</title>
      <dc:creator>BhasinAnshita</dc:creator>
      <pubDate>Tue, 27 Jun 2023 08:20:31 +0000</pubDate>
      <link>https://dev.to/testmuai/cypress-should-command-a-detailed-guide-49h4</link>
      <guid>https://dev.to/testmuai/cypress-should-command-a-detailed-guide-49h4</guid>
      <description>&lt;p&gt;An assertion is a way to validate that the application or system under test is functioning as expected. In &lt;a href="https://www.lambdatest.com/learning-hub/cypress-tutorial?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jun27_kj&amp;amp;utm_term=kj&amp;amp;utm_content=learning_hub" rel="noopener noreferrer"&gt;Cypress&lt;/a&gt;, assertions are used to ensure that the state of the application being tested meets the anticipated conditions.&lt;/p&gt;

&lt;p&gt;Typically, an assertion consists of two parts: a target value (the actual value being tested) and an expected value (the expected result of the test). If the target value matches the expected value, the assertion passes, indicating that the application functions as expected.&lt;/p&gt;

&lt;p&gt;However, if the target value does not match the expected value, the assertion fails, indicating that something is wrong with the application, and the test fails.&lt;/p&gt;

&lt;p&gt;&lt;strong&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=jun27_kj&amp;amp;utm_term=kj&amp;amp;utm_content=learning_hub" rel="noopener noreferrer"&gt;Cypress tutorial&lt;/a&gt;, I will explain in detail about using Cypress &lt;em&gt;.should()&lt;/em&gt; command along with some real time use cases.&lt;br&gt;
_&lt;/strong&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  Quick Recap: What are Assertions?
&lt;/h2&gt;

&lt;p&gt;Assertions are used to define the expected behavior or outcome of a test. When the test results deviate from the expected behavior, the assertions fail, indicating a mismatch between the actual and expected outcomes.&lt;/p&gt;

&lt;p&gt;Let’s take an example scenario where you have an eCommerce website, and your objective is to validate that the number of products displayed on the page is exactly 10. But, if you don’t have any assertion in place. You will miss verifying the total count of products which can lead to misleading results.&lt;/p&gt;

&lt;p&gt;It is the most important part of &lt;a href="https://www.lambdatest.com/learning-hub/test-execution?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jun27_kj&amp;amp;utm_term=kj&amp;amp;utm_content=learning_hub" rel="noopener noreferrer"&gt;test execution&lt;/a&gt;. As a tester, your primary responsibility is to ensure the seamless functionality of the application. If the results of the Application Under Test (AUT) do not align with the expected outcome, it is crucial to report any discrepancies as bugs. This practice plays a vital role in upholding the reliability and quality of the application.&lt;/p&gt;

&lt;p&gt;Assertions are also important as they contribute to early issue detection, effective debugging, and improved code quality. By incorporating assertions into testing processes, software testers can enhance the overall quality and reliability of the software system. You can learn more about assertions through this tutorial on &lt;a href="https://www.lambdatest.com/learning-hub/cypress-assertions?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jun27_kj&amp;amp;utm_term=kj&amp;amp;utm_content=learning_hub" rel="noopener noreferrer"&gt;Cypress assertions&lt;/a&gt;.&lt;/p&gt;

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

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Here's Top 30+ &lt;a href="https://www.lambdatest.com/learning-hub/webdriverio-interview-questions?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jun27_kj&amp;amp;utm_term=kj&amp;amp;utm_content=learning_hub" rel="noopener noreferrer"&gt;WebdriverIO Interview Questions&lt;/a&gt; and Answers that will help you boost your confidence in an Interview.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  What is the use of Cypress .should() Command?
&lt;/h2&gt;

&lt;p&gt;Cypress provides its custom assertion library, which extends the Chai assertion library. One of the assertion commands provided by Cypress is &lt;em&gt;.should()&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;The Cypress &lt;em&gt;.should()&lt;/em&gt; command is used to make assertions about the state of the AUT. It is used to ensure that certain conditions are met before proceeding with the test.&lt;/p&gt;

&lt;p&gt;These assertions are automatically retried until they pass or the command times out. This means that if an assertion fails initially, Cypress will retry it until the test passes or the command results in a time out of 4000ms. This makes tests more resilient to flakiness caused by timing issues or network latency.&lt;/p&gt;

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

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

&lt;p&gt;Here are some examples that demonstrate the usage of the Cypress &lt;em&gt;.should()&lt;/em&gt; command with &lt;em&gt;cy.get()&lt;/em&gt;, &lt;em&gt;cy.contains()&lt;/em&gt;, and &lt;em&gt;cy.wrap()&lt;/em&gt;:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2000%2F0%2AuVxcqWl-81bLlRKw.png" class="article-body-image-wrapper"&gt;&lt;img src="https://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%2AuVxcqWl-81bLlRKw.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In this blog, I will be using &lt;em&gt;cy.get()&lt;/em&gt; for &lt;em&gt;.should()&lt;/em&gt; assertion.&lt;/p&gt;

&lt;p&gt;Assertion can be handled in different ways. Below are the most commonly used ways you can handle assertion in Cypress.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Assert based on class value&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Assert based on length&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Assert based on text&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Assert based on value tag&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Assert based on HTML attribute&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Assert for checkboxes&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Chaining Multiple Assertions&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Assert if the text is visible/hidden&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Assert if the value is empty&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Assert if the URL is correct&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Assert if the element is not present&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Let’s understand in detail:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Prepare to ace your &lt;a href="https://www.lambdatest.com/learning-hub/jest-interview-questions?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jun27_kj&amp;amp;utm_term=kj&amp;amp;utm_content=learning_hub" rel="noopener noreferrer"&gt;Jest interview questions&lt;/a&gt; with our thorough set of interview questions and solutions that will enable you to prove your command of the Jest testing framework.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Assert based on class value
&lt;/h2&gt;

&lt;p&gt;To perform assertions where the class of an element can change dynamically based on user interactions or other events, you can use Cypress &lt;em&gt;.should(‘have.class’, ‘className’)&lt;/em&gt; command. This command allows you to verify that an element has the expected class. By specifying the desired class name, you can assert whether the element possesses that class as part of your test validation.&lt;/p&gt;

&lt;p&gt;It can be useful if the UI changes dynamically based on user interactions or application state. By asserting specific class values, you can ensure the expected behavior is upheld. For example, you can verify whether a button appropriately includes the disabled class when specific conditions require it to be disabled.&lt;/p&gt;

&lt;p&gt;An additional scenario where the Cypress &lt;em&gt;.should()&lt;/em&gt; command can be utilized is when your application exhibits various states indicated by different class values. In such cases, you can employ assertions to validate the transitions between these states.&lt;/p&gt;

&lt;p&gt;For example, you can verify that an element has the loading class during an asynchronous operation and then changes to the loaded class when the operation is complete.&lt;/p&gt;

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

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

&lt;p&gt;It can be used with &lt;a href="https://www.lambdatest.com/blog/document-object-model/" rel="noopener noreferrer"&gt;DOM&lt;/a&gt; commands like &lt;em&gt;cy.get(), cy.contains(), or cy.wrap(),&lt;/em&gt; as shown below:&lt;/p&gt;

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

&lt;p&gt;Below is an example of how to use the assertion with &lt;em&gt;cy.get()&lt;/em&gt; in 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;Navigate to URL &lt;a href="https://ecommerce-playground.lambdatest.io/" rel="noopener noreferrer"&gt;https://ecommerce-playground.lambdatest.io/&lt;/a&gt; using &lt;em&gt;cy.visit()&lt;/em&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Enter the email address in a textbox and verify the class value is as expected.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Enter the password in the textbox.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Verify the class value of the submit button is as expected.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

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

&lt;p&gt;Below is the Cypress code to open the web application and verify the class using the Cypress &lt;em&gt;.should(‘have.class’,className)&lt;/em&gt; assertion.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; describe('Cypress Assertions', () =&amp;gt; {
       it('Should - Class Assertion', () =&amp;gt; {
           cy.visit(' https://ecommerce-playground.lambdatest.io/')   cy.get('#input-email').type('lambdatest.Cypress@disposable.com').should('have.class', 'form-control')
           cy.get('#input-password').type('Cypress123!!')
           cy.get('[value="Login"]').should('have.class', 'btn btn-primary')
       })
    })
&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;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3200%2F0%2AhbP8sNiI7Jka2xLU.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3200%2F0%2AhbP8sNiI7Jka2xLU.png"&gt;&lt;/a&gt;&lt;/p&gt;

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

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

&lt;p&gt;&lt;strong&gt;Step 1&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Firstly, the test navigates to the URL of the website using &lt;em&gt;cy.visit()&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2350%2F0%2AQBYykX0fwryQMq5e.png" class="article-body-image-wrapper"&gt;&lt;img src="https://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%2F0%2AQBYykX0fwryQMq5e.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 2&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;In the below code snippet, the initial step involves selecting the input field with the id input-email. Subsequently, a test email address is entered into the selected field.&lt;/p&gt;

&lt;p&gt;Finally, the validation process checks whether the input field possesses the form-control class by utilizing the Cypress &lt;em&gt;.should(‘have.class’, ‘form-control’)&lt;/em&gt; command.&lt;/p&gt;

&lt;p&gt;It should be noted that although an ID is utilized as a locator in this particular example, you can also create CSS based on other HTML attributes if desired, providing further flexibility.&lt;/p&gt;

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

&lt;p&gt;&lt;strong&gt;Step 3&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;As shown in the screenshot below, the class name of the locator is “&lt;em&gt;form-control&lt;/em&gt;” in DOM. So, in Cypress &lt;em&gt;.should()&lt;/em&gt;, the same class name is passed along with the locator of the element on the webpage.&lt;/p&gt;

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

&lt;p&gt;&lt;strong&gt;Step 4&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;In the below code, I select the password input field and then type in a test password.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://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%2AYrstecjs7hUISfJT.png" class="article-body-image-wrapper"&gt;&lt;img src="https://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%2AYrstecjs7hUISfJT.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 5&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The last line selects the login button on the page using a &lt;a href="https://www.lambdatest.com/learning-hub/css-selectors?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jun27_kj&amp;amp;utm_term=kj&amp;amp;utm_content=learning_hub" rel="noopener noreferrer"&gt;CSS Selector&lt;/a&gt; and then checks that it has the classes &lt;em&gt;btn *and *btn-primary&lt;/em&gt;.&lt;/p&gt;

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

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

&lt;p&gt;As shown above, the class value of the locator is “&lt;em&gt;btn btn-primary&lt;/em&gt;”, which is passed in the Cypress &lt;em&gt;.should()&lt;/em&gt; command.&lt;/p&gt;

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

&lt;h2&gt;
  
  
  Assert based on length
&lt;/h2&gt;

&lt;p&gt;In Cypress, if you want to handle a scenario where you want to verify the expected number of elements for a specific set of elements, you can use Cypress &lt;em&gt;.should(‘have.length’,totalLength)&lt;/em&gt; command.&lt;/p&gt;

&lt;p&gt;For example, it can be helpful in cases where you have multiple products on the page and want to check the length of it or if you wish to verify the number of search results. It is also helpful in cases where you want to check the number of products in a shopping cart.&lt;/p&gt;

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

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

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

&lt;p&gt;Let’s understand in detail with a test scenario.&lt;/p&gt;

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

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Navigate to the &lt;a href="https://ecommerce-playground.lambdatest.io/" rel="noopener noreferrer"&gt;https://ecommerce-playground.lambdatest.io/&lt;/a&gt; webpage using &lt;em&gt;cy.visit()&lt;/em&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Verify that there are six categories displayed on the page using the &lt;em&gt;.should(have.length)&lt;/em&gt; assertion.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Verify that there are 10 top products displayed on the page.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Implementation&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('Cypress Assertions', () =&amp;gt; {
       it('Should - Length Assertion', () =&amp;gt; {
           /* Verify the number of categories on the page */
           cy.visit('https://ecommerce-playground.lambdatest.io/')
           cy.get('.navbar-nav.horizontal&amp;gt;li').should('have.length', 6)
           /* Verify the number of top products on the page */
           cy.get('.swiper-wrapper').eq(1).find('&amp;gt;div').should('have.length, 10)
       })  })
&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;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3200%2F0%2AkFAMc3Zmmwd2jxl0.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3200%2F0%2AkFAMc3Zmmwd2jxl0.png"&gt;&lt;/a&gt;&lt;/p&gt;

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

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

&lt;p&gt;&lt;strong&gt;Step 1&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Firstly, the test navigates to the URL of the website using &lt;em&gt;cy.visit()&lt;/em&gt;.&lt;/p&gt;

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

&lt;p&gt;&lt;strong&gt;Step 2&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Then, it verifies that there are six categories displayed on the page using the &lt;em&gt;.should(have.length)&lt;/em&gt; assertion on the class value, which is &lt;em&gt;‘.navbar-nav.horizontal &amp;gt;li’&lt;/em&gt;.&lt;/p&gt;

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

&lt;p&gt;In the below screenshot, it can be seen that the category locator with class value ‘&lt;em&gt;.navbar-nav.horizontal &amp;gt;li&lt;/em&gt;’ has six 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%2F0%2AC1ltwXedKRlQTrs5.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3200%2F0%2AC1ltwXedKRlQTrs5.png"&gt;&lt;/a&gt;&lt;/p&gt;

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

&lt;p&gt;&lt;strong&gt;Step 3&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Next, it verifies that there are 10 top products displayed on the page using the &lt;em&gt;.should(have.length)&lt;/em&gt; assertion on the class locator, which is ‘&lt;em&gt;.swiper-wrapper&lt;/em&gt;‘.&lt;/p&gt;

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

&lt;p&gt;As shown below in the screenshot, &lt;em&gt;cy.get(‘.swiper-wrapper’).eq(1)&lt;/em&gt; is used, which returns the matched element, which is at location 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%2F2000%2F0%2APiUn_oLeq5e1p2JF.png" class="article-body-image-wrapper"&gt;&lt;img src="https://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%2APiUn_oLeq5e1p2JF.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 3&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;It is seen in the below screenshot that the div element count is ten, which is inside &lt;em&gt;cy.get(‘.swiper-wrapper’).eq(1).find(‘&amp;gt;div’)&lt;/em&gt;.&lt;/p&gt;

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

&lt;p&gt;The below command &lt;em&gt;cy.get(‘.swiper-wrapper’).eq(1).find(‘&amp;gt;div’).should(‘have.length’, 10)&lt;/em&gt; searches for the element with class value ‘&lt;em&gt;.swiper-wrapper&lt;/em&gt;’, which is at index 1 (or location2) and then finds the div elements and in the end it verifies that the total number of div elements are 10 using &lt;em&gt;.should(‘have.length’,10)&lt;/em&gt;.&lt;/p&gt;

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

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

&lt;h2&gt;
  
  
  Assert based on text
&lt;/h2&gt;

&lt;p&gt;In Cypress, if you want to verify the expected text on the page, you can use Cypress &lt;em&gt;.should(‘have.text’,expectedText)&lt;/em&gt; assertion. This is one of the most commonly used Cypress assertions.&lt;/p&gt;

&lt;p&gt;It is helpful in cases where your application supports multiple languages. In those cases, you can use text-based assertions to verify the correct translation of text elements. By asserting the presence of specific translated text, you can ensure that the application displays the correct language based on the user’s preferences.&lt;/p&gt;

&lt;p&gt;This type of assertion is frequently used in testing when a tester needs to verify an expected value, often in the form of text, on a webpage. As such, assertions based on text can be used in a wide range of scenarios where verifying expected text is a critical part of the test case.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Syntax&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%2F2980%2F0%2A9Wl94gqGCV2cdGlm.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2980%2F0%2A9Wl94gqGCV2cdGlm.png"&gt;&lt;/a&gt;&lt;/p&gt;

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

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Navigate to the website &lt;a href="https://ecommerce-playground.lambdatest.io/" rel="noopener noreferrer"&gt;https://ecommerce-playground.lambdatest.io/&lt;/a&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Verify that the text “&lt;em&gt;Upto 30% Off on Popular Smartphones + Exchange Offers&lt;/em&gt;” is displayed under the Top Products section.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Verify that the third product displayed under the Top Collection section is “HTC Touch HD”.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Implementation&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('Cypress Assertions', () =&amp;gt; {
       it('Should - Text Assertion', () =&amp;gt; {
           /* Verify the text of category on the page */
           cy.visit('https://ecommerce-playground.lambdatest.io/')    cy.get('.m-md-0.d-flex.align-items-center.mb-3').should('have.text', "Upto 30% Off on Popular Smartphones + Exchange Offers")
           /* Verify the text of specific products at specific location on the page */    cy.get('.swiper-slide.swiper-slide-active').eq(2).find('&amp;gt;div&amp;gt;div&amp;gt;h4&amp;gt;a').first().should('have.text', 'HTC Touch HD')
       }) })

&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;&lt;a href="https://media2.dev.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-ypbdBqyMWrPU22-.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.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-ypbdBqyMWrPU22-.png"&gt;&lt;/a&gt;&lt;/p&gt;

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

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

&lt;p&gt;&lt;strong&gt;Step 1&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Firstly, the test navigates to the URL of the website using &lt;em&gt;cy.visit()&lt;/em&gt;.&lt;/p&gt;

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

&lt;p&gt;&lt;strong&gt;Step 2&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;It uses the &lt;em&gt;cy.get()&lt;/em&gt; command with a class selector to target an element on the page with the class “&lt;em&gt;m-md-0.d-flex align-items-center.mb-3&lt;/em&gt;“.&lt;/p&gt;

&lt;p&gt;Then, the Cypress &lt;em&gt;.should()&lt;/em&gt; command is used with the assertion “&lt;em&gt;have.text&lt;/em&gt;” to check that the element contains the expected text “Upto 30% Off on Popular Smartphones + Exchange Offers”.&lt;/p&gt;

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

&lt;p&gt;As shown in the screenshot below, locator values have matching text. It is important to note in the case of Cypress &lt;em&gt;.should(‘have.text’expectedText)&lt;/em&gt; assertion, you need to pass the exact text value else your test case will fail. Even if there is space in the text, the test case will fail in that case.&lt;/p&gt;

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

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

&lt;p&gt;&lt;strong&gt;Step 3&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The last line of code verifies the text of a specific product located at a specific location on the page. It finds the specific location using class “&lt;em&gt;.swiper-slide.swiper-slide-active’&lt;/em&gt;” at location 3. Then it finds the first text, which is under the element (&lt;em&gt;‘&amp;gt;div&amp;gt;div&amp;gt;h4&amp;gt;a&lt;/em&gt;‘).&lt;/p&gt;

&lt;p&gt;In the end, it asserts the text of the link using the Cypress &lt;em&gt;.should(‘have.text’, ‘HTC Touch HD’)&lt;/em&gt;” assertion.&lt;/p&gt;

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

&lt;p&gt;In the below screenshot, it can be seen for the locator with class “&lt;em&gt;.swiper-slide.swiper-slide-active&lt;/em&gt;”, which is at 3rd location, inside that &lt;em&gt;div&amp;gt;div&amp;gt;h4&amp;gt;a&lt;/em&gt; has specific text, which we are validating in our code.&lt;/p&gt;

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

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

&lt;p&gt;In summary, this test case navigates to a website and verifies that two elements on the page contain expected text using the Cypress &lt;em&gt;.should()&lt;/em&gt; command with the “&lt;em&gt;have.text&lt;/em&gt;” assertion.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Ace your QA interviews with our comprehensive guide on 60+ &lt;a href="https://www.lambdatest.com/learning-hub/specflow-interview-questions?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jun27_kj&amp;amp;utm_term=kj&amp;amp;utm_content=learning_hub" rel="noopener noreferrer"&gt;SpecFlow Interview Questions&lt;/a&gt; and Answers. Boost your BDD knowledge and showcase your SpecFlow expertise.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Assert based on value tag
&lt;/h2&gt;

&lt;p&gt;It is a common practice in web applications to assert based on the value tag, which sets the initial value of an input element, such as a text input field, to validate whether an element contains a specific value.&lt;/p&gt;

&lt;p&gt;This can be easily achieved using the Cypress &lt;em&gt;.should(‘have.value’,expectedValue)&lt;/em&gt; command, which verifies whether a particular element has the expected value.&lt;/p&gt;

&lt;p&gt;It can be used in cases when you are interacting with select dropdowns. You can verify that the selected option’s value matches the expected value. This is useful for validating the correctness of user selections in dropdown menus.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Syntax&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%2A1L_YNawbuNwiV5Va.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3200%2F0%2A1L_YNawbuNwiV5Va.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Let’s understand it with the below examples.&lt;/p&gt;

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

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

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Navigate to URL &lt;a href="https://ecommerce-playground.lambdatest.io/" rel="noopener noreferrer"&gt;https://ecommerce-playground.lambdatest.io/&lt;/a&gt; using &lt;em&gt;cy.visit()&lt;/em&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Enter text in a search box using &lt;em&gt;cy.type()&lt;/em&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Verify the entered text value is correct.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Also, Verify if the entered text is not equal to some other value. It is case-sensitive.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

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

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Navigate to URL &lt;a href="https://www.lambdatest.com/selenium-playground/select-dropdown-demo" rel="noopener noreferrer"&gt;https://www.lambdatest.com/selenium-playground/select-dropdown-demo&lt;/a&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Select the dropdown value.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Verify the selected dropdown value is as expected.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Implementation&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('Cypress Assertions', () =&amp;gt; {
       it.only('Should - Value Assertion for Textbox', () =&amp;gt; {
           cy.visit('https://ecommerce-playground.lambdatest.io/')
           cy.get('input[name="search"]').first().type('iphone')
           cy.get('input[name="search"]').first().should('have.value', 'iphone')
          cy.get('input[name="search"]').first().should('not.have.value', 'IPHONE')


       })


       it('Should - Value Assertion for Dropdown', () =&amp;gt; {
    cy.visit('https://www.lambdatest.com/selenium-playground/select-dropdown-demo')
           cy.get('#select-demo').select('Wednesday')
           cy.get('#select-demo option:selected').should('have.value', 'Wednesday')
       })
    })

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

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

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

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

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

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

&lt;p&gt;In the first test case, it opens a web application. Enter the text and verify if the entered text value matches the expected value.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 1&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The first step is to navigate to the URL using &lt;em&gt;cy.visit()&lt;/em&gt;.&lt;/p&gt;

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

&lt;p&gt;&lt;strong&gt;Step 2&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Using &lt;em&gt;cy.get(selector)&lt;/em&gt;, it will find the element and then using &lt;em&gt;.type(‘iphone’)&lt;/em&gt;, will pass the text to the textbox.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://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%2AvfeAWf2ytOTXt_Yy.png" class="article-body-image-wrapper"&gt;&lt;img src="https://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%2AvfeAWf2ytOTXt_Yy.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 3&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;After entering the text in the textbox, it verifies if the entered text matches the expected text using &lt;em&gt;.should(‘have.value’,expectedText)&lt;/em&gt;.&lt;/p&gt;

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

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

&lt;p&gt;In the second test case, it opens a web application. Select the value from the dropdown and verify if the selected text value matches the expected value.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 1&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;First step is to navigate to the URL using &lt;em&gt;cy.visit()&lt;/em&gt;.&lt;/p&gt;

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

&lt;p&gt;&lt;strong&gt;Step 2&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Using the below code, choose the value of the dropdown. In this case, &lt;em&gt;.select()&lt;/em&gt; is used to select the dropdown value.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://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%2AG6y02axoZD8NWmhG.png" class="article-body-image-wrapper"&gt;&lt;img src="https://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%2AG6y02axoZD8NWmhG.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 3&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;In the end, assert the selected dropdown value is as expected using Cypress &lt;em&gt;.should(‘have.value’,expectedText)&lt;/em&gt; command.&lt;/p&gt;

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

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Here's Top 30 &lt;a href="https://www.lambdatest.com/learning-hub/robot-framework-interview-questions?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jun27_kj&amp;amp;utm_term=kj&amp;amp;utm_content=learning_hub" rel="noopener noreferrer"&gt;Robot Framework Interview Questions&lt;/a&gt; and Answers that will help you boost your confidence in an Interview.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Assert based on attribute
&lt;/h2&gt;

&lt;p&gt;It’s often important to verify that certain attributes of elements on the page have the expected values.&lt;/p&gt;

&lt;p&gt;For example, if you have a link on the page and want to assert that the value of the href attribute is correct, Cypress makes it easy to do this using its built-in &lt;em&gt;.should()&lt;/em&gt; function.&lt;/p&gt;

&lt;p&gt;To assert based on attribute, you can use the should function with the have.attr property. The &lt;em&gt;have.attr&lt;/em&gt; property allows you to check the value of any attribute on an element.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Syntax&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%2F2082%2F0%2Ab6jPfXL_kC4kruzc.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2082%2F0%2Ab6jPfXL_kC4kruzc.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Let’s understand with below test scenario:&lt;/p&gt;

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

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Navigate to the URL &lt;a href="https://ecommerce-playground.lambdatest.io/" rel="noopener noreferrer"&gt;https://ecommerce-playground.lambdatest.io/&lt;/a&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Select dropdown value.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Verify the selected dropdown value is as expected.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Implementation&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('Cypress Assertions', () =&amp;gt; {


       it.only('Should - Attribute Assertion for Textbox', () =&amp;gt; {
           cy.visit('https://ecommerce-playground.lambdatest.io/')
           cy.get('span:contains("Home")').parents('a').should('have.attr', 'href','https://ecommerce-playground.lambdatest.io/index.php?route=common/home')
           })
    })
&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;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3200%2F0%2ADNkYAU9t8_AmFuNE.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3200%2F0%2ADNkYAU9t8_AmFuNE.png"&gt;&lt;/a&gt;&lt;/p&gt;

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

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

&lt;p&gt;&lt;strong&gt;Step 1&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;In the first step, the &lt;em&gt;cy.visit()&lt;/em&gt; command is used to navigate to the specified URL, which is &lt;a href="https://ecommerce-playground.lambdatest.io/" rel="noopener noreferrer"&gt;https://ecommerce-playground.lambdatest.io/&lt;/a&gt;.&lt;/p&gt;

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

&lt;p&gt;&lt;strong&gt;Step 2&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;I am using the &lt;em&gt;cy.get()&lt;/em&gt; command to select the element on the web page containing the text “&lt;em&gt;Home&lt;/em&gt;“, which in this case is a span element.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://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%2AlIBz8JrcwqQw_DT2.png" class="article-body-image-wrapper"&gt;&lt;img src="https://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%2AlIBz8JrcwqQw_DT2.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;As shown below, &lt;em&gt;.parents(‘a’)&lt;/em&gt; Cypress command is used, which traverses up the DOM tree from the span element to select its parent element, which is an ‘a’ tag.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://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%2A2zsFZOUgG5ZIziVz.png" class="article-body-image-wrapper"&gt;&lt;img src="https://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%2A2zsFZOUgG5ZIziVz.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In the end, the Cypress &lt;em&gt;.should()&lt;/em&gt; command is used to assert that the a tag selected in the previous step has a specific attribute called &lt;em&gt;href&lt;/em&gt;, with a value of &lt;a href="https://ecommerce-playground.lambdatest.io/index.php?route=common/home" rel="noopener noreferrer"&gt;https://ecommerce-playground.lambdatest.io/index.php?route=common/home&lt;/a&gt;.&lt;/p&gt;

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

&lt;p&gt;So overall, this code navigates to the website, selects the “Home” link, and checks if its href attribute has a specific value.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://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%2A7cQyHXmDxglvKVdz.png" class="article-body-image-wrapper"&gt;&lt;img src="https://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%2A7cQyHXmDxglvKVdz.png"&gt;&lt;/a&gt;&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=jun27_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;
  
  
  Assert for checkboxes
&lt;/h2&gt;

&lt;p&gt;When it comes to testing forms, checkboxes are a common element to be included. As a test automation engineer, we need to assert the expected behavior of the checkboxes in our test cases.&lt;/p&gt;

&lt;p&gt;In scenarios where mandatory terms and conditions checkboxes are required for user login, you can utilize the Cypress &lt;em&gt;.should(‘be.checked’)&lt;/em&gt; assertion to verify whether the checkbox is selected before proceeding with the login process. This approach ensures that the user can proceed only when the checkbox is checked, the user can proceed.&lt;/p&gt;

&lt;p&gt;Additionally, this approach proves useful when you need to confirm that a checkbox has been unchecked. For instance, certain web applications provide a checkbox during registration to receive notifications via email. Users have the option to opt out of this feature. By employing the Cypress &lt;em&gt;.should(‘be.unchecked’)&lt;/em&gt; command, you can verify whether the already selected checkbox can be successfully deselected.&lt;/p&gt;

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

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

&lt;p&gt;Let’s understand in detail, using the below scenario on how to write assertions for checkboxes 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;Navigate to URL &lt;a href="https://www.lambdatest.com/selenium-playground/checkbox-demo" rel="noopener noreferrer"&gt;https://www.lambdatest.com/selenium-playground/checkbox-demo&lt;/a&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Select a single checkbox and validate if it got checked.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Select multiple checkboxes on the page.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Verify all the checkboxes got selected/checked.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Uncheck the single checkbox and verify it got unchecked.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Uncheck the multiple checkboxes and verify if they got unchecked.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Implementation&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('Cypress Assertions', () =&amp;gt; {
       it('Should - Checkbox Assertion', () =&amp;gt; {   cy.visit('https://www.lambdatest.com/selenium-playground/checkbox-demo')
           /* select checkbox and verify if it is checked */
           cy.get('#isAgeSelected').check().should('be.checked')
           cy.get('.cb-element.mr-10').check().should('be.checked')
           /* unselect checkbox and verify if it is unchecked */
           cy.get('#isAgeSelected').uncheck().should('not.be.checked')
           cy.get('.cb-element.mr-10').uncheck().should('not.be.checked')
       })
    })

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

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

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

&lt;p&gt;The above code verifies that the checkboxes on the provided webpage can be selected and unselected correctly.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 1&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Using the below code, the &lt;em&gt;cy.visit()&lt;/em&gt; command is used to navigate to the specified URL, which is &lt;a href="https://www.lambdatest.com/selenium-playground/checkbox-demo" rel="noopener noreferrer"&gt;https://www.lambdatest.com/selenium-playground/checkbox-demo.&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%2F2052%2F0%2A4dwchq1G9MDdm_A8.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2052%2F0%2A4dwchq1G9MDdm_A8.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 2&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;As shown in the below screenshot, I am using the &lt;em&gt;cy.get()&lt;/em&gt; command to select the element on the webpage along with the &lt;em&gt;.check()&lt;/em&gt; command, which is used to select the checkbox. Then, Cypress &lt;em&gt;.should(‘be.checked’)&lt;/em&gt; command is used to assert that the checkboxes are checked.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://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%2AwyMCfoVyY6gc30uX.png" class="article-body-image-wrapper"&gt;&lt;img src="https://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%2AwyMCfoVyY6gc30uX.png"&gt;&lt;/a&gt;&lt;/p&gt;

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

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

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

&lt;p&gt;&lt;strong&gt;Step 3&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;In the below code, I am using the &lt;em&gt;cy.get()&lt;/em&gt; command to select the element on the webpage along with the &lt;em&gt;.uncheck()&lt;/em&gt; command to uncheck the checkboxes.&lt;/p&gt;

&lt;p&gt;Then the Cypress &lt;em&gt;.should(‘not.be.checked’)&lt;/em&gt; command is used to assert that the checkboxes are unchecked.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://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%2Acx8duPX-NaYjDOD9.png" class="article-body-image-wrapper"&gt;&lt;img src="https://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%2Acx8duPX-NaYjDOD9.png"&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=jun27_kj&amp;amp;utm_term=kj&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;Selenium Automation Testing&lt;/a&gt; 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;
  
  
  Chaining Multiple Assertions using Cypress .should() Command
&lt;/h2&gt;

&lt;p&gt;In Cypress, you can easily perform multiple assertions on the same element or group of elements using the chaining method. This makes it possible to write more concise and efficient tests.&lt;/p&gt;

&lt;p&gt;Let’s understand in detail why Chaining is used:&lt;/p&gt;

&lt;p&gt;Chaining in Cypress should be used when you want to perform multiple assertions on an element or a series of actions in a specific order. It allows you to express the expected behavior of your application in a concise and readable manner.&lt;/p&gt;

&lt;p&gt;For example, You can use multiple assertions on the same element using the chaining method for a case where you want first to verify if there are eight products on the page. Then you want to perform a second assertion to validate the text of each product.&lt;/p&gt;

&lt;p&gt;By chaining multiple assertions together, you can create a sequence of conditions that need to be satisfied for the test to pass. In this case, each assertion in the chain is executed sequentially, and the next assertion is only evaluated if the previous one passes.&lt;/p&gt;

&lt;p&gt;It is important to note if any assertion in the chain fails, the test will immediately fail and stop executing further assertions. In Cypress, if there is a failure case in the chain, the test will stop the execution at that point, and the failure will be reported in the test results.&lt;/p&gt;

&lt;p&gt;Let’s understand this with the below example of how to perform multiple assertions on an element using the chaining method:&lt;/p&gt;

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

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

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Navigate to the URL &lt;a href="https://www.lambdatest.com/selenium-playground/checkbox-demo" rel="noopener noreferrer"&gt;https://www.lambdatest.com/selenium-playground/checkbox-demo.&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Verify Top Trending Category products on the page are 8 in the count and verify the last element is “MP3 Players” and has CSS “font-family”&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Verify search box has the attribute aria-label has the value “Search For Products”.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Enter the text in the search box and verify the entered text is as expected.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

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

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Navigate to URL &lt;a href="https://www.lambdatest.com/selenium-playground/select-dropdown-demo" rel="noopener noreferrer"&gt;https://www.lambdatest.com/selenium-playground/select-dropdown-demo.&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Select the dropdown value “Wednesday” from a single dropdown and verify that the element got selected and has the same value which was selected.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Implementation&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('Cypress Assertions', () =&amp;gt; {
       it('Should - Multiple Assertion', () =&amp;gt; {
           cy.visit('https://ecommerce-playground.lambdatest.io/')
           cy.get('.figure.img-top').should('have.length', 8)
               .last()
               .should('include.text', "MP3 Players").should('have.css', 'font-family')
           cy.get('input[name="search"]').first().should('have.attr', 'aria-label', "Search For Products").type('iphone').should('have.value', 'iphone')
       })
       it('Should - Multiple Assertion for Dropdown', () =&amp;gt; {    cy.visit('https://www.lambdatest.com/selenium-playground/select-dropdown-demo')
           cy.get('#select-demo').select('Wednesday')
           cy.get('#select-demo option:selected').should('be.selected').and('have.value', 'Wednesday')
       })
    })

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

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

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

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

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

&lt;p&gt;&lt;strong&gt;Step 1&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Using the below code, the &lt;em&gt;cy.visit()&lt;/em&gt; command is used to navigate to the specified URL, which is &lt;a href="https://ecommerce-playground.lambdatest.io/" rel="noopener noreferrer"&gt;https://ecommerce-playground.lambdatest.io/.&lt;/a&gt;&lt;/p&gt;

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

&lt;p&gt;&lt;strong&gt;Step 2&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The first assertion &lt;em&gt;cy.get(‘.figure.img-top’).should(‘have.length’, 8)&lt;/em&gt; verifies that there are eight elements with the class “&lt;em&gt;figure img-top&lt;/em&gt;“.&lt;/p&gt;

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

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

&lt;p&gt;The second assertion &lt;em&gt;.last().should(‘include.text’, “MP3 Players”)&lt;/em&gt; verifies that the last element with the class “figure img-top” contains the text “MP3 Players”.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://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%2AurNXD9hFr6-TxpMN.png" class="article-body-image-wrapper"&gt;&lt;img src="https://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%2AurNXD9hFr6-TxpMN.png"&gt;&lt;/a&gt;&lt;/p&gt;

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

&lt;p&gt;The third assertion &lt;em&gt;.should(‘have.css’, ‘font-family’)&lt;/em&gt; verifies that the font family of the last element with the class “figure img-top” is defined.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://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%2AVPeEcN6hgDV0xjte.png" class="article-body-image-wrapper"&gt;&lt;img src="https://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%2AVPeEcN6hgDV0xjte.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 3&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;As per the below code, first assertion &lt;em&gt;cy.get(‘input[name=”search”]’).&lt;/em&gt; &lt;em&gt;first().should(‘have.attr’, ‘aria-label’, “Search For Products”)&lt;/em&gt; verifies that the first input element with the name attribute “&lt;em&gt;search&lt;/em&gt;” has an &lt;em&gt;aria-label&lt;/em&gt; attribute set to “&lt;em&gt;Search For Products&lt;/em&gt;“.&lt;/p&gt;

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

&lt;p&gt;The second assertion &lt;em&gt;.type(‘iphone’).should(‘have.value’, ‘iphone’)&lt;/em&gt; types the value “&lt;em&gt;iphone&lt;/em&gt;” into the first input element with the name attribute “&lt;em&gt;search&lt;/em&gt;” and then verifies that the input value is set to “&lt;em&gt;iphone&lt;/em&gt;“.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2000%2F0%2AU-g1ex0L9cPt-vQ4.png" class="article-body-image-wrapper"&gt;&lt;img src="https://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%2AU-g1ex0L9cPt-vQ4.png"&gt;&lt;/a&gt;&lt;/p&gt;

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

&lt;p&gt;&lt;strong&gt;Step 1&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;First, I am navigating to the specified URL, which is &lt;a href="https://www.lambdatest.com/selenium-playground/select-dropdown-demo" rel="noopener noreferrer"&gt;https://www.lambdatest.com/selenium-playground/select-dropdown-demo&lt;/a&gt; using &lt;em&gt;cy.visit()&lt;/em&gt;.&lt;/p&gt;

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

&lt;p&gt;&lt;strong&gt;Step 2&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;As per the below code, &lt;em&gt;cy.get(‘#select-demo’).select(‘Wednesday’)&lt;/em&gt; selects the option “&lt;em&gt;Wednesday&lt;/em&gt;” from the dropdown menu with the ID “&lt;em&gt;select-demo&lt;/em&gt;“.&lt;/p&gt;

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

&lt;p&gt;&lt;strong&gt;Step 3&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The below code &lt;em&gt;cy.get(‘#select-demo option:selected’).should(‘be.selected’).and(‘have.value’, ‘Wednesday’)&lt;/em&gt; verifies that the selected option is “&lt;em&gt;Wednesday&lt;/em&gt;” and that it is marked as selected.&lt;/p&gt;

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

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Do you need to gather more knowledge on &lt;a href="https://www.lambdatest.com/blog/website-testing/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jun27_kj&amp;amp;utm_term=kj&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;website testing&lt;/a&gt;? LambdaTest is here to explain further.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Assert if the text is visible/hidden
&lt;/h2&gt;

&lt;p&gt;To verify if the DOM element is visible on the page. In Cypress, &lt;em&gt;.should(‘be.visible’)&lt;/em&gt; command is used. This assertion can be used to ensure that certain UI elements are displayed correctly and that the user can interact with them as expected.&lt;/p&gt;

&lt;p&gt;This is helpful in cases where you want to verify the content on the page. For example, after successful registration, you can verify if the name is the same, which was entered while registering. It can also be used in cases where you want to verify that a successful message is displayed or not&lt;/p&gt;

&lt;p&gt;You can check both the cases about visibility and non-visibility of an element.&lt;/p&gt;

&lt;p&gt;For non-visibility, it can be helpful in cases where you want to verify if an element does not exist on the page. For example, if you want to verify the error text on the page does not exist. In that case, you can use the Cypress &lt;em&gt;.should(‘not.be.visible’)&lt;/em&gt; command.&lt;/p&gt;

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

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

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

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

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Navigate to the URL &lt;a href="https://ecommerce-playground.lambdatest.io/" rel="noopener noreferrer"&gt;https://ecommerce-playground.lambdatest.io/&lt;/a&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Verify on the web page that the category “Home” is visible.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Verify if a modal dialog is hidden on the page.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Implementation&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('Cypress Assertions', () =&amp;gt; {
       it.only('Should - Visibility Assertion', () =&amp;gt; {
           cy.visit('https://ecommerce-playground.lambdatest.io/')
           cy.get('span:contains("Home")').should('be.visible')
           cy.get('.modal-dialog').should('not.be.visible');
           }) })
&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;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3200%2F0%2AYvEMyjCtZWTGXWkB.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3200%2F0%2AYvEMyjCtZWTGXWkB.png"&gt;&lt;/a&gt;&lt;/p&gt;

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

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

&lt;p&gt;&lt;strong&gt;Step 1&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Using the below code, the &lt;em&gt;cy.visit()&lt;/em&gt; command is used to navigate to the specified URL, which is &lt;a href="https://ecommerce-playground.lambdatest.io/" rel="noopener noreferrer"&gt;https://ecommerce-playground.lambdatest.io/&lt;/a&gt;&lt;/p&gt;

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

&lt;p&gt;&lt;strong&gt;Step 2&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;As per the code in the below screenshot, I am using the &lt;em&gt;cy.get()&lt;/em&gt; command to select the element on the webpage along with the Cypress &lt;em&gt;.should(‘be.visible’)&lt;/em&gt; command, which asserts that the text is visible on the page.&lt;/p&gt;

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

&lt;p&gt;&lt;strong&gt;Step 3&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;As per the code in the below screenshot, I am using the &lt;em&gt;cy.get().should(‘not.be.visible’)&lt;/em&gt; command to check that a modal dialog is hidden: Modal dialogs are often used in web applications to display important messages or prompts to the 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%2Fcdn-images-1.medium.com%2Fmax%2F2000%2F0%2AadfiJ_BeBQf0xW5w.png" class="article-body-image-wrapper"&gt;&lt;img src="https://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%2AadfiJ_BeBQf0xW5w.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;It is important to note that by using the Cypress &lt;em&gt;.should(‘not.be.visible’)&lt;/em&gt; assertion, you can ensure that it is hidden from the user when it is not needed.&lt;/p&gt;

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

&lt;h2&gt;
  
  
  Assert if the value is empty
&lt;/h2&gt;

&lt;p&gt;In Cypress if you want to verify if a value is empty or not, based on the value for the input field or text content or URL. You can use Cypress &lt;em&gt;.should(‘be.empty’)&lt;/em&gt; command.&lt;/p&gt;

&lt;p&gt;Some of the most common use cases where Cypress &lt;em&gt;.should(‘be.empty’)&lt;/em&gt; can be used are:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;&lt;em&gt;Validating Cleared Fields&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;&lt;em&gt;Verifying Empty Lists or Tables&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;&lt;em&gt;Testing Empty Input Fields&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

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

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

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

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Navigate to the URL &lt;a href="https://ecommerce-playground.lambdatest.io/" rel="noopener noreferrer"&gt;https://ecommerce-playground.lambdatest.io/&lt;/a&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Verify the URL hash is being used correctly.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Implementation&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('Cypress Assertions', () =&amp;gt; {


       it.only('Should - Empty Assertion', () =&amp;gt; {
           cy.visit('https://ecommerce-playground.lambdatest.io/')
           cy.hash().should('be.empty')
       })
    })
&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;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3200%2F0%2AlrSM1GpM-fGM6sRb.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3200%2F0%2AlrSM1GpM-fGM6sRb.png"&gt;&lt;/a&gt;&lt;/p&gt;

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

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

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

&lt;p&gt;&lt;strong&gt;Step 1&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Using the below code, the &lt;em&gt;cy.visit()&lt;/em&gt; command is used to navigate to the specified URL, which is &lt;a href="https://ecommerce-playground.lambdatest.io/" rel="noopener noreferrer"&gt;https://ecommerce-playground.lambdatest.io/&lt;/a&gt;.&lt;/p&gt;

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

&lt;p&gt;&lt;strong&gt;Step 2&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;cy.hash()&lt;/em&gt; is a command that retrieves the current URL hash. The URL hash is part of the URL that comes after the “#” symbol, and it is often used to store data that is used by JavaScript on the client side.&lt;/p&gt;

&lt;p&gt;The Cypress &lt;em&gt;.should(‘be.empty’)&lt;/em&gt; assertion checks that a value is empty. When applied to &lt;em&gt;cy.hash()&lt;/em&gt;, it checks that the current URL hash is empty.&lt;/p&gt;

&lt;p&gt;In the below code, this assertion is used to verify that a page has not been loaded with a specific URL hash.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://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%2ArI9mfxHbGe2Aup1r.png" class="article-body-image-wrapper"&gt;&lt;img src="https://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%2ArI9mfxHbGe2Aup1r.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;This tutorial dive deep into &lt;a href="https://www.lambdatest.com/learning-hub/web-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jun27_kj&amp;amp;utm_term=kj&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;web testing&lt;/a&gt; to help you understand its life cycle, elements, angles, the role of automation, and more.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Assert if the URL is correct
&lt;/h2&gt;

&lt;p&gt;As a tester, one of the most common assertions you perform is verifying if the URL of the page is valid. There are no additional parameters added to the URL after opening the web application.&lt;/p&gt;

&lt;p&gt;If you want to verify the URL, there is Cypress .&lt;em&gt;should()&lt;/em&gt; assertion, which can be used with &lt;em&gt;cy.url()&lt;/em&gt;. You can either match the exact URL or match some of the URL contents using &lt;em&gt;cy.url().should()&lt;/em&gt;.&lt;/p&gt;

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

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

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

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Navigate to the URL &lt;a href="https://ecommerce-playground.lambdatest.io/" rel="noopener noreferrer"&gt;https://ecommerce-playground.lambdatest.io/&lt;/a&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Verify that the URL of the website is the same as the expected text.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Verify that the URL of the website includes the expected text in the URL.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

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

&lt;p&gt;&lt;a href="https://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%2AdeqM4IzUUbjmQ5Br.png" class="article-body-image-wrapper"&gt;&lt;img src="https://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%2AdeqM4IzUUbjmQ5Br.png"&gt;&lt;/a&gt;&lt;/p&gt;

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

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

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

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

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

&lt;p&gt;&lt;strong&gt;Step 1&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Firstly, it opens the web application using &lt;em&gt;cy.visit()&lt;/em&gt;.&lt;/p&gt;

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

&lt;p&gt;&lt;strong&gt;Step 2&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Then, it asserts that the URL of the website is exactly equal to&lt;br&gt;
&lt;a href="https://ecommerce-playground.lambdatest.io/" rel="noopener noreferrer"&gt;https://ecommerce-playground.lambdatest.io/&lt;/a&gt; using &lt;em&gt;cy.url().should(‘eq’,&lt;br&gt;
“&lt;a href="https://ecommerce-playground.lambdatest.io/%E2%80%9D" rel="noopener noreferrer"&gt;https://ecommerce-playground.lambdatest.io/”&lt;/a&gt;)&lt;/em&gt;.&lt;/p&gt;

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

&lt;p&gt;&lt;strong&gt;Step 3&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;In the end, use &lt;em&gt;cy.url().should(‘include’, “&lt;a href="https://ecommerce-playground%E2%80%9D" rel="noopener noreferrer"&gt;https://ecommerce-playground”&lt;/a&gt;)&lt;/em&gt; asserts that the URL of the website includes the string “&lt;a href="https://ecommerce-playground.lambdatest.io/" rel="noopener noreferrer"&gt;https://ecommerce-playground&lt;/a&gt;”.&lt;/p&gt;

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

&lt;p&gt;It is important to note that the above assertion doesn’t look for exact text. It checks if the passed text is present in the URL or not, whereas, in the first assertion, it tries to match the exact URL passed.&lt;/p&gt;

&lt;p&gt;You need to choose it as per the requirement if the URL keeps updating based on the parameters. In those cases, include assertion &lt;em&gt;cy.url().should(‘include’,URL)&lt;/em&gt; can be used, but if you have a fixed URL. you can directly use &lt;em&gt;cy.url().should(‘eq’,URL)&lt;/em&gt;.&lt;/p&gt;
&lt;h2&gt;
  
  
  Assert if the element is not present
&lt;/h2&gt;

&lt;p&gt;If you want to verify if an element is not present on the page, you can use the Cypress &lt;em&gt;.should(‘not.exist’)&lt;/em&gt; assertion. It is one of the most useful assertions and my personal favorite ,when you want to verify the absence of an element on the page, such as when testing error messages, pop-up notifications, or elements that should be hidden or removed based on certain conditions.&lt;/p&gt;

&lt;p&gt;In certain scenarios, a pop-up may appear on a web page when it is loaded, but it disappears after a certain period of time. In such cases, the Cypress &lt;em&gt;.should(‘not.exist’)&lt;/em&gt; assertion proves to be extremely valuable as it allows you to verify the visibility of the pop-up.&lt;/p&gt;

&lt;p&gt;For instance, consider a situation where a pop-up message is displayed upon page load, providing important information or updates to the user. After a brief moment, the pop-up disappears automatically. By using the Cypress &lt;em&gt;.should(‘not.exist’)&lt;/em&gt; assertion, you can ensure that the pop-up is no longer present in the DOM, indicating that it has disappeared from the user’s view.&lt;/p&gt;

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

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

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

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Navigate to the URL &lt;a href="https://ecommerce-playground.lambdatest.io/" rel="noopener noreferrer"&gt;https://ecommerce-playground.lambdatest.io/&lt;/a&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Enter Iphone in the search box.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Verify search results do not have “Samsung”.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Implementation&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('Cypress Assertions', () =&amp;gt; {


       it('Should - Multiple Assertion', () =&amp;gt; {
           cy.visit('https://ecommerce-playground.lambdatest.io/')
           cy.get('[placeholder="Search For Products"]').first().type('iphone')
           cy.get('.dropdown-menu.autocomplete.w-100').contains('samsung').should('not.exist')


       })
    })
&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;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3200%2F0%2Aeih2hSslzasrs9O4.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3200%2F0%2Aeih2hSslzasrs9O4.png"&gt;&lt;/a&gt;&lt;/p&gt;

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

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

&lt;p&gt;&lt;strong&gt;Step 1&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Using the below code, the &lt;em&gt;cy.visit()&lt;/em&gt; command is used to navigate to the specified URL, which is &lt;a href="https://ecommerce-playground.lambdatest.io/" rel="noopener noreferrer"&gt;https://ecommerce-playground.lambdatest.io/&lt;/a&gt;.&lt;/p&gt;

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

&lt;p&gt;&lt;strong&gt;Step 2&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;In the below code, it selects the first input field with the placeholder text Search For Products and then types &lt;em&gt;iphone&lt;/em&gt;.&lt;/p&gt;

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

&lt;p&gt;&lt;strong&gt;Step 3&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;In the below code, it checks for text &lt;em&gt;Samsung&lt;/em&gt; in the dropdown and then verifies if Samsung does not exist.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://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%2Az6-4UQ-pvY63SvUU.png" class="article-body-image-wrapper"&gt;&lt;img src="https://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%2Az6-4UQ-pvY63SvUU.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;It is important to note that by adding Cypress &lt;em&gt;.should(‘not.exist’)&lt;/em&gt; to any DOM command, Cypress will reverse its default assertion and automatically wait until the element does not exist.&lt;/p&gt;

&lt;p&gt;For the cases where the element is present in the DOM but hidden from view, the Cypress &lt;em&gt;.should(‘not.exist’)&lt;/em&gt; assertion will fail. In such cases, you may need to use other assertions, like visibility assertions, to handle elements that are hidden but still present in the DOM.&lt;/p&gt;

&lt;p&gt;When leveraging the powerful Cypress &lt;em&gt;.should()&lt;/em&gt; command, you can enhance your &lt;a href="https://www.lambdatest.com/automation-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jun27_kj&amp;amp;utm_term=kj&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;test automation&lt;/a&gt; by performing precise assertions, ensuring the desired behavior and quality of your application in the cloud-based testing environment.&lt;/p&gt;

&lt;p&gt;Cloud testing platforms like LambdaTest allow you to perform &lt;a href="https://www.lambdatest.com/blog/cypress-test-automation-framework/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jun27_kj&amp;amp;utm_term=kj&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;Cypress automation&lt;/a&gt; at scale over an &lt;a href="https://www.lambdatest.com/online-browser-farm?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jun27_kj&amp;amp;utm_term=kj&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;online browser farm&lt;/a&gt; of 3000+ browsers and operating systems. You can further optimize and reduce your test execution time by harnessing the power of &lt;a href="https://www.lambdatest.com/cypress-parallel-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jun27_kj&amp;amp;utm_term=kj&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;Cypress parallel testing&lt;/a&gt;.&lt;/p&gt;

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

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

&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; Here is our support documentation to help you &lt;a href="https://www.lambdatest.com/support/docs/getting-started-with-cypress-testing/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jun27_kj&amp;amp;utm_term=kj&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;get started with Cypress testing&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Are you ready to elevate your Cypress automation skills? Join our specialized &lt;a href="https://www.lambdatest.com/certifications/cypress-101?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jun27_kj&amp;amp;utm_term=kj&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;Cypress 101 certification&lt;/a&gt; course, tailored for developers and testers seeking to expand their expertise in &lt;a href="https://www.lambdatest.com/blog/cypress-test-automation-framework/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jun27_kj&amp;amp;utm_term=kj&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;Cypress test automation&lt;/a&gt;. Gain advanced knowledge and sharpen your skills to unlock new possibilities in your test automation journey.&lt;/p&gt;

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

&lt;p&gt;&lt;a href="https://www.lambdatest.com/cypress-ui-automation?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jun27_kj&amp;amp;utm_term=kj&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;Cypress UI automation&lt;/a&gt; framework offers a versatile and robust assertion method, &lt;em&gt;.should()&lt;/em&gt;, that empowers you to perform a wide range of assertions based on various use cases. From verifying element visibility and content to examining attributes, CSS properties, URLs, and hash values, Cypress &lt;em&gt;.should()&lt;/em&gt; provides a flexible and powerful approach to writing assertions. By leveraging this capability, you can enhance the quality and reliability of your web application by validating critical aspects and ensuring they meet the desired expectations.&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>testing</category>
      <category>cypress</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Strategy for starting Test Automation in an organization</title>
      <dc:creator>BhasinAnshita</dc:creator>
      <pubDate>Mon, 26 Jun 2023 10:44:30 +0000</pubDate>
      <link>https://dev.to/testmuai/strategy-for-starting-test-automation-in-an-organization-4ffe</link>
      <guid>https://dev.to/testmuai/strategy-for-starting-test-automation-in-an-organization-4ffe</guid>
      <description>&lt;p&gt;A well-crafted test automation strategy is essential for any organization or enterprise striving to provide top-quality products or services. Today, where we want a major chunk of test cases to be automated, the main painful area for every QA is understanding where to start.&lt;/p&gt;

&lt;p&gt;Through my personal experience, I have witnessed that many individuals struggle with initiating automation.While they may be familiar with the latest tools and technologies available in the market, selecting an automation tool and adopting a CI/CD approach is insufficient. Instead, they require a deeper understanding of where to commence automation.&lt;/p&gt;

&lt;p&gt;In an organization where no test strategy has been defined, testers may find it challenging to begin automation because they lack a clear starting point ,especially If there are a large number of test cases to work on and they don’t know which one to pick first for the automation or how to start and where to start.&lt;/p&gt;

&lt;p&gt;This problem can be particularly challenging in an agile methodology, where short sprints require strategic planning to ensure that automation work is completed on time. In my experience, I have seen many people struggling to begin automation because they lack a clear plan for strategizing. Without a roadmap, they can feel lost and uncertain about where and how to begin.&lt;/p&gt;

&lt;p&gt;So, in this blog I will guide you in planning the automation strategy for existing components in your organization.&lt;/p&gt;

&lt;p&gt;It is essential to plan the process before automating the test cases in any organization. If you are new to a team/squad in an organization and are unaware of the scope of testing for your team/squad, then it can be challenging for you to start the automation.However, with a well-planned strategy in place, the process can be done efficiently and effectively.&lt;/p&gt;

&lt;p&gt;While working with one of my previous organizations, I faced a challenge where many teams were contributing to a single application. I knew which tech tools, which framework and which CI/CD I had to use but the issue was to identify what are the components/modules which were under my scope of testing.&lt;/p&gt;

&lt;p&gt;So, based on my extensive background in QA, I have developed a four-step plan which I put into action while working with one of my previous organizations. This plan helped me gain clarity on the components/modules under my testing scope and their corresponding test case requirements, even though many teams were contributing to a single application. By following this strategy, I observed a significant improvement in my automation efforts.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Ace your Protractor interview with these 50+ &lt;a href="https://www.lambdatest.com/learning-hub/protractor-interview-questions?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jun26_kj&amp;amp;utm_term=kj&amp;amp;utm_content=learning_hub" rel="noopener noreferrer"&gt;Protractor interview questions&lt;/a&gt;. Boost you confidence and land your dream job with this comprehensive guide.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  A four-step strategy for starting test automation in an organization
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;Identify the scope of testing&lt;/li&gt;
&lt;li&gt;Prioritize the testing scope&lt;/li&gt;
&lt;li&gt;Write test cases&lt;/li&gt;
&lt;li&gt;Test Execution Strategy&lt;/li&gt;
&lt;li&gt;We will see in detail the step-by-step process.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  1. Identify the scope of testing
&lt;/h2&gt;

&lt;p&gt;In an organization, if you are working in an agile methodology there can be different divisions like Teams/Squads that handle the respective components and different teams/squads can contribute to a single web application. In that case, it becomes difficult for QA engineers to finalize the scope of testing with respect to their teams/squads.&lt;/p&gt;

&lt;p&gt;Let’s try to understand with a real-time example.&lt;/p&gt;

&lt;p&gt;Taking the example of an e-commerce application, there can be multiple teams/squads working on it. One team/squad may handle the user profile, and another might handle the checkout. But these are all part of a single web application and you are the QA for the core team (Let’s say “marketplace”). FYI: Marketplace covers end-to-end web applications but there are other teams/squads involved in adding functionality to the web application and their QA is responsible for the functional testing.&lt;/p&gt;

&lt;p&gt;So, the issue that arises is–who takes ownership? If you are the QA of the leading team, are you responsible for the whole end-to-end testing?&lt;/p&gt;

&lt;p&gt;In order to decide this, it is always good to communicate within the team and define the scope of testing for your team/squad, which is the first step in planning QA automation.&lt;/p&gt;

&lt;p&gt;As part of step 1, we should have a meeting involving PM/PO, leads, and QA and define the scope of testing. As part of this step, you can prepare a table with 3 columns ( as shown below) which is the prerequisite to joining the meeting, and then you can discuss and finalize the scope of testing for different teams/squads. As QA, you should take ownership of this meeting and finalize the scope.&lt;/p&gt;

&lt;p&gt;Make sure you are prepared before going to the meeting so that you make proper use of everyone’s time.&lt;/p&gt;

&lt;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%2F78v64tzxnkbff64gvf2o.png" class="article-body-image-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%2F78v64tzxnkbff64gvf2o.png" alt=" " width="800" height="134"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;So, as per the above table, we see there are 2 components but there are 2 different teams/squads that are responsible for automating the test cases. So, the outcome of this meeting is we have the scope ready and we know clearly which team/squad will handle the automation of the respective components.&lt;/p&gt;

&lt;p&gt;You can create a confluence page with the above table or upload the table on any shared portal in your organization like SharePoint. Uploading it on a common platform like Confluence will help you to share it easily with others and let anyone view it anytime.&lt;/p&gt;

&lt;p&gt;Be it the test plan or automation test cases, it is always a good idea to upload it on the shared platform so that all the team members in the organization can view it. If you have it on the local machine, it won’t add that much value to the work you are doing.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Ace your &lt;a href="https://www.lambdatest.com/learning-hub/cypress-interview-questions?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jun26_kj&amp;amp;utm_term=kj&amp;amp;utm_content=learning_hub" rel="noopener noreferrer"&gt;Cypress interview questions&lt;/a&gt; with these 60+ Cypress interview questions. Boost you confidence and land your dream job with this comprehensive guide.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  2. Prioritize the testing scope components
&lt;/h2&gt;

&lt;p&gt;Your job does not end after defining the scope of testing. Now, you have all the components ready that you have to automate but which one to pick first for automation, is the next question. So, in order to decide which component should be picked up first for the automation, we need to know the priority.&lt;/p&gt;

&lt;p&gt;There are various factors involved in prioritizing the test cases for automation but it is recommended to involve all the members (PM/PO, Leads, QA). Everyone’s input is important in defining the priority. PM/PO would know from the business perspective which area is highly important. The team lead can provide inputs with respect to technical scope and QA knows whether this can be automated or not.&lt;/p&gt;

&lt;p&gt;So, as part of this step, there would be brainstorming among all the members and then you can prioritize the test cases.&lt;/p&gt;

&lt;p&gt;The table would look something like the 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%2F9mug4er3637elgbwfy4e.png" class="article-body-image-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%2F9mug4er3637elgbwfy4e.png" alt=" " width="800" height="133"&gt;&lt;/a&gt;&lt;br&gt;
P0 would be the component that needs to be automated first, followed by P1, P2, and P3.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Again, the above table should be created as a Confluence page or should be uploaded on the shared platform which is used in your organization.&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  3. Write test cases in the test management tool
&lt;/h2&gt;

&lt;p&gt;By now, you have the components ready and you know the priority of the test components. The next step is writing the test cases using any test management tool.&lt;/p&gt;

&lt;p&gt;As automation engineers, we sometimes tend to ignore this step because it seems boring to write test cases and save them, but it is imperative with respect to tracking the test cases.&lt;/p&gt;

&lt;p&gt;If you are automating the test cases but not writing them, how will your PM or other team members know? Not everyone is interested in looking at your code. By writing test cases, you can link them to the project management tool you follow in your organization and everyone would have visibility about the test cases which are related to the story.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Get ready to ace your &lt;a href="https://www.lambdatest.com/learning-hub/Junit-interview-questions?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jun26_kj&amp;amp;utm_term=kj&amp;amp;utm_content=learning_hub" rel="noopener noreferrer"&gt;Selenium interview questions&lt;/a&gt; in 2023 with our comprehensive list of 90 questions and answers that will help you sharpen your testing skills.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  4. Test Execution Strategy
&lt;/h2&gt;

&lt;p&gt;Once you have the test cases and you know the priority of the test cases. The next step is to plan the test execution. The objective of a Test Execution Strategy is to provide a comprehensive plan for the execution and maintenance of the automated tests, ensuring the quality and efficiency of the testing process.&lt;/p&gt;

&lt;p&gt;Deciding the test execution depends on several factors such as:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Test requirements:&lt;/strong&gt; The framework should support the testing needs and requirements of your project.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Test Tools:&lt;/strong&gt; Identify the test automation tools to be used for execution and any dependencies required. If you want to go for the open-source tool. You need to decide which tool is best for the team depending on the factors like language ( It’s Java or Javascript or Python) and its Integration with CI/CD&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Test Data:&lt;/strong&gt; Determine the test data that needs to be created and managed for the automated tests. Gather all the test data required for testing ( Example: user details If you want to login into a web application and perform testing and If you are checking multiple countries then all the country URLs)&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Test environment:&lt;/strong&gt; Manually check if a web application is stable or not. The environment you are working on should not throw any server issues. Check if the environment does not have features like a captcha (which can’t be automated)&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Test Maintenance:&lt;/strong&gt; Establish a process for maintaining the automated tests, including regular reviews, updates, and bug fixes.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Before you start the automation, It is always advisable to manually test the application. You cannot directly start writing the code without understanding if the environment is stable and if you have all the required test data.&lt;/p&gt;

&lt;p&gt;If you follow all 4 steps above. You would know the test cases (which are the candidates for automation), and the priority of test components with respect to automation and then you can easily start the automation of the test cases based on the priority of the cases.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;If you are preparing for a Playwright automation interview, this list of &lt;a href="https://www.lambdatest.com/learning-hub/playwright-interview-questions?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jun26_kj&amp;amp;utm_term=kj&amp;amp;utm_content=learning_hub" rel="noopener noreferrer"&gt;Playwright interview questions&lt;/a&gt; can help you get a list of the most asked questions with detailed answers.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Strategies to speed up the test automation
&lt;/h2&gt;

&lt;p&gt;Starting an automation process can also be a challenging part if you don’t know where to start. Above mentioned steps is the prerequisite if you are planning to start test automation in your organization.&lt;/p&gt;

&lt;p&gt;After you have identified the areas of the organization that would benefit most from automation, such as processes that are time-consuming, error-prone, or repetitive, you can then follow a few other potential strategies which will benefit you:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Develop a plan for implementing automation in the selected areas. This plan should include the specific tools and technologies that will be used, the processes that will be automated, and the resources that will be required. It should also include a timeline for implementing the automation and any potential challenges or risks that need to be addressed.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Train and support the staff who will be using automation tools and technologies. Automation can be a significant change for many organizations, and it is important to ensure that staff is properly trained and supported so that they can use the automation tools effectively and efficiently.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Monitor and evaluate the results of the automation implementation. This can help to identify any problems or issues that need to be addressed, as well as any opportunities for further improvement or expansion.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Continuously improve and expand the automation implementation over time. As the organization learns more about automation and gains experience with it, it can continue to refine and improve its automation strategy, tools, and processes to achieve even better results.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Here's Top 30+ &lt;a href="https://www.lambdatest.com/learning-hub/webdriverio-interview-questions?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jun26_kj&amp;amp;utm_term=kj&amp;amp;utm_content=learning_hub" rel="noopener noreferrer"&gt;WebdriverIO Interview Questions&lt;/a&gt; and Answers that will help you boost your confidence in an Interview.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

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

&lt;p&gt;In conclusion, the test strategy for starting a QA automation process is a crucial aspect of software development. It requires a systematic and well-planned approach to ensure that the automation process is effective, efficient, and meets the project requirements and user expectations. By following a structured approach, organizations can establish a solid foundation for their QA automation efforts, leading to higher-quality software and a better user experience.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Prepare to ace your Jest interviews with our thorough set of &lt;a href="https://www.lambdatest.com/learning-hub/jest-interview-questions?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jun26_kj&amp;amp;utm_term=kj&amp;amp;utm_content=learning_hub" rel="noopener noreferrer"&gt;Jest interview questions&lt;/a&gt; and solutions that will enable you to prove your command of the Jest testing framework.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Running Tests In Cypress With GitHub Actions [Complete Guide]</title>
      <dc:creator>BhasinAnshita</dc:creator>
      <pubDate>Fri, 23 Jun 2023 07:42:15 +0000</pubDate>
      <link>https://dev.to/testmuai/running-tests-in-cypress-with-github-actions-complete-guide-372g</link>
      <guid>https://dev.to/testmuai/running-tests-in-cypress-with-github-actions-complete-guide-372g</guid>
      <description>&lt;p&gt;In today’s tech world, where speed is the key to modern software development, we should aim to get quick feedback on the impact of any change, and that is where CI/CD comes in place.&lt;/p&gt;

&lt;p&gt;Setting up CI/CD is crucial for automated test cases because it gives more consistent results, agility, and efficient assessment of minor changes. With the shorter release and fast development cycles, we need to check that automated tests are passing on every code change, which can be easily done by configuring the CI/CD pipeline.&lt;/p&gt;

&lt;p&gt;Let’s try to understand the impact of CI/CD with an example here:&lt;/p&gt;

&lt;p&gt;You want to execute the automation suite whenever anyone pushes the code in the Git repository. So, how will you do that?&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;With no CI/CD set up for your project&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;To run the automation suite, you have to pull the latest code and then run it locally on your machine, which is a tedious and lengthy process.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;With CI/CD implemented&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;You will set up your project’s CI/CD pipeline. So, your automation &lt;a href="https://www.lambdatest.com/learning-hub/test-suite?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jun23_kj&amp;amp;utm_term=kj&amp;amp;utm_content=learning_hub" rel="noopener noreferrer"&gt;test suite&lt;/a&gt; would run whenever anyone pushes a code or creates a pull request automatically. It will take the latest code from the Git repository and run the test.&lt;/p&gt;

&lt;p&gt;Setting up CI/CD helps to save time. Over the past few years, &lt;a href="https://www.lambdatest.com/blog/getting-started-with-devops/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jun23_kj&amp;amp;utm_term=kj&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;DevOps&lt;/a&gt; has become an important part of the software life cycle, leading to the growth of various DevOps tools and practices.&lt;/p&gt;

&lt;p&gt;There are many &lt;a href="https://www.lambdatest.com/blog/best-ci-cd-tools/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jun23_kj&amp;amp;utm_term=kj&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;CI/CD tools&lt;/a&gt; available in the market used by automation testers, but these days most people are using GitHub for version control and collaboration. So, GitHub Actions is becoming the favorite choice for automation testers/developers for CI/CD.&lt;/p&gt;

&lt;p&gt;GitHub Actions is offered by GitHub as a SaaS offering. With GitHub Actions, you can achieve scheduling, parallelization, &lt;a href="https://www.lambdatest.com/blog/run-selenium-tests-in-docker/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jun23_kj&amp;amp;utm_term=kj&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;run your tests on Docker&lt;/a&gt; Containers, and can do many more.&lt;/p&gt;

&lt;p&gt;In this blog on Cypress with GitHub Actions, we will learn how to set up CI/CD pipeline for Cypress test cases using GitHub Actions.&lt;/p&gt;

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

&lt;p&gt;&lt;a href="https://www.lambdatest.com/learning-hub/cypress-tutorial?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jun23_kj&amp;amp;utm_term=kj&amp;amp;utm_content=learning_hub" rel="noopener noreferrer"&gt;Cypress&lt;/a&gt; is an open-source framework, which is built on Node.js and comes packaged as an npm module. It uses JavaScript for &lt;a href="https://www.lambdatest.com/blog/17-lessons-i-learned-for-writing-effective-test-cases/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jun23_kj&amp;amp;utm_term=kj&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;writing the test cases&lt;/a&gt;. As it runs tests directly inside the browser, it is fast compared to the other &lt;a href="https://www.lambdatest.com/blog/automation-testing-tools/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jun23_kj&amp;amp;utm_term=kj&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;automation testing tools&lt;/a&gt; (or frameworks).&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.lambdatest.com/cypress-automation-tool?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jun23_kj&amp;amp;utm_term=kj&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;Cypress automation tool&lt;/a&gt; has received huge acceptance from QA and Developers and is constantly gaining popularity due to its features like easy installation, easy debugging, real-time reloads, and ease of use.&lt;/p&gt;

&lt;p&gt;Below are some of the features, which make it unique from other &lt;a href="https://www.lambdatest.com/learning-hub/web-automation?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jun23_kj&amp;amp;utm_term=kj&amp;amp;utm_content=learning_hub" rel="noopener noreferrer"&gt;web automation&lt;/a&gt; tools in the market:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Easy Installation.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Easy Debugging.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;In-built support for Retries, Screenshots, and Videos (No Extra code needs to be written).&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Automatic Reload (Cypress reloads your test case whenever you make any changes to your script).&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Can easily run your tests on different viewports ( iPad, iPhone, Samsung).&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Flake Resistant (Cypress waits for commands and assertions before moving on to the next step which avoids flakiness in a test).&lt;/p&gt;&lt;/li&gt;
&lt;/ul&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;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=jun23_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;
  
  
  What is GitHub Actions?
&lt;/h2&gt;

&lt;p&gt;GitHub Actions is a &lt;a href="https://www.lambdatest.com/blog/what-is-continuous-integration-and-continuous-delivery/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jun23_kj&amp;amp;utm_term=kj&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;Continuous Integration&lt;/a&gt; (build, test, merge) and Continuous Delivery (automatically released to the repository) &lt;strong&gt;(CI/CD)&lt;/strong&gt; platform. It automates and executes the software development workflows right from GitHub.&lt;/p&gt;

&lt;p&gt;With GitHub Actions, you can build, test, and publish across multiple platforms, operating systems, and languages all within the same workflow and then see the status checks displayed within the pull request.&lt;/p&gt;

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

&lt;p&gt;All GitHub Actions are handled via workflows, which are .yml files placed under the .github/workflows directory in a repository that defines automated processes. It brings automation directly into the software development lifecycle via event-driven triggers such as creating a pull request or pushing a code into a remote branch.&lt;/p&gt;

&lt;p&gt;With GitHub Action, the pain of keeping your plugins updated is gone (which is the issue for other CI/CD tools like Jenkins), You don’t have to go to a separate tab for running CI/CD and pushing your code. It is all done in GitHub.&lt;/p&gt;

&lt;p&gt;Some of the features of GitHub Actions are:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Ease of setup. There is no installation required as it is on the cloud.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Support of multiple languages and frameworks.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Provides actions to every GitHub event.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;It can be shared via GitHub Marketplace.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;No explicit plugin is required for caching. You can write your own caching mechanism if you require caching.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Asynchronous CI/CD is achieved using GitHub Actions.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;em&gt;At present, GitHub Actions is free to use for public repositories, and for private, it has a pay-as-you-go mechanism.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;We can speed up the software validation process and boost testing coverage by adopting automated testing. However, there are a lot of &lt;a href="https://www.lambdatest.com/blog/python-automation-testing/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jun23_kj&amp;amp;utm_term=kj&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;challenges in test automation&lt;/a&gt;.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  How to setup GitHub Actions in your Git repository?
&lt;/h2&gt;

&lt;p&gt;GitHub Actions lets you run workflows when a certain triggering event occurs such as a code push, or pull request. A GitHub repository can have multiple workflows. For example, we can create 1 workflow to run our test case whenever there is a code push and one workflow to test the pull requests.&lt;/p&gt;

&lt;p&gt;As part of this Cypress with GitHub Actions tutorial, we will learn how to set up the GitHub Action pipeline whenever there is a code push to the remote branch.&lt;br&gt;
Reference code can be found here:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://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%2AKCJ6weuMl5D-OV_X.png" class="article-body-image-wrapper"&gt;&lt;img src="https://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%2AKCJ6weuMl5D-OV_X.png" width="156" height="53"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Below are the steps to set up GitHub Actions in the Git repository:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Login to your GitHub account.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Create a workflow: Click on &lt;strong&gt;Add file &amp;gt; Create new file&lt;/strong&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Enter .github/workflows/main.yml ( It has to be in the same sequence). main.yml is the file name, you can name it as per your choice.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Create a workflow file.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Follow the below sample code to create a GitHub Actions workflow (.yml file)&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  name: Add Action
    on:
     push:
       branches:
         - main
    jobs:
     Cypress-Test:
       runs-on: ubuntu-latest
       steps:
         - name: Checkout GitCode
           uses: actions/checkout@v2
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;name&lt;/strong&gt; =&amp;gt; It is the name of the workflow file. It appears in the “Actions” tab of the GitHub Repository with the same name.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;on&lt;/strong&gt;=&amp;gt; On is the trigger condition, it specifies the trigger for the workflow. We have to add the events (&lt;strong&gt;push, pull_request&lt;/strong&gt;, etc.) as subsections. In the above example, the workflow would be triggered whenever anyone pushes a change to the repository.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;jobs&lt;/strong&gt;=&amp;gt; Groups all the jobs/tasks that are defined inside the job section in the yml file. We can define the name of jobs just in the next line.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;runs-on&lt;/strong&gt;: ubuntu-latest =&amp;gt; It configures the job to run on the latest version of Ubuntu. The job will execute on a fresh virtual machine hosted by GitHub. You can configure any value of the OS where you would like to execute the GitHub Actions workflow on.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Steps&lt;/strong&gt;=&amp;gt; It groups together all the steps that are defined in the yml file. There can be multiple steps in a .yml file. It is placed at the same level as the on section.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Uses&lt;/strong&gt;=&amp;gt;Syntax to use the GitHub Actions in the .yml file. You can pass the GitHub Actions to run the test case/ to checkout the code.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Now if you add this simple workflow to your repo, and push your code on the &lt;strong&gt;main&lt;/strong&gt; branch, you can check that a workflow has been added under the Actions tab.&lt;/p&gt;

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

&lt;p&gt;If you click on the workflow run, you’ll see some details such as the commit, the status, the time duration, as well as the jobs that have run.&lt;/p&gt;

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

&lt;p&gt;As per the above screenshot, we have only 1 job, i.e., Cypress-Test. We can also view the logs about setting up the job and completing it just by clicking Cypress-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%2A2qIjY3SUUlMlvJo6.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3200%2F0%2A2qIjY3SUUlMlvJo6.png" width="800" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If you want to explore more on the workflow syntax. You can check &lt;a href="https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions" rel="noopener noreferrer"&gt;here&lt;/a&gt;.&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=jun23_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;
  
  
  How to run Cypress tests using GitHub Actions?
&lt;/h2&gt;

&lt;p&gt;Cypress is a &lt;a href="https://www.lambdatest.com/automation-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jun23_kj&amp;amp;utm_term=kj&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;test automation&lt;/a&gt; tool for web applications, and GitHub Actions is a service that allows developers to automate various tasks, such as building, testing, and deploying code. Using Cypress with GitHub Actions allows us to automate the testing of a web application as part of the continuous integration and continuous deployment process. This can help ensure that the application is working properly and save time and effort for the development team.&lt;/p&gt;

&lt;p&gt;To use Cypress with GitHub Actions, you would need to create a workflow file that defines the steps for running your Cypress tests. This file would be stored in your GitHub repository and would be executed by GitHub Actions whenever a specified event, such as pushing code to the repository, occurs.&lt;/p&gt;

&lt;p&gt;We will see step by step, how to run the tests using Cypress with GitHub Actions.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Pre-Requisites:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;GitHub Repository with working Cypress code&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Knowledge of Cypress&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

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

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Open URL. &lt;a href="https://ecommerce-playground.lambdatest.io/index.php?route=account/login%22" rel="noopener noreferrer"&gt;https://ecommerce-playground.lambdatest.io/index.php?route=account/login%22&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Log in to the application.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Search the product.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Verify the searched product.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Below is the &lt;a href="https://www.lambdatest.com/cypress-e2e-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jun23_kj&amp;amp;utm_term=kj&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;Cypress end-to-end test&lt;/a&gt; code where the user opens the browser, searches for a product, and verifies it in the end.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;describe("Automation using Cypress", () =&amp;gt; {
     it("Open website and enter username, password", () =&amp;gt; {
       cy.visit(
         "https://ecommerce-playground.lambdatest.io/index.php?route=account/login"
       );
     });
     it("Login into the application using credentials", () =&amp;gt; {
       cy.get('[id="input-email"]').type("lambdatest.Cypress@disposable.com");
       cy.get('[id="input-password"]').type("Cypress123!!");
       cy.get('[type="submit"]').eq(0).click();
     });
     it("Search the Product", () =&amp;gt; {
       cy.get('[name="search"]').eq(0).type("Macbook");
       cy.get('[type="submit"]').eq(0).click();
     });
     it("Verify Product after search ", () =&amp;gt; {
       cy.contains("Macbook");
     });
    });
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In order to run the above code locally through the terminal, we would run the command &lt;strong&gt;“npx cypress run”&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;It will run 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=jun23_kj&amp;amp;utm_term=kj&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;Cypress test automation&lt;/a&gt; and show you the test result in the terminal just like shown below:&lt;/p&gt;

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

&lt;p&gt;Let’s learn how to run the above tests using Cypress with GitHub Actions. If you have followed setting up GitHub Actions in the above section of this blog on Cypress with GitHub Actions, by now you would know how to create a workflow .yml file.&lt;/p&gt;

&lt;p&gt;Follow the below code to run the tests using Cypress with Github Actions:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;name: Cypress Tests
    on: [push]
    jobs:
     Cypress-Test:
       runs-on: ubuntu-latest
       steps:
         - name: Checkout GitCode
           uses: actions/checkout@v2

         - name: Run Cypress Test
           uses: cypress-io/github-action@v4
           with:
             command: npx cypress run
             browser: chrome
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In order to run it using Cypress with GitHub Actions workflow, we will use the Cypress official GitHub Actions (&lt;strong&gt;cypress-io/github-action@v4&lt;/strong&gt;) (ref : Line11)&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;We have provided the name of the workflow as &lt;strong&gt;“Cypress Test”&lt;/strong&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;We provided the trigger condition, In the above case, it would be pushed. So, whenever there would be code push to the remote branch, this workflow would be executed.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Jobs’ name is passed as &lt;strong&gt;“Cypress Test”&lt;/strong&gt; under which we are providing the OS info to run it on the latest ubuntu OS.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;There are 2 steps added as part of the shared workflow .yml file.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;The first step, would checkout the code from the GitHub repository using GitHub Actions &lt;strong&gt;“actions/checkout@v2”&lt;/strong&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The second step would run the Cypress tests. Cypress has official GitHub Actions for running the Cypress tests, which is &lt;strong&gt;“cypress-io/github-action@v4”&lt;/strong&gt;. This action provides npm installation, custom caching, and additional configuration options and simplifies the setup of advanced workflows using Cypress with GitHub Actions platform.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

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

&lt;p&gt;The above workflow would be called whenever there will be code push in your remote GitHub repository.&lt;/p&gt;

&lt;p&gt;Once, the workflow is run. You can view the workflow run status from the Actions tab in your GitHub Project just as shown in the below screenshot.&lt;/p&gt;

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

&lt;p&gt;You can also check the step-by-step summary of each GitHub Actions just by clicking the file name and it will take you to the summary screen.&lt;/p&gt;

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

&lt;p&gt;&lt;em&gt;cypress-io/&lt;a href="mailto:github-action@v4.x.x"&gt;github-action@v4.x.x&lt;/a&gt; . . is the Cypress official GitHub Action. By default, it:&lt;/em&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;em&gt;Install npm dependencies.&lt;/em&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;em&gt;Build the project (npm run build)&lt;/em&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;em&gt;Start the project web server (npm start)&lt;/em&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;em&gt;Run the Cypress tests within our GitHub repository within Electron&lt;/em&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;In this Selenium with Java tutorial, you will learn everything you need to know to kick start your journey in Selenium &lt;a href="https://www.lambdatest.com/blog/selenium-with-java/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jun23_kj&amp;amp;utm_term=kj&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;automation testing with Java&lt;/a&gt;.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  How to run the Cypress Test Case on a cloud platform using GitHub Actions?
&lt;/h2&gt;

&lt;p&gt;There are multiple approaches to perform &lt;a href="https://www.lambdatest.com/cypress-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jun23_kj&amp;amp;utm_term=kj&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;Cypress testing&lt;/a&gt; on a cloud testing platform like LambdaTest using GitHub Actions.&lt;/p&gt;

&lt;p&gt;Continuous quality cloud testing platforms such as LambdaTest lets you perform manual and automation testing of your websites and mobile applications on an &lt;a href="https://www.lambdatest.com/online-device-farm?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jun23_kj&amp;amp;utm_term=kj&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;online device farm&lt;/a&gt; of 3000+ real browsers, devices, and platform combinations. It provides developers with the ability to run their automated tests using different &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=jun23_kj&amp;amp;utm_term=kj&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;automation testing frameworks&lt;/a&gt; including &lt;a href="https://www.lambdatest.com/selenium?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jun23_kj&amp;amp;utm_term=kj&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;Selenium&lt;/a&gt;, Cypress, Playwright and more.&lt;/p&gt;

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

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Jenkins 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 &lt;a href="https://www.lambdatest.com/learning-hub/jenkins?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jun23_kj&amp;amp;utm_term=kj&amp;amp;utm_content=learning_hub" rel="noopener noreferrer"&gt;Jenkins Tutorial&lt;/a&gt;.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;One of the ways is using the &lt;strong&gt;&lt;em&gt;command&lt;/em&gt;&lt;/strong&gt; as part of Cypress with GitHub Actions.&lt;/p&gt;

&lt;p&gt;Below is the &lt;a href="https://www.lambdatest.com/cypress-e2e-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jun23_kj&amp;amp;utm_term=kj&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;Cypress end-to-end testing&lt;/a&gt; code, which I would run in the LambdaTest cloud platform.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; describe("Automation using Cypress", () =&amp;gt; {
     it("Open website and enter username, password", () =&amp;gt; {
       cy.visit(
         "https://ecommerce-playground.lambdatest.io/index.php?route=account/login"
       );
     });
     it("Login into the application using credentials", () =&amp;gt; {
       cy.get('[id="input-email"]').type("lambdatest.Cypress@disposable.com");
       cy.get('[id="input-password"]').type("Cypress123!!");
       cy.get('[type="submit"]').eq(0).click();
     });
     it("Search the Product", () =&amp;gt; {
       cy.get('[name="search"]').eq(0).type("Macbook");
       cy.get('[type="submit"]').eq(0).click();
     });
     it("Verify Product after search ", () =&amp;gt; {
       cy.contains("Macbook");
     });
    });
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To run the &lt;a href="https://www.lambdatest.com/cypress-ui-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jun23_kj&amp;amp;utm_term=kj&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;Cypress UI tests &lt;/a&gt;on the LambdaTest Platform, we need to do the configuration using 3 steps.&lt;/p&gt;

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

&lt;p&gt;Install LambdaTest CLI using npm, use the below command:&lt;/p&gt;

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

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

&lt;p&gt;&lt;strong&gt;Step 2: Set up the config.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Once the LambdaTest CLI is installed, now we need to set up the configuration using the below command:&lt;/p&gt;

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

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

&lt;p&gt;After running the command, there will be a file created in your project named &lt;em&gt;“lambdatest-config.json”&lt;/em&gt;. We need to set up the configuration in order to run our test case on different browsers on LambdaTest.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;auth:&lt;/strong&gt; We need to set up the LambdaTest credentials, which will be used in lambdatest-config.json to run my test case on the cloud platform.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;browsers:&lt;/strong&gt; Need to specify the browser and OS version on which we want our test case to run.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;run_setting:&lt;/strong&gt; Need to set up the config in run_settings.&lt;br&gt;
Set up the config name, which would differ based on different Cypress Versions, and set up the spec file.&lt;br&gt;
&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  {
      "lambdatest_auth": {
         "username": "user.name",
         "access_key": "access.key"
      },
      "browsers": [
         {
            "browser": "Chrome",
            "platform": "Windows 10",
            "versions": [
               "latest-1"
            ]
         },
         {
            "browser": "Firefox",
            "platform": "Windows 10",
            "versions": [
               "latest-1"
            ]
         }
      ],
      "run_settings": {
         "config_file": "cypress.config.js",
         "reporter_config_file": "base_reporter_config.json",
         "build_name": "Cypress-Test",
         "parallels": 1,
         "specs": "./cypress/e2e/*/*.cy.js",
         "ignore_files": "",
         "network": false,
         "headless": false,
         "npm_dependencies": {
            "cypress": "11.2.0"
         }
      },
      "tunnel_settings": {
         "tunnel": false}}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Step 3: Execute Test Case&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Once the config is done, now you can execute the Cypress test case on the LambdaTest cloud Platform. You just need to run the below command to run it on LambdaTest.&lt;/p&gt;

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

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

&lt;p&gt;After the command is run and test cases are executed successfully, you can view the Cypress test run on LambdaTest cloud platform (Just like shown in the screenshot below):&lt;/p&gt;

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

&lt;p&gt;You can also view the logs by navigating to the logs section.&lt;/p&gt;

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

&lt;p&gt;Until now, we learnt how to run &lt;a href="https://www.lambdatest.com/cypress-ui-automation?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jun23_kj&amp;amp;utm_term=kj&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;Cypress automation tests&lt;/a&gt; on the LambdaTest cloud platform using the IDE terminal. Let’s see how to run the above flow using Cypress with GitHub Actions.&lt;/p&gt;

&lt;p&gt;In order to run it using Cypress with GitHub Actions workflow, we will use the Cypress official GitHub Actions (&lt;strong&gt;cypress-io/github-action@v4&lt;/strong&gt;), which either works on the script passed in the package.json or directly picks the cypress commands passed in the .yml file.&lt;/p&gt;

&lt;p&gt;So, we will create a script in package.json. In order to run the Cypress test on the LambdaTest cloud platform, we need to run the command “&lt;strong&gt;&lt;em&gt;lambdatest-cypress run&lt;/em&gt;&lt;/strong&gt;”.&lt;/p&gt;

&lt;p&gt;The same command, we will create as a script in package.json just as shown below:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  {
     "name": "cypress_github-actions-example",
     "version": "1.0.0",
     "description": "test automation using cypress",
     "main": "index.js",
     "scripts": {
       "test": "lambdatest-cypress run"
     },
     "repository": {
       "type": "git",
       "url": "https://github.com/Anshita-Bhasin/Cypress_Github-Actions.git"
     },
     "author": "Anshita Bhasin",
     "license": "ISC",
     "devDependencies": {
       "cypress": "^11.2.0"
     },
     "dependencies": {
       "lambdatest-cypress-cli": "^3.0.7"
     }}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To test if the above script is working fine, Go to the terminal and execute the command “&lt;em&gt;&amp;lt; npm run scriptname &amp;gt;&lt;/em&gt;”&lt;/p&gt;

&lt;p&gt;For the above code, the command would be &lt;strong&gt;&lt;em&gt;npm run test&lt;/em&gt;&lt;/strong&gt;. If you see the tests result just as shown below, that means your script is absolutely working fine.&lt;/p&gt;

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

&lt;p&gt;To run the same using GitHub Actions.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Go to the workflow .yml file. (We covered above, how to create a .yml workflow file)&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Pass the script name as a command :&lt;br&gt;
&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; name: Cypress Cloud Tests
    on: [push]
    jobs:
     Cypress-Test:
       runs-on: ubuntu-latest
       steps:
         - name: Checkout GitCode
           uses: actions/checkout@v2

         - name: Run Cypress Test
           uses: cypress-io/github-action@v4
           with:
             command: npm run test
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Command basically runs the Cypress command to execute the Cypress tests. It will check in package.json if there is a command with the name “test” and then it will run, else it will throw an error.&lt;/p&gt;

&lt;p&gt;After creating the workflow, you can check the Actions tab in your GitHub Repository. It will show the summary of the workflow run.&lt;/p&gt;

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

&lt;p&gt;Now, navigate to the LambdaTest cloud platform to ensure whether tests are executed or not. You should be able to see the latest build 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%2F3200%2F0%2AuuMb7-XsZHkDsHgH.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3200%2F0%2AuuMb7-XsZHkDsHgH.png" width="800" height="330"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Here’s a guide on how to &lt;a href="https://www.lambdatest.com/blog/how-to-automate-android-apps-using-appium/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jun23_kj&amp;amp;utm_term=kj&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;automate Android app testing using Appium&lt;/a&gt;, a powerful framework that can help you streamline your testing process. Learn more now.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  How to run Cypress tests for the specific browser using GitHub Actions?
&lt;/h2&gt;

&lt;p&gt;You can also run tests on different browsers using Cypress with GitHub Actions. Just provide the Cypress-supported browser name on which you want to run your test case. As part of the code below, I have passed Firefox. So, the test case would run on the Firefox browser but you can pass Chrome, Electron, or any other browser which Cypress supports.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; name: Cypress Test on Firefox
    on: [push]
    jobs:
     cypress-run:
       runs-on: ubuntu-20.04

       name: E2E Test on Firefox
       steps:
         - uses: actions/checkout@v2
         - uses: cypress-io/github-action@v4
           with:
             browser: firefox
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Once the above workflow is executed, you can go to the Actions tab and view the logs where you should be able to see the browser name. It should be the same as passed in the workflow file. Below is the sample screenshot of the workflow logs:&lt;/p&gt;

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

&lt;h2&gt;
  
  
  How to run Cypress tests in Docker Container GitHub Actions?
&lt;/h2&gt;

&lt;p&gt;You can also run the Cypress tests in your Docker Container using GitHub Actions. There is already a docker image available online with chrome version 78 and Firefox version 70 pre-installed. You can pass the container image using an argument container. After executing the test cases, it also stops the container.&lt;/p&gt;

&lt;p&gt;Below is the sample code to run the Cypress test in the docker container using GitHub Actions:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;name: Cypress Test in custom container
    on: [push]
    jobs:
     cypress-test:
       runs-on: ubuntu-20.04
       name: Cypress Tests on docker container
       # Cypress Docker image with Chrome v78
       # and Firefox v70 pre-installed
       container: cypress/browsers:node12.13.0-chrome78-ff70
       steps:
         - uses: actions/checkout@v2
         - uses: cypress-io/github-action@v4
           with:
             browser: chrome
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  How to get the Cypress test run results using GitHub Actions Artifacts?
&lt;/h2&gt;

&lt;p&gt;You can get the Cypress test result as an artifact after your workflow is executed. You can store the generated videos or screenshots as CI artifacts. Let’s take an example — you want videos of your test run after every run but you want screenshots only when your test fails. So, this can be done by passing conditions in the workflow. We will use GitHub Actions actions/upload-artifact@v2 for storing the artifacts and then will pass the condition to show the artifacts.&lt;/p&gt;

&lt;p&gt;Below is the sample code.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; name: Cypress Artifacts
    on: [push]
    jobs:
     cypress-run:
       runs-on: ubuntu-latest
       name: Test Artifacts
       steps:
         - uses: actions/checkout@v2
         - uses: cypress-io/github-action@v4
         - uses: actions/upload-artifact@v2
           if: failure()
           with:
             name: cypress-screenshots
             path: ./cypress/screenshots
         - uses: actions/upload-artifact@v2
           if: always()
           with:
             name: cypress-videos
             path: ./cypress/videos
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;After your workflow is executed, you can check the artifacts from the summary of the workflow.&lt;/p&gt;

&lt;p&gt;Click on the Actions tab. Select the action for the desired workflow run. Click the workflow and it will navigate to the summary page.&lt;/p&gt;

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

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

&lt;p&gt;Cypress is compatible with different CI tools available in the market but one of the leading ones is GitHub Actions. Cypress even has its official GitHub Action(cypress-io/&lt;a href="mailto:github-action@v4.x.x"&gt;github-action@v4.x.x&lt;/a&gt;) which installs the npm dependency and runs the Cypress test. Running your Cypress test case on CI/CD platform gives you leverage to schedule it and run it on different trigger events which save a lot of time.&lt;/p&gt;

&lt;p&gt;As part of this blog on Cypress with GitHub Actions, we covered the scenarios where we executed the Cypress test cases using GitHub Actions and also covered running it on a cloud platform.&lt;/p&gt;

&lt;p&gt;Stay tuned for the next topics on the Cypress with GitHub Actions Series. Where the topics like test case scheduling, slack notification, and uploading results on AWS S3 Bucket using GitHub Actions would be covered.&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>cypress</category>
      <category>automation</category>
      <category>testing</category>
    </item>
  </channel>
</rss>
