<?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 Prince Soni on Medium]]></title>
        <description><![CDATA[Stories by Prince Soni on Medium]]></description>
        <link>https://medium.com/@prince83?source=rss-8d981a4c52fe------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*pIwxf39D0cSX-3tHLMwSqA.png</url>
            <title>Stories by Prince Soni on Medium</title>
            <link>https://medium.com/@prince83?source=rss-8d981a4c52fe------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 20 Nov 2026 07:48:55 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@prince83/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[Selenium 4 Architecture — W3C WebDriver Protocol]]></title>
            <link>https://prince83.medium.com/selenium-4-architecture-w3c-webdriver-protocol-e7de341dd5f1?source=rss-8d981a4c52fe------2</link>
            <guid isPermaLink="false">https://medium.com/p/e7de341dd5f1</guid>
            <category><![CDATA[selenium-webdriver]]></category>
            <category><![CDATA[selenium]]></category>
            <category><![CDATA[w3c-standards]]></category>
            <category><![CDATA[selenium-test-automation]]></category>
            <dc:creator><![CDATA[Prince Soni]]></dc:creator>
            <pubDate>Tue, 30 Aug 2022 00:04:52 GMT</pubDate>
            <atom:updated>2023-07-21T08:26:33.420Z</atom:updated>
            <content:encoded><![CDATA[<h3>Selenium 4 Architecture — W3C WebDriver Protocol</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*48MWTRNw1Vn7C3t86bL93A.png" /></figure><blockquote>Selenium has come a long way since its inception in 2004, and the foundations of the Selenium project are WebDriver, Grid, and IDE. Speaking about the <strong>Webdriver</strong> which is an <strong>interface</strong> that allows users to execute cross-browser tests, is no more using the JSON Wire protocol and its client-server architecture is fully standardized with W3C. In this post, I’ve explained the basics of the W3C Webdriver protocol.</blockquote><p>If you’ve landed here and are already aware of the w3c webdriver protocol, use this post as a refresher.. 😊</p><p><strong>Selenium with JSON Wire Protocol</strong></p><blockquote>As per <a href="https://www.selenium.dev/documentation/legacy/json_wire_protocol/"><strong>Selenium legacy documentation</strong></a>, “All implementations of WebDriver that communicate with the browser, or a RemoteWebDriver server shall use a common wire protocol. This wire protocol defines a RESTful web service using JSON over HTTP.”</blockquote><p>The main drawback of this protocol was that there was no direct communication between the client libraries (Java, Ruby, Python, etc..) and the browser driver. JSON wire protocol acts as a mediator between client libraries and webdriver.</p><p>Because the server doesn’t understand the programming language but only the protocols, hence it uses the process of <strong>serialization</strong> (convert object’s data to JSON format) and <strong>deserialization</strong> (convert JSON format to object). This results sometime in exceptions, slower test execution, and more chances of the test getting flaky.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LO-dxt_GOekhgol5mWaL0w.png" /><figcaption>JSON Wire Protocol</figcaption></figure><p><strong><em>Selenium with W3C Protocol</em></strong></p><blockquote>Based on <a href="https://www.w3.org/TR/webdriver1/"><strong>W3C</strong></a> website, “WebDriver is a remote control interface that enables introspection and control of user agents. It provides a platform- and language-neutral wire protocol as a way for out-of-process programs to remotely instruct the behavior of web browsers.”</blockquote><p>It is interesting to know that in selenium version 3.8 both json wire and w3c protocol ware existed in the web driver. But since version 4.0 selenium is only using World Wide Web Consortium (W3C) standard.</p><p>Now as almost all browsers and language bindings use the W3C, communication becomes much easier between client and server (driver). It is like two same language-speaking persons talking to each other.</p><p>Below is the improvement list in selenium 4 with the new protocol:</p><ul><li>Standard — common code Almost all the browsers and client library are already adopted the w3c protocol.</li><li>Stability — reduction in different runtime browser exceptions.</li><li>Action API — Multiple keyboard and mouse actions allowed like two keys press, Zoom In Zoom out operations, etc.</li><li>Introduction of <strong><em>ChromiumDriver (</em></strong><em>now chrome and edge driver extends the ChromiumDriver</em><strong><em>)</em></strong></li><li>Optimized Desired Capability</li><li>Selenium codebase is more optimized and cleaned as the legacy code is removed.</li></ul><figure><img alt="Same standard is used to communicate between client (scripts) and server(driver and actual browsers)" src="https://cdn-images-1.medium.com/max/955/1*42dHOXwo9Tk4IWwDtaIDqQ.png" /><figcaption>W3C WebDriver Protocol</figcaption></figure><p><strong><em>Conclusion</em></strong></p><p>There are multiple stable version has been released after selenium 4.0 and users are getting its benefits with more consistent and stable test execution across the browsers. Execution time got improved as the request and response Encoding-Decoding process is removed and the code base is optimized. Action APIs offer multiple keyboard and actions, zoom-in, and zoom-out mouse operations. With selenium 4 there are some interesting new features like Enhanced Selenium Grid, Upgraded Selenium IDE, Support for Chrome Debugging Protocol, Friendly Locators, etc.</p><blockquote>Thanks for reading this post. As it is my first in the selenium series therefore I felt that it would be good to start with the basics and hence explain the new WebDriver protocol and its architecture.</blockquote><p><strong>Reference</strong>: <a href="https://www.selenium.dev/">https://www.selenium.dev/</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e7de341dd5f1" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Playwright - new warrior in the automation arena]]></title>
            <link>https://prince83.medium.com/playwright-new-warrior-in-the-automation-arena-59ccc06b4356?source=rss-8d981a4c52fe------2</link>
            <guid isPermaLink="false">https://medium.com/p/59ccc06b4356</guid>
            <category><![CDATA[cross-browser-testing]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[test-automation]]></category>
            <category><![CDATA[playwrights]]></category>
            <category><![CDATA[web-development]]></category>
            <dc:creator><![CDATA[Prince Soni]]></dc:creator>
            <pubDate>Thu, 11 Mar 2021 11:36:10 GMT</pubDate>
            <atom:updated>2021-03-11T14:28:04.924Z</atom:updated>
            <content:encoded><![CDATA[<p><em>Playwright enables reliable end-to-end testing for modern web apps.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_DVJxVjB1Tto1mE8JBe0cQ.gif" /><figcaption><a href="https://playwright.dev/">Playwright</a></figcaption></figure><p>In recent years, we have witnessed major changes in web development technology, web browser vendors are now more aligned towards the <strong>JavaScript</strong> engine, and websites these days are often referred to as <strong>Web Apps</strong>. These apps are running across multiple devices and on different browsers. Hence web developers and testers are now more committed to <strong>cross-browser</strong> and <strong>end-to-end</strong> testing of web apps in every release cycle. <a href="https://en.wikipedia.org/wiki/Single-page_application"><strong>Single Page Apps</strong></a> and <a href="https://en.wikipedia.org/wiki/Progressive_web_application"><strong>Progressive Web Apps</strong></a> are the two major evolution&#39;s in the current scenario.</p><p>In reality, it is difficult to test the web app in all major browsers and match the expected result, as one <strong>web element</strong> may work perfectly on one browser but can give weird behavior on another browser. Recently I’ve come across a new test automation tool — “<a href="https://playwright.dev/"><strong>Playwright</strong></a>” which efficiently handles the cross-browser end-to-end tests. It can be used for browser automation by <strong>developers</strong> and as an end-to-end test automation tool for <strong>testers</strong>.</p><p>So what are we waiting for? Let’s get deep dive into it!</p><h3>Introduction and Setup</h3><p>Playwright is a <a href="https://nodejs.org/en/"><strong>Node.js</strong></a> library to automate <a href="https://www.chromium.org/Home">Chromium</a>, <a href="https://www.mozilla.org/en-US/firefox/new/">Firefox</a>, and <a href="https://webkit.org/">WebKit</a> with a single API. It is built to enable cross-browser web automation that is ever-green, capable, reliable, and fast. Playwright is the successor of “<a href="https://pptr.dev/"><strong>Puppeteer</strong></a>” and created by the same people who created the predecessor. With Playwright API, you can write JavaScript code to create new browser pages, navigate to URLs and then interact with elements on a page.</p><blockquote><strong>Puppeteer</strong> supports only <strong>chrome</strong> browser family whereas <strong>Playwright</strong> supports <strong>multiple</strong> browsers.</blockquote><p>To install the tool, write the following command in a terminal:</p><pre>$ npm i -D playwright</pre><blockquote>here <strong>i</strong> and <strong>-D</strong> are the shorthand for install and — save-dev.</blockquote><p>This single command downloads the Playwright NPM package and browser binaries for <strong>Chromium</strong>, <strong>Firefox</strong>, and <strong>WebKit</strong>.</p><p>Now create a directory, navigate into it, and do npm init (create a package.json with default options)</p><pre>npm init -y</pre><p>I am a huge fan of behavior-driven testing so couldn&#39;t resist giving it a <strong>BDD</strong> flavor. We can use <a href="https://www.npmjs.com/package/@cucumber/cucumber"><strong>cucumber.js</strong></a><strong> </strong>as a <strong>test runner </strong>by installing it as a dev dependency:</p><pre>npm i -D @cucumber/cucumber</pre><p><strong>Voila! </strong>We have now successfully installed Playwright with Cucumber.</p><h3>Core Concepts</h3><ul><li>Browser, Context, and Page</li><li>Cross-Browser Testing</li><li>Auto-waiting</li><li>Page Object Models</li><li>Screenshots and Video</li><li>Continuous Integration</li></ul><h4>Browser, Context, and Page</h4><p>In Playwright, a <a href="https://playwright.dev/docs/api/class-browser"><strong>Browser</strong></a> refers to an instance of Chromium, Firefox, or WebKit. Playwright scripts generally start with launching a browser instance and end with closing the browser.</p><p>A <a href="https://playwright.dev/docs/api/class-browsercontext"><strong>BrowserContext</strong></a> is an isolated incognito-alike session within a browser instance. Browser contexts are fast and cheap to create. Browser contexts can be used to parallelize isolated test executions:</p><p>A browser Context can have multiple pages. A <a href="https://playwright.dev/docs/api/class-page"><strong>Page</strong></a> refers to a single tab or a popup window within a browser context. It should be used to navigate to URLs and interact with the page content.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/65347cb53ed1760d740d99cc38b59e72/href">https://medium.com/media/65347cb53ed1760d740d99cc38b59e72/href</a></iframe><h4>Cross-Browser Testing</h4><p>Playwright can test web apps across multiple browsers: Chromium-based browsers like <strong>Google Chrome</strong> and the <strong>new Microsoft Edge</strong>, WebKit-based <strong>Apple Safari,</strong> and the Gecko-based <strong>Mozilla Firefox. </strong>The good thing about Playwright is, we <strong>don&#39;t</strong> need to <strong>close the test session</strong> (for the next browser) to perform cross-browser tests. This feature makes the tool unique from the current generation automation tools.</p><p>let see the code below which run’s the cross-browser test and takes the screenshot for each page:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/1f2cad9e40d201b61bfab4ce77056760/href">https://medium.com/media/1f2cad9e40d201b61bfab4ce77056760/href</a></iframe><h4>Auto-waiting</h4><p>Playwright performs a range of actionability checks on the elements before making actions to ensure these actions behave as expected. It auto-waits for all the relevant checks to pass and only then performs the requested action. If the required checks do not pass within the given timeout, the action fails with the TimeoutError.</p><p>For example, on <a href="https://playwright.dev/docs/api/class-page#pageclickselector-options">page.click(selector[, options])</a>, Playwright will ensure that:</p><ul><li>element is <a href="https://playwright.dev/docs/actionability?_highlight=wait#attached">Attached</a> to the DOM</li><li>element is <a href="https://playwright.dev/docs/actionability?_highlight=wait#visible">Visible</a></li><li>element is <a href="https://playwright.dev/docs/actionability?_highlight=wait#stable">Stable</a>, as in not animating or completed animation</li><li>element <a href="https://playwright.dev/docs/actionability?_highlight=wait#receives-events">Receives Events</a>, as in not obscured by other elements</li><li>element is <a href="https://playwright.dev/docs/actionability?_highlight=wait#enabled">Enabled</a></li></ul><h4>Page-Objects</h4><p>Page Object is a Design Pattern that has become popular in test automation for enhancing test maintenance and reducing code duplication. A page object is an object-oriented class that serves as an interface to a page of your AUT. The tests then use the methods of this page object class whenever they need to interact with the UI of that page. The benefit is that if the UI changes for the page, the tests themselves don’t need to change, only the code within the page object needs to change. Subsequently, all changes to support that new UI are located in one place.</p><p>An example I’ve created for Login Page:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/25ae3da7fc7e49ed7d14bcf09890f34b/href">https://medium.com/media/25ae3da7fc7e49ed7d14bcf09890f34b/href</a></iframe><p>and here is how I’ve used these page methods in my step definition file. This way my code looks cleaner, simple, and reusable.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b360e62735dcb63b9e3d1476f8c024d5/href">https://medium.com/media/b360e62735dcb63b9e3d1476f8c024d5/href</a></iframe><h4>Screenshots and Video</h4><p>There is three-way in which we can capture an application state with Playwright.</p><ul><li>Full Page screenshot</li><li>Element screenshot</li><li>Capture into a buffer</li></ul><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fcarbon.now.sh%2Fembed%3Fbg%3Drgba%2528171%252C%2B184%252C%2B195%252C%2B1%2529%26t%3Dseti%26wt%3Dsharp%26l%3Djavascript%26ds%3Dtrue%26dsyoff%3D20px%26dsblur%3D68px%26wc%3Dtrue%26wa%3Dtrue%26pv%3D0px%26ph%3D0px%26ln%3Dfalse%26fl%3D1%26fm%3DHack%26fs%3D14px%26lh%3D133%2525%26si%3Dfalse%26es%3D2x%26wm%3Dfalse%26code%3D%25252F%25252F%252520Quick%252520way%252520to%252520capture%252520a%252520screenshot%252520and%252520save%252520it%252520into%252520a%252520file%25250Aawait%252520page.screenshot%2528%25257B%252520path%25253A%252520%2527screenshot.png%2527%252520%25257D%2529%25250Aawait%252520page.screenshot%2528%25257B%252520path%25253A%252520%2527screenshot.png%2527%25252C%252520fullPage%25253A%252520true%252520%25257D%2529%25253B%25250A%25250A%25252F%25252F%252520Element%252520screenshot%25250Aconst%252520elementHandle%252520%25253D%252520await%252520page.%252524%2528%2527.header%2527%2529%25253B%25250Aawait%252520elementHandle.screenshot%2528%25257B%252520path%25253A%252520%2527screenshot.png%2527%252520%25257D%2529%25253B%25250A%25250A%25252F%25252F%252520Save%252520into%252520the%252520buffer%252520for%252520post%252520processing%252520and%252520diff%25252Fcompare%25250Aconst%252520buffer%252520%25253D%252520await%252520page.screenshot%2528%2529%25253B%25250Aconsole.log%2528buffer.toString%2528%2527base64%2527%2529%2529%25253B%25250A&amp;display_name=Carbon&amp;url=https%3A%2F%2Fcarbon.now.sh%2F%3Fbg%3Drgba%252528171%25252C%2B184%25252C%2B195%25252C%2B1%252529%26t%3Dseti%26wt%3Dsharp%26l%3Djavascript%26ds%3Dtrue%26dsyoff%3D20px%26dsblur%3D68px%26wc%3Dtrue%26wa%3Dtrue%26pv%3D0px%26ph%3D0px%26ln%3Dfalse%26fl%3D1%26fm%3DHack%26fs%3D14px%26lh%3D133%252525%26si%3Dfalse%26es%3D2x%26wm%3Dfalse%26code%3D%2525252F%2525252F%25252520Quick%25252520way%25252520to%25252520capture%25252520a%25252520screenshot%25252520and%25252520save%25252520it%25252520into%25252520a%25252520file%2525250Aawait%25252520page.screenshot%252528%2525257B%25252520path%2525253A%25252520%252527screenshot.png%252527%25252520%2525257D%252529%2525250Aawait%25252520page.screenshot%252528%2525257B%25252520path%2525253A%25252520%252527screenshot.png%252527%2525252C%25252520fullPage%2525253A%25252520true%25252520%2525257D%252529%2525253B%2525250A%2525250A%2525252F%2525252F%25252520Element%25252520screenshot%2525250Aconst%25252520elementHandle%25252520%2525253D%25252520await%25252520page.%25252524%252528%252527.header%252527%252529%2525253B%2525250Aawait%25252520elementHandle.screenshot%252528%2525257B%25252520path%2525253A%25252520%252527screenshot.png%252527%25252520%2525257D%252529%2525253B%2525250A%2525250A%2525252F%2525252F%25252520Save%25252520into%25252520the%25252520buffer%25252520for%25252520post%25252520processing%25252520and%25252520diff%2525252Fcompare%2525250Aconst%25252520buffer%25252520%2525253D%25252520await%25252520page.screenshot%252528%252529%2525253B%2525250Aconsole.log%252528buffer.toString%252528%252527base64%252527%252529%252529%2525253B%2525250A&amp;image=https%3A%2F%2Fcarbon.now.sh%2Fstatic%2Fbrand%2Fbanner.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;scroll=auto&amp;schema=carbon" width="1024" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/d9a413cafcb7d005c2a630b5bb2db998/href">https://medium.com/media/d9a413cafcb7d005c2a630b5bb2db998/href</a></iframe><h4>Continuous Integration</h4><p>Running the Playwright tests in a CI server is quite easy and can be divided into 3 sections:</p><ul><li>First, we need to make sure that CI agents can run browsers: Use P<a href="https://playwright.dev/docs/docker">laywright Docker image</a> in Linux agents. Windows and macOS agents do not require any additional dependencies.</li><li>Install Dependencies: <strong>$ <em>npm install</em></strong><em> or </em><strong><em>$ npm ci</em></strong></li><li>Run the tests: <strong><em>$ npm test</em></strong></li></ul><h4>CI Configuration</h4><ol><li><strong>Github Action</strong>: Here is how I’ve created a YAML file with the below code and placed it in the .github/workflow directory.</li></ol><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b045b793fadfba2dad322803c2961185/href">https://medium.com/media/b045b793fadfba2dad322803c2961185/href</a></iframe><p>2. <strong>Jenkins: </strong>Jenkins supports Docker agents for pipelines. Use can use the <a href="https://playwright.dev/docs/docker">Playwright Docker image</a> to run tests on Jenkins. Below is the pipeline flow in a <a href="https://www.jenkins.io/doc/book/pipeline/jenkinsfile/">.jenkinfile</a></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d911201182f7c05f9daf0325a2e32679/href">https://medium.com/media/d911201182f7c05f9daf0325a2e32679/href</a></iframe><h4>Final Thought</h4><p>Playwright belongs to the modern generation test automation tools family and is quite useful in cross-browser testing especially for WebKit (safari browser). It has a <a href="https://playwright.dev/docs/cli?_highlight=comman#generate-code"><strong>CLI tool</strong></a> also which generates the code for test automation. With a <a href="https://hub.docker.com/_/microsoft-playwright"><strong>docker image</strong></a>, this can be easily integrated with different CI tools. Well, this was pretty much about the tool and its basic features.</p><p>If you are looking for BDD test support with Playwright and want to generate the cucumber HTML report with the failure screenshot attached and run your test cases on every push to the git branch, then you may wanna check out my <a href="https://github.com/PrinceSoni83/playwright-cucumber-js-e2e-boilerplate"><strong>git repository</strong></a><strong>. </strong>It has all the examples I have explained in this post.</p><blockquote>Thanks for reading! If you think that this post is useful for your next automation setup with playwright, then please click a few <strong>“clap”</strong> below and leave any feedback or questions in the comments section.</blockquote><blockquote><strong>Source Code</strong>: <a href="https://github.com/PrinceSoni83/playwright-cucumber-js-e2e-boilerplate">https://github.com/PrinceSoni83/playwright-cucumber-js-e2e-boilerplate</a></blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=59ccc06b4356" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to Fast-track the Testing Process with Cypress]]></title>
            <link>https://prince83.medium.com/how-to-fast-track-the-testing-process-with-cypress-215c4d1dd99b?source=rss-8d981a4c52fe------2</link>
            <guid isPermaLink="false">https://medium.com/p/215c4d1dd99b</guid>
            <category><![CDATA[e2e-testing]]></category>
            <category><![CDATA[best-practices]]></category>
            <category><![CDATA[cypress]]></category>
            <category><![CDATA[test-automation]]></category>
            <category><![CDATA[software-testing]]></category>
            <dc:creator><![CDATA[Prince Soni]]></dc:creator>
            <pubDate>Sat, 16 Jan 2021 14:41:10 GMT</pubDate>
            <atom:updated>2021-01-16T14:41:10.475Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*g3w7F-B8tcsjKJ9smneMkQ.jpeg" /></figure><p>Testing is an integral part of the Software Development Lifecycle but fast cycle time and software testing often at odds in many organizations. The main challenge is in today’s fast-paced agile development, testing must be completed in a small-time period as possible without compromising the product quality.</p><p>As the application grows and new features get added up in each release, the manual test case stack increase. Along with this the <strong>Regression Testing</strong> cycle also expands, which leads to a delay in getting testing feedback and leaves less time for potential issue resolution. In this scenario, <strong>Test Automation</strong> has a vital role to play as it not only reduces the testing cycle but also allows QA and Dev team to focus on the new feature.</p><p>In this blog post, I’ve picked <a href="https://www.cypress.io/"><strong>Cypress</strong></a> as a test automation tool which is a <strong>JavaScript End-to-End Testing Framework</strong> that makes it really simple to set up, write, run, and debug tests. With Cypress, we do not need to <strong>reinvent the wheel</strong> as it already comes with its own setup which significantly reduces the tool configuration time and complexity. Let&#39;s discuss further what are the key things Cypress offers us for <strong>better</strong> and <strong>faster</strong> testing.</p><ol><li>Ease of use</li><li>Cross-browser Testing</li><li>Parallel Testing</li><li>Flaky Test Management</li><li>Organising Test Scenario’s</li></ol><h3>Ease of use</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qcgOna_X-HHqwpcb_wnv-g.png" /><figcaption>How Cypress works, Source: <a href="https://www.cypress.io/how-it-works/">Cypress.io</a></figcaption></figure><p>Cypress can be easily installed with npm or yarn :</p><p><em>Install Cypress via</em> <strong>npm</strong> :</p><pre>$ cd /your/prodject/path</pre><pre>$ npm install cypress --save-dev</pre><p><em>Install Cypress via </em><strong>yarn</strong> :</p><pre>$ cd /your/prodject/path</pre><pre>$ yarn add cypress --dev</pre><p>This will install Cypress locally as a dev dependency for your project.</p><p><em>Launch Cypress</em>:</p><p>by using npx</p><pre>$ npx cypress open</pre><p>or by using yarn</p><pre>yarn run cypress open</pre><p>After a moment, the Cypress Test Runner will launch.</p><p><em>Write your first test:</em></p><blockquote>Open up your favourite IDE (mine is VS Code 😎) and create a test spec file first_spec.js and add the below code:</blockquote><pre>describe(&#39;My First Test&#39;, () =&gt; { <br>  it(&#39;Does not do much!&#39;, () =&gt; {  <br>   expect(true).to.equal(true)<br>   })<br> })</pre><p>Although it doesn’t do anything useful, this is your first passing test! ✅</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/447/1*iAMYMHAl7WtirRdZEmIBAg.png" /></figure><blockquote>here are the self-explanatory details on writing tests in Cypress — <a href="https://docs.cypress.io/guides/getting-started/writing-your-first-test.html#Add-a-test-file">Writing your first test</a></blockquote><h3>Cross-Browser Testing</h3><p>Testing the app on multiple browsers to make sure the app is working in the same way in each browser <em>could </em><strong><em>be a drag on</em></strong> the overall testing time. Thankfully, Cypress has support for<strong> </strong><a href="https://docs.cypress.io/guides/guides/launching-browsers.html#Chrome-Browsers"><strong>Chrome-family browsers</strong></a> (including Electron and Chromium-based Microsoft Edge), and Firefox.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/912/0*V0v6HAWMmeHw_k00.png" /><figcaption>Cross-Browser Support</figcaption></figure><p>In <strong>headless</strong> mode, the desired browser can be specified via --browser flag when using run command.</p><pre>$ cypress run --browser <em>your-browser-for-test</em></pre><p>npm scripts can be used as a shortcut for launching Cypress with a specific browser:</p><pre>&quot;scripts&quot;: {<br>   &quot;cy:run:chrome&quot;: &quot;cypress run --browser chrome&quot;, <br>   &quot;cy:run:firefox&quot;: &quot;cypress run --browser firefox&quot;<br> }</pre><h3>Parallel Testing</h3><p>This is a great way of reducing the overall test execution time, only when the tests are designed independent of each other. Running tests in parallel across many virtual machines can save your team time and money when running in <strong>Continuous Integration (CI)</strong>. Once multiple machines are available within your CI environment, you can pass the <a href="https://docs.cypress.io/guides/guides/command-line.html#cypress-run-parallel">--parallel</a> key to <a href="https://docs.cypress.io/guides/guides/command-line.html#cypress-run">cypress run</a> to have your recorded tests parallelized.</p><pre>$ cypress run --record --key=abc123 --parallel--record</pre><blockquote>Passing the — record<a href="https://docs.cypress.io/guides/guides/command-line.html#Commands"><strong>flag</strong></a> ensures that Cypress can properly collect the data needed to parallelize future runs.</blockquote><h3>Flaky Test Management</h3><blockquote>What is a flaky test?</blockquote><blockquote>A test is considered to be flaky when it can pass and fail across multiple retry attempts without any code changes.</blockquote><p>A <strong>Flaky</strong> test could cause serious problems to the overall test results if not handled properly. Other <strong>tests</strong>, and even the entire <strong>test</strong> <strong>suite</strong>, can also be collateral damage.</p><p>Cypress has the ability to automatically <strong>retry</strong> failed tests to mitigate flaky tests from failing entire test runs or CI builds.</p><p><a href="https://docs.cypress.io/faq/questions/dashboard-faq.html#What-is-the-Dashboard"><strong>Cypress Dashboard</strong></a> provides birds-eye-view on the state of flake within your project by showing:</p><ul><li>Plot of the number of flaky tests over time.</li><li>Overall flakiness level of the entire project.</li><li>Number of flake tests grouped by their severity.</li><li>Filterable log of all flaky test cases ordered by severity.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8gJK9Cj6IY7Bk2nib_qFxw.png" /></figure><h3>Organise Test Scenario’s</h3><p>“<strong><em>Don’t Automate the test cases, but Automate the Scenario or Flow</em></strong>” as it is impossible to automate all testing. What is important for a good quality build is that it is covered by the <strong>high-risk</strong> scenarios (which takes a lot of effort and time when manual testing.) Further to this, it’s a good practice to assign the “type” to each test scenario. Let’s see how can we configure to run multiple test or type of tests in Cypress:</p><p>Run tests specifying multiple test files to run:</p><p>$ cypress run --spec &lt;spec1.js,spec2.js....&gt;</p><p>Run tests within the folder matching the glob:</p><p>$ cypress run --spec &quot;cypress/integration/login/**/*&quot;</p><p>Add a tag or tags to the recorded run. This can be used to help identify separate runs when displayed in the Dashboard.</p><pre>$ cypress run --record --tag &quot;staging&quot;<br>$ cypress run --record --tag &quot;production,nightly&quot;<br>$ cypress run --record --tag &quot;smoke&quot;</pre><p>This approach will ensure that a potentially critical issue will be found way faster and the results will be provided in a timely manner.</p><h3>Conclusion</h3><p>The key benefit of minimizing the test cycle is the additional time gained that can be directed towards the completion of other testing activities, thereby increasing the overall quality of the product, improving test coverage. Though the prospect of reducing test run time may be daunting, by focusing on a limited set of key features and best automation practices mentioned in this post, the end goal of shorter, more stable tests is indeed attainable. Test Automation using Cypress has many more benefits like the <a href="https://www.cypress.io/blog/2020/11/24/introducing-cy-intercept-next-generation-network-stubbing-in-cypress-6-0/#header">Next Generation Network Stubbing</a>, <a href="https://docs.cypress.io/guides/tooling/visual-testing.html#Functional-vs-visual-testing">Visual Testing</a>, <a href="https://docs.cypress.io/guides/tooling/reporters.html#Custom-reporter">Custom Reporting</a>, <a href="https://docs.cypress.io/guides/guides/screenshots-and-videos.html#Screenshots">Screenshot and Video</a>s, and so on which will once included in practice, surely helps in reducing Test Life Cycle.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=215c4d1dd99b" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>