<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Waris Jamal on Medium]]></title>
        <description><![CDATA[Stories by Waris Jamal on Medium]]></description>
        <link>https://medium.com/@waris-jamal?source=rss-b33183acfc96------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*Jjf1oHcIeF7IMnDSvSpx-A.jpeg</url>
            <title>Stories by Waris Jamal on Medium</title>
            <link>https://medium.com/@waris-jamal?source=rss-b33183acfc96------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 21 Nov 2026 03:27:47 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@waris-jamal/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Data-Driven Automation in Postman: Streamline Your API Testing]]></title>
            <link>https://medium.com/@waris-jamal/data-driven-automation-in-postman-streamline-your-api-testing-9aa62e988e17?source=rss-b33183acfc96------2</link>
            <guid isPermaLink="false">https://medium.com/p/9aa62e988e17</guid>
            <category><![CDATA[api]]></category>
            <category><![CDATA[api-automation]]></category>
            <category><![CDATA[postman]]></category>
            <category><![CDATA[api-testing]]></category>
            <category><![CDATA[postman-testing]]></category>
            <dc:creator><![CDATA[Waris Jamal]]></dc:creator>
            <pubDate>Mon, 28 Aug 2023 07:15:40 GMT</pubDate>
            <atom:updated>2023-08-28T07:15:40.230Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*u-MX_3uS3mPpem5R3MHSYw.png" /></figure><p>In today’s software development landscape, APIs (Application Programming Interfaces) play a critical role in connecting various services and applications. As a result, efficient API testing is essential to ensure the smooth functioning of your software. Enter Postman, a popular tool that simplifies API development and testing. In this post, we’ll explore the concept of data-driven automation in Postman, a technique that can significantly enhance your API testing capabilities especially when you have huge data to test.</p><h3>What is Data-Driven Automation?</h3><p>Data-driven automation is a testing approach that separates the <strong><em>test logic</em></strong> from the <strong><em>test data</em></strong>. Instead of hardcoding specific inputs for your tests, you use external data sources to drive your tests. This approach has several advantages:</p><ul><li><strong>Reusability:</strong> You can reuse the same test scripts with different data sets, reducing duplication of effort.</li><li><strong>Maintainability:</strong> Test data changes do not require test script modifications, making maintenance easier.</li><li><strong>Scalability:</strong> As your application grows, it’s easier to add new test cases by simply adding more data.</li><li><strong>Coverage:</strong> You can test a wide range of scenarios by feeding various data inputs to your tests.</li></ul><h3>Prerequisites</h3><ol><li><strong>Postman:</strong> Download and install the Postman app if you haven’t already. You can get it from the <a href="https://www.postman.com/">Postman website</a>.</li><li><strong><em>API to Test:</em></strong> I am using Weather APIfor testing purposes.</li></ol><h3>Setting up Data-Driven Testing in Postman</h3><h4>Step 1: Create a Collection</h4><ol><li>Open Postman.</li><li>Click on the “New” button, then select “Collection.”</li><li>Give your collection a name, such as “Booking Details.”</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WOupbuvx1rEBPr7n3zpGjA.gif" /></figure><h4>Step 2: Add a Request</h4><ol><li>Click on your newly created collection, then click the “Add request” button.</li><li>Give your request a name, such as “<strong>Get booking details</strong>”</li><li>Specify the <strong>HTTP</strong> method as <strong>“GET.”</strong></li><li>Set the request URL to your weather API endpoint, e.g., <a href="https://restful-booker.herokuapp.com/booking">https://restful-booker.herokuapp.com/booking</a>.</li><li>Click “Save” to add the request to your collection.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vwgaKPydgNPcZmOCMY4E3Q.gif" /></figure><h4>Step 3: Create a Data File</h4><ol><li>Create a CSV file named “booking_test_data.csv” with the following headers: bookingID</li><li>Populate the CSV file with test data(you can give any IDs that are present in the request data). For example:</li></ol><pre>bookingID<br>2<br>4<br>7</pre><h4>Step 4: Modify the request</h4><ol><li>Based on the data in the CSV file, we can enhance the request by incorporating a variable into it, <a href="https://restful-booker.herokuapp.com/booking/%7B%7BbookingID%7D%7D">https://restful-booker.herokuapp.com/booking/</a>{{bookingID}}</li></ol><h4>Step 5: Add some Test validation for Automation verification</h4><pre>// Check the status code<br>pm.test(&quot;Status code is 200&quot;, function () {<br>    pm.response.to.have.status(200);<br>});<br><br>// Get the response JSON<br>var jsonData = pm.response.json();<br><br>// Check if the response contains booking information<br>pm.test(&quot;Booking Details are Present&quot;, function () {<br>    pm.expect(jsonData.firstname).to.exist;<br>    pm.expect(jsonData.lastname).to.exist;<br>});</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nbHuV85PPnyOt0XJ3cJINg.gif" /></figure><h4>Step 6: Create a Collection Runner</h4><ol><li>Click on the “…” button on the collection Booking Details.</li><li>Select Run collection.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gYlnttducjwx1bqRlVCOSA.gif" /></figure><h4>Step 6: Configure the Collection Runner</h4><p>In the Collection Runner window:</p><ol><li>Choose how to run your collection Run manually, Schedule runs &amp; Automate run via CLI. We are using Run manually</li><li>Choose your data file (“booking_test_data.csv”).</li><li>Click “Run Booking Details.”</li></ol><p>Postman will execute the “Get booking details” request for each row of data from your CSV file, adding the CSV bookingID variables with the corresponding request bookingID values.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UDkzwLOt2AJ99FXbNt9xJg.gif" /></figure><h3>Using Data-Driven Testing Results</h3><p>This will give us a detailed report about the execution total passed, failed &amp; skipped. To export the report, simply click on Export Results. Please note that this option is only available on the desktop app and not on the browser version.</p><p>There are various methods for implementing data-driven automation in Postman. One way is to make use of environment variables to access variables and other necessary resources.</p><h3>Conclusion</h3><p>Data-driven automation in Postman is a powerful technique for enhancing your API testing efforts. By separating test logic from test data and using external data sources especially when you have huge data, you can increase the efficiency, coverage, and maintainability of your tests.</p><p>So, the next time you’re testing an API, consider using data-driven automation in Postman to streamline your testing process and ensure your application’s reliability.</p><p>Happy testing! 🚀</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9aa62e988e17" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[SoftAssertion in Cypress]]></title>
            <link>https://medium.com/@waris-jamal/softassertion-in-cypress-a7055f40ecc6?source=rss-b33183acfc96------2</link>
            <guid isPermaLink="false">https://medium.com/p/a7055f40ecc6</guid>
            <category><![CDATA[cypress-automation]]></category>
            <category><![CDATA[testing-tools]]></category>
            <category><![CDATA[typescript]]></category>
            <category><![CDATA[qa-engineer]]></category>
            <category><![CDATA[automation-testing]]></category>
            <dc:creator><![CDATA[Waris Jamal]]></dc:creator>
            <pubDate>Sun, 06 Aug 2023 12:46:14 GMT</pubDate>
            <atom:updated>2023-08-06T12:46:14.427Z</atom:updated>
            <content:encoded><![CDATA[<p>Enhance Test Robustness with Soft Assertions in Cypress.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9Y-c9QNGodUq5O4fSnwAUA.png" /></figure><p><strong>Problem Statement:<br></strong>When writing automated tests in Cypress, it’s common to encounter situations where multiple assertions must be made within single or multiple tests. However, if one assertion fails, the test will immediately stop and the subsequent assertions will not be executed. This makes it difficult to identify all the issues within a test, as only the first failure will be reported. For example, consider the following Cypress test:</p><pre>describe(&quot;Scenario-1 with native assertions&quot;, () =&gt; {<br>    it(&#39;should validate multiple assertions using native assertions&#39;, () =&gt; {<br>        cy.visit(&#39;https://www.saucedemo.com/&#39;);<br>        cy.get(&#39;#user-name&#39;).type(&#39;standard_user&#39;);<br>        cy.get(&#39;#password&#39;).type(&#39;secret_sauce&#39;);<br>        cy.get(&#39;#login-button&#39;).click();<br>        cy.get(&#39;#react-burger-menu-btn&#39;).click();<br>        //error assertion code<br>        cy.get(&#39;a#inventory_sidebar_link&#39;).should(&#39;have.text&#39;, &#39;All Item&#39;); //it should be &quot;All Items&quot;<br>        cy.get(&#39;button#react-burger-cross-btn&#39;).click();<br><br>        cy.get(&#39;button#add-to-cart-sauce-labs-backpack&#39;).should(&#39;have.text&#39;, &#39;Add to cart&#39;);<br>        cy.get(&#39;.app_logo&#39;).should(&#39;contain&#39;, &#39;Swag Labs&#39;);<br>        cy.get(&#39;div#inventory_container&#39;).last().should(&#39;have.class&#39;, &#39;inventory_container&#39;);<br>        cy.get(&#39;.inventory_item&#39;).should(&#39;have.length&#39;, 6);<br>        cy.get(&#39;img[alt=&quot;Sauce Labs Backpack&quot;]&#39;).should(&#39;have.attr&#39;, &#39;src&#39;, &#39;/static/media/sauce-backpack-1200x1500.0a0b85a3.jpg&#39;);<br>    });<br>});</pre><p>In the above example, I have implemented multiple assertions. If the first assertion fails, the subsequent assertions will not be executed, and only the error message for the first assertion will be reported. This makes it challenging to identify all the issues within the test, as the test will stop executing after the first failure.</p><p><strong>Output:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*IJvbYkJnywiQKdV73hujmA.png" /></figure><p><strong>Solution Statement:<br></strong>To overcome this problem, I have added a <strong>softAssert &amp; assertAll custom command</strong>, which allows multiple assertions to be executed within a single test or multiple tests without stopping the test on the first failure. The softAssert command can be chained to the Cypress object, followed by the assertion method. For example:</p><pre>// should(&#39;have.text&#39;)<br>cy.get(&#39;a#inventory_sidebar_link&#39;).then($el =&gt; {<br>    cy.softAssert($el.text(), &#39;All Items&#39;, &#39;The text should be &quot;All Items&quot;&#39;);<br>});</pre><p>If any of the assertions fail, the test will continue to execute, and all the failures will be reported at the end of the test along with their corresponding error messages. For example, consider the following Cypress test that uses the <strong>softAssert &amp; assertAll custom command</strong>:</p><pre>describe(&quot;Scenario-2 with SoftAssertions&quot;, () =&gt; {<br>    after(&quot;This will store all the errors for all the describe blocks&quot;, function () {<br>        cy.assertAll(); // This we need to add for throwing the errors<br>    });<br><br>    it(&#39;should validate multiple assertions using softAssert&#39;, () =&gt; {<br>        cy.visit(&#39;https://www.saucedemo.com/&#39;);<br>        cy.get(&#39;#user-name&#39;).type(&#39;standard_user&#39;);<br>        cy.get(&#39;#password&#39;).type(&#39;secret_sauce&#39;);<br>        cy.get(&#39;#login-button&#39;).click();<br>        cy.get(&#39;#react-burger-menu-btn&#39;).click();<br>        cy.get(&#39;a#inventory_sidebar_link&#39;).then($el =&gt; {<br>            cy.softAssert($el.text(), &#39;All Items&#39;, &#39;The text should be &quot;All Items&quot;&#39;);<br>        });<br>        cy.get(&#39;button#react-burger-cross-btn&#39;).click();<br>        cy.get(&#39;button#add-to-cart-sauce-labs-backpack&#39;).then($el =&gt; {<br>            cy.softAssert($el.text(), &#39;Add to cart&#39;, &#39;The text should be &quot;Add to cart&quot;&#39;);<br>        });<br>        // should(&#39;contain&#39;)<br>        cy.get(&#39;.app_logo&#39;).then($el =&gt; {<br>            cy.softAssert($el.text().includes(&#39;Swag Labs&#39;), true, &#39;The element should contain Swag Labs&#39;);<br>        });<br>        // should(&#39;have.class&#39;)<br>        cy.get(&#39;div#inventory_container&#39;).then($el =&gt; {<br>            cy.softAssert($el.hasClass(&#39;inventory_container&#39;), true, &#39;The element should have the class &quot;inventory_container&quot;&#39;);<br>        });<br>        // should(&#39;not.have.class&#39;)<br>        cy.get(&#39;div#inventory_container&#39;).then($el =&gt; {<br>            cy.softAssert(!$el.hasClass(&#39;inventory&#39;), true, &#39;The element should not have the class &quot;inventory&quot;&#39;);<br>        });<br>        // should(&#39;have.length&#39;)<br>        cy.get(&#39;.inventory_item&#39;).then($el =&gt; {<br>            cy.softAssert($el.length, 6, &#39;The length should be 6&#39;);<br>        });<br>        // should(&#39;have.attr&#39;)<br>        cy.get(&#39;img[alt=&quot;Sauce Labs Backpack&quot;]&#39;).then($el =&gt; {<br>            cy.softAssert($el.attr(&#39;src&#39;), &#39;/static/media/sauce-backpack-1200x1500.0a0b85a3.jpg&#39;, &#39;attribute should be present&#39;);<br>        });<br>    });<br>});</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5SI3lsAF4CPbyLBnW6fxHA.png" /></figure><p>In the above example, the softAssert method is used instead of the should method, which allows multiple assertions to be executed without stopping the test on the first failure. If any of the assertions fail, the test will continue to execute, and all the failures will be reported at the end of the test along with their corresponding error messages.</p><h4><strong>Enable softAssert</strong></h4><p>To enable softAssert in Cypress, you need to add the below 2 custom commands in the commands.ts file.</p><pre>let itBlockErrors = {}; // Define an object to store errors for each &#39;it&#39; block title globally<br>let totalFailedAssertionsByDescribe = {}; // Keep track of the total number of assertion failures for each &quot;describe&quot; block<br><br>Cypress.Commands.add(&#39;softAssert&#39;, { prevSubject: false }, (actualValue, expectedValue, message) =&gt; {<br>  return cy.wrap(null, { timeout: Cypress.config(&#39;defaultCommandTimeout&#39;) }).then(() =&gt; {<br>    try {<br>      expect(actualValue).to.equal(expectedValue, message);<br>    } catch (err) {<br>      const itBlockTitle = Cypress.currentTest.title;<br>      const describeBlockTitle = Cypress.currentTest.titlePath[0];<br>      <br>      // Initialize the count for the &quot;describe&quot; block if it doesn&#39;t exist<br>      totalFailedAssertionsByDescribe[describeBlockTitle] = totalFailedAssertionsByDescribe[describeBlockTitle] || 0;<br>      totalFailedAssertionsByDescribe[describeBlockTitle]++;<br><br>      if (!itBlockErrors[itBlockTitle]) {<br>        itBlockErrors[itBlockTitle] = [];<br>      }<br>      itBlockErrors[itBlockTitle].push({ message, error: err });<br>    }<br>  });<br>});<br><br>Cypress.Commands.add(&#39;assertAll&#39;, () =&gt; {<br>  const errors = itBlockErrors;<br>  itBlockErrors = {};<br><br>  if (Object.keys(errors).length &gt; 0) {<br>    const errorMessages = Object.entries(errors).map(([title, entries], index) =&gt; {<br>      const errorMessage = (entries as Array&lt;{ error: Error }&gt;).map(({ error }) =&gt; (<br>        `${&quot;=&gt; &quot;+error.message}`<br>      )).join(&#39;\n\n&#39;);<br><br>      return `${index + 1}. Test Title: ${title}\n${errorMessage}`;<br>    });<br><br>    const errorMessage = Object.entries(totalFailedAssertionsByDescribe).map(([describe, count]) =&gt; {<br>      return `Total assertion failures in &quot;${describe}&quot;: ${count}`;<br>    }).join(&#39;\n&#39;);<br><br>    throw new Error(`Soft assertion failed: Total it block failed (${Object.keys(errors).length})\n${errorMessages.join(&#39;\n&#39;)}\n\n${errorMessage}`);<br>  }<br>});</pre><p>Add the chainable interface under index.d.ts file.</p><pre>declare namespace Cypress {<br>  interface Chainable&lt;Subject&gt; {<br>    softAssert(actualValue: any, expectedValue: any, message: string): Chainable&lt;any&gt;;<br>    assertAll(): Chainable&lt;any&gt;;<br>  }<br>}</pre><p><strong>Multiple softAssertion errors</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zKaNegptGJshHoMmt5GYng.png" /></figure><p>We can implement this feature with multiple it blocks as well as multiple describe blocks in the same spec file or in different spec files.</p><p><strong>Please check out the link for Some </strong><a href="https://docs.google.com/document/d/16ZFIObpgfYsib8h50QHgA1PJYaLmLQAdTgDT8a5bsRU/edit?usp=sharing"><strong>Commands</strong></a><strong> Example.</strong></p><p><strong>Conclusion:</strong></p><p>In conclusion, the softAssert method in Cypress allows multiple assertions to be executed within a single test without stopping the test on the first failure. This makes it easier to identify all the issues within a test, as all the failures will be reported at the end of the test along with their corresponding error messages.</p><p>By using the softAssert method, you can write more robust tests that are less likely to fail due to small issues. This can help you catch bugs early on in the development process and reduce the time it takes to identify and fix issues.</p><p><strong>Limitations<br>- </strong>This code will only work till Cypress version 10.3.0 because of some new features introduced by Cypress.<br>- Last it block only becomes red even if any previous it block is having any error.<br>- We cannot chain anything after using the softAssertion command.</p><p><strong><em>Please let me know in the comment section any new ideas and implementation of this for the newer version of Cypress.</em></strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a7055f40ecc6" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Cypress — How to Download Multiple Audio/Video files]]></title>
            <link>https://medium.com/@waris-jamal/cypress-how-to-download-multiple-audio-video-files-162afa841fa6?source=rss-b33183acfc96------2</link>
            <guid isPermaLink="false">https://medium.com/p/162afa841fa6</guid>
            <category><![CDATA[cypress]]></category>
            <category><![CDATA[automation-testing]]></category>
            <category><![CDATA[cypressio]]></category>
            <category><![CDATA[testing-tools]]></category>
            <category><![CDATA[automation]]></category>
            <dc:creator><![CDATA[Waris Jamal]]></dc:creator>
            <pubDate>Mon, 18 Jul 2022 16:51:28 GMT</pubDate>
            <atom:updated>2022-07-18T16:51:28.189Z</atom:updated>
            <content:encoded><![CDATA[<h3>Cypress — How to Download Multiple Audio/Video files</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BDhqwNDBUXtqh_Va3JkKug.png" /></figure><p>I want to give some context about this article before we get into the actual solution. I worked on this pet project just for fun, and I learned so much while working on it. In this article, we’ll talk about how to write a Cypress Test Script to download multiple audio/video files that<strong> are larger (6MB, 10MB, 100MB, etc.)</strong>. There are many articles and YouTube videos about downloading .txt, .csv, and .zip, but not for downloading audio/video files. As I was working on this project, I had already done a lot of research, so I thought why not share it with others as well?</p><h3>Scenario</h3><p>To download the original audio/song files for free, I browse YouTube and locate the songs I want to download, copy the URL of the YouTube video and go to another website that will convert the YouTube video into an audio file, and then download the converted audio file on my computer. My previous method of doing this was manually, but after learning Cypress I decided to automate it just for practice and I can now download multiple files at once. I just have to provide the names of the songs.</p><h3>Test Case</h3><ol><li>Go to <a href="https://www.youtube.com/">YouTube</a>.</li><li>Search the songs.</li><li>Click on the thumbnail/title of the video and Get the URL of the video.</li><li>Go to any YouTube to mp3 converter website, we are using <a href="https://getn.topsandtees.space/JGAWO7Njkj">getmp3</a>.</li><li>Paste the URL and Validate for MP3 320kbps.</li><li>Click on the download button and It will redirect us to a new page.</li><li>Click on the final download button.</li><li>Verify whether the file is downloaded or not.</li><li>Repeat steps 1 to 8 for the next song if present.</li></ol><blockquote><strong>NOTE:</strong> The plugin I use for <a href="https://github.com/Xvier/cypress-downloadfile"><strong>downloading</strong></a> and <a href="https://github.com/elaichenkov/cy-verify-downloads"><strong>verifying</strong></a> is available on <a href="https://docs.cypress.io/plugins/directory"><strong>Cypress</strong></a> official website. Check their setup and installation documentation to learn more.</blockquote><p>I added the name of the songs in the <strong>songs.json</strong> file in the <strong>fixtures</strong> folder in order to download multiple songs at once.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*u4gC9dk0AfPtTuvpBGddjA.png" /><figcaption>fixture-song-file</figcaption></figure><p>The next step is to install the plugins <strong>cypress-downloadfile</strong> and <strong>cy-verify-downloads, </strong>below are the commands to install both packages:</p><h4>Individual Commands</h4><pre><strong>npm install cypress-downloadfile</strong></pre><pre><strong>npm i -D cy-verify-downloads</strong></pre><h4>Combine Command</h4><pre><strong>npm i -D cypress-downloadfile cy-verify-downloads</strong></pre><p>After installing the packages we need to add the following lines to the <strong>cypress/support/commands.js.</strong></p><pre><strong>require(&#39;cypress-downloadfile/lib/downloadFileCommand&#39;);</strong></pre><pre><strong>require(&#39;cy-verify-downloads&#39;).addCustomCommand();</strong></pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*L_27DU1DLsXfroxrPp3sSA.png" /><figcaption>required-commands.js</figcaption></figure><p>Then you need to add the following lines to <strong>cypress.config.js </strong>for cypress version 10.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OKiPYtbaqz2_L5N9yKGovg.png" /><figcaption>download &amp; verify cypress.config.json setup</figcaption></figure><p>We are now ready to write the code to execute the different steps of our test case after setting up the plugins.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ggDz13nQjC39_cdJfM1ZbQ.png" /><figcaption>main-code</figcaption></figure><h3>Solution</h3><p>The <strong>cy.fixtures()</strong> command is used to retrieve song names from the <strong>songs.json</strong> file and <strong>each()</strong> loop is used to access the song names one by one and then perform all the steps inside the loop. <strong>cy.url()</strong>is used for obtaining the URL of the song from the YouTube page address bar and <strong>.then()</strong> is used for resolving the promise and passing the URL to the mp3 converter website. <a href="https://medium.com/@waris-jamal/handle-multi-domain-or-cross-origin-in-cypress-ea6fdc4f5e55"><strong>cy.origin()</strong></a> is used to visit the different domains in the same test case i.e.; getmp3. Now I used <strong>cy.downloadFile(&#39;Provide Url&#39;,&#39;Folder Path&#39;, &#39;File Name&#39;)</strong> to download the files in my <strong>cypress/downloads</strong> folder. You can modify the path and name of the folder however you like. <strong>cy.verifyDownload() </strong>is used to assert/verify that the file exists or not.</p><blockquote><strong>Note: I modified the core files of the </strong><strong>downloadFile() package so that I can download larger files and Cypress will wait until the file has not been downloaded.</strong></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Bd-LQODLwM-RmdPHAtNcnQ.png" /><figcaption>core-changes @ node_modules\cypress-downloadfile\lib\downloadFileCommand.js</figcaption></figure><pre><strong>&quot;use strict&quot;;</strong></pre><pre><strong>Cypress.Commands.add(&#39;downloadFile&#39;, function (url, dir, fileName, userAgent) {<br>     return cy.getCookies().then(function (cookies) {<br>        return cy.task(&#39;downloadFile&#39;, {<br>          url: url,<br>          directory: dir,<br>          cookies: cookies,<br>          fileName: fileName,<br>          userAgent: userAgent<br>        },{timeout:600000});   // This timeout you can modify <br>     });                       //according to your expected max file <br>});                            //size</strong></pre><p>Example: <strong>timeout:6000</strong>is an implicit request timeout<strong>. </strong>We can modify the default timeout for a single command by passing a timeout parameter<strong>. </strong>The best part of timeout is that if you pass <strong>timeout:6000</strong>(6 sec) if the request is completed in 3 seconds, it will move on to the next command after 3 seconds rather than waiting 6 seconds.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=162afa841fa6" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Handle Multi-Domain or Cross-Origin in Cypress]]></title>
            <link>https://medium.com/@waris-jamal/handle-multi-domain-or-cross-origin-in-cypress-ea6fdc4f5e55?source=rss-b33183acfc96------2</link>
            <guid isPermaLink="false">https://medium.com/p/ea6fdc4f5e55</guid>
            <category><![CDATA[cypress-testing]]></category>
            <category><![CDATA[automation-testing]]></category>
            <category><![CDATA[cypress]]></category>
            <category><![CDATA[cypressio]]></category>
            <category><![CDATA[automation]]></category>
            <dc:creator><![CDATA[Waris Jamal]]></dc:creator>
            <pubDate>Mon, 27 Jun 2022 13:33:37 GMT</pubDate>
            <atom:updated>2022-06-27T13:53:26.097Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3RmGuF64enkIFgYu6WO-DQ.png" /></figure><p>In order to test the e2e functionality of your product, you might often need to visit multiple domains in a single test case and If you choose Cypress then it becomes very difficult to accomplish this before <a href="https://docs.cypress.io/guides/references/changelog#9-6-0"><strong>Cypress version 9.6.0</strong>.</a> This article will cover all the problems and solutions that you may encounter when working with multiple domains.</p><h3>Test Case:</h3><ol><li>Go to <strong>T</strong><a href="http://techedclasses.in/"><strong>echEdClasses</strong></a></li><li>Reach to Notes &gt; Class X</li><li>Click on the <strong>YouTube link</strong>. (<strong>Cross-Origin Error occurs</strong>)</li><li>Verify and click on the playlist title.</li></ol><h3><strong>The Problem</strong></h3><p>So till cypress updated 9.6.0, we had to write complex code to accomplish cross-Domain functionality because <a href="https://docs.cypress.io/guides/references/trade-offs#Inside-the-browser">Cypress runs inside the browser</a>, and tests that execute commands against multiple superdomains fail due to the same-origin rule. As an example of a cross-origin error, the following test will fail:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Y3mqmyqS02CjDViNoWuFfA.png" /><figcaption>cypress-cross-domain-error-code</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/628/1*_xZdaNPJxNkOacffqBKhrg.png" /><figcaption>cypress-cross-domain-error</figcaption></figure><p>Therefore, this problem occurs while switching from one domain to another. The reason we are facing this issue in the above example is because we are switching from <strong>TechEdClasses</strong> to <strong>YouTube</strong> in the same test case.</p><h3>What is Cross-Origin</h3><p>When a domain name, hostname, and port are the same, it is said to be “same-origin”. Everything else is called “cross-origin”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fJKcPSxesrNLw93hvAQ81A.png" /><figcaption>cross-origin-example</figcaption></figure><h3>The Solution</h3><p>The solution to this problem is in <a href="https://docs.cypress.io/guides/references/changelog#9-6-0"><strong>cypress version 9.6.0</strong></a>. <a href="https://docs.cypress.io/api/commands/origin"><strong>cy.origin()</strong></a> which allows you to execute commands against any number of superdomains, all within a single test case.</p><blockquote>In order to use <strong>cy.origin()</strong>, the <a href="https://docs.cypress.io/guides/references/experiments"><strong>experimentalSessionAndOrigin</strong></a>flag must be set to <strong>true</strong>in the Cypress configuration file(cypress.config.js).</blockquote><h3>Syntax</h3><pre><strong>cy.origin(url, callbackFn)<br>cy.origin(url, options, callbackFn)</strong></pre><p>Now in our test case, we need to do some modifications for solving this issue. The following example fixes the failing test we mentioned in the problem section:</p><blockquote><strong>Step: 1-</strong> Add <strong>experimentalSessionAndOrigin:true </strong>in cypress.config.js file.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/861/1*kdIQilhXICG1MPPtcmDwCA.png" /><figcaption>cypress.config.js</figcaption></figure><blockquote><strong>Step: 2- </strong>Add<strong>cy.origin() </strong>in your test case and visit the URL.<br><strong>Note: </strong>Listed here is one of the ways you can use it, but there are other ways as well, for more information visit <a href="https://docs.cypress.io/api/commands/origin#Usage"><strong>cypress.io</strong></a>.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ErpZMjdKu2-wVUrRyBkTdg.png" /><figcaption>crossOrigin.cy.js</figcaption></figure><h3>Test Runner Window</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*33xMwB4eBNUu2zoq6P66vw.gif" /></figure><p>If you want to resolve the promise/want to pass the variable in <strong>cy.origin() </strong>then you can use the below mentioned way.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wMY5fr1Q_8PWAkoDn5WOqQ.png" /></figure><p>Thank you for reading the article and if you have any suggestions please put them in a comment. If you find it useful, please clap.</p><h3>Conclusion</h3><p>Cypress made so many improvements to solve our problems after the update. Many things have changed in Cypress update 10.0.0, so please let us know if you find any issues.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ea6fdc4f5e55" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Handling a New/Child Tab in Cypress]]></title>
            <link>https://medium.com/@waris-jamal/handling-a-new-child-tab-in-cypress-982531debd24?source=rss-b33183acfc96------2</link>
            <guid isPermaLink="false">https://medium.com/p/982531debd24</guid>
            <category><![CDATA[handle-child-tab-cypress]]></category>
            <category><![CDATA[cypress]]></category>
            <category><![CDATA[cypressio]]></category>
            <category><![CDATA[testing-tools]]></category>
            <category><![CDATA[automation-testing]]></category>
            <dc:creator><![CDATA[Waris Jamal]]></dc:creator>
            <pubDate>Wed, 08 Jun 2022 10:03:03 GMT</pubDate>
            <atom:updated>2022-06-08T10:03:03.133Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1jIfBlCvIb6YkaYnzgoYlA.png" /></figure><p>Cypress has some shortcomings and this article will discuss one of them. The architecture has been designed that way to avoid flaky automation tests and provide consistent results. Therefore, Cypress does not support child tabs.</p><blockquote>We often open child tabs when we click on a particular link element (<strong>anchor tag</strong>) and this link has a <strong>target=&quot;_blank&quot;</strong>attribute. This opens a new tab within the same browser window.</blockquote><p><strong>TEST CASE:</strong></p><ol><li>Go to <a href="http://techedclasses.in/">http://techedclasses.in/</a></li><li>Reach to Notes &gt; Class X</li><li>Click on the YouTube link. This opens a new Tab.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Nngs08p-iNcTt8-ZsWs3Og.png" /></figure><p>It’s very easy to operate the <strong>DOM</strong> with Cypress, so the same technique we will employ to resolve this issue. Therefore, the issue will be resolved if we <strong>remove</strong> <strong>target=&quot;_blank&quot;</strong> before clicking on the desired link. So now we first look at the issue that we will face after running this test script.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/877/1*-azlqLKwT-HhzDA3jQE5sA.png" /></figure><p>Test Runner window with issue:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/627/1*J3irmB2Tpk8pHf_oqTdYNg.png" /></figure><p>In the above screenshot, you can see that a new tab opens within the same window after clicking on the link, and Cypress does not have access to the new tab, hence we can’t even validate any scenario.</p><p><strong>Solution:</strong></p><pre><strong>cy.get(&#39;p a&#39;).first().invoke(&#39;removeAttr&#39;,&#39;target&#39;).click();</strong></pre><p>Using the command <strong>cy.get(&#39;p a&#39;)</strong>we can get the element and first() allows us to select the first anchor available on the page. The main part is to invoke the<strong> jquery method</strong> with the attribute name <strong>removeAttr</strong> and the target name by using <strong>invoke(&#39;removeAttr&#39;,&#39;target&#39;)</strong>, then perform a click operation with <strong>click()</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_o05rBD36Y3GSQlduqjttg.png" /></figure><p>Now the child tab will open inside the parent tab, and if you want to return to the same <strong>URL</strong> you can use the following command.</p><pre><strong>cy.go(&#39;back&#39;);</strong></pre><p><strong>Note:</strong> In this test case, you will see a <strong>cross origin error</strong>, as we’re redirecting from <a href="http://techedclasses.in/"><strong>http://techedclasses.in/</strong></a> to <a href="https://www.youtube.com/,"><strong>https://www.youtube.com/</strong>,</a> which is also a disadvantage of Cypress up to version 9.6.0, however the flow of the child tabs is not affected.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/618/1*ET092tu3BsDT2zYdO3Uckw.png" /></figure><h3><strong>Conclusion</strong></h3><p>Those who use other automation tools have found that working in child tabs is relatively easy. Managing child tabs in Cypress is a bit challenging as native support is not available. We can easily manage child tabs by following the instructions given in this article, avoiding unnecessary R&amp;D, and saving a lot of time. Feel free to leave a comment if you found it useful.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=982531debd24" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Introduction to Cypress]]></title>
            <link>https://medium.com/atom-platform/introduction-to-cypress-a7e794cd3906?source=rss-b33183acfc96------2</link>
            <guid isPermaLink="false">https://medium.com/p/a7e794cd3906</guid>
            <category><![CDATA[e2e-testing]]></category>
            <category><![CDATA[cypress]]></category>
            <category><![CDATA[quality-assurance]]></category>
            <category><![CDATA[end-to-end-testing]]></category>
            <category><![CDATA[automation-testing]]></category>
            <dc:creator><![CDATA[Waris Jamal]]></dc:creator>
            <pubDate>Mon, 16 May 2022 14:56:05 GMT</pubDate>
            <atom:updated>2022-05-16T15:06:40.011Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lRjJeOXN67oHQyYfPIBeDg.jpeg" /><figcaption>Automation Testing image</figcaption></figure><p>Quality assurance plays an important role in ensuring quality standards are met in production applications to help reduce unexpected UX defects for end users. Therefore it is important to ensure that QA testing becomes an integral part of every application release process.</p><p>Ensuring that every build or release process of an application has some level of quality assurance guarantees can become a time and resource-intensive process when it is required to be done manually. Ideally, you will want to automate your testing process as much as possible, but it may become difficult or time-consuming to build your automation testing tooling.</p><p>Researching for the perfect test automation tool or library may become a very tedious task, especially with all the available open-source options in the market. You will need to make a trade-off and pick whichever works best for your particular team or use case.</p><p>In this article, I would like to introduce you to <strong>Cypress</strong>, the open-source next-generation automation testing tool built for modern web applications written in JavaScript and built on <strong>Node.js</strong>. Cypress may be all you need for your Automation testing needs.</p><p><strong>What is Cypress?</strong></p><p><a href="https://www.cypress.io/"><strong>Cypress</strong></a> is a QA and developer-friendly tool that uses a unique DOM manipulation technique and operates directly in the browser.</p><figure><a href="http://cypress.io/"><img alt="ref:cypress.io" src="https://cdn-images-1.medium.com/max/909/0*7ivSMXJeyCRXslzK" /></a><figcaption>Cypress logo</figcaption></figure><p>Cypress solves the key pain points developers and QA engineers face when testing modern applications. E.g., synchronization issues, the inconsistency of tests due to elements not visible or available, etc.</p><p><strong>Cypress is best suited for:</strong></p><ul><li><strong>Unit tests</strong></li><li><strong>Integration tests</strong></li><li><strong>End to End Tests (E2E)</strong></li></ul><figure><a href="http://cypress.io/"><img alt="ref:cypress.io" src="https://cdn-images-1.medium.com/max/879/0*AGw9TVqz-DwFKoaa" /></a><figcaption>Cypress vs other Automation Tools</figcaption></figure><p>Before Cypress, we had to think about what framework, assertion library, and debugger we wanted to use. However, there is no need to worry about frameworks, libraries, or debuggers after Cypress. By default, Cypress uses <strong>Mocha</strong> as a <strong>framework</strong> and <strong>Chai</strong> as a <strong>library</strong> for <strong>assertions</strong> and Cypress has one of the most effective debuggers. It takes snapshots when your tests run. Hovering over the commands in the Command Log gives a clear view of what happened at each stage.</p><p><strong>Advantages of Cypress</strong></p><p>Working with any tool requires that you understand its merits and demerits before you get started, otherwise you will be stuck. Here are a few benefits of Cypress:</p><ul><li>There are no additional dependencies for running test cases on the browser.</li><li>There are no additional dependencies for running test cases on the browser.</li><li>In contrast to other testing tools, there is no need to add explicit or implicit wait commands to test scripts. Cypress waits automatically for commands and assertions.</li><li>Earlier Cypress supported only Chrome testing. However, with recent updates, Cypress now provides support for electron, Firefox, Brave, and Edge browsers.</li></ul><p>The mocking of server requests and responses can be used to test edge scenarios.</p><ul><li>API testing capabilities.</li><li>According to the latest update now we can test Cross-Domain test scenarios.</li><li>It captures Videos or Screenshots at the time of test execution.</li><li>To verify and control the behavior of server responses, functions, or timers, developers or QA experts can use Spies, Stubs, and Clocks.</li><li>Cypress Dashboard shows you every detail of your test execution, including assertions, network requests, page loads, stubs, and spies.</li><li>There is no necessity for JSON Wire (or some other protocol) in Cypress. Since Cypress operates within the application, the test code can access all the objects (not limited to DOM elements) that the application code can.</li><li>It supports parallel testing (or parallelization) by default. It also lets you group tests by Browsers, test labels, and more by grouping test runs. Here is a short depiction of parallel testing with Cypress.</li></ul><p><strong>Cypress installation</strong></p><p>Cypress is very easy to install. The only thing you need to do is run a few commands in your text editor (VS Code) terminal, and you’re ready to create your automation scripts. It’s just like installing a game and starting it. Follow the given steps for a smooth installation:</p><p><strong>Step 1: Install Node.js and Node Package Manager (NPM)</strong></p><p>When you install<a href="https://nodejs.org/en/download/"> node.js</a>, make sure you are going to install the Latest Stable version (LTS) for your machine. Node is available for many operating systems, so download as per your system requirements</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*xHqWZpKM5GrQXMdw" /></figure><p>If you want to check whether the node.js and npm have been successfully installed or not. You can use the below command in your command prompt(CMD):</p><ul><li><strong>node -v</strong></li><li><strong>npm -v</strong></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/490/0*XBCaUKamZzZyirt3" /></figure><p><strong>Step 2: Create a Project folder</strong></p><p>Cypress is installed locally in your project folder only i.e.; we need to create a folder before installing the cypress. We can create our folder by using <strong>CTRL + SHIFT + N</strong> and rename it with your project name or by using terminal commands which are given below:</p><ul><li><strong>mkdir foldername — make directory/folder</strong></li><li><strong>cd foldername — change directory/folder</strong></li></ul><p><strong>Step 3: Create a package.json file</strong></p><p>The package.json file is the heart of any project. It records important metadata about a project and also defines functional attributes of a project that npm uses to install dependencies, run scripts, and identify the entry point to our package.</p><ul><li><strong>npm init -y</strong></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*4Y1w1yd7uzbRck2y" /></figure><p>After running this command, the One package.json file will be created with some default values.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*QaIpCD73pYh6rY7J" /></figure><p><strong>Step 4: Install Cypress</strong></p><ul><li><strong>npm install cypress — save-dev</strong></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*oG4dJ8M0u322rP0G" /></figure><p>After running the above command you have to wait for one or so minutes depending on your internet speed.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*jiAb0e0nFCILKSad" /></figure><p>Now after completing all the installation processes you will get a successful message in your terminal and one folder named <strong>node_module</strong> will be added to your folder structure along with the <strong>package-lock.json</strong> file.</p><p><strong>Step 5: Open Cypress test runner</strong></p><p>To run the cypress test cases we need to open its test runner, so the command to run cypress are:</p><ul><li><strong>.\node_modules.bin\cypress open or</strong></li><li><strong>npx cypress open</strong></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*bVA1IWk9A4MUEPds" /></figure><p>After running the above command, you will find one new folder named <strong>cypress</strong> in your folder structure, and inside this folder, you will see the architectural design of cypress. The white window in the center of <em>shot-8</em> is the <strong>test runner</strong> window through this you can execute your test cases very easily. Cypress provides you with some pre-defined test suits inside the integration folder.</p><p><strong>Disadvantages of Cypress</strong></p><ul><li>Cypress can only be used in browsers.</li><li>There is no support for multiple tabs or windows.</li><li>Cypress currently supports JavaScript and TypeScript for creating test cases.</li><li>There is no support for Safari.</li><li>It is not possible to run multiple browser sessions at the same time.</li></ul><p><strong>Conclusion</strong></p><p>Considering Cypress’s relatively easy learning curve, you can start creating meaningful tests quickly. Another great thing about Cypress is that they are constantly resolving its shortcomings.</p><p>In general, I found Cypress to be a very handy and easy-to-use tool for doing end-to-end testing. I can cover most of my needs with just a few built-in commands and find additional help with third-party packages when I need them. Despite that, Cypress has its shortcomings. In some cases, parts of the application do not load quickly enough and the tests fail due to an insufficient default wait time. Cypress then times out while it waits for the element to show up. Despite these faults, I would still recommend Cypress to anyone who needs end-to-end testing for their app.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a7e794cd3906" width="1" height="1" alt=""><hr><p><a href="https://medium.com/atom-platform/introduction-to-cypress-a7e794cd3906">Introduction to Cypress</a> was originally published in <a href="https://medium.com/atom-platform">Atom Platform</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>