<?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: Atul Sharma</title>
    <description>The latest articles on DEV Community by Atul Sharma (@atulkrsharma).</description>
    <link>https://dev.to/atulkrsharma</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%2F1014774%2Fb924cee6-be02-437a-befe-5e9f0551627b.JPG</url>
      <title>DEV Community: Atul Sharma</title>
      <link>https://dev.to/atulkrsharma</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/atulkrsharma"/>
    <language>en</language>
    <item>
      <title>Performance Testing with NeoLoad</title>
      <dc:creator>Atul Sharma</dc:creator>
      <pubDate>Wed, 09 Oct 2024 14:26:04 +0000</pubDate>
      <link>https://dev.to/atulkrsharma/performance-testing-with-neoload-597m</link>
      <guid>https://dev.to/atulkrsharma/performance-testing-with-neoload-597m</guid>
      <description>&lt;h2&gt;
  
  
  An Overview of NeoLoad: Performance Testing with Tricentis
&lt;/h2&gt;

&lt;p&gt;NeoLoad, a performance testing tool by Tricentis, is designed to simulate large user loads on web applications, APIs, and mobile apps to evaluate their performance under stress. Its intuitive interface, wide-ranging features, and scalability make it a powerful choice for performance testing. This article provides a detailed explanation of NeoLoad's various tabs, how to use them effectively, and tips on interpreting the results for better decision-making.&lt;/p&gt;

&lt;h3&gt;
  
  
  1. &lt;strong&gt;Project Design Tab&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;The &lt;strong&gt;Project Design&lt;/strong&gt; tab is where users create and design their performance testing scenarios. Here’s what you can expect:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;User Paths (Virtual Users)&lt;/strong&gt;: These represent the actions that will be performed by virtual users during the test. Using the graphical interface, you can record interactions or manually design scripts to simulate real-world user behavior.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Advanced Actions&lt;/strong&gt;: You can parameterize data, define conditions (if/else loops), add delays, or perform correlation, which handles dynamic values like session IDs.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Servers and Endpoints&lt;/strong&gt;: Define the servers and the endpoints that will be targeted during the performance test.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Usage&lt;/strong&gt;: This tab is essential for designing scenarios that simulate user behavior, such as navigating through a website or interacting with a mobile app. You can also add assertions to validate the performance of your application.&lt;/p&gt;

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

&lt;h3&gt;
  
  
  2. &lt;strong&gt;Population Tab&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;The &lt;strong&gt;Population&lt;/strong&gt; tab allows you to group user paths and define populations for load testing. A population in NeoLoad is a set of virtual users with defined behavior patterns.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;User Path Distribution&lt;/strong&gt;: You can assign different user paths to a population to simulate various behaviors. For example, 70% of users might be browsing while 30% are making purchases.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Geographical Distribution&lt;/strong&gt;: NeoLoad allows you to simulate users from different geographical locations by configuring IP addresses and network settings.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Usage&lt;/strong&gt;: Use this tab to define how different types of users (browsers, shoppers, admins, etc.) will interact with your system under load. This helps replicate realistic traffic patterns.&lt;/p&gt;

&lt;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%2Fymmh53hclyjju12pm9ek.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fymmh53hclyjju12pm9ek.jpg" alt="Image description" width="800" height="358"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  3. &lt;strong&gt;Runtime Tab&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;The &lt;strong&gt;Runtime&lt;/strong&gt; tab allows you to configure the execution of your performance test. It gives control over:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Test Duration&lt;/strong&gt;: Define the start, ramp-up, and steady state phases for your test.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Number of Users&lt;/strong&gt;: Set the number of concurrent virtual users (VU) to simulate during different phases.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Load Generators&lt;/strong&gt;: Allocate specific machines or cloud-based resources to generate the load.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Usage&lt;/strong&gt;: This tab is vital for controlling the overall execution of your performance tests. You can ramp up users gradually to observe system behavior under increasing load, and define thresholds for when the system is under maximum stress.&lt;/p&gt;

