<?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 Akhil Singh Rawat on Medium]]></title>
        <description><![CDATA[Stories by Akhil Singh Rawat on Medium]]></description>
        <link>https://medium.com/@akhilsr20?source=rss-562013655beb------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*w_lKr2fGKL5pDLSv</url>
            <title>Stories by Akhil Singh Rawat on Medium</title>
            <link>https://medium.com/@akhilsr20?source=rss-562013655beb------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 02 Dec 2026 09:33:45 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@akhilsr20/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[Playwright 202: CLI in playwright]]></title>
            <link>https://medium.com/@akhilsr20/playwright-202-cli-in-playwright-78b1ff21cd43?source=rss-562013655beb------2</link>
            <guid isPermaLink="false">https://medium.com/p/78b1ff21cd43</guid>
            <category><![CDATA[automation]]></category>
            <category><![CDATA[playwright-community]]></category>
            <category><![CDATA[automation-testing]]></category>
            <category><![CDATA[playwright-test]]></category>
            <dc:creator><![CDATA[Akhil Singh Rawat]]></dc:creator>
            <pubDate>Mon, 06 Mar 2023 12:38:48 GMT</pubDate>
            <atom:updated>2023-03-06T12:38:48.728Z</atom:updated>
            <content:encoded><![CDATA[<p>Playwright is a powerful and feature-rich automation tool that helps developers test their web applications. One of the key features of Playwright is its Test CLI, which provides a command-line interface to run tests and generate reports. In this blog, we will explore the Playwright Test CLI and its various options with examples.</p><h3>Installing Playwright Test CLI</h3><p>Before we dive into the Test CLI, let’s make sure we have it installed. Playwright Test CLI can be installed via npm using the following command:</p><pre>npm i -D @playwright/test</pre><h3>Running Tests with Playwright Test CLI</h3><p>Once the Test CLI is installed, we can use it to run our tests. By default, Playwright Test CLI looks for test files in the tests/ directory. You can customize the directory by passing the --test-dir option followed by the directory path.</p><p>To run all tests, simply run the following command:</p><pre>npx playwright test</pre><p>You can also specify a specific test file or directory by passing the path as an argument:</p><pre>npx playwright test tests/sample-test.spec.ts</pre><p>The --forbid-only option can be used to ensure that no tests are skipped due to a test.only statement in the test code.</p><h3>Selecting Browsers</h3><p>Playwright Test CLI allows you to select which browsers you want to use to run your tests. By default, Playwright Test CLI uses Chromium, Firefox, and WebKit.</p><p>To run tests in a specific browser, use the --browser option followed by the browser name. For example, to run tests in Firefox, use the following command:</p><pre>npx playwright test --browser=firefox</pre><p>You can also run tests in multiple browsers at once by passing multiple --browser options:</p><pre>npx playwright test --browser=chromium --browser=webkit</pre><h3>Generating Reports</h3><p>Playwright Test CLI allows you to generate reports in various formats, including JSON, JUnit, and HTML. By default, Playwright Test CLI generates a simple text report in the terminal.</p><p>To generate a report in a specific format, use the --reporter option followed by the reporter name. For example, to generate a JSON report, use the following command:</p><pre>npx playwright test --reporter=json</pre><p>You can also generate multiple reports at once by passing multiple --reporter options:</p><pre>npx playwright test --reporter=json --reporter=line</pre><h3>Filtering Tests</h3><p>Playwright Test CLI allows you to filter tests based on their name or tags. To filter tests by name, use the --grep option followed by a regular expression. For example, to run tests that include the word &quot;login&quot; in their name, use the following command:</p><pre>npx playwright test --grep=login</pre><h3>Conclusion</h3><p>In this blog, we have explored the Playwright Test CLI and its various options. With the Test CLI, developers can easily run tests, select browsers, generate reports, and filter tests based on their name or tags. These features make Playwright Test CLI a powerful and flexible tool for testing web applications.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=78b1ff21cd43" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Playwright 201: Annotations]]></title>
            <link>https://medium.com/@akhilsr20/playwright-201-annotations-5d4ea5c7c07d?source=rss-562013655beb------2</link>
            <guid isPermaLink="false">https://medium.com/p/5d4ea5c7c07d</guid>
            <category><![CDATA[playwright-test]]></category>
            <category><![CDATA[automation]]></category>
            <category><![CDATA[automation-testing]]></category>
            <category><![CDATA[playwright-community]]></category>
            <dc:creator><![CDATA[Akhil Singh Rawat]]></dc:creator>
            <pubDate>Mon, 06 Mar 2023 12:23:13 GMT</pubDate>
            <atom:updated>2023-03-06T12:23:13.043Z</atom:updated>
            <content:encoded><![CDATA[<h3>Introduction</h3><p>Playwright is a powerful automation tool that is gaining popularity among developers for its ease of use and flexibility. One of the standout features of Playwright is its support for annotations, which allow you to add metadata to your tests. In this blog, we will explore the concept of test annotations in Playwright, and how you can use them to improve your testing workflow.</p><h3>What are Test Annotations?</h3><p>Test annotations are special tags that you can add to your tests to provide additional information about them. They allow you to label your tests, group them together, and specify various parameters that control how they are executed.</p><h3>How to use Test Annotations?</h3><p>Test annotations in Playwright are implemented using decorators, which are special functions that modify the behavior of other functions. You can add these decorators to your test functions to customize their behavior.</p><p>Here are some of the most commonly used test annotations in Playwright:</p><ul><li><strong>test</strong> — The @test annotation is used to indicate that a function is a test. You can use it to group your tests together and run them all at once.</li></ul><p><strong>Example:</strong></p><pre>import { test } from &#39;@playwright/test&#39;;<br>test(&#39;My Test&#39;, async ({ page }) =&gt; {<br>  // test code goes here<br>});</pre><ul><li><strong>only —</strong> The @only annotation is used to run a single test exclusively. This is useful when you are developing a new test and want to focus on getting it to pass before moving on to other tests.</li></ul><p><strong>Example:</strong></p><pre>import { test } from &#39;@playwright/test&#39;;<br>test.only(&#39;My Test&#39;, async ({ page }) =&gt; {<br>  // test code goes here<br>});</pre><ul><li><strong>skip —</strong> The @skip annotation is used to skip a test. This is useful when a test is currently failing and you want to temporarily disable it until you can fix it.</li></ul><p><strong>Example:</strong></p><pre>import { test } from &#39;@playwright/test&#39;;<br>test.skip(&#39;My Test&#39;, async ({ page }) =&gt; {<br>  // test code goes here<br>});</pre><ul><li><strong>describe —</strong> The @describe annotation is used to group your tests together. You can use it to create a hierarchy of tests, with each level of the hierarchy providing additional context about the tests it contains.</li></ul><p><strong>Example:</strong></p><pre>import { test, describe } from &#39;@playwright/test&#39;;<br>describe(&#39;My Test Suite&#39;, () =&gt; {<br>  test(&#39;Test 1&#39;, async ({ page }) =&gt; {<br>    // test code goes here<br>  });<br>  <br>  test(&#39;Test 2&#39;, async ({ page }) =&gt; {<br>    // test code goes here<br>  });<br>});</pre><ul><li><strong>repeat —</strong> The @repeat annotation is used to run a test multiple times. This is useful when you want to verify that a test is consistent across multiple runs.</li></ul><p><strong>Example:</strong></p><pre>import { test } from &#39;@playwright/test&#39;;<br>test.repeat(3)(&#39;My Test&#39;, async ({ page }) =&gt; {<br>  // test code goes here<br>});</pre><ul><li><strong>timeout —</strong> The @timeout annotation is used to specify a timeout for a test. If a test takes longer than the specified timeout, it will fail.</li></ul><p><strong>Example:</strong></p><pre>import { test } from &#39;@playwright/test&#39;;<br>test.describe(&#39;My Test Suite&#39;, () =&gt; {<br>  test(&#39;My Test&#39;, async ({ page }) =&gt; {<br>    // test code goes here<br>  }).timeout(5000);<br>});</pre><h3>Conclusion:</h3><p>Test annotations in Playwright provide a powerful way to customize the behavior of your tests. By adding metadata to your tests, you can group them together, run them exclusively, skip them temporarily, specify a timeout, and more. With these annotations, you can create a flexible and efficient testing workflow that meets your needs.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5d4ea5c7c07d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Playwright 109: Mouse events]]></title>
            <link>https://medium.com/@akhilsr20/playwright-109-mouse-events-8bc40ab24fcc?source=rss-562013655beb------2</link>
            <guid isPermaLink="false">https://medium.com/p/8bc40ab24fcc</guid>
            <category><![CDATA[playwright-community]]></category>
            <category><![CDATA[playwright-test]]></category>
            <category><![CDATA[automation]]></category>
            <category><![CDATA[automation-testing]]></category>
            <dc:creator><![CDATA[Akhil Singh Rawat]]></dc:creator>
            <pubDate>Mon, 06 Mar 2023 11:58:06 GMT</pubDate>
            <atom:updated>2023-05-22T19:00:21.883Z</atom:updated>
            <content:encoded><![CDATA[<p>Mouse events are essential in web automation to simulate user interactions, and Playwright offers a wide range of functions to handle them. In this blog, we will explore the different types of mouse events and their implementation in Playwright.</p><h3>Mouse events in Playwright</h3><p>Playwright provides a range of mouse event functions to simulate different types of user interactions. These events include:</p><ol><li>Click — simulates a single click on a web element.</li><li>Double click — simulates a double click on a web element.</li><li>Right-click — simulates a right-click on a web element.</li><li>Hover — simulates a mouse hover over a web element.</li><li>Drag and Drop — simulates dragging and dropping of an element.</li></ol><h3>Implementation of Mouse Events in Playwright</h3><p>To perform mouse actions in Playwright, we need to create a mouse object using the page.mouse function. This function provides access to different mouse events functions like click, doubleClick, rightClick, hover, etc. Let&#39;s see each event implementation in detail.</p><ul><li><strong>Click Event</strong></li></ul><p>To perform a single click on an element, we use the click function. The syntax for the click function is:</p><pre>await page.click(selector[, options])</pre><p>Here selector is the element to be clicked, and options are the additional parameters like button (left, right, or middle) and clickCount (number of clicks to perform).</p><p><strong>Example:</strong></p><pre>await page.click(&#39;button#login-btn&#39;)</pre><ul><li><strong>Double Click Event</strong></li></ul><p>To perform a double click on an element, we use the doubleClick function. The syntax for the doubleClick function is:</p><pre>await page.doubleClick(selector[, options])</pre><p>Here selector is the element to be double-clicked, and options are the additional parameters like button (left, right, or middle) and delay (delay in milliseconds between two clicks).</p><p><strong>Example:</strong></p><pre>await page.doubleClick(&#39;button#submit-btn&#39;)</pre><ul><li><strong>Right Click Event</strong></li></ul><p>To perform a right click on an element, we use the rightClick function. The syntax for the rightClick function is:</p><pre>await page.rightClick(selector[, options])</pre><p>Here selector is the element on which right-click action needs to be performed, and options are the additional parameters like button (left, right, or middle) and position (x and y coordinates of the mouse pointer).</p><p><strong>Example:</strong></p><pre>await page.rightClick(&#39;input#username-field&#39;)</pre><ul><li><strong>Hover Event</strong></li></ul><p>To simulate a hover event, we use the hover function. The syntax for the hover function is:</p><pre>await page.hover(selector[, options])</pre><p>Here selector is the element on which the mouse needs to be hovered, and options are the additional parameters like position (x and y coordinates of the mouse pointer).</p><p><strong>Example:</strong></p><pre>await page.hover(&#39;div#profile-menu&#39;)</pre><ul><li><strong>Drag and Drop Event</strong></li></ul><p>To simulate drag and drop events, we use the dragAndDrop function. The syntax for the dragAndDrop function is:</p><pre>await page.dragAndDrop(sourceSelector, targetSelector[, options])</pre><p>Here sourceSelector is the element that needs to be dragged, targetSelector is the element where it needs to be dropped, and options are additional parameters like sourcePosition and targetPosition (x and y coordinates of the elements).</p><p><strong>Example:</strong></p><pre>await page.dragAndDrop(&#39;div#source-element&#39;, &#39;div#target-element&#39;)</pre><h3>Conclusion</h3><p>In conclusion, Playwright provides a rich set of mouse event actions that can be used to simulate user interactions with a web page. The mouse event actions, such as click, doubleClick, hover, rightClick, and dragAndDrop, can be combined with other Playwright features, such as selectors and waiting for conditions, to create powerful automated tests. With these mouse event actions, you can simulate the user&#39;s behavior and verify that your web application behaves as expected.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8bc40ab24fcc" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Playwright 109 : Assertions]]></title>
            <link>https://medium.com/@akhilsr20/playwright-109-assertions-41b137d8e1b6?source=rss-562013655beb------2</link>
            <guid isPermaLink="false">https://medium.com/p/41b137d8e1b6</guid>
            <category><![CDATA[playwright-test]]></category>
            <category><![CDATA[playwright-community]]></category>
            <category><![CDATA[automation-testing]]></category>
            <category><![CDATA[automation]]></category>
            <dc:creator><![CDATA[Akhil Singh Rawat]]></dc:creator>
            <pubDate>Mon, 06 Mar 2023 11:45:00 GMT</pubDate>
            <atom:updated>2023-03-06T11:45:53.411Z</atom:updated>
            <content:encoded><![CDATA[<h3>Playwright 108 : Assertions</h3><h3>Introduction:</h3><p>When building automated tests in Playwright, assertions are an essential part of ensuring that the test cases are working as expected. Playwright provides a variety of assertion options, including the expect function. In this blog, we will explore the expect function in Playwright, how it can be used to perform assertions in automated tests, and examples of how to use it.</p><h3>What is the expect function?</h3><p>The expect function is a method that can be used to assert that certain conditions are true in the test case. This function takes an actual value and compares it to an expected value, throwing an error if they do not match. The expect function is part of the Jest testing framework that is integrated into Playwright, and it can be used to create powerful and precise assertions.</p><p><strong>Syntax:</strong></p><p>The basic syntax of the expect function in Playwright is as follows:</p><pre>expect(actual).matcher(expected)</pre><p>In this syntax, the actual parameter is the value being tested, and the matcher parameter is the expected value. Matchers are functions that perform the actual comparison between the actual and expected values.</p><h3>Matchers:</h3><p>Playwright provides a variety of matchers that can be used with the expect function, including:</p><ul><li><strong>toBe()</strong>: This matcher compares the actual and expected values using the strict equality operator (===).</li><li><strong>toEqual()</strong>: This matcher compares the actual and expected values using a deep equality algorithm.</li><li><strong>toMatch()</strong>: This matcher compares the actual and expected values using a regular expression.</li><li>t<strong>oContain()</strong>: This matcher checks if the actual value contains the expected value.</li><li><strong>toBeTruthy()</strong>: This matcher checks if the actual value is truthy.</li><li><strong>toBeFalsy()</strong>: This matcher checks if the actual value is falsy.</li></ul><p><strong>Examples:</strong></p><p>Let’s look at some examples of how to use the expect function in Playwright.</p><p><strong>Example 1:</strong> Using toBe() matcher</p><pre>const result = 10 + 20;<br>expect(result).toBe(30);</pre><p>In this example, we use the toBe() matcher to assert that the result of the addition of 10 and 20 is equal to 30. If the result is not equal to 30, an error will be thrown.</p><p><strong>Example 2:</strong> Using toEqual() matcher</p><pre>const obj1 = { name: &#39;John&#39;, age: 25 };<br>const obj2 = { name: &#39;John&#39;, age: 25 };<br>expect(obj1).toEqual(obj2);</pre><p>In this example, we use the toEqual() matcher to assert that obj1 and obj2 are equal in value. The matcher performs a deep comparison, so even though obj1 and obj2 are different objects, they have the same properties and values, so the assertion will pass.</p><p><strong>Example 3:</strong> Using toMatch() matcher</p><pre>const sentence = &#39;The quick brown fox jumps over the lazy dog.&#39;;<br>expect(sentence).toMatch(/brown fox/);</pre><p>In this example, we use the toMatch() matcher to assert that the sentence contains the words “brown fox”. The matcher uses a regular expression to check if the expected value matches any part of the actual value.</p><h3>Conclusion:</h3><p>The expect function is a powerful tool for performing assertions in Playwright tests. By using different matchers, you can perform a variety of comparisons and ensure that your test cases are working as expected. Whether you’re testing user interfaces, APIs, or any other aspect of your application, the expect function is an essential part of building reliable and robust automated tests.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=41b137d8e1b6" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Playwright 107: Basic playwright]]></title>
            <link>https://medium.com/@akhilsr20/playwright-107-basic-playwright-a75c3df39157?source=rss-562013655beb------2</link>
            <guid isPermaLink="false">https://medium.com/p/a75c3df39157</guid>
            <category><![CDATA[playwright-test]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[automation]]></category>
            <category><![CDATA[playwright-community]]></category>
            <dc:creator><![CDATA[Akhil Singh Rawat]]></dc:creator>
            <pubDate>Wed, 01 Mar 2023 21:05:04 GMT</pubDate>
            <atom:updated>2023-03-06T10:28:04.861Z</atom:updated>
            <content:encoded><![CDATA[<h3>Playwright 107: Basic playwright commands</h3><p>Playwright is a powerful automation framework that provides a wide range of functionalities to interact with a web page. Here are some of the basic actions that can be performed using Playwright along with examples:</p><h3>Launching a Browser</h3><p>To start automating a web page, we need to launch a browser instance. Playwright provides a simple API to launch different types of browsers such as Chromium, Firefox, and WebKit. Here’s how we can launch a Chromium browser instance:</p><pre>const { chromium } = require(&#39;playwright&#39;);<br>(async () =&gt; {<br>  const browser = await chromium.launch();<br>  const context = await browser.newContext();<br>  const page = await context.newPage();<br>  // Perform actions on the page<br>  await browser.close();<br>})();</pre><h3>Navigating to a URL</h3><p>After launching a browser, the next step is to navigate to a URL. We can use the goto() method provided by Playwright to navigate to a specific URL:</p><pre>await page.goto(&#39;https://www.example.com&#39;);</pre><h3>Interacting with Elements</h3><p>Playwright provides various methods to interact with elements on a web page. Here are some examples:</p><ul><li>Clicking on an element:</li></ul><pre>await page.click(&#39;#my-button&#39;);</pre><ul><li>Typing text into an input field:</li></ul><pre>await page.fill(&#39;#my-input&#39;, &#39;Hello, World!&#39;);</pre><ul><li>Selecting an option from a dropdown menu:</li></ul><pre>await page.selectOption(&#39;#my-select&#39;, &#39;Option 1&#39;);</pre><ul><li>Hovering over an element:</li></ul><pre>await page.hover(&#39;#my-element&#39;);</pre><h3>Taking Screenshots</h3><p>Playwright allows us to take screenshots of a web page using the screenshot() method. We can pass different options to this method to take screenshots of a specific element or the full page:</p><pre>// Full page screenshot<br>await page.screenshot({ path: &#39;example.png&#39;, fullPage: true });<br><br>// Screenshot of a specific element<br>const elementHandle = await page.$(&#39;#my-element&#39;);<br>await elementHandle.screenshot({ path: &#39;element.png&#39; });</pre><h3>Handling Dialogs</h3><p>Playwright allows us to handle different types of dialogs such as alerts, confirmations, and prompts using the dialog() method. We can pass different options to this method to accept or dismiss a dialog:</p><pre>// Accept an alert<br>page.on(&#39;dialog&#39;, async dialog =&gt; {<br>  await dialog.accept();<br>});</pre><h3>Selecting Checkboxes/Radio Buttons</h3><p>To select a checkbox or radio button in Playwright, we first need to locate the element using a selector. Then, we can use the check method to select the checkbox or the click method to select the radio button.</p><p>For example, suppose we have a checkbox with the selector input[type=checkbox] that we want to select. We would write:</p><pre>await page.check(&#39;input[type=checkbox]&#39;);</pre><p>This would select the checkbox.</p><p>Similarly, if we have a radio button with the selector input[type=radio] that we want to select, we would write:</p><pre>await page.click(&#39;input[type=radio]&#39;);</pre><p>This would select the radio button. Note that if there are multiple radio buttons with the same name, we need to specify the value of the radio button we want to select using the value attribute. For example:</p><pre>await page.click(&#39;input[type=radio][value=option1]&#39;);</pre><p>This would select the radio button with a value of “option1”.</p><h3>Conclusion</h3><p>These are some of the basic actions that can be performed using Playwright. Playwright provides many more features and functionalities that can help us create powerful automation scripts.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a75c3df39157" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Playwright 106: Playwright.config.js]]></title>
            <link>https://medium.com/@akhilsr20/playwright-106-playwright-config-js-d0aa48009108?source=rss-562013655beb------2</link>
            <guid isPermaLink="false">https://medium.com/p/d0aa48009108</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[playwright-community]]></category>
            <category><![CDATA[playwright-test]]></category>
            <category><![CDATA[automation-testing]]></category>
            <dc:creator><![CDATA[Akhil Singh Rawat]]></dc:creator>
            <pubDate>Wed, 01 Mar 2023 20:46:27 GMT</pubDate>
            <atom:updated>2023-03-01T20:53:17.939Z</atom:updated>
            <content:encoded><![CDATA[<h3>Introduction</h3><p>playwright.config.js is a configuration file that is used to configure Playwright test runner. It is a JavaScript file that exports an object containing various configuration options. These configuration options can be used to set up the test environment and modify the behavior of the test runner.</p><h3>Creating a playwright.config.js File</h3><p>To create a playwright.config.js file, simply create a new JavaScript file in the root directory of your project and name it playwright.config.js. Once the file is created, you can export an object containing the configuration options you wish to set.</p><h3>Configuration Options</h3><p>Here are some of the configuration options that can be set in the playwright.config.js file:</p><h3>Global Setup and Teardown</h3><p>The globalSetup and globalTeardown options allow you to specify a file that contains code to be executed before and after all tests, respectively. This can be useful for setting up a test environment, such as starting a server or initializing a database.</p><h3>Timeout Settings</h3><p>The timeout option allows you to specify a global timeout for all tests. This timeout is used to ensure that tests do not run for too long and cause the test runner to hang.</p><h3>Headless</h3><p>If set to true, runs the browser in headless mode without UI, which means it runs in the background without a visible window. This can be useful when running tests in a headless environment or when you want to speed up the test execution.</p><h3>Viewport</h3><p>Sets the viewport size of the browser window. This is useful when you want to test how the website looks on different screen sizes or when you want to take screenshots of a specific size.</p><h3>IgnoreHTTPSErrors</h3><p>If set to true, ignores HTTPS errors. This is useful when testing a website with a self-signed certificate or when the certificate has expired.</p><h3>Video</h3><p>Enables video recording of the test. The on-first-retry option records a video of the test and saves it on the first retry of a failed test. This option is useful for debugging and identifying the root cause of test failures. The video can also be disabled or configured to record on every test run.</p><h3>Reporter</h3><p>The reporter option allows you to specify a reporter to use for test results. The built-in reporters include dot, line, and list. You can also specify a custom reporter by providing a path to a reporter module.</p><p>Here’s an example playwright.config.js file:</p><pre>const config = {<br>  globalSetup: require.resolve(./global-setup),<br>  headless: false,<br>  viewport: { width: 1280, height: 720 },<br>  ignoreHTTPSErrors: true,<br>  video: &#39;on-first-retry&#39;,<br>  testDir: &#39;test&#39;,<br>  timeout: 60000,<br>  use: &#39;firefox&#39;,<br>  reporter: &#39;list&#39;,<br>  workers: 4<br>};</pre><p>In this example, we have defined the testDir, timeout, use, reporter, and workers settings. The list reporter is set as the default reporter which gives a nice terminal output, and four worker processes are used for running tests in parallel.</p><h3>Conclusion</h3><p>In conclusion, the playwright.config.js file is a powerful tool that allows you to configure the behavior of the Playwright test runner. By setting options such as global setup and teardown, timeout settings, and test environment options, you can ensure that your tests run smoothly and efficiently. Additionally, by specifying a test match pattern and reporter, you can easily customize the test runner to meet your needs.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d0aa48009108" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Playwright 105: Global-Setup.js]]></title>
            <link>https://medium.com/@akhilsr20/playwright-105-global-setup-js-38d3844acfc9?source=rss-562013655beb------2</link>
            <guid isPermaLink="false">https://medium.com/p/38d3844acfc9</guid>
            <category><![CDATA[automation-testing]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[playwright-test]]></category>
            <category><![CDATA[playwright-community]]></category>
            <dc:creator><![CDATA[Akhil Singh Rawat]]></dc:creator>
            <pubDate>Wed, 01 Mar 2023 20:38:34 GMT</pubDate>
            <atom:updated>2023-03-01T20:38:34.939Z</atom:updated>
            <content:encoded><![CDATA[<h3>Introduction</h3><p>In Playwright, global-setup.js is a file that can be used to define code that is executed once before all tests in a test suite. It is useful for setting up common configurations, environment variables, or global objects.</p><h3>Creating a global-setup.js file</h3><p>To use global-setup.js, create a file with that name in the root directory of your project. In this file, you can define any setup code that you want to run before the tests. For example, you might want to set up a global object that is used by all the tests:</p><pre>// global-setup.js<br><br>const globalObject = {};<br>module.exports = async () =&gt; {<br>  // Set up the global object<br>  globalObject.foo = &#39;bar&#39;;<br>};</pre><p>This code sets up a global object called globalObject, and sets its foo property to &#39;bar&#39;. This setup code will be executed once, before any tests are run.</p><h3>Using the global object in tests</h3><p>To use the global object in a test, you can simply reference it:</p><pre>// my-test.js<br><br>const { test } = require(&#39;@playwright/test&#39;);<br>test(&#39;My test&#39;, async ({ page }) =&gt; {<br>  // Use the global object<br>  console.log(globalObject.foo);<br>});</pre><p>This test code references the globalObject that was set up in global-setup.js, and logs its foo property to the console.</p><h3>Conclusion</h3><p>In summary, global-setup.js is a useful tool for setting up global configurations, environment variables, or objects that are needed by multiple tests in a test suite. By defining this code once in the global-setup.js file, you can ensure that it is executed before any tests are run, and is available to all the tests in the suite.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=38d3844acfc9" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Learning the basics — Xpath]]></title>
            <link>https://medium.com/@akhilsr20/learning-the-basics-xpath-77742fb180d?source=rss-562013655beb------2</link>
            <guid isPermaLink="false">https://medium.com/p/77742fb180d</guid>
            <category><![CDATA[xpath]]></category>
            <category><![CDATA[playwright-test]]></category>
            <category><![CDATA[playwright-community]]></category>
            <category><![CDATA[automation-testing]]></category>
            <dc:creator><![CDATA[Akhil Singh Rawat]]></dc:creator>
            <pubDate>Mon, 27 Feb 2023 20:13:10 GMT</pubDate>
            <atom:updated>2023-03-01T11:57:38.346Z</atom:updated>
            <content:encoded><![CDATA[<h3>Learning the basics — Xpath</h3><p>XPath is a powerful tool for locating elements on a webpage, and it’s widely used in web development and testing. Playwright supports XPath locators, and it’s a great way to navigate through complex web pages and find the elements you need. In this blog post, we’ll introduce XPath and show you how to use it with playwright.</p><h3>What is XPath?</h3><p>XPath stands for XML Path Language, and it’s a query language used to traverse and select elements from an XML or HTML document. XPath expressions are used to identify elements on a web page and can be used to extract data from them. XPath expressions consist of one or more path expressions that are separated by slashes (/). Path expressions can select elements based on their name, attribute values, or position in the document tree.</p><h3>XPath Syntax</h3><p>XPath expressions use a syntax that is similar to file system paths. Here are a few examples:</p><ul><li><strong>//tagname</strong> selects all elements with the specified tag name.</li><li><strong>//tagname[@attribute=&#39;value&#39;] </strong>selects all elements with the specified tag name and attribute value.</li><li><strong>//tagname[contains(text(),&#39;value&#39;)]</strong> selects all elements with the specified tag name and containing the specified text.</li><li><strong>//tagname[position()=1]</strong> selects the first element with the specified tag name.</li></ul><p><strong>Using XPath with Playwright</strong></p><p>Playwright provides a method called page.locator() that can be used to locate an element on a web page using an XPath expression. Here&#39;s an example:</p><pre>let element = await page.locator(&quot;//input[@id=&#39;username&#39;]&quot;)</pre><p>This expression finds the input element with an id attribute of &quot;username&quot;.</p><h3>XPath Axes</h3><p>XPath provides a set of axes that can be used to select elements based on their relationship to other elements. Here are a few examples:</p><ol><li>Ancestor Axis</li><li>Descendant Axis</li><li>Following Axis</li><li>Following-sibling Axis</li><li>Parent Axis</li><li>Preceding Axis</li><li>Preceding-sibling Axis</li><li>Self Axis</li></ol><p>Below are some examples to explain each of the XPath axes:</p><ul><li><strong>Ancestor Axis:</strong> Selects all the ancestors of the current node.</li></ul><p><strong>Example:</strong> //div[@class=&#39;child&#39;]/ancestor::*</p><p>This XPath expression selects all the ancestors of the div element with class child.</p><ul><li><strong>Descendant Axis:</strong> Selects all the descendants of the current node.</li></ul><p>Example: //div[@class=&#39;parent&#39;]/descendant::*</p><p>This XPath expression selects all the descendants of the div element with class parent.</p><ul><li><strong>Following Axis:</strong> Selects all the nodes that come after the current node.</li></ul><p>Example: //div[@class=&#39;current&#39;]/following::*</p><p>This XPath expression selects all the nodes that come after the div element with class current.</p><ul><li><strong>Following-sibling Axis:</strong> Selects all the siblings that come after the current node.</li></ul><p>Example: //div[@class=&#39;current&#39;]/following-sibling::*</p><p>This XPath expression selects all the siblings that come after the div element with class current.</p><ul><li><strong>Parent Axis:</strong> Selects the parent of the current node.</li></ul><p>Example: //div[@class=&#39;child&#39;]/parent::*</p><p>This XPath expression selects the parent of the div element with class child.</p><ul><li><strong>Preceding Axis:</strong> Selects all the nodes that come before the current node.</li></ul><p>Example: //div[@class=&#39;current&#39;]/preceding::*</p><p>This XPath expression selects all the nodes that come before the div element with class current.</p><ul><li><strong>Preceding-sibling Axis:</strong> Selects all the siblings that come before the current node.</li></ul><p>Example: //div[@class=&#39;current&#39;]/preceding-sibling::*</p><p>This XPath expression selects all the siblings that come before the div element with class current.</p><ul><li><strong>Self Axis:</strong> Selects the current node.</li></ul><p>Example: //div[@class=&#39;current&#39;]/self::*</p><p>This XPath expression selects the div element with class current.</p><p>In conclusion, XPath axes are a powerful tool that can be used to select elements on a web page based on their relationship to other elements. By understanding how to use these axes, you can write more targeted and effective XPath expressions for your test automation scripts.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=77742fb180d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Playwright 104: Locators]]></title>
            <link>https://medium.com/@akhilsr20/playwright-104-locators-94a9e60080df?source=rss-562013655beb------2</link>
            <guid isPermaLink="false">https://medium.com/p/94a9e60080df</guid>
            <category><![CDATA[playwright-community]]></category>
            <category><![CDATA[playwright-test]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[automation-testing]]></category>
            <dc:creator><![CDATA[Akhil Singh Rawat]]></dc:creator>
            <pubDate>Mon, 27 Feb 2023 19:41:41 GMT</pubDate>
            <atom:updated>2023-02-27T19:41:41.528Z</atom:updated>
            <content:encoded><![CDATA[<p>Locators are an essential part of browser automation frameworks like Playwright. They are used to identify and interact with different elements on a webpage. Locators are essentially a way to find an element on a webpage using different attributes like ID, class name, name, and more. In this blog post, we will explore the different types of locators in Playwright and how to use them effectively.</p><p>Types of Locators in Playwright:</p><ul><li><a href="https://playwright.dev/docs/locators#locate-by-role">page.getByRole()</a> to locate by explicit and implicit accessibility attributes.</li><li><a href="https://playwright.dev/docs/locators#locate-by-text">page.getByText()</a> to locate by text content.</li><li><a href="https://playwright.dev/docs/locators#locate-by-label">page.getByLabel()</a> to locate a form control by associated label’s text.</li><li><a href="https://playwright.dev/docs/locators#locate-by-placeholder">page.getByPlaceholder()</a> to locate an input by placeholder.</li><li><a href="https://playwright.dev/docs/locators#locate-by-alt-text">page.getByAltText()</a> to locate an element, usually image, by its text alternative.</li><li><a href="https://playwright.dev/docs/locators#locate-by-title">page.getByTitle()</a> to locate an element by its title attribute.</li><li>page.locator() to locate an element by xpath / selector</li></ul><p><strong>page.getByRole()</strong></p><p>Playwright’s page.getByRole() method is used to locate elements on a webpage based on their role attribute. The role attribute describes an element&#39;s purpose or function, which can assist assistive technologies and improve accessibility.</p><p>This method takes a role name as a parameter and returns the first element that matches the specified role.</p><p>Here’s an example of how to use page.getByRole() to locate a button on a webpage:</p><pre>const searchButton = await page.getByRole(&#39;button&#39;, { name: &#39;Search&#39; });</pre><p><strong>Page.getByText()</strong></p><p>The page.getByText() method in Playwright is used for locating elements on a webpage based on their text content. It accepts a string as a parameter and returns the first element on the page that contains the specified text. It&#39;s a versatile method that can be used to locate a variety of elements on a webpage, including links, buttons, and paragraphs.</p><p>Here’s an example of how to use page.getByText() to locate a heading on a webpage:</p><pre>const exampleHeading = await page.getByText(&#39;Example Domain&#39;);</pre><p><strong>page.getByLabel()</strong></p><p>page.getByLabel() is a locator method provided by Playwright that is used for locating form elements on a webpage based on their label text. It accepts a string as a parameter and returns the first element on the page that has a label with the specified text.</p><p>Here’s an example of how to use page.getByLabel() to locate a form input on a webpage:</p><pre>const input = await page.getByLabel(&#39;Username:&#39;);</pre><p><a href="https://playwright.dev/docs/locators#locate-by-placeholder"><strong>page.getByPlaceholder()</strong></a></p><p>page.getByPlaceholder() is a locator method in Playwright that is used for locating form elements on a webpage based on their placeholder text. It accepts a string as a parameter and returns the first element on the page that has a placeholder attribute with the specified text.</p><p>Here’s an example of how to use page.getByPlaceholder() to locate a search input on a webpage:</p><pre>const searchInput = await page.getByPlaceholder(&#39;Search...&#39;);</pre><p><a href="https://playwright.dev/docs/locators#locate-by-alt-text"><strong>page.getByAltText()</strong></a></p><p>page.getByAltText() is a locator method in Playwright that is used for locating image elements on a webpage based on their alt text. It accepts a string as a parameter and returns the first element on the page that has an alt attribute with the specified text.</p><p>Here’s an example of how to use page.getByAltText() to locate an image on a webpage:</p><pre>const image = await page.getByAltText(&#39;A cute cat&#39;);</pre><p><a href="https://playwright.dev/docs/locators#locate-by-title"><strong>page.getByTitle()</strong></a></p><p>page.getByTitle() is a locator method in Playwright that is used for locating elements on a webpage based on their title attribute. It accepts a string as a parameter and returns the first element on the page that has a title attribute with the specified text.</p><p>Here’s an example of how to use page.getByTitle() to locate an element with a specific title:</p><pre>const element = await page.getByTitle(&#39;My tooltip text&#39;);</pre><p><strong>page.locator</strong></p><p>The method returns an element locator that can be used to perform actions on this page / frame. Locator is resolved to the element immediately before performing an action, so a series of actions on the same locator can in fact be performed on different DOM elements. That would happen if the DOM structure between those actions has changed.</p><pre>const element = await page.locator(&#39;custom xpath&#39;);</pre><h3>Conclusion</h3><p>Locators are a crucial aspect of writing effective automation scripts in Playwright. Playwright provides several built-in locator methods that can be used to locate elements on a webpage, as well as several convenience methods that make it easier to interact with those elements.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=94a9e60080df" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Playwright 103: Playwright vs Cypress]]></title>
            <link>https://medium.com/@akhilsr20/playwright-103-playwright-vs-cypress-2345abcdfcea?source=rss-562013655beb------2</link>
            <guid isPermaLink="false">https://medium.com/p/2345abcdfcea</guid>
            <category><![CDATA[automation]]></category>
            <category><![CDATA[playwright-test]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[playwright-community]]></category>
            <dc:creator><![CDATA[Akhil Singh Rawat]]></dc:creator>
            <pubDate>Mon, 27 Feb 2023 18:27:14 GMT</pubDate>
            <atom:updated>2023-02-27T18:27:14.937Z</atom:updated>
            <content:encoded><![CDATA[<h3>Introduction</h3><p>When it comes to testing web applications, there are many different automation frameworks to choose from. Two popular choices are Playwright and Cypress. In this article, we’ll compare the two frameworks and explore their similarities and differences.</p><h3>Architecture</h3><p>One of the main differences between Playwright and Cypress is their architecture. Playwright is a multi-page, multi-context framework, which means that it can work with multiple pages and contexts at the same time. This makes it more efficient and faster than other frameworks that work on a single-threaded architecture.</p><p>Cypress, on the other hand, runs in a single-threaded environment and executes commands sequentially. This can make it slower for complex applications that require a lot of interaction with the browser.</p><h3>API</h3><p>Both Playwright and Cypress have a simple and intuitive API, but Cypress is generally considered to be easier to learn and use. Cypress provides a higher-level API that abstracts away many of the complexities of browser automation, while Playwright’s API is more low-level and requires a bit more knowledge of JavaScript.</p><p>Here’s an example of how to use Playwright to navigate to a website and fill in a form:</p><pre>const { chromium } = require(&#39;playwright&#39;);<br><br>(async () =&gt; {<br>  const browser = await chromium.launch();<br>  const context = await browser.newContext();<br>  const page = await context.newPage();<br>  <br>  await page.goto(&#39;https://www.example.com&#39;);<br>  await page.fill(&#39;#username&#39;, &#39;john.doe&#39;);<br>  await page.fill(&#39;#password&#39;, &#39;password123&#39;);<br>  await page.click(&#39;#login-button&#39;);<br>  <br>  await browser.close();<br>})();</pre><p>And here’s how to achieve the same thing with Cypress:</p><pre>describe(&#39;Login&#39;, () =&gt; {<br>  it(&#39;Logs in successfully&#39;, () =&gt; {<br>    cy.visit(&#39;https://www.example.com&#39;);<br>    cy.get(&#39;#username&#39;).type(&#39;john.doe&#39;);<br>    cy.get(&#39;#password&#39;).type(&#39;password123&#39;);<br>    cy.get(&#39;#login-button&#39;).click();<br>  });<br>});</pre><p>As you can see, the Cypress code is more concise and easier to read, but it also hides some of the underlying complexity of browser automation.</p><h3>Cross-Browser Support</h3><p>One advantage of Playwright is that it supports Chromium, Firefox, and WebKit browsers out of the box, while Cypress only supports Chromium-based browsers. However, both frameworks allow you to run tests in headless mode and to customize the browser configuration.</p><h3>Community Support</h3><p>Cypress has a larger community than Playwright, which means that it has more resources and support available. Cypress also has a comprehensive documentation and a large number of plugins and integrations. However, Playwright has a growing community and is quickly gaining popularity.</p><p><strong>Playwright vs Cypress</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/628/1*zD3Ne89K8mfE3p7R-NGd0w.png" /></figure><h3>Conclusion</h3><p>In summary, both Playwright and Cypress are excellent choices for web application testing, but they have different strengths and weaknesses. Playwright is faster and more efficient, supports more browsers, and has a low-level API. Cypress is easier to learn and use, has a large community and extensive documentation, and provides a higher-level API.</p><p>Ultimately, the choice between Playwright and Cypress depends on your specific needs and preferences. If you prioritize performance and browser support, Playwright may be the better choice. If you prefer ease of use and a larger community, Cypress may be the way to go.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2345abcdfcea" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>