<?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 Alpana Mishra on Medium]]></title>
        <description><![CDATA[Stories by Alpana Mishra on Medium]]></description>
        <link>https://medium.com/@alpanamishra2009?source=rss-239e92e34db9------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*QwAHQqPqY0-9npm_pCefzg.jpeg</url>
            <title>Stories by Alpana Mishra on Medium</title>
            <link>https://medium.com/@alpanamishra2009?source=rss-239e92e34db9------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 02 Dec 2026 08:42:14 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@alpanamishra2009/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[A Practical Guide to .nth() and :nth-child() for writing reliable Playwright tests]]></title>
            <link>https://medium.com/@alpanamishra2009/a-practical-guide-to-nth-and-nth-child-for-writing-reliable-playwright-tests-ae599cce371c?source=rss-239e92e34db9------2</link>
            <guid isPermaLink="false">https://medium.com/p/ae599cce371c</guid>
            <category><![CDATA[css-nth-child]]></category>
            <category><![CDATA[how-nth-child-works]]></category>
            <category><![CDATA[playwright-nth]]></category>
            <category><![CDATA[nth-child]]></category>
            <dc:creator><![CDATA[Alpana Mishra]]></dc:creator>
            <pubDate>Wed, 11 Feb 2026 16:51:53 GMT</pubDate>
            <atom:updated>2026-02-11T17:51:10.668Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6ezMZouIoIFNuf1jZUJq6Q.png" /></figure><p>When writing automated tests in Playwright, selecting the correct element is often more challenging than it first appears. Modern web applications generate dynamic content and frequently update their DOM structure. Choosing the wrong strategy can introduce fragile tests that fail with even minor structural changes.</p><p>A common scenario is when testing web applications, it often involves dealing with lists of elements — menus, links, buttons, or table rows. Sometimes, we want to select the second link in a navigation bar or the third button in a list or a specific row in a table.</p><p>Playwright provides multiple ways to do this:</p><ul><li>Using <strong>Playwright-specific locators</strong> with .nth()</li><li>Using <strong>CSS pseudo-classes</strong> like :nth-child()</li></ul><p>Although they seem similar, .nth() and :nth-child() approaches operate on fundamentally different principles. One depends strictly on DOM hierarchy, while the other works within the result set of matched elements. Understanding this distinction is essential for writing stable automation tests.</p><p>This article explores how .nth() and :nth-child() differ, when to use each one, and how this understanding improves the reliability of Playwright test suite.</p><h3>How .nth() Works in Playwright</h3><p>Playwright’s .nth() method lets you pick an element based on its position among elements that match your locator.</p><p><strong>Things to understand about .nth():</strong></p><ul><li>Indexing starts at zero, so .nth(0) is the first element.</li><li>It only counts elements that match your locator, ignoring other tags or elements.</li><li>Because of this, it is very reliable on dynamic pages where extra elements might appear.</li></ul><p>For Example:</p><p>Consider the following simplified HTML structure (without &lt;li&gt; elements for clarity):</p><pre>&lt;ul&gt;<br>  &lt;a href=&quot;#&quot;&gt;Placeholder&lt;/a&gt;<br>  &lt;a href=&quot;&quot;&gt;Username&lt;/a&gt;<br>  &lt;a href=&quot;/logout&quot;&gt;Sign out&lt;/a&gt;<br>&lt;/ul&gt;</pre><p>To select the Username link, we might write the Playwright locator as:</p><pre>const usernameLink = page.locator(&#39;ul a&#39;).nth(1)</pre><p>Output : This selects the second &lt;a&gt; element — “Username.”</p><p><strong>How Playwright Executes .nth()</strong></p><p>This locator statement does not immediately resolve to a single element. Instead, page.locator(‘ul a’) creates a locator representing all &lt;a&gt; elements inside &lt;ul&gt;, and .nth() narrows that result to a specific match.</p><p>An important detail to understand is that .nth() does not immediately query the DOM when it is written. Playwright locators are lazy and are resolved only when an action is performed such as .click(), .fill(), or .innerText().</p><p>This built-in waiting mechanism makes .nth() particularly reliable in dynamic applications where elements may not be immediately available.</p><p>Now, a common question at this stage is: Why does it select the second element from the filtered result set? Why not the first? I specified .nth(1), so shouldn’t it fetch the first element?</p><p>The reason is, .nth() uses zero-based indexing (counting starts from 0, not 1). As a result, .nth(0) refers to the first matched element in the locator result set.</p><p>Accordingly:</p><ul><li>.nth(0) → first match (i.e. Placeholder, in the above example)</li><li>.nth(1) → second match (i.e. Username)</li><li>.nth(2) → third match (i.e. Sign out)</li></ul><p>Even if additional elements such as &lt;span&gt; or &lt;div&gt; are inserted before it, the targeted &lt;a&gt; element remains unaffected. This is because .nth() operates on the filtered set of matching elements rather than the overall DOM structure.</p><h3>Understanding :nth-child() in CSS</h3><p>:nth-child() is a CSS pseudo-class, not specific to Playwright. It selects an element based on its exact position among all children of its parent.</p><p><strong>Things to understand about .nth-child():</strong></p><ul><li>Indexing is one-based, so :nth-child(1) is the first child.</li><li>It counts all children, not just the ones matching a particular tag.</li><li>If other elements (like &lt;span&gt; or &lt;div&gt;) are added, it may no longer select the element you expect.</li></ul><p>For Example:</p><p>Consider the following HTML:</p><pre>&lt;ul&gt;<br>  &lt;span&gt;Logo&lt;/span&gt;          <br>  &lt;a href=&quot;#&quot;&gt;Placeholder&lt;/a&gt;  <br>  &lt;a href=&quot;&quot;&gt;Username&lt;/a&gt;     <br>  &lt;a href=&quot;/logout&quot;&gt;Sign out&lt;/a&gt;<br><br>&lt;/ul&gt;</pre><p>To select the Username link looking at the HTML structure we might write the locator as:</p><pre>const usernameLink = page.locator(&#39;ul a:nth-child(2)&#39;);</pre><p>Output : It will select second child from the parent i.e. &lt;a&gt; of “ Placeholder” not “Username”.</p><p>But why?</p><p>Because, the locator we specified for this case is :nth-child(2), which means — Select the element that is the second child of its parent. It does not mean “second &lt;a&gt;.”</p><p>Indexing for nth-child() is one-based and looks like below:</p><pre>&lt;ul&gt;<br>  &lt;span&gt;Logo&lt;/span&gt;          &lt;!-- 1st child --&gt;<br>  &lt;a href=&quot;#&quot;&gt;Placeholder&lt;/a&gt;  &lt;!-- 2nd child --&gt;<br>  &lt;a href=&quot;&quot;&gt;Username&lt;/a&gt;     &lt;!-- 3rd child --&gt;<br>  &lt;a href=&quot;/logout&quot;&gt;Sign out&lt;/a&gt; &lt;!-- 4th child --&gt;<br><br>&lt;/ul&gt;</pre><p>In this case, &lt;span&gt; is the first child of &lt;ul&gt;. To select the Username link, the third child must be targeted. The corresponding Playwright locator would be:</p><pre> const usernameLink = page.locator(&#39;ul a:nth-child(3)&#39;);</pre><p>This time it will work and select Username — because &lt;a href=””&gt;Username&lt;/a&gt; is literally the third child of &lt;ul&gt;.</p><p>This is how nth-child() works.</p><p><strong>Let’s Introduce a Small DOM Change</strong></p><p>In real-world applications, markup often evolves. Designers might add icons, badges, or labels. Suppose the HTML changes like this:</p><pre>&lt;ul&gt;<br>&lt;span class=&quot;nav-label&quot;&gt;Account&lt;/span&gt;  &lt;!-- New element --&gt;<br>  &lt;div class=&quot;icon-wrapper&quot;&gt;&lt;/div&gt;        &lt;!-- Another new element --&gt;<br>  &lt;a href=&quot;#&quot;&gt;Placeholder&lt;/a&gt;<br>  &lt;a href=&quot;&quot;&gt;Username&lt;/a&gt;<br>  &lt;a href=&quot;/logout&quot;&gt;Sign out&lt;/a&gt;<br>&lt;/ul&gt;</pre><p>Now, if the same locator (as used above) is used after the DOM changes:</p><pre>const usernameLink = page.locator(&#39;ul a:nth-child(3)&#39;);</pre><p>This locator is pointing to the third child but now the third child is “Placeholder” instead of “Username”.</p><p>As a result, using a strict structural locator like :nth-child() can cause tests to fail or select the wrong element when the DOM changes slightly.</p><p>Take a look at the Playwright version of locator used above (nth):</p><pre>const usernameLink = page.locator(&#39;ul a&#39;).nth(1)</pre><p>The output is still “Username”, even after the DOM changed.</p><p><strong>Why does .nth() still works in this case?</strong> Here’s what happens:</p><ul><li>page.locator(‘ul a’) collects only the &lt;a&gt; elements</li><li>.nth(1) selects the second match from that filtered list</li><li>The &lt;span&gt; and &lt;div&gt; are completely ignored</li></ul><p>Even after adding new elements, .nth(1) still correctly selects &lt;a href=””&gt;Username&lt;/a&gt;, because .nth() operates on the matched result set, not on the raw DOM structure.</p><p><strong>When .nth() Can Fail</strong></p><p>While .nth() is generally safer than :nth-child(), it is not bulletproof. .nth() depends on the order of matching elements. If that order changes, your test may silently start targeting the wrong element. In the above example, if the order of &lt;a&gt; elements changes, .nth() will select a different element.</p><p><strong>When to avoid .nth()?</strong></p><p>.nth() becomes potentially fragile in the interfaces where:</p><ul><li>The order of elements is dynamic or user-driven</li><li>Items are sorted, filtered, or paginated</li><li>New elements may be inserted into the same group</li><li>Rendering order changes due to asynchronous updates</li></ul><p>In such cases, the selector may still resolve successfully, but it may interact with the wrong element — which can be harder to detect than a test failure.</p><h3>Conclusion</h3><p>Throughout this discussion, we’ve seen that :nth-child() is tied directly to DOM structure and uses one-based indexing, while .nth() operates on the filtered set of matched elements and uses zero-based indexing.</p><p>That distinction affects how stable your tests will be when the UI evolves. Small structural changes can break :nth-child(), while changes in element order can affect .nth().</p><p>The important learning is not that one is universally better than the other, but that both are position-based strategies. Position can be useful, but it should be chosen deliberately. When the position represents stable meaning in the interface, .nth() can be a practical and readable solution. When structure is guaranteed and predictable, :nth-child() may still be appropriate.</p><p>Reliable Playwright tests come from understanding the behavior behind your selectors. The more intentional you are with element selection, the fewer surprises you’ll face as the application grows and changes.</p><p>Mastering selector strategy is a small skill that makes a significant difference in long-term test stability!</p><p>Happy Learning :)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ae599cce371c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[A Beginner’s Guide to Setting Up SSH Keys for GitHub]]></title>
            <link>https://medium.com/@alpanamishra2009/a-beginners-guide-to-setting-up-ssh-keys-for-github-e8e60418c733?source=rss-239e92e34db9------2</link>
            <guid isPermaLink="false">https://medium.com/p/e8e60418c733</guid>
            <dc:creator><![CDATA[Alpana Mishra]]></dc:creator>
            <pubDate>Sat, 24 Jan 2026 00:15:53 GMT</pubDate>
            <atom:updated>2026-02-16T15:47:48.853Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KuKaEtJ_Al02NnOibOzU1w.png" /></figure><p>GitHub authentication has evolved over time, and passwords are no longer considered secure enough for daily Git operations. If you use GitHub regularly, you’ve probably been asked for a username, password while pushing code.</p><p>SSH (Secure Shell) is a protocol that allows you to securely connect and authenticate to remote servers and services. When used with GitHub, it lets GitHub recognize and trust your machine without repeatedly asking for credentials.</p><p><strong>What is an SSH Key?</strong></p><p>An SSH key acts like a digital identity for your machine. So instead of authenticating you every time, GitHub authenticates your machine. Your machine keeps a private key (which is secret) and GitHub stores a public key (which is safe to share).</p><p>In this blog, we’ll walk through how to set up an SSH key on a Windows laptop, step by step, in the simplest way possible. Let’s get started!</p><p><strong>Step 1: Open Git Bash</strong></p><p><strong>Step 2: Check if an SSH Key Already Exists</strong></p><p>Before creating a new key, check if your system already has one.</p><pre>ls ~/.ssh</pre><p>If the folder doesn’t exist, it simply means no SSH key has been created yet. This is normal and expected behaviour. Proceed to Step # 3.</p><p>Note: If the .ssh folder already exists, it simply means SSH has been used on this machine before. And as a result you may see id_ed25519 (Private Key) and id_ed25519.pub (Public Key).</p><p>In this case, you have two options:</p><ul><li>Reuse the existing key (skip to Step # 4)</li><li>Create a new key for a fresh setup (continue to Step # 3)</li></ul><p><strong>Step 3: Generate a new SSH key</strong></p><p>Create a new SSH key using the following command:</p><pre>ssh-keygen -t ed25519 -C &quot;your_email@example.com&quot;</pre><p>When prompted for the file location, press <strong>Enter</strong> to use the default.<br> You may also set a passphrase for extra security, but this step is optional.</p><p>Once the key is generated, the .ssh folder will be created automatically</p><p>Try looking for SSH folder again, Run:</p><pre>ls ~/.ssh</pre><p>Results will show something like:</p><pre>id_ed25519<br>id_ed25519.pub</pre><p>Two files are now created, id_ed25519 (Private Key) and id_ed25519.pub (Public Key — goes to GitHub). Never share your private key (id_ed25519). It should stay only on your local machine.</p><p><strong>Step 4: Start the SSH agent</strong></p><p>The SSH agent allows Git to use your key.</p><pre>eval &quot;$(ssh-agent -s)&quot;</pre><p>This command starts a helper program that keeps your keys ready for Git. You’ll see:</p><pre>Agent pid 1234</pre><p><strong>Step 5: Add the SSH key to the agent</strong></p><p>Run below command:</p><pre>ssh-add ~/.ssh/id_ed25519</pre><p>This command loads your private key into memory. If you have set a passphrase enter it now.</p><p><strong>Step 6: Copy the public SSH key</strong></p><p>Run below command:</p><pre>cat ~/.ssh/id_ed25519.pub</pre><p>This displays your public key. Copy the entire line that starts with “ssh-ed25519”</p><p><strong>Step 7: Add SSH key to GitHub</strong></p><ol><li>Go to github.com</li><li>Click your profile photo → Settings</li><li>Click SSH and GPG keys</li><li>Click New SSH key</li><li>Fill in the details:</li></ol><ul><li>Title: &lt;My Windows Laptop&gt;</li><li>Key type: Authentication Key</li><li>Key: Paste the copied key</li></ul><p>6. Click Add SSH key</p><p>7. On the prompted screen, enter the GitHub login password</p><p>SSH Keys will be displayed successfully on the GitHub account page.</p><p><strong>Step 8: Test the SSH connection</strong></p><p>Go to Git Bash. Run below command:</p><pre>ssh -T git@github.com</pre><p>If checking for the first time, you may see:</p><pre>Are you sure you want to continue connecting?</pre><p>Type “yes” for this question.</p><p>A success message will appear:</p><pre>Hi &lt;username&gt;! You&#39;ve successfully authenticated...</pre><p>Congratulations! SSH is working!</p><p>Once set up, SSH quietly works in the background — secure, fast, and hassle-free.</p><p>Hope you find this information helpful! Happy Learning :)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e8e60418c733" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Demystifying Browser Communication: Selenium and Playwright in Action]]></title>
            <link>https://medium.com/@alpanamishra2009/how-selenium-and-playwright-talk-to-the-browser-a-deep-dive-f5286d7bf654?source=rss-239e92e34db9------2</link>
            <guid isPermaLink="false">https://medium.com/p/f5286d7bf654</guid>
            <dc:creator><![CDATA[Alpana Mishra]]></dc:creator>
            <pubDate>Wed, 21 Jan 2026 02:12:46 GMT</pubDate>
            <atom:updated>2026-01-21T03:00:46.806Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kFllPzL-IOSz9xc0ZB2myg.png" /></figure><p>When people compare Selenium and Playwright, the conversation usually starts with speed, flakiness, or few survival tactics like adding waits, tuning timeouts, or constantly updating drivers frequently. But these are really just symptoms of something deeper not the root cause.</p><p>Selenium and Playwright don’t just look different at the API level — they talk to browsers in completely different ways.</p><p>At their core, these tools use very different browser communication models, WebDriver versus WebSocket based native protocols. That architectural choice explains why Selenium behaves the way it does, why Playwright feels more stable and deterministic, and why certain problems exist in one but not the other.</p><p>This blog focuses on that “under the hood” layer and why it matters more than most feature comparisons.</p><h3><strong>Selenium: Browser Communication via WebDriver (HTTP Request-Response)</strong></h3><p>Selenium is a widely used browser automation library. It allows user to interact with browsers using the WebDriver API.</p><p>Selenium uses the W3C WebDriver protocol to communicate with browsers.</p><p>Selenium uses a client-server architecture:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/780/1*uhSenG9f4qO8CDMzHvgyVw.png" /><figcaption>Selenium Architechture</figcaption></figure><ul><li><strong>Test Script </strong>-&gt; The automation code calls Selenium APIs such as click() and findElement().</li><li><strong>Selenium Client (WebDriver API) -</strong>&gt; The Selenium Client converts these API calls into standardized WebDriver commands and sends them to the browser driver using an HTTP request–response model defined by the W3C WebDriver specification.</li><li><strong>Browser Driver -</strong>&gt; A browser-specific driver (such as ChromeDriver or GeckoDriver) acts as the server side of the WebDriver protocol. It receives WebDriver commands from the Selenium Client and translates them into native browser actions.</li><li><strong>Browser</strong> -&gt; The browser executes the requested actions and returns a response. Selenium interacts with the browser through discrete, stateless commands rather than a persistent, real-time connection.</li></ul><p>Selenium implements the W3C WebDriver Standard, which modern browsers also support through their respective drivers. This ensures that browser commands and responses follow a consistent, standardized protocol. By adhering to this industry-wide specification, Selenium guarantees broad compatibility and reliable automation across multiple browsers. Hence, Selenium achieves a high level of uniformity and cross-browser compatibility, which is why it is often described as highly standardized.</p><p><strong>The Cost of the Driver Layer in Selenium</strong></p><p>Because communication is strictly request–response based, Selenium only learns about the browser’s state after explicitly asking for it.</p><p>The browser cannot proactively notify the test about DOM changes, rendering completion, or network activity. Selenium sees snapshots, not a live stream and hence it heavily relies on explicit waits or retry logic to ensure elements exist or are ready before interacting.</p><h3><strong>Playwright: Browser Communication via WebSocket (Persistent Connection)</strong></h3><p>Playwright is an integrated end-to-end testing framework. Playwright uses WebSocket to communicate directly with the browser process.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/672/1*2ib5Meuh3o5E9KSw2OcxAA.png" /><figcaption>Playwright Architechture</figcaption></figure><p>When you launch a browser, Playwright opens a WebSocket endpoint inside the browser.</p><ul><li><strong>Test Script </strong>-&gt; Test Script connects to that WebSocket endpoint.</li><li><strong>Playwright Engine</strong> -&gt; All commands (click(), fill(), navigate()) flow over the same open WebSocket.</li><li><strong>Browser</strong> -&gt; Browser can also push asynchronous events (like console logs, network requests) to the test script in real-time.</li></ul><p>WebSocket in Playwright allows direct, continuous communication with the browser, making tests faster and more reliable.</p><p>Playwright is slightly less standardized than Selenium as it’s mainly focused on Chromium, Firefox and Webkit. Describing Playwright as less standardized does not imply that it is unstable, unofficial, or unreliable. Instead, it reflects a fundamental architectural difference.</p><p>Playwright does not rely on a universal industry standard such as the W3C WebDriver specification. Rather than depending on browser-vendor-maintained drivers, Playwright implements its own automation layer using browser-specific automation APIs for modern browser engines such as Chromium, Firefox, and WebKit.</p><p>In practical terms, this means that:</p><ul><li>Playwright defines how automation commands are sent and handled</li><li>It communicates directly with the browser’s automation endpoints</li><li>It does not have to wait for official standards to be updated before adding new features or improvements.</li></ul><p>As a result, Playwright can adopt new browser capabilities more quickly that are difficult or limited when relying solely on the WebDriver standard.</p><h3>Conclusion</h3><p>Selenium and Playwright differ not just in features, but in how they communicate with the browser and that architectural choice directly shapes their performance, reliability, and synchronization behavior.</p><p>Once you understand how each tool talks to the browser, flakiness, waits, and speed stop being mysteries and start making architectural sense.</p><p>Hope you find this information useful! Happy Learning :)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f5286d7bf654" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Browser Installation and Version Management in Selenium and Playwright]]></title>
            <link>https://medium.com/@alpanamishra2009/how-selenium-and-playwright-handle-browser-installation-and-versions-cd75f61b638a?source=rss-239e92e34db9------2</link>
            <guid isPermaLink="false">https://medium.com/p/cd75f61b638a</guid>
            <dc:creator><![CDATA[Alpana Mishra]]></dc:creator>
            <pubDate>Tue, 20 Jan 2026 05:42:13 GMT</pubDate>
            <atom:updated>2026-01-21T03:04:48.629Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xxUHYcM1H_Ro-sOMxBWn4Q.png" /></figure><p>When it comes to automated testing, one of the most important differences between Selenium and Playwright is how they handle browser requirements on your machine. While both are capable of automating browsers, they handle browser management very differently — a factor that often trips up teams, especially when running tests across multiple machines or in CI/CD pipelines.</p><p>In this post, we’ll break down this key difference, how each tool handles browser installation, version control, and cross-browser testing and why it matters for consistent, reliable test automation.</p><h3><strong>Selenium and Local Browser Dependency</strong></h3><p>Selenium does not come with browsers. It expects a compatible browser to be already installed on your machine.</p><p>For example: if you want to test Chrome, you must have Chrome installed and its version must match the chromedriver you’re using.</p><p>This can lead to problems such as:</p><ul><li>Automatic browser updates : Modern browsers like Chrome update automatically in the background. When this happens, tests can break because the updated browser becomes incompatible with the existing ChromeDriver.</li><li>Inconsistent test behavior across machines : Because Selenium relies on the browser version installed on each machine, as a result, a test that passes on one machine may fail on another or in a CI environment.</li><li>Manual driver and version management : To run tests across multiple browsers for cross-browser testing, you must install and maintain each browser along with its corresponding driver.</li></ul><p>Newer versions of Selenium(4.6+) include Selenium Manager, which automatically detects the browser installed on your machine and download the compatible browser drivers.</p><p>However, Selenium Manager only manages drivers, not browsers. Selenium still relies on the browser version installed on the machine, meaning browser auto-updates and environment differences can still affect test stability.</p><h3>Playwright and Automatic Browser Installation</h3><p>Playwright adopts a fundamentally different approach to browser management as part of its design evolution. When you install it, Playwright downloads its own controlled versions of Chromium, Firefox, and WebKit. These versions are guaranteed to work with Playwright’s API.</p><p>You do not need to manually install browsers on your system in order to run tests. When you install Playwright, it automatically downloads and manages its own browser binaries (Chromium, Firefox, and WebKit) that are specifically built and tested to work with Playwright.</p><p>These browsers are stored inside the Playwright installation and are completely independent of any browsers you may already have on your machine. Even if Chrome is not installed or is installed with a different version, Playwright tests will still run without issues.</p><p>This means:</p><ul><li>Your local browser setup does not affect test execution</li><li>Browser updates on your machine do not break tests</li><li>The same browser versions are used across all environments</li></ul><h3><strong>Conclusion</strong></h3><p>Selenium automates the browsers already installed on your machine, whereas Playwright, by default, runs tests against its own bundled browser binaries to ensure consistency across environments.</p><p>This difference makes Playwright particularly well-suited for CI/CD pipelines and teams looking for predictable, low-maintenance test execution, while Selenium offers flexibility when testing against real, system-installed browsers.</p><p>Hope this information was helpful! Happy learning :)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=cd75f61b638a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Hooks vs Background in Playwright BDD: What Goes Where?]]></title>
            <link>https://medium.com/@alpanamishra2009/hooks-vs-background-in-playwright-bdd-what-goes-where-b308e635cee1?source=rss-239e92e34db9------2</link>
            <guid isPermaLink="false">https://medium.com/p/b308e635cee1</guid>
            <category><![CDATA[bdd]]></category>
            <category><![CDATA[test-automation]]></category>
            <category><![CDATA[beforehooks]]></category>
            <category><![CDATA[hooks]]></category>
            <category><![CDATA[playwrights]]></category>
            <dc:creator><![CDATA[Alpana Mishra]]></dc:creator>
            <pubDate>Mon, 19 Jan 2026 04:08:28 GMT</pubDate>
            <atom:updated>2026-01-24T17:20:36.397Z</atom:updated>
            <content:encoded><![CDATA[<h3><em>Hooks vs Background Given Steps in Playwright BDD: What Goes Where?</em></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9AFHbGNkJL7-9P7nDooc-g.png" /></figure><p>In Behaviour Driven Development (BDD), small design decisions can have an outsized impact on the long-term readability and maintainability of a test suite. <br>Early on, these decisions rarely feel important as tests are few, scenarios are simple, and almost any structure seems to work. <br>Over time, however, these choices shape how difficult it is to evolve the suite without introducing duplication or hidden dependencies.</p><p>One recurring question in Playwright BDD projects is: Where should Page Object instances be created — in a Before hook or inside Background Given step.</p><p>At first glance, both options seem reasonable. After all, both approaches work. Tests pass. The browser launches. The page loads. But architecturally, they are <strong>not equivalent</strong>, and choosing the wrong one may lead to brittle tests, hidden dependencies or unnecessary re-initialization.</p><p>In this article, we’ll look in detail what is the best approach and why.</p><h3>Understanding the Roles</h3><p>Before we answer where Page Objects belong, we must understand what problem each layer is trying to solve.</p><p><strong>Understanding the Intent of BDD : BDD Is About Behavior, Not Technical abstraction.</strong></p><p>Behaviour Driven Development (BDD) was never designed to describe technical steps like creating objects, initializing dependencies. It is about specification.<br>Gherkin was designed to express system behavior in a way that is readable by developers, testers, and non-technical stakeholders alike.</p><p>That’s why Gherkin uses plain English sentences like below:</p><pre>  @smoke<br>  Scenario: User successfullly logs into the application<br>    Given the user is on the login page<br>    When the user logs into the application<br>    Then the user sees the dashboard</pre><p>These statements describe the intent, not procedure. They describe what is true, not how it is implemented.</p><p><strong>Page Objects Are a Technical Abstraction</strong></p><p>A Page Object is not a behaviour. It is a design pattern. Its one of the main purposes is to hide locator complexity, provide reusable UI actions, acts as a boundary between tests and DOM structure.</p><p><strong>The Temptation to create Page Objects in Background Given step</strong></p><p>A Background runs before every scenario, so it may seem convenient to create Page Object instances here. You might write something like:</p><pre>Background<br>Given the user is on the login page</pre><p>And in the step definition:</p><pre>Given(&#39;user is on the login page&#39;, async function ({page}) {<br>     this.loginPage = new loginPage(page);<br>     await this.loginPage.gotoLoginPage();<br>});</pre><p>At a glance, this seems reasonable. The Page Object is ready, the login page is open and scenarios can continue. So why this is a problem?</p><p><strong>The problem: An Architectural Mismatch with BDD Principles</strong></p><p><strong>1. You Are Encoding Technical Abstraction Inside Behavior</strong></p><p>The moment you instantiate a Page Object inside a Background Given step, you are no longer describing behavior you are building test middleware.</p><p>Step definitions are not just random automation code. They are the formal binding between:</p><ul><li>Business language</li><li>Technical implementation</li></ul><p>The sentence “Given the user is on the login page” now secretly means “Create a LoginPage object, bind it to the Playwright page, and navigate to a URL”. When you write “Given user is on the login page” the semantic BDD contract of that step is “The application is currently showing login page”. Nothing more than that.</p><p><strong>2. Hidden Dependencies Between Steps</strong></p><p>When the step definition does this</p><pre>Given(&#39;user is on the login page&#39;, async function ({page}) {<br>     this.loginPage = new loginPage(page);<br>     await this.loginPage.gotoLoginPage();<br>});</pre><p>You have now added extra responsibilities to the step that are not part of its semantic contract:</p><ol><li>It initializes automation middleware</li><li>It becomes a provider of shared objects</li><li>Other steps now depend on it having run</li></ol><p>This Given step has now has hidden implicit dependency “The login object must already exist even before the login page is open.” Other steps now depend on this specific Given step having executed.</p><p>This is a classic example of implicit coupling, and it is one of the biggest causes of flaky and fragile test suites.</p><p><strong>3. Background becomes Setup Factory</strong></p><p>Over time, teams add more and more to Backgrounds:</p><ul><li>Page objects</li><li>Test data</li><li>API calls</li></ul><p>Eventually, the Background stops being a shared behavior in true essence and rather secretly becomes a hidden setup script.</p><p>And when a Given step becomes a setup factory, the step no longer only assumes state it creates test middleware. And when this happens, debugging becomes painful and reusing becomes dangerous. That breaks the fundamental model of BDD, even if the feature file text still looks clean.</p><h3><strong>The Correct Paradigm: Hooks Own Technical Abstraction</strong></h3><p>To fix the problem we discussed so far, we must move Page Object creation to the layer that owns technical abstraction : Hooks.</p><p>Hooks exist specifically to:</p><ul><li>Prepare the test environment</li><li>Initialize dependencies</li><li>Clean up afterward</li></ul><p>They are intentionally invisible to feature files and that is exactly what we want.</p><p>Creating objects in Before hooks is the best practice. A Before hook runs once per scenario, giving you a fresh state, test isolation and safe parallel execution.</p><pre>Before(async function ({ page }) {<br>    this.loginPage = new LoginPage(page);<br>});</pre><h3>Conclusion</h3><p>The apparent contradiction between “Before hooks prepare the test engine” and “Background prepares the user’s world” disappears once responsibilities are clearly separated.</p><p>Before hooks exist to prepare technical capabilities. Background exists to describe shared, user-visible conditions. Page Objects, despite modeling pages, are part of the test middleware and should be created in hooks, not in Background steps.</p><p>When these boundaries are respected, BDD tests become clearer, more stable, and easier to scale both for teams and for long-lived test suites.</p><p>Hope, you find this information useful. Happy BDDing!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b308e635cee1" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The JavaScript Import Mistake Every Beginner Makes]]></title>
            <link>https://medium.com/@alpanamishra2009/the-javascript-import-mistake-every-beginner-makes-55021c6f3f8e?source=rss-239e92e34db9------2</link>
            <guid isPermaLink="false">https://medium.com/p/55021c6f3f8e</guid>
            <dc:creator><![CDATA[Alpana Mishra]]></dc:creator>
            <pubDate>Mon, 22 Dec 2025 17:32:44 GMT</pubDate>
            <atom:updated>2026-01-19T15:56:58.025Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iD8rj0blrWM0pC1n3-ZDpQ.png" /></figure><p>You import a JavaScript file expecting to use a single function — and suddenly, a while loop starts running. If this has ever confused you, you’re not alone.</p><p>When learning JavaScript, importing files often feels simple at first — you expect to bring in a function and use it when needed. However, many beginners are surprised when <strong>code from an imported file runs automatically</strong>, even when they never explicitly call it.</p><p>This confusion usually shows up when:</p><ul><li>A while loop runs unexpectedly</li><li>Console messages appear before your main code runs</li><li>Output seems duplicated or out of order</li><li>Terminal is showing output for functions which were never called in the current file (where user is trying to import )</li></ul><p>These issues are not bugs. They happen because of how <strong>JavaScript ES modules are designed to work</strong>. Any code written outside a function is called <strong>top-level code</strong>, and JavaScript executes it immediately when the module is imported</p><p>Understanding this behavior early is important because:</p><ul><li>It helps you write <strong>cleaner, predictable code</strong></li><li>It prevents <strong>unexpected execution</strong></li><li>It teaches proper <strong>module structure and separation of logic</strong></li></ul><p>In this blog, we’ll look at <strong>why imported JavaScript files execute automatically</strong>, what “top-level code” means, and how to structure your modules so that <strong>only the code you want runs</strong>.</p><h3>Understanding JavaScript Imports</h3><p>In JavaScript, when you write:</p><pre>import { goToSleep, pet } from &#39;./Assignment02B_PetSimulator.js&#39;</pre><p>You might expect that <strong>only the exported function</strong> (goToSleep) will run.</p><p>But that’s <strong>not how JavaScript works</strong>.</p><p>The important rule here is, when a JavaScript file is imported, the entire file is executed from top to bottom.</p><p>This means:</p><ul><li>JavaScript does <strong>not</strong> import just the function</li><li>It <strong>loads and runs the whole file</strong></li></ul><p>So any code written <strong>outside a function</strong> will run automatically.</p><p>For Example, in the current file where an import statement is written it, one might just expect output of the function “go to sleep()” .</p><p>But the output also has result of a “While” loop followed by results of the function “go to sleep()”.</p><p>If your imported file looks like this:</p><pre>export let pet = { energy: 5 };</pre><pre>// This runs immediately on import<br>while (pet.energy &lt; 10) {<br>  console.log(&quot;Pet is playing&quot;);<br>  pet.energy++;<br>}</pre><pre>export function goToSleep(pet) {<br>  console.log(&quot;Pet is sleeping&quot;);<br>}</pre><p>Note that, the while loop is <strong>not inside any function</strong>, so it runs immediately when this file is imported.</p><p>That’s why you see output from the while loop — even if you never called it in your main file (the file where Import statement is specified)</p><h3>Why This Feels Confusing</h3><p>Many beginners think, “If I export a function, it should only run when I call it.” That idea is correct — <strong>but only for code inside functions</strong>.</p><p>JavaScript sees everything outside a function as <strong>instructions to run right away</strong>.</p><h3>The Correct Way to Fix It</h3><p>To prevent automatic execution, put your logic inside a function.</p><p><strong>Fixed version:</strong></p><pre>export let pet = { energy: 5 };<br><br>//Adding while loop inside a function<br>function playWithPet() {<br>  while (pet.energy &lt; 10) {<br>    console.log(&quot;Pet is playing&quot;);<br>    pet.energy++;<br>  }<br>}<br><br>export function goToSleep(pet) {<br>  console.log(&quot;Pet is sleeping&quot;);<br>}</pre><p>Now nothing runs automatically.</p><p><strong>Using It in Another File</strong></p><pre>import { goToSleep, pet } from &#39;./Assignment02B_PetSimulator.js&#39;;<br><br>goToSleep(pet); // Only this runs</pre><p>✔ The while loop runs <strong>only if you tag the associated function as export and then call </strong><strong>playWithPet()</strong><br> ✔ Your program behaves exactly as expected</p><p><strong>Examples in enterprise applications:</strong></p><p>A utility file is created with all functions in it marked as “export”. Here no active calls to any function is made inside the file neither there are any loops outside of any function. And when this utility file is imported in some other .js file, it just executes the specified imported method(s) and not the entire utilities.js file.</p><p><strong>Final Takeaway Points to Remember:</strong></p><ol><li>Code outside functions runs immediately when a file is imported.</li></ol><p>2. Code inside functions runs only when called.</p><p>To summarize, importing a JavaScript file runs all top-level code. To control execution, always place logic inside functions.</p><p>Hope, you find this information useful. Happy Learning!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=55021c6f3f8e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[What is Web Scraping?]]></title>
            <link>https://medium.com/@alpanamishra2009/what-is-web-scraping-6f1208f9edb?source=rss-239e92e34db9------2</link>
            <guid isPermaLink="false">https://medium.com/p/6f1208f9edb</guid>
            <dc:creator><![CDATA[Alpana Mishra]]></dc:creator>
            <pubDate>Wed, 02 Aug 2023 03:00:58 GMT</pubDate>
            <atom:updated>2023-08-02T12:38:28.209Z</atom:updated>
            <content:encoded><![CDATA[<h3>Overview</h3><p>Talking in general, what is the process involved if we want to browse any information on the internet and copy it onto a local file, let’s say for some presentation. We go to the specific website, copy the desired information and paste it into our local file. Seems pretty easy task, right? Since most websites do not allow users to download or save their data, copying and pasting manually is the one of the best choice to achieve results quickly.</p><p>Now, Imagine there is a requirement to train a machine learning algorithm for which we want to fetch a large amount of data, including more than 1000s or millions of records from a website and select only specific information from the page’s source code, ignoring the rest which is not required at the moment? Doing the entire process manually and and in less amount of time seems mind-numbing and time-consuming. In simple words, when the same process is automated using a tool, an app or a browser extension it is called Web Scraping.</p><h3><strong>Web Scraping</strong></h3><p>Web Scraping is an automated process of extracting required data from specific website using automated software or script. It is a process in which a HTTP request is sent to the server which in turn returns the desired page with information, data is then extracted from the page’s source code and parsed as structured data into the desired file or database.</p><p>For example: One can use Web Scraping to export a list of products from an e-commerce website including the online price and excluding customer reviews onto an excel spreadsheet.</p><p>Web Scraping will automatically load, crawl and extract required data from multiple web pages of a website.</p><p>Web scraping can also be done manually which involves using browser’s Developer tools for viewing page’s source code, locating/extracting required data, copying and storing it in the desired format. But, as said, it will be a tedious and time consuming activity.</p><p>There are many different ways to perform automated web scraping to obtain data from various websites. Large tech-giants like Google, Facebook, Twitter etc have API’s that can access their data in a structured format, which is a best option. But, there are many websites that don’t have this provision, and in such cases Web Scraping plays a major role to scrape their website data. Web Scrapers can come in many different forms including,</p><ul><li><strong>Self-built Scrapers </strong>(e.g. Just like anyone can build a website, same way anyone can build their own web scraper. One can build a Scraper using Java/Python programming languages and browser automation tools like Selenium WebDriver)</li><li><strong>Readymade Scraper API’s </strong>(e.g. Scraping Bee, Scraping Ant, Crawler, Scrape Goat etc.)</li><li><strong>Browser Extensions</strong> — Web scraping extensions have the benefit of being simpler to run and being integrated right into your browser (e.g. Chrome Extensions — Web Scraper, Scraper, Agency, Data Scraper etc.)</li><li><strong>Scraping Softwares </strong>— Just like any other softwares, scraping softwares can be downloaded and installed on your computer (e.g. import.io)</li><li><strong>Cloud-based Web Scraper </strong>— Cloud-based web scrapers run on an off-site server which is usually provided by the company that developed the scraper itself. This means that your computer’s resources are freed up while your scraper runs and gathers data.(e.g. Bright Data, Mozenda etc.)</li></ul><p><strong><em>Note</em></strong><em>: If running a Web scraper locally, it will run on your computer consuming local resources. In case the amount of data to be scraped is large enough, it might demand more CPU or RAM which in turn impact your system’s performance, making it very slow.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/980/0*AMjyKlrAe_osG0fz.png" /></figure><h3>How does Web Scraping work?</h3><p>Automated Web Scraping involves scraping tools like Self-built scrappers built using any programming language or Python Scrapy. The basic steps includes,</p><ol><li>The tool/automated script sends HTTP request to the hosting server</li><li>The server returns the HTML source code of the targeted web pages</li><li>Desired data is parsed and extracted from the page’s source cod</li><li>Structured data is stored in the required format (CSV files, Excel sheet, JSON or Database).</li></ol><h3>What is Web Scraping used for?</h3><p>In today’s era, the most valuable asset of any business is its Data. It is often used for data mining and gathering valuable insights from large websites. Web Scraping is used for a variety of business purposes across multiple industries. Lets see some of them,</p><ol><li><strong>Data Collection</strong> — Collecting data from multiple websites for market research or analysis.</li><li><strong>Training and testing data for Machine Learning Projects</strong> — Web Scraping helps you to gather data for testing / training your Machine Learning models.</li><li><strong>Monitoring e-commerce prices </strong>— Web Scraping can be used by companies to scrap competing products data and see how it impacts their pricing strategies</li><li><strong>Real Estate Listing Scraping </strong>— Many real estate agents use web scraping to populate their database of available properties for sale or for rent</li><li><strong>Lead Generation</strong> — Many companies collect contact information, including email addresses and phone numbers about potential customers using web scraping for marketing or business purpose</li><li><strong>Stock Data Scraping</strong> — Finance and investment research firms use web scraping tools to make decisions and create frameworks because it provides relevant and timely information</li><li><strong>Financial Data Aggregation </strong>— Aggregating financial data from various banking instuitions into one single website e.g. Mint</li></ol><h3>Is Web Scraping Legal or Ilegal?</h3><p>Web Scraping is technically not any kind of illegal process but the decision is based on many factors including but not limited to, how the extracted data is used further? Or Did the data scraping process violate any terms and conditions of the website under consideration? The legality of web scraping also depends on the legislation for data sovereignty in the country/state/city where the scraping takes place. Web scraping may become illegal when non publicly available data becomes extracted and is used as your own without the consent of the owner. Web Scraping is actually not illegal on its own but one should be ethical while doing it.</p><h3>Conclusion</h3><p>Web Scraping is a very helpful method. If done in a good way, Web Scraping can help us to make the best use of the web, the biggest example of which is Google Search Engine.</p><p>I hope through this article I was able to provide you an overview and usage of Web Scraping. Happy Learning!</p><p><strong>Resources</strong></p><p><a href="https://www.parsehub.com/blog/what-is-web-scraping/">https://www.parsehub.com/blog/what-is-web-scraping/</a></p><p><a href="https://www.geeksforgeeks.org/web-scrapping-legal-or-illegal/">https://www.geeksforgeeks.org/web-scrapping-legal-or-illegal/</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6f1208f9edb" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[What is Idempotent HTTP Method?]]></title>
            <link>https://medium.com/@alpanamishra2009/what-is-idempotent-http-method-652a3cf663fc?source=rss-239e92e34db9------2</link>
            <guid isPermaLink="false">https://medium.com/p/652a3cf663fc</guid>
            <dc:creator><![CDATA[Alpana Mishra]]></dc:creator>
            <pubDate>Mon, 24 Jul 2023 13:16:19 GMT</pubDate>
            <atom:updated>2023-07-24T13:29:21.802Z</atom:updated>
            <content:encoded><![CDATA[<h3><strong>Idempotency — Overview</strong></h3><p>Idempotency is a very popular term in HTTP verbs. Before we go ahead with each method, let us understand what is Idempotency? A HTTP method is Idempotent if the intended effect of making a single request on the server is same as the effect of making several identical requests. In other words, it guarantees that performing the operation multiple times will yield the same result as if it was executed only once.To summarize, it basically does not have any side-effects on the server or resource. Only the first request has an effect on the server and subsequent requests sent later have no effect.</p><p>As a mathematical example, adding a zero to any number will basically have no effect on the number, or rotating something 360 degrees.Both of these examples describe an operation that is idempotent.</p><h3>What is a Safe HTTP Method?</h3><p>HTTP methods are considered safe if they do not alter the state of the server. So safe methods should be used for read-only operations and not write operations.</p><h3>Idempotency and HTTP Requests</h3><p>When we say Idempotent HTTP requests, it means safe and reliable trying of the requests without accidentally duplicating or repeating entries of the same request.</p><p>To perform an idempotent request, a unique idempotency key must be provided to the server along with the request options. The server uses this key to recognize and distinguish subsequent retries of the same request.Non-idempotent operations can have different results.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/631/0*xsiHbiRraViUqRwH.png" /></figure><p>Now that we understood the concept of Idempotency in HTTP verbs, let us take a walkthrough of each method individually and understand it’s behavior</p><p>While there are around a dozen of available HTTP methods, most services deal primarily with the 4 CRUD operations: POST, GET, PUT, and DELETE.</p><p>Let’s have a look at which HTTP Methods are Idempotent and which are not.</p><h3><strong>HTTP POST</strong></h3><p>POST represents ‘C’ for ‘Create’ in the CRUD operations. The primary purpose of the POST method is to create a new resource. It is often employed when submitting form data, uploading files, or sending JSON payloads to the server.</p><p>POST request is<strong> non-Idempotent </strong>, meaning sending two identical POST requests might result in duplicate entries of the same resource. POST URI often points to the resource collection where a new resource is to be created. Usually, in POST requests we cannot have predictable outcomes.</p><p>POST method is <strong>not safe.</strong> Since POST requests alter the state of the server by creating a new resource, it’s considered as not safe.</p><h3>HTTP GET</h3><p>GET represents ‘R’ for ‘Read’ in the CRUD OperationsThis request is primarily used to read or request a representation of a specified resource. GET requests are <strong>Idempotent</strong> as they’re read-only methods and hence subsequent identical requests to the server for the same resource do not create any side-effects on the server.</p><p>The GET method is <strong>safe</strong>, as it does not alter the state of the server.</p><h3>HTTP PUT</h3><p>PUT represents ‘U’ for ‘Update’ in the CRUD operations</p><p>This request is primarily used to update/modify the entire resource with the data that is passed in the body payload (In some implementations, it creates a new resource if the resource does not already exist, though not a recommended practice).</p><p>The URI of PUT requests mostly specifies the unique ID of the resource to be updated using which server locates the exact resource from the resource collection.</p><p>PUT request is <strong>Idempotent </strong>because of its ability to modify the resource’s entire content. Since the client is providing the complete representation of the resource (i.e. complete payload data), the server can update the resource to the exact same state as many times as needed without any unintended side effects. Therefore, we can send the same PUT request multiple times with predictable outcomes.</p><p>The PUT method is <strong>not safe </strong>as it alters the state of the server by modifying the resource.</p><h3>HTTP DELETE</h3><p>DELETE represents ‘D’ for ‘Delete’ in the CRUD operations. It requests the deletion of a specific resource represented by a unique ID sent as URI (Uniform Resource Identifier).</p><p>Delete requests are <strong>Idempotent</strong> as sending multiple delete request for the same ID will result in the same outcome. Only the first delete request will have an effect on the server by deleting the requested resource and any subsequent delete request will not have any side-effects on the state of the server as the resource is already deleted.</p><p>Delete request is <strong>not safe</strong>, as it is altering the state of the server by deleting the specified resource in the first request.</p><h3>HTTP PATCH</h3><p>PATCH also represents ‘U’ for Update/Modify in the ‘CRUD’ operations.</p><p>The PATCH request is primarily used to modify/update partial details of the resource. Here, the client need not send entire details of the resource to be modified, rather only the specific details that need modification can be sent as Payload in the Patch request, without affecting any other attributes of the resource.</p><p>Patch request is <strong>non-Idempotent</strong> (although it can be Idempotent) and the idempotency basically depends on how one wants to change the resource and implementation on the server side. For example, if the Patch request wants to move the resource, in this case the first request will perform the desired modification but subsequent identical Patch request might have side-effects on the server as the desired movement is already done. Patch requests may have side-effects on other resources as well.</p><p>The PATCH method is <strong>not safe </strong>, as it alters the state of the server by updating the specified attributes of the resource.</p><h3><strong>HTTP Verbs Overview</strong></h3><p>Till now we have seen various HTTP methods and their behavior with respect to idempotency, below table summarizes this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rwTIfQeUsxtVwsmdkJviTA.png" /></figure><h3><strong>Conclusion</strong></h3><p>So now that we know what is Idempotency and the overview of major CRUD operations. A question might strike your mind, as to why Idempotency is so important in HTTP methods? An idempotent operation can be safely transmitted or re-tried without any additional side effects. Consider an environment with network latency, often experiencing network slowness. Here there are high chances that the same request might be sent multiple times erroneously creating unintended side-effects on the server and thereby creating additional resources or modifying them, causing unexpected changes on the server side.</p><p>As accuracy of data is an important aspect of any business, non-idempotency can pose a significant risk on businesses.</p><p>Thus, Idempotency is very crucial to maintain consistency, better Fault Tolerance API and Error Handling.</p><p>Hope, you find this information useful. Happy HTTPing!</p><h3>Resources</h3><p><a href="https://dev.to/mehmehmehlol/put-vs-patch-put-vs-post-56i9">https://dev.to/mehmehmehlol/put-vs-patch-put-vs-post-56i9</a></p><p><a href="https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods">https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods</a></p><p><a href="https://blog.dreamfactory.com/what-is-idempotency/#:~:text=HTTP%20methods%20like%20GET%2C%20HEAD,predictable%20web%20applications%20and%20APIs">https://blog.dreamfactory.com/what-is-idempotency/#:~:text=HTTP%20methods%20like%20GET%2C%20HEAD,predictable%20web%20applications%20and%20APIs</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=652a3cf663fc" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Cucumber — Scenario Outline Examples and Data Table Differences]]></title>
            <link>https://medium.com/@alpanamishra2009/cucumber-scenario-outline-examples-and-data-table-differences-ed38f088fd6f?source=rss-239e92e34db9------2</link>
            <guid isPermaLink="false">https://medium.com/p/ed38f088fd6f</guid>
            <dc:creator><![CDATA[Alpana Mishra]]></dc:creator>
            <pubDate>Sat, 22 Jul 2023 16:44:49 GMT</pubDate>
            <atom:updated>2026-02-09T16:09:09.905Z</atom:updated>
            <content:encoded><![CDATA[<h3><strong>Cucumber — Scenario Outline Examples and Data Table Differences</strong></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/521/0*fgIiNEL-RRza6rTe.png" /></figure><h3>1. Introduction</h3><p>Recently, I was working on a project where I had a requirement to pass a variety of input test data in the feature file &amp; glue code using Cucumber tool. Deciding on which format to use from Examples Table or Data Table for my use case was getting bit challenging. I tried doing my research, but couldn’t find any consolidated information as to which approach is a better choice and why? In this blog, I will walk through the implementation of Examples Table and Data Table with some use cases and highlight the key differences between them.</p><h3>2. Overview</h3><p>Cucumber is a tool that supports Behavior Driven Development (BDD) framework and allows to create specification based scenarios using Gherkin language. Some cases require combination of test data as input to complete the execution of scenarios. Writing the same scenario repeatedly with different sets of data/input can get cumbersome. Hence, Cucumber provides a special provision for parameterization in the form of Scenario Outline and Data Tables, thereby allowing engineer to pass the values from one step to another and validating the application behavior with different combination of data. There are multiple ways to provide data to cucumber steps like “Scenario Outline — Examples”, “Data Tables” and “External Files”. In this blog we are going to see — Scenario Outline — Examples and Data Tables. Let’s have a look at the usage and differences between each of them.</p><h3>2.1 Scenario Outline — Examples Table and its Implementation</h3><ul><li>The Scenario Outline keyword can be used to run the same scenario multiple times, with different combination of data. The parameterized variables are specified within angular brackets &lt;&gt; which acts as headers in the examples table.</li><li>Test data for scenario outline will be placed under the scenario using keyword “Examples”. A Scenario Outline must have one or more “Examples” associated with it.</li><li>Cucumber automatically runs the complete scenario (i.e all Given/When/Then steps of that scenario) once for each row of data provided beneath Examples keyword. Here, the header is not counted as Data.</li><li>Cucumber will replace the parameterized variables &lt;&gt; in the Scenario Outline (that reference headers in the examples table) with actual data from the examples table during the execution of step definition.</li></ul><p>Let’s see an example of “Scenario Outline — Examples” table in Feature File:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PPAVMJaXfwfMfgMYyFfG1Q.png" /></figure><p>Given below is the Implementation of above Examples tables in Step Definition:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7DHfNlnh2HGIUC7XGszucw.png" /></figure><h3>2.2 Data Table and its Implementation</h3><ul><li>Data Table works for the single step below which it is defined rather than the entire scenario</li><li>Test Data is directly specified below the particular step in a scenario and no separate keyword is needed to define the test data. It doesn’t necessarily have a header row either.</li></ul><blockquote>Note: In the case where header row is provided in the data table, we have to programmatically skip the first row while parsing the data in step definition</blockquote><ul><li>Separate code is required (e.g. List, Map) to interpret the Data Tables in step definitions(or Glue code). Several methods are provided to convert tables to common data structures such as lists, maps etc. There are different ways to handle it, depending on the structure and complexity of the data. Most common are:(1) list of lists (2) list of maps and (3) table transformer</li><li>Data Tables can be accessed by using the DataTables object as a parameter in the step definition. For Example: In the case of the below two scenarios, ‘DataTable datatable’ will be passed as a parameter in the functions for ‘Given’ step and ‘When’ step respectively.</li><li>Depending on the input data , Data Table can be implemented using various Collections, for example</li></ul><p><em>List&lt;List&lt;String&gt;&gt; tableName</em></p><p><em>Map&lt;String, String&gt; tableName</em></p><p><em>List&lt;Map&lt;String, String&gt;&gt; tableName</em></p><p>Let’s see few examples of Data Table in Feature File and its implementation in Glue Code</p><h4>A. Example of DataTable without header in Feature File</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-tUIlvQG4AnsbbjbbJjmWA.png" /></figure><p>Implementation of above data table using List&lt;List&lt;String&gt;&gt; approach:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1c7E98ogz3kAXvrabDSnwg.png" /></figure><h4>B. Example of DataTable with header and single row in Feature File</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bntKAs4ShIum6dDHwJc7QQ.png" /></figure><p>Implementation of above data table using Map&lt;String, String&gt; approach:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ApJPj8E2YFn_AmxPH_UPog.png" /></figure><h4>C. Example of DataTable with header and multiple rows in Feature File</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fgYCeCvL1nJh0AnsaIg2YQ.png" /></figure><p>Implementation of above data table using List&lt;Map&lt;String, String&gt; approach:</p><pre>@Given(&quot;I have the following staff members to add&quot;)<br>public void I_have_the_following_staff_members_to_add(DataTable dataTable)<br>        throws InterruptedException {<br><br>    logger.info(&quot;Enter the staff member details: &quot;);<br><br>    List&lt;Map&lt;String, String&gt;&gt; staffMembersList =<br>            dataTable.asMaps(String.class, String.class);<br><br>    for (Map&lt;String, String&gt; eachMember : staffMembersList) {<br><br>        String fName = eachMember.get(&quot;FirstName&quot;);<br>        testPageObjectRepository.enterStaffFirstName(fName);<br><br>        String lName = eachMember.get(&quot;LastName&quot;);<br>        testPageObjectRepository.enterStaffLastName(lName);<br><br>        String role = eachMember.get(&quot;Role&quot;);<br>        testPageObjectRepository.enterRole(role);<br><br>        testPageObjectRepository.clickAddUserBtn();<br>    }<br>}</pre><h3>3. Key Differences:</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/738/1*JZp_dEGcoo3zYWreROMX0w.png" /></figure><h3>4. Conclusion</h3><p>In this blog, we saw the different ways to pass input data through Cucumber. For repeated actions with different combinations of data, “Scenario Outline-Examples” is a better choice as it does not require seperate code to interpret the test data, Cucumber automatically interprets it. However, if we don’t want to repeat the entire scenario but just one step, Data Table can be used. Certainly both approaches can be used to specify input test data thereby avoiding hard-coded values in the tests.</p><p>Utilizing these rich features of Cucumber enables Data Driven Testing and Parameterization, allowing engineers to create robust and reusable test scenarios, enhanced test coverage, reduce redundancy and make our test steps more readable and understandable.</p><p>Hope you find this information useful. Happy Learning!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ed38f088fd6f" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>