&lt;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%2Fijqbhrakar74wmvykg8d.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fijqbhrakar74wmvykg8d.jpg" alt="Image description" width="800" height="445"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  4. &lt;strong&gt;Monitoring Tab&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;NeoLoad integrates with various monitoring tools to capture server and application metrics while tests are running. This tab includes:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Monitored Systems&lt;/strong&gt;: Add servers, databases, and other system components to monitor during the test.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Performance Counters&lt;/strong&gt;: Select counters like CPU utilization, memory usage, disk I/O, and network traffic to track while the test runs.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Usage&lt;/strong&gt;: Use the Monitoring tab to collect real-time data from your infrastructure, which helps in identifying performance bottlenecks and ensuring resource utilization is optimal during tests.&lt;/p&gt;

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

&lt;h3&gt;
  
  
  5. &lt;strong&gt;Results Tab&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;The &lt;strong&gt;Results&lt;/strong&gt; tab displays the outcome of the performance tests after they are executed. This is where the most critical insights into your application's performance are drawn:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Summary Report&lt;/strong&gt;: NeoLoad generates a report that provides an overview of the test, including total requests, failures, and average response times.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Graphs and Charts&lt;/strong&gt;: View detailed graphs on throughput, response times, errors, and resource consumption during the test.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;SLA Status&lt;/strong&gt;: NeoLoad allows you to define Service Level Agreements (SLAs) for various KPIs like response time, throughput, or error rates. The Results tab will show if your application met the set SLAs during the test.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Usage&lt;/strong&gt;: This tab is crucial for analyzing how well your application performed under load. The data can help identify trends and highlight areas that need improvement.&lt;/p&gt;

&lt;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%2Fx5a617i6xnojjg5gxuag.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fx5a617i6xnojjg5gxuag.jpg" alt="Image description" width="800" height="568"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  How to Use NeoLoad for Performance Testing
&lt;/h3&gt;

&lt;h4&gt;
  
  
  Step-by-Step Guide:
&lt;/h4&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Design User Paths&lt;/strong&gt;: Start by recording or manually creating user paths representing typical user behavior on your system.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Define Populations&lt;/strong&gt;: Group different user paths to simulate the behavior of various user types.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Configure Runtime Settings&lt;/strong&gt;: Specify the number of virtual users, ramp-up time, and test duration to match real-world load conditions.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Monitor Systems&lt;/strong&gt;: Connect to servers or databases to gather performance metrics from the infrastructure during the test.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Run the Test&lt;/strong&gt;: Start the test and monitor it in real-time using NeoLoad’s dashboard.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Analyze Results&lt;/strong&gt;: After the test, use the Results tab to evaluate the data. Pay close attention to response times, error rates, and resource utilization.&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  Interpreting Performance Test Results
&lt;/h3&gt;

&lt;p&gt;Interpreting the results is key to improving the performance and scalability of your application. Here are the primary metrics and their importance:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Response Times&lt;/strong&gt;: The time it takes for a server to respond to a request. Short response times indicate good performance, while long ones suggest potential bottlenecks.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Throughput&lt;/strong&gt;: This shows how much data is being sent and received during the test. Low throughput could indicate network or bandwidth limitations.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Error Rates&lt;/strong&gt;: Any errors or failed transactions that occur during the test. A high error rate typically indicates that the application can’t handle the load.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Resource Utilization&lt;/strong&gt;: Use CPU, memory, and disk I/O monitoring to check if server resources are being fully utilized or if they are being overburdened.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Conclusion
&lt;/h3&gt;

&lt;p&gt;NeoLoad is an effective performance testing tool for assessing the scalability and robustness of your applications. By using its well-structured tabs, you can simulate various load conditions, monitor system performance, and gain insights into potential bottlenecks. Interpreting the results helps you improve application responsiveness and meet performance expectations, ensuring a seamless user experience. &lt;/p&gt;

&lt;p&gt;Whether you’re testing web applications, APIs, or mobile apps, NeoLoad provides the flexibility and depth needed for robust performance testing.&lt;/p&gt;

&lt;p&gt;Please refer to my online portfolios:-&lt;br&gt;
&lt;a href="https://www.linkedin.com/in/atulkmrsharma/" rel="noopener noreferrer"&gt;LinkedIn&lt;/a&gt;&lt;br&gt;
&lt;a href="https://github.com/AtulKrSharma" rel="noopener noreferrer"&gt;GitHub&lt;/a&gt;&lt;br&gt;
&lt;a href="https://stackoverflow.com/users/10837620/atul-kumar-sharma" rel="noopener noreferrer"&gt;StackOverflow&lt;/a&gt;&lt;/p&gt;

</description>
      <category>loadtesting</category>
      <category>performance</category>
      <category>webapp</category>
    </item>
    <item>
      <title>Unlocking the Power of Conditional Testing in Cypress</title>
      <dc:creator>Atul Sharma</dc:creator>
      <pubDate>Fri, 29 Sep 2023 04:24:54 +0000</pubDate>
      <link>https://dev.to/atulkrsharma/unlocking-the-power-of-conditional-testing-in-cypress-51o9</link>
      <guid>https://dev.to/atulkrsharma/unlocking-the-power-of-conditional-testing-in-cypress-51o9</guid>
      <description>&lt;p&gt;Conditional testing in Cypress involves using conditional statements and commands to control the flow of your test scripts based on certain conditions. Cypress provides a powerful set of commands for handling conditional logic within your tests. Here are some common scenarios and techniques for conditional testing in Cypress:&lt;/p&gt;

&lt;h2&gt;
  
  
  1. &lt;strong&gt;Conditional Assertions&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;You can use conditional logic to make assertions based on the state of the application. For example, you might want to assert that a certain element is visible only if a specific condition is met. Here's an example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;   &lt;span class="nx"&gt;cy&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;.some-element&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;should&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="nx"&gt;$el&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
     &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;condition&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
       &lt;span class="nf"&gt;expect&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;$el&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nx"&gt;to&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;be&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;visible&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
     &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
       &lt;span class="c1"&gt;// Add assertions or actions for the opposite condition&lt;/span&gt;
     &lt;span class="p"&gt;}&lt;/span&gt;
   &lt;span class="p"&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  2. &lt;strong&gt;Using &lt;code&gt;if&lt;/code&gt; Statements&lt;/strong&gt;:
&lt;/h2&gt;

&lt;p&gt;You can use standard JavaScript &lt;code&gt;if&lt;/code&gt; statements in your Cypress tests to conditionally execute commands or assertions. For example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;   &lt;span class="nx"&gt;cy&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;.some-button&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;then&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="nx"&gt;$button&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
     &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;$button&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;is&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;:visible&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
       &lt;span class="c1"&gt;// Perform actions if the button is visible&lt;/span&gt;
       &lt;span class="nx"&gt;cy&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;.some-element&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;click&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
     &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
       &lt;span class="c1"&gt;// Perform actions for the opposite condition&lt;/span&gt;
     &lt;span class="p"&gt;}&lt;/span&gt;
   &lt;span class="p"&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  3. &lt;strong&gt;&lt;code&gt;cy.wait&lt;/code&gt; with Condition&lt;/strong&gt;:
&lt;/h2&gt;

&lt;p&gt;You can use &lt;code&gt;cy.wait&lt;/code&gt; with a condition to pause the test execution until the condition is met. For example, you can wait for an element to exist or for a specific network request to complete:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;   &lt;span class="nx"&gt;cy&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;waitUntil&lt;/span&gt;&lt;span class="p"&gt;(()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;cy&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;.some-element&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;should&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;exist&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  4. &lt;strong&gt;Custom Cypress Commands&lt;/strong&gt;:
&lt;/h2&gt;

&lt;p&gt;You can create custom Cypress commands to encapsulate conditional logic and make your tests more readable. For example, you can create a custom command to log in if the user is not already logged in:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;   &lt;span class="nx"&gt;Cypress&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;Commands&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;add&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;loginIfNeeded&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
     &lt;span class="nx"&gt;cy&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;.user-profile&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;then&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="nx"&gt;$userProfile&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
       &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="nx"&gt;$userProfile&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;length&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
         &lt;span class="c1"&gt;// Log in logic here&lt;/span&gt;
       &lt;span class="p"&gt;}&lt;/span&gt;
     &lt;span class="p"&gt;});&lt;/span&gt;
   &lt;span class="p"&gt;});&lt;/span&gt;

   &lt;span class="c1"&gt;// Usage&lt;/span&gt;
   &lt;span class="nx"&gt;cy&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;loginIfNeeded&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  5. &lt;strong&gt;Using &lt;code&gt;.then()&lt;/code&gt; with Promises&lt;/strong&gt;:
&lt;/h2&gt;

&lt;p&gt;Cypress commands return Promises, so you can use &lt;code&gt;.then()&lt;/code&gt; to handle conditions based on the resolved values of those promises. For example, you can check the text of an element:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;   &lt;span class="nx"&gt;cy&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;.status-message&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;invoke&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;text&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;then&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="nx"&gt;text&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
     &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;text&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Success&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
       &lt;span class="c1"&gt;// Handle success condition&lt;/span&gt;
     &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
       &lt;span class="c1"&gt;// Handle other conditions&lt;/span&gt;
     &lt;span class="p"&gt;}&lt;/span&gt;
   &lt;span class="p"&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;Please keep it in the mind&lt;/em&gt; when using then/should. Utilizing .then() enables you to employ the returned object in a callback function, making it suitable for scenarios where you require value manipulation or the execution of specific actions.&lt;/p&gt;

&lt;p&gt;Conversely, when employing a callback function with .should() or .and(), a unique mechanism is in place to repeatedly execute the callback until no assertions result in errors. It's important to exercise caution regarding any side effects within a .should() or .and() callback, as these may unintentionally occur multiple times.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Remember&lt;/strong&gt; that Cypress tests are written in JavaScript, so you have the flexibility to use all JavaScript language features and libraries to handle conditional testing. Make sure to structure your tests in a way that makes them clear and maintainable, especially when dealing with complex conditional logic.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Catch you in the next article coming next week&lt;/em&gt;. Feel free to comment on this.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Please refer to my online portfolios:&lt;/em&gt;&lt;br&gt;
&lt;a href="https://www.linkedin.com/in/atulkmrsharma/" rel="noopener noreferrer"&gt;LinkedIn&lt;/a&gt;&lt;br&gt;
&lt;a href="https://github.com/AtulKrSharma" rel="noopener noreferrer"&gt;GitHub&lt;/a&gt;&lt;br&gt;
&lt;a href="https://stackoverflow.com/users/10837620/atul-kumar-sharma" rel="noopener noreferrer"&gt;StackOverflow&lt;/a&gt;&lt;/p&gt;

</description>
      <category>cypress</category>
      <category>automaton</category>
      <category>conditionaltesting</category>
      <category>softwaretesting</category>
    </item>
    <item>
      <title>Selenium Behind: Taking the Leap Into the Cypress World Part-II</title>
      <dc:creator>Atul Sharma</dc:creator>
      <pubDate>Thu, 02 Feb 2023 00:32:37 +0000</pubDate>
      <link>https://dev.to/atulkrsharma/selenium-behind-taking-the-leap-into-the-cypress-world-part-ii-2njj</link>
      <guid>https://dev.to/atulkrsharma/selenium-behind-taking-the-leap-into-the-cypress-world-part-ii-2njj</guid>
      <description>&lt;p&gt;Here is the &lt;a href="https://dev.to/atulkrsharma/selenium-behind-taking-the-leap-into-the-cypress-world-2637"&gt;link of the Part-I&lt;/a&gt;, if you've landed directly here.&lt;/p&gt;

&lt;p&gt;Many are curious about Part-I of this dev blog that only features content (I agree but that's the bare minimum theoretical background one must have to start) and no code and it echoes in every Developer's mind, Isn't it? Mine too.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;“Talk is cheap. Show me the code.” ― Linus Torvalds&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;so, Let's continue the rest of the concepts needed to work with &lt;a href="https://www.cypress.io/" rel="noopener noreferrer"&gt;Cypress&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Subject Management in Cypress&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In Cypress, commands do not return their subjects, instead yield them. Cypress commands are asynchronous and get queued for execution at a later time. During execution, subjects are yielded from one command to the next and a lot of helpful Cypress code runs between each command to ensure everything is in order.&lt;br&gt;
Okay, you've written code in &lt;a href="https://www.selenium.dev/" rel="noopener noreferrer"&gt;Selenium&lt;/a&gt; like this 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%2Fh81jvb6gcm7smmr9xfec.PNG" class="article-body-image-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%2Fh81jvb6gcm7smmr9xfec.PNG" alt="Subject Management in Cypress" width="656" height="132"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;del&gt;It's going to work like charm&lt;/del&gt;. Sorry, &lt;em&gt;Did you forget??&lt;/em&gt; In Cypress, commands do not return their subjects, instead yield them.&lt;br&gt;
Now, &lt;em&gt;a million dollar question- How can user interact with subject directly&lt;/em&gt;? My only reply will be this:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;"Patience is not just about waiting for something; it's about how you wait, or your attitude while waiting." - Joyce Meyer&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;As advised in the above quote, talking about how or your attitude while waiting. Do you know that Cypress wait command can wait for a specific request to respond?&lt;/em&gt;&lt;/strong&gt; &lt;/p&gt;

&lt;p&gt;Alrighty folks, let's park this subject for now, tackle this some other article &amp;amp; continue our thrilling ride through the fundamentals of Cypress.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Context switching b/w Cypress &amp;amp; jQuery [.then() &amp;amp; .wrap()]&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;After going above Point, we know that commands do not return their subjects then, &lt;strong&gt;&lt;em&gt;user can interact with subject directly with command -then()&lt;/em&gt;&lt;/strong&gt;. Whatever is returned from the callback function becomes the new subject and will flow into the following command and Cypress will wait for that to resolve before continuing forward through the chain of commands.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F2smsessbt8vz2t6jkdo4.PNG" class="article-body-image-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%2F2smsessbt8vz2t6jkdo4.PNG" alt="Cypress .then command" width="800" height="312"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Before using .then(), user is in Cypress context and can use the Cypress commands as its disposal. See below, find() command of Cypress is used &amp;amp; tooltip is confirming the same.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqss5uhy7ydd6r0nohjx4.PNG" class="article-body-image-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%2Fqss5uhy7ydd6r0nohjx4.PNG" alt=" Before .then() command" width="800" height="259"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;After using .then() command, user comes into jQuery context leaving the Cypress context. See below, &lt;a href="https://api.jquery.com/find/" rel="noopener noreferrer"&gt;find() command of jQuery&lt;/a&gt; is used, tooltip is showing the same and work with your Subject, as desired.&lt;/p&gt;

&lt;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%2Flre7kapu6k0xvr6m8037.PNG" class="article-body-image-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%2Flre7kapu6k0xvr6m8037.PNG" alt="After .then() command" width="800" height="337"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Oh No!! We're stuck again in the jQuery context and someone tell me how to get out of this context switch to Cypress context??&lt;/p&gt;

&lt;p&gt;&lt;em&gt;It's my pleasure to remind you the same quote by "Joyce Meyer" about Patience.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Now, Cypress has built .wrap command to switch to Cypress context, so that user can start leveraging the Cypress commands.  See below, jQuery object is wrapped with Cypress .wrap command, regular Cypress commands can be used again to carry on the tests. Observe the tooltip and it's showing up that Cypress find() command is being used now.&lt;/p&gt;

&lt;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%2Fzpntijx0583x8utedad2.PNG" class="article-body-image-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%2Fzpntijx0583x8utedad2.PNG" alt="After .wrap command" width="800" height="250"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Catch you in the next article coming next week&lt;/em&gt;. Feel free to comment on this.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Please refer to my online portfolios:&lt;/em&gt;&lt;br&gt;
&lt;a href="https://www.linkedin.com/in/atulkmrsharma/" rel="noopener noreferrer"&gt;LinkedIn&lt;/a&gt;&lt;br&gt;
&lt;a href="https://github.com/AtulKrSharma" rel="noopener noreferrer"&gt;GitHub&lt;/a&gt;&lt;br&gt;
&lt;a href="https://stackoverflow.com/users/10837620/atul-kumar-sharma" rel="noopener noreferrer"&gt;StackOverflow&lt;/a&gt;&lt;/p&gt;

</description>
      <category>networking</category>
      <category>discuss</category>
    </item>
    <item>
      <title>Selenium Behind: Taking the Leap Into the Cypress World Part-I</title>
      <dc:creator>Atul Sharma</dc:creator>
      <pubDate>Sat, 28 Jan 2023 04:34:13 +0000</pubDate>
      <link>https://dev.to/atulkrsharma/selenium-behind-taking-the-leap-into-the-cypress-world-2637</link>
      <guid>https://dev.to/atulkrsharma/selenium-behind-taking-the-leap-into-the-cypress-world-2637</guid>
      <description>&lt;p&gt;It's been 3+ years working with &lt;a href="https://www.cypress.io/" rel="noopener noreferrer"&gt;Cypress.io&lt;/a&gt; and now, I completely think(so but catching up with Cypress updates is endless) understand the hurdles that need to be crossed and pave a path for Selenium QA Engineers to make them understand the &lt;strong&gt;actual differences&lt;/strong&gt; vis a vis Cypress &amp;amp; Selenium world. now, Why JS? The reason wise, Cypress only understand JS. It's going to be multi-part series around what I've learnt while taking the leap into the Cypress world.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;“The journey matters as much as the goal.”- Kalpana Chawla&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Her above quote resonates the idea of working towards a goal and the experiences we have along the way are just as valuable as the goal itself. The journey can be full of challenges, failures and learning experiences which can shape us, make us stronger and better equipped to face the future.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.cypress.io/" rel="noopener noreferrer"&gt;Cypress.io&lt;/a&gt; has such a nice documentation that I can't think of referring other tutorials/blogs to you. Here, is the starter kit for you:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;a href="https://docs.cypress.io/guides/overview/why-cypress" rel="noopener noreferrer"&gt;Why Cypress&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://docs.cypress.io/guides/overview/key-differences" rel="noopener noreferrer"&gt;Key Differences&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://docs.cypress.io/guides/getting-started/installing-cypress" rel="noopener noreferrer"&gt;Installing Cypress&lt;/a&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Now, I can safely assume that you've set up everything for writing the Cypress+ JS code in Mocha style using IDE of your choice (mine is VS Code)&lt;/p&gt;

&lt;p&gt;In my opinion, understanding the following concepts is essential for effectively utilizing Cypress. So, Ready to bite the bullet?&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Cypress Commands Are Asynchronous&lt;/li&gt;
&lt;li&gt;Cypress Commands Run Serially&lt;/li&gt;
&lt;li&gt;Cypress Command Chaining&lt;/li&gt;
&lt;li&gt;Subject Management in Cypress&lt;/li&gt;
&lt;li&gt;Context Switching between Cypress &amp;amp; jQuery [.then() &amp;amp; .wrap()]&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Let me take all pointers one-by-one and break them down, while adding code snippets to make things more clearer to you.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Cypress Commands Are Asynchronous&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;It simply means that as soon as you run the Cypress tests, commands don't get executed right away but get queued to be executed to a later time. Cypress does not wait for one command or action to be completed before moving on to the next one. While commands are executed, their subjects are yielded from one command to the next, which allows for faster test execution and more efficient use of system resources. This also allows Cypress to automatically handle waiting for elements to load or for certain conditions to be met before moving on to the next step in the test, which simplifies the test writing process.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Cypress Commands Run Serially&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;It means that Cypress Commands execute one at a time in the order that they are called. It has been possible by the hard work put in by Cypress Team to make use of a built-in command queue to ensure that commands are executed in the correct order. The serial execution of Cypress commands ensures that each command has a chance to complete before the next one begins. This makes it easier to reason about the state of the application under test and to understand the results of the test.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Cypress Command Chaining&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This allows multiple commands to be chained together in a single line of code. Commands are designed to be chainable, meaning that they return the same subject that they were called on, allowing you to chain multiple commands together &amp;amp; allows for more concise and readable tests, as well as the ability to perform multiple actions on a single element. For example, instead of writing separate lines of code to visit a website, click a button, and then check the text of an element, all of these actions can be chained together in a single line of 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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F3mp29yusinqipnu8u9hv.png" class="article-body-image-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%2F3mp29yusinqipnu8u9hv.png" alt="Command Chainging" width="800" height="252"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;del&gt;Catch you in the next article coming next week.&lt;/del&gt;&lt;br&gt;
Part-II has arrived now and here is the &lt;a href="https://dev.to/atulkrsharma/selenium-behind-taking-the-leap-into-the-cypress-world-part-ii-2njj"&gt;link to Part-II&lt;/a&gt; of this series. Feel free to comment on this.&lt;/p&gt;

&lt;p&gt;Please refer to my online portfolios:-&lt;br&gt;
&lt;a href="https://www.linkedin.com/in/atulkmrsharma/" rel="noopener noreferrer"&gt;LinkedIn&lt;/a&gt;&lt;br&gt;
&lt;a href="https://github.com/AtulKrSharma" rel="noopener noreferrer"&gt;GitHub&lt;/a&gt;&lt;br&gt;
&lt;a href="https://stackoverflow.com/users/10837620/atul-kumar-sharma" rel="noopener noreferrer"&gt;StackOverflow&lt;/a&gt;&lt;/p&gt;

</description>
      <category>cypress</category>
      <category>javascript</category>
      <category>testing</category>
      <category>testautomation</category>
    </item>
  </channel>
</rss>
