<?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 Sumithra Anandhajothi on Medium]]></title>
        <description><![CDATA[Stories by Sumithra Anandhajothi on Medium]]></description>
        <link>https://medium.com/@sumithra.anand687?source=rss-b32cdc1bb07d------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*Z6UbzPV4XBX5cKibWNwNdA.jpeg</url>
            <title>Stories by Sumithra Anandhajothi on Medium</title>
            <link>https://medium.com/@sumithra.anand687?source=rss-b32cdc1bb07d------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 19 Nov 2026 22:18:10 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@sumithra.anand687/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[Understanding AI Skill Files: Creating Reusable Instructions for AI Assistants]]></title>
            <link>https://medium.com/@sumithra.anand687/understanding-ai-skill-files-creating-reusable-instructions-for-ai-assistants-57478439d8df?source=rss-b32cdc1bb07d------2</link>
            <guid isPermaLink="false">https://medium.com/p/57478439d8df</guid>
            <category><![CDATA[ai-assistant]]></category>
            <category><![CDATA[ai-skill-file]]></category>
            <category><![CDATA[skill-file]]></category>
            <dc:creator><![CDATA[Sumithra Anandhajothi]]></dc:creator>
            <pubDate>Fri, 23 Oct 2026 18:00:28 GMT</pubDate>
            <atom:updated>2026-10-23T18:04:20.462Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uyf-CkcRYJrIskmrOM7mNQ.jpeg" /></figure><p><strong>Introduction:</strong></p><p>AI assistants, such as GitHub Copilot can help developers write code, generate test cases, review existing implementations, and troubleshoot issues. The quality of the output depends on how clearly we communicate our requirements.</p><p>When working on a project, we may repeatedly provide the same instructions, such as following existing coding conventions, reusing components and avoiding duplicate code.</p><p>Instead of repeating these instructions for every task, we can organize them into reusable files called <strong>AI skill files</strong>.</p><p>In this article, I will explain what AI skill files are, how they differ from prompts, and how to create one using a practical example from Playwright testing.</p><p><strong>What is an AI Skill File ?</strong></p><p>An AI skill file contains reusable instructions that guide an AI assistant when performing a particular type of task.</p><p>For example, a Playwright testing skill can include instructions to:</p><ul><li>Review the existing project structure before making changes.</li><li>Reuse existing page objects and BDD step definitions.</li><li>Follow the project’s coding conventions.</li><li>Avoid duplicate test scenarios.</li><li>Include meaningful assertions.</li><li>Avoid unnecessary hard-coded waits.</li></ul><p>These instructions help communicate the expected approach when the skill is used in a supported AI environment.</p><p>A skill file does not guarantee correct results. The generated code and recommendations still need to be reviewed and validated.</p><p><strong>Skill File vs. Prompt :</strong></p><p>Although prompts and skill files are related, they serve different purposes.</p><p><strong>A prompt</strong> describes a specific task.</p><p>Example:</p><p>Create a negative login test for invalid password credentials using the existing Playwright framework.</p><p><strong>A skill file</strong> contains reusable instructions for approaching tasks.</p><p><strong>Example:</strong></p><p>Before adding a test, check the existing feature files and step definitions. Reuse existing components and avoid duplicate scenarios.</p><p>The prompt explains what to do ,while the skill provides guidance on how to appraoch the task.</p><p>Together, they can help communicate both task-specific requirements and reusable project conventions.</p><p><strong>Understanding the Structure of a Skill File:</strong></p><p>A skill file contains metadata and instructions that guide an AI assistant when performing a particular task.</p><p>In my project, I created a playwright-testing skill with the following structure:</p><p><strong>skills/</strong></p><p><strong>└── playwright-testing/</strong></p><p><strong>└── SKILL.md</strong></p><p><strong>The beginning of my actual SKILL.md file looks like this:</strong></p><p><strong>name: playwright-testing</strong></p><p><strong>description: Create and review Playwright UI automation tests using JavaScript for this QA project, with a focus on existing page-object and BDD conventions.</strong></p><p>The metadata identifies the skill and describes its purpose.</p><p>Below the metadata, I organized the instructions under <strong>Working Rules</strong>. These rules guide the AI assistant when working with the existing automation framework.</p><p>The instructions cover several areas:</p><ul><li><strong>Review the existing project:</strong> Inspect relevant feature files, page objects, step definitions, test data, and configuration before writing code.</li><li><strong>Reuse existing components:</strong> Extend existing page objects and step definitions rather than creating duplicate implementations.</li><li><strong>Choose appropriate Playwright locators:</strong> Prefer stable, accessible locators such as getByRole, getByLabel, and getByTestId when appropriate.</li><li><strong>Follow project conventions:</strong> Maintain the repository’s existing coding style and module-import patterns.</li><li><strong>Write meaningful assertions:</strong> Verify the expected application behavior.</li><li><strong>Avoid unnecessary waits:</strong> Prefer reliable synchronization over unnecessary hard-coded delays.</li><li><strong>Review generated code:</strong> Check that proposed changes follow the project’s conventions and meet the task requirements.</li></ul><p>These instructions are specific to my Playwright project not a generic set of testing guidelines.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FT9tpA4-UOgetzHlY8mpow.png" /><figcaption>Figure 1 : Playwright Skill file</figcaption></figure><p>The exact metadata and directory structure can vary depending on the AI tool and its skill-file conventions. The important point is to keep the instructions clear, relevant, and aligned with the project in which the skill will be used.</p><p><strong>Creating a Playwright Testing Skill</strong></p><p>I created a playwright-testing skill while working with GitHub Copilot in Visual Studio Code.</p><p>The purpose was to organize reusable instructions for AI-assisted testing in an existing Playwright project.</p><p><strong>A Practical Example: Writing a Negative Login Test</strong></p><p>To explore how the skill could be used, I provided the following task prompt:</p><p><strong>/playwright-testing</strong></p><p><strong>Based on your analysis, implement a negative login test</strong></p><p><strong>for invalid password credentials.</strong></p><p><strong>Requirements:</strong></p><p><strong>1. Reuse the existing login page object.</strong></p><p><strong>2. Reuse existing BDD step definitions.</strong></p><p><strong>3. Do not create duplicate step definitions.</strong></p><p><strong>4. Add a scenario to the existing Login.feature file</strong></p><p><strong>only if an equivalent scenario does not already exist.</strong></p><p><strong>5. Follow the project’s existing test-data conventions.</strong></p><p><strong>6. Explain which files you intend to change before</strong></p><p><strong>making any changes.</strong></p><p><strong>Do not modify unrelated files.</strong></p><p>Here, <strong>/playwright-testing</strong> was the invocation syntax used in my environment. The syntax may differ between AI tools.</p><p>The remaining instructions described the task and the constraints the assistant should follow.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/335/1*BUvD_n7GIjMNiOGTTIjP5w.png" /><figcaption>Figure2: Task prompt</figcaption></figure><p>When I tried this task, the AI assistant identified an existing equivalent scenario in the project. So, adding another scenario was unnecessary.</p><p><strong>Other uses of AI skill:</strong></p><p>The same concept can be applied to other software development and testing activities.</p><ul><li><strong>API testing:</strong> Guide the assistant to validate status codes, response bodies, headers, and schemas.</li><li><strong>Code reviews:</strong> Provide guidelines for identifying potential defects, duplication, and maintainability issues.</li><li><strong>Test case generation:</strong> Encourage consideration of positive, negative, boundary, and edge cases.</li><li><strong>Debugging:</strong> Guide the assistant to inspect relevant code and error messages before suggesting potential fixes.</li></ul><p><strong>Conclusion:</strong></p><p>AI skill files provide a way to organize reusable instructions for AI assistants. They can describe how to approach recurring tasks while incorporating relevant project conventions.</p><p>Through my Playwright testing , I explored how instructions can encourage code reuse, prevent duplicate scenarios, and make proposed file changes easier to review.</p><p>My learning is a useful AI skill file should contain clear, focused instructions tailored to a specific task or workflow.</p><p>AI skill files are not a replacement for code reviews, or test execution. They are another way to structure instructions when working with AI-assisted development tools.</p><p>Thank you for reading this blog. Hope you find this useful.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=57478439d8df" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Beyond the 200 OK: Understanding Positive and Negative API Testing]]></title>
            <link>https://medium.com/@sumithra.anand687/beyond-the-200-ok-understanding-positive-and-negative-api-testing-98e7cebe2b8b?source=rss-b32cdc1bb07d------2</link>
            <guid isPermaLink="false">https://medium.com/p/98e7cebe2b8b</guid>
            <category><![CDATA[api-testing]]></category>
            <category><![CDATA[negative-api-testing]]></category>
            <category><![CDATA[qa-and-testing]]></category>
            <category><![CDATA[positive-api-testing]]></category>
            <category><![CDATA[postman-testing]]></category>
            <dc:creator><![CDATA[Sumithra Anandhajothi]]></dc:creator>
            <pubDate>Thu, 22 Oct 2026 15:39:42 GMT</pubDate>
            <atom:updated>2026-10-22T15:39:42.786Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/618/1*EIekUQ2ASolk6lcI468qQw.jpeg" /></figure><p><strong>Introduction:</strong></p><p>When testing an API, one of the first things we usually check is the HTTP status code. If an API returns 200 OK, we think that everything is working as expected. But,</p><p>is checking the status code enough?</p><p>During my API testing experience, I realized that validating an API involves more than checking whether the server returned a successful response. We also need to verify the response body, validate the expected data, check error handling, and ensure that the API behaves correctly when it receives invalid input.</p><p>Let’s explore the positive and negative API testing using practical examples from my experience testing an APIs with Postman.</p><p><strong>1. Positive API Testing: Validating a Successful Login</strong></p><p>Positive API testing verifies whether an API behaves as expected when it receives valid input.</p><p>For example, consider a login API that accepts an email address and password. When valid credentials are provided, the API should authenticate the user and return the expected response.</p><p><strong>Admin Login Test</strong></p><p>For positive testing scenario, I used the Admin Login POST request in Postman.</p><p>The API returned the following results:</p><ul><li><strong>HTTP status:</strong> 200 OK</li><li><strong>Response body:</strong> JSON containing an authentication token, login email, and user role.</li><li><strong>Content type:</strong> JSON.</li><li><strong>Postman assertions:</strong> Six passed and one failed.</li></ul><p>I configured multiple assertions to validate the response.</p><p>One of the assertions checked the HTTP status code:</p><p><strong>pm.test(“Status code is 200”, () =&gt; {</strong></p><p><strong>pm.response.to.have.status(200);</strong></p><p><strong>});</strong></p><p><strong>This assertion verifies that the API returns the expected status code.</strong></p><p><strong>Validating the status code was only one part of my testing but i also</strong></p><p><strong>checked whether the response time was below 400 milliseconds:</strong></p><p><strong>pm.test(“Response time is less than 400ms”, () =&gt; {</strong></p><p><strong>pm.expect(pm.response.responseTime).to.be.below(400);</strong></p><p><strong>});</strong></p><p><strong>My observation:</strong></p><p>The API returned 200 OK, but the response took approximately 1,361 milliseconds.</p><p>As a result, six of my seven assertions passed, while the response-time assertion failed.</p><p>The failure happened because of the actual response time exceeded my configured threshold of 400 milliseconds.</p><p>This was an interesting observation. The API returned the expected login response, but the request did not meet my performance threshold.</p><p>This experience helped me understand that functional validation and performance validation measure different aspects of API behavior.</p><p><strong>2. JSON Schema Validation: Checking the Response Structure</strong></p><p>Checking the HTTP status code is important, but it doesn’t tell us whether the response follows the expected structure.</p><p>For example, a login API might return 200 OK, but what if the userId is returned as a string instead of an integer? Or what if the roles field is returned in an unexpected format?</p><p>This is where JSON schema validation becomes useful.</p><p>In my API project, I implemented JSON schema validation in Postman to verify the structure and data types of the Admin Login response.</p><p>My schema defined the expected properties, including the authentication token, token type, user ID, login email, and user roles. I also specified which fields were required.</p><p>Here is the actual implementation:</p><p>// JSON Schema Validation</p><p><strong>var schema = {</strong></p><p><strong>“type”: “object”,</strong></p><p><strong>“properties”: {</strong></p><p><strong>“token”: {</strong></p><p><strong>“type”: “string”</strong></p><p><strong>},</strong></p><p><strong>“type”: {</strong></p><p><strong>“type”: “string”</strong></p><p><strong>},</strong></p><p><strong>“userId”: {</strong></p><p><strong>“type”: “integer”</strong></p><p><strong>},</strong></p><p><strong>“loginUserEmail”: {</strong></p><p><strong>“type”: “string”</strong></p><p><strong>},</strong></p><p><strong>“roles”: {</strong></p><p><strong>“type”: “array”,</strong></p><p><strong>“items”: {</strong></p><p><strong>“type”: “string”</strong></p><p><strong>}</strong></p><p><strong>}</strong></p><p><strong>},</strong></p><p><strong>“required”: [</strong></p><p><strong>“token”,</strong></p><p><strong>“type”,</strong></p><p><strong>“userId”,</strong></p><p><strong>“loginUserEmail”,</strong></p><p><strong>“roles”</strong></p><p><strong>]</strong></p><p><strong>};</strong></p><p>The required array ensures that these five properties must be present in the response. The schema also defines the expected data type of each property.</p><p>I then validated the response against the schema:</p><p><strong>pm.test(“Schema is valid”, () =&gt; {</strong></p><p><strong>pm.response.to.have.jsonSchema(schema);</strong></p><p><strong>});</strong></p><p>In addition to schema validation, I used individual assertions to check the response field types:</p><p><strong>pm.test(“Get type of login response fields”, () =&gt; {</strong></p><p><strong>pm.expect(jsonData.token).to.be.a(“string”);</strong></p><p><strong>pm.expect(jsonData.type).to.be.a(“string”);</strong></p><p><strong>pm.expect(jsonData.loginUserEmail).to.be.a(“string”);</strong></p><p><strong>pm.expect(jsonData.userId).to.be.a(“number”);</strong></p><p><strong>pm.expect(jsonData.roles).to.be.an(“array”);</strong></p><p><strong>});</strong></p><p>In Admin Login test, both the schema validation and field-type validation assertions passed.</p><p>The schema check verified that the response matched the defined structure and required fields. The individual assertions provided additional checks on the expected field types.</p><p>Here schema validation does not prove that the returned values are correct. A token can be a string without being a valid token, and a user ID can be a number without belonging to the expected user and those requirements need separate assertions.</p><p>This helped me understand that reliable API testing involves checking the response structure, the actual values and the expected application behavior .</p><p><strong>3. Negative API Testing: Login with Invalid Credentials</strong></p><p>Positive testing checks whether an API works correctly with valid input.</p><p>Negative API testing checks whether the API handles invalid input, unauthorized requests, and unsupported endpoints correctly.</p><p>The objective is not to make an invalid request succeed. Instead, we want to verify that the API rejects the request appropriately and returns the expected error response.</p><p><strong>Invalid Login Test</strong></p><p>I sent a POST request to the /login endpoint using invalid credentials.</p><p>The API returned a 401 Unauthorized response with the following error details:</p><p><strong>{</strong></p><p><strong>“errorCode”: “Invalid UserName or Password”,</strong></p><p><strong>“errorMessage”: “Bad credentials”</strong></p><p><strong>}</strong></p><p>I used the following assertions in Postman:</p><p><strong>pm.test(“Status code is 401 for invalid credentials”, () =&gt; {</strong></p><p><strong>pm.response.to.have.status(401);</strong></p><p><strong>});</strong></p><p><strong>pm.test(“Error message indicates bad credentials”, () =&gt; {</strong></p><p><strong>var jsonData = pm.response.json();</strong></p><p><strong>pm.expect(jsonData.errorMessage).to.eql(“Bad credentials”);</strong></p><p><strong>});</strong></p><p>Here both assertions passed. The first assertion verified the HTTP status code, while the second checked the expected error message.</p><p>A negative test can pass even when the API returns an error status. What matters is whether the API behaves as expected for the invalid request.</p><p><strong>4. Negative API Testing: Requesting an Invalid Endpoint</strong></p><p>Another scenario involved sending a request to an incorrect endpoint.</p><p>Instead of using /login, I used /loginn.</p><p>The API returned a 404 Not Found response:</p><p><strong>{</strong></p><p><strong>“status”: 404,</strong></p><p><strong>“error”: “Not Found”,</strong></p><p><strong>“message”: “Endpoint not supported.”</strong></p><p><strong>}</strong></p><p>The response shows that the requested endpoint are not supported.</p><p>The Postman test results showed that both configured assertions passed. So this example shows that different negative scenarios can produce different HTTP status codes.</p><p>Invalid login credentials returned 401 Unauthorized, while the invalid endpoint returned 404 Not Found.</p><p>Understanding this difference helps us create more meaningful test cases and validate the expected behavior of individual endpoints.</p><ul><li>A contact number containing letters.</li><li>An invalid date of birth.</li><li>An incorrectly formatted email address.</li></ul><p>The API returned:</p><p><strong>{</strong></p><p><strong>“status”: 400,</strong></p><p><strong>“error”: “Bad Request”,</strong></p><p><strong>“message”: “An unexpected error occurred.”</strong></p><p><strong>}</strong></p><p>The response status was 400 Bad Request and both of my Postman assertions passed.</p><p>One assertion checked the status code. The other checked whether the response contained an error message.</p><p>However, the response raised an important question.</p><p>Does receiving a 400 Bad Request response prove that every invalid field was validated correctly?</p><p>Not necessarily.</p><p>Because the request contained multiple invalid values, I could confirm that the request was rejected, but I could not determine which field caused the rejection from this response alone.</p><p>The generic error message also did not identify the specific validation problem.</p><p>This experience helped me understand that passing assertions only confirms that the configured expectations were met. It does not automatically prove that every validation rule works correctly or that the error message provides sufficient detail.</p><p><strong>5. Common Mistakes to Avoid in API Testing</strong></p><p>Based on these examples, there are several things testers should keep in mind.</p><p><strong>Checking Only the Status Code</strong></p><p>A 200 OK response does not prove that the response contains the correct data or that every test condition has passed.</p><p>Validate the response body, required fields, data types, and business rules.</p><p><strong>Assuming Every Negative Test Should Fail</strong></p><p>A negative test should pass when the API correctly handles invalid input.</p><p>For example, receiving the expected 401 Unauthorized response for invalid credentials can represent a successful test.</p><p>The request is rejected, but the test passes because the API behaved as expected.</p><p><strong>Writing Overly Broad Assertions</strong></p><p>Checking only whether an error message exists may not be enough.</p><p>If the API contract specifies a particular validation message, the test should verify that expected message rather than accepting any string.</p><p><strong>Mixing Multiple Invalid Inputs in One Test</strong></p><p>Testing several invalid fields together can make it difficult to determine the cause of a failure.</p><p>Where appropriate, isolate invalid conditions so that each test verifies a specific validation rule.</p><p><strong>Treating Every Failed Assertion as an Application Defect</strong></p><p>A failed assertion means that an expectation was not met. The reason could be an application defect, an unrealistic performance threshold, incorrect test data, or an issue with the test itself.</p><p>Investigating the failure is an important part of testing.</p><p><strong>6. What I Learned from These Tests</strong></p><p>Working with positive and negative API testing helped me understand that API validation involves multiple layers.</p><p><strong>Functional validation</strong> checks whether the API behaves as expected for valid and invalid requests.</p><p><strong>Response validation</strong> checks whether the response contains the expected fields, data types, and error information.</p><p><strong>Schema validation</strong> checks whether the response follows a predefined structure and satisfies its required-field and type constraints.</p><p><strong>Performance validation</strong> checks whether the response time meets the defined threshold.</p><p>These checks complement one another, but they measure different aspects of API behavior.</p><p>The Admin Login example was particularly useful because it showed that an API can return 200 OK while one of the configured assertions fails.</p><p>The negative testing examples also demonstrated that receiving an error response does not automatically mean the test failed. If the API rejects an invalid request as expected, the negative test can pass.</p><p><strong>Conclusion:</strong></p><p>My experience with positive and negative API testing helped me understand that API validation requires more than checking HTTP status codes.</p><p>A successful positive test should verify that valid requests produce the expected results. A successful negative test should verify that invalid requests are rejected according to the API’s expected behavior.</p><p>Postman makes it possible to automate these checks using JavaScript assertions, JSON schema validation, and response-time measurements.</p><p>Thanks for reading. I hope you find this blog useful.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=98e7cebe2b8b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Reliable Browser Dialog Handling in Playwright: A Case Study]]></title>
            <link>https://medium.com/@sumithra.anand687/reliable-browser-dialog-handling-in-playwright-a-case-study-4e820a4e2a3e?source=rss-b32cdc1bb07d------2</link>
            <guid isPermaLink="false">https://medium.com/p/4e820a4e2a3e</guid>
            <category><![CDATA[autoamtion-testing]]></category>
            <category><![CDATA[quality-assurance]]></category>
            <category><![CDATA[software-testing]]></category>
            <category><![CDATA[playwright-automation]]></category>
            <category><![CDATA[test-automation]]></category>
            <dc:creator><![CDATA[Sumithra Anandhajothi]]></dc:creator>
            <pubDate>Thu, 22 Oct 2026 01:42:55 GMT</pubDate>
            <atom:updated>2026-10-22T01:42:55.656Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/646/1*92iTr102toytVNCYbF2oGA.png" /></figure><p><strong>Introduction:</strong></p><p>Have you ever experienced a situation where a automated test fails unexpectedly, but the same test passes when you run it again?</p><p>These inconsistent test results can indicate flaky tests. They reduces automation speed and reliability and creates unnecessary debugging work. Not every automation failure is caused by flakiness. Sometimes, the problem lies in how the test interacts with the application.</p><p>While working on my Playwright BDD automation project, I encountered an interesting challenge while automating the Try Editor functionality. When valid Python code was executed, the application displayed the output normally. But, when invalid Python code was executed, the application displayed a JavaScript browser dialog containing an error message.</p><p>My automation needed to handle these dialogs without interrupting test execution.</p><p>Initially, I used Playwright’s page.waitForEvent(‘dialog’) to handle the dialog. During debugging, I encountered an issue with the event-handling sequence and changed my implementation to use page.once(‘dialog’, …).</p><p>This experience highlighted an important principle in UI automation: <strong>event listeners must be registered before the actions that trigger the events.</strong></p><p><strong>Understanding the Problem:</strong></p><p>The Try Editor automation need to support these three scenarios:</p><ul><li>Executing valid Python code and verifying the output.</li><li>Executing invalid Python code and handling the resulting browser dialog.</li><li>Executing empty input and handling the application’s response.</li></ul><p>The challenge was handling the browser dialog in the invalid and empty input scenarios.</p><p>If the dialog appears before the automation establishes its listener, the test can miss the event and fail.</p><p><strong>Investigating the Root Cause:</strong></p><p>When debugging browser automation, it is tempting to increase a timeout whenever a test fails while waiting for an event. However, a longer timeout is not always the right solution.</p><p>I focused on understanding the sequence of operations.</p><p><strong>Example:</strong></p><p><strong>await this.runBtn.click();</strong></p><p><strong>const dialog = await this.page.waitForEvent(‘dialog’);</strong></p><p><strong>await dialog.accept();</strong></p><p>In this implementation, the Run button is clicked before the automation starts waiting for the dialog.</p><p>If the application triggers the dialog before the wait is established, the automation risks missing the event and waiting unnecessarily.</p><p>Here page.waitForEvent() is valid Playwright API. The issue is the order in which the wait and the triggering action are performed.</p><p>So the investigation centered on three questions:</p><ol><li>When does the application trigger the browser dialog?</li><li>When does the automation register the dialog listener?</li><li>Is the listener ready before the Run button is clicked?</li></ol><p>This helped identify the importance of event synchronization.</p><p><strong>Implementing solution :</strong></p><p>I updated my runcode() method to register a dialog listener before clicking Run.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/523/1*RQlJ8XE3I3_3-mCxaVLmMQ.png" /><figcaption>Figure : code example</figcaption></figure><p>The key part of the implementation is:</p><p><strong>if (type === ‘invalid’ || type === ‘empty’) {<br> this.page.once(‘dialog’, async (dialog) =&gt; {<br> console.log(‘Dialog message:’, dialog.message());<br> await dialog.accept();<br> });<br>}</strong></p><p><strong>await this.runBtn.click();</strong></p><p>Let’s break down what happens here.</p><p><strong>1. Register the dialog handler</strong></p><p><strong>this.page.once(‘dialog’, async (dialog) =&gt; {<br> console.log(‘Dialog message:’, dialog.message());<br> await dialog.accept();<br>});</strong></p><p>The page.once() method registers a handler for the next matching dialog event. After the handler is invoked, Playwright removes that listener.</p><p><strong>Inside the handler:</strong></p><p>dialog.message() retrieves the dialog’s message.<br>dialog.accept() accepts the dialog, allowing the interaction to proceed.</p><p><strong>2. Register the handler before clicking Run</strong></p><p>await this.runBtn.click();</p><p>The handler is registered before the action that may trigger the dialog. This ensures that the automation is prepared to handle the expected event.</p><p><strong>3. Handle only the relevant scenarios</strong></p><p>The handler is registered only when the input type is invalid or empty. This keeps the dialog-handling logic aligned with the scenarios that are expected to produce a browser dialog.</p><p>This implementation makes the event-handling sequence explicit and keeps the logic within the page object.</p><p>Actually ,both approaches can be used to handle browser dialogs in Playwright, but they serve slightly different purposes.</p><p><strong>A. Using page.once()</strong></p><p>The page.once() method registers an event listener that executes when the specified event occurs. The listener is automatically removed after handling the event once.</p><p><strong>this.page.once(‘dialog’, async (dialog) =&gt; {<br> console.log(‘Dialog message:’, dialog.message());<br> await dialog.accept();<br>});</strong></p><p><strong>await this.runBtn.click();</strong></p><p>In this example, the dialog listener is registered before clicking the Run button. When the application triggers a dialog, the handler captures the message and accepts it.</p><p>This approach is useful when you want to register a handler for the next occurrence of an event.</p><p><strong>B. Using page.waitForEvent()</strong></p><p>The page.waitForEvent() method returns a promise that resolves when the specified event occurs. You can await that promise and then handle the event.</p><p><strong>const dialogPromise = this.page.waitForEvent(‘dialog’);</strong></p><p><strong>await this.runBtn.click();</strong></p><p><strong>const dialog = await dialogPromise;<br>console.log(‘Dialog message:’, dialog.message());<br>await dialog.accept();</strong></p><p>here the event wait is established before clicking the Run button. This ensures that Playwright is already waiting when the application triggers the dialog.</p><p>So this approach is useful when you want to wait for an event and handle it explicitly within your test flow.</p><p>Both approaches are valid for handling browser dialogs in Playwright. The choice depends on how you want to structure your automation.</p><p><strong>key Lessons Learned:</strong></p><p><strong>Understand the order of operations:</strong></p><p>When an action triggers a browser event, the automation must be prepared to handle that event before performing the action.</p><p><strong>Investigate the root cause instead of increasing timeouts:</strong></p><p>A longer timeout cannot recover an event that has already occurred. Understanding the execution sequence is more effective than simply extending the waiting period.</p><p><strong>Choose the appropriate event-handling mechanism:</strong></p><p>Both page.once() and page.waitForEvent() can be used to handle browser dialogs. The correct choice depends on the test&#39;s requirements and how the event is handled.</p><p><strong>Validate reliability through execution evidence:</strong></p><p>When investigating flaky tests, repeated runs and before-and-after comparisons provides the stronger evidence than a single successful execution.</p><p><strong>Conclusion:</strong></p><p>The Try Editor scenario in my project helped me understand the importance of browser event synchronization in Playwright automation.</p><p>By examining the event-handling sequence and registering the dialog listener before clicking Run, I implemented a more appropriate approach to handle the browser dialogs.</p><p>Thank you for reading! Hope you find this blog useful.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4e820a4e2a3e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Building a scalable playwright automation framework with JavaScript]]></title>
            <link>https://medium.com/@sumithra.anand687/building-a-scalable-playwright-automation-framework-with-javascript-b1e9b1d9b297?source=rss-b32cdc1bb07d------2</link>
            <guid isPermaLink="false">https://medium.com/p/b1e9b1d9b297</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[software-testing]]></category>
            <category><![CDATA[quality-assurance]]></category>
            <category><![CDATA[playwright-automation]]></category>
            <category><![CDATA[test-automation]]></category>
            <dc:creator><![CDATA[Sumithra Anandhajothi]]></dc:creator>
            <pubDate>Wed, 08 Jul 2026 21:55:34 GMT</pubDate>
            <atom:updated>2026-07-08T21:55:34.343Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5nndnm5RswGjsUeuKiz61w.png" /></figure><p><strong>Introduction:</strong></p><p>As I learned Playwright and worked on automation projects, I realized that building a robust automation framework involves more than just writing test scripts. A well-structured framework is essential for creating automation that is maintainable, reusable, and scalable.</p><p>In this article, I’ll share how I structured a Playwright automation framework using JavaScript, along with the key components that make it modular, reusable, and easy to manage.</p><p><strong>Why Playwright?</strong></p><p>In today’s fast-paced software development environment, delivering high-quality applications quickly is essential. Automation testing plays a vital role in achieving this goal, and <strong>Playwright</strong>, Microsoft’s open-source automation framework, has become one of the most popular choices for modern web application testing.</p><p>Playwright supports <strong>end-to-end testing, browser automation, web scraping, and browser interaction for AI-powered applications</strong>. Its rich feature set, excellent reliability, and impressive performance have made it a preferred framework for QA Automation Engineers and developers.</p><p>Some of the key advantages of Playwright includes:</p><p><strong>Built-in Auto-Waiting </strong>— Automatically waits for elements to become actionable, reducing flaky tests.<br><strong>Cross-Browser Support </strong>— Run the same tests on Chromium, Firefox, and Web Kit without changing your code.<br><strong>Cross-Platform Compatibility </strong>— Execute tests on Windows, macOS, and Linux.<br><strong>Multiple Language Support</strong> — Develop automation using JavaScript, TypeScript, Python, Java, or .NET.<br><strong>Browser Context Isolation </strong>— Create independent browser sessions for parallel execution and multi-user testing.<br><strong>Multiple Tabs and Windows Handling </strong>— Easily manage pop-ups, new tabs, and multiple browser windows.<br><strong>Mobile Device Emulation</strong> — Test responsive web applications using built-in device profiles.<br><strong>Fast Test Execution </strong>— Playwright’s modern architecture enables significantly faster execution compared to many traditional automation tools.<br><strong>Powerful Debugging Features</strong> — Trace Viewer, screenshots, videos, and execution logs simplify troubleshooting.<br><strong>Parallel Test Execution </strong>— Reduce execution time by running tests simultaneously across multiple browsers and environments.</p><p>These capabilities make Playwright an excellent choice for building scalable, maintainable, and reliable automation frameworks.</p><p><strong>Project Folder Structure:</strong></p><p>A well-organized project structure is the foundation of a scalable automation framework. Keeping test assets separated into logical folders improves maintainability, readability, and collaboration among team members.</p><p>A typical Playwright automation framework includes the following components:</p><p><strong>Configuration File </strong>— Stores framework settings such as browser configuration, timeouts, retries, reporters, and execution options.<br><strong>node modules</strong> — Contains all installed project dependencies managed by npm.<br><strong>tests</strong> (or <strong>features</strong>) — Stores test cases or BDD feature files.<br><strong>pages </strong>— Contains Page Object Model (POM) classes that encapsulate web element locators and page-specific methods.<br><strong>steps </strong>— Holds step definition files that implement the behavior described in BDD feature files.<br><strong>test-data </strong>— Stores external test data such as JSON, Excel, or CSV files to support data-driven testing.<br><strong>playwright-report </strong>— Generated HTML reports after test execution.<br><strong>test-results </strong>— Stores screenshots, videos, traces, and execution artifacts for failed or completed tests.<br>.<strong>env </strong>— Keeps environment-specific configuration such as application URLs, usernames, passwords, and API keys.<br>.<strong>git ignore</strong> — Excludes generated files, dependencies, reports, and sensitive information from version control.<br><strong>package.json</strong> — Defines project metadata, dependencies, npm scripts, and framework configuration.<br><strong>package-lock.json</strong> — Maintains consistent dependency versions across development environments.</p><p>Organizing the framework in this manner helps teams build automation solutions that are easier to scale, maintain, and integrate with CI/CD pipelines such as Jenkins or GitHub Actions.</p><p><strong>Example:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/350/1*_UC9yquP44_oc4D9f5xx3Q.png" /><figcaption><strong>Figure 1:</strong> Folder structure of the Playwright BDD automation framework.</figcaption></figure><p>The framework follows the Page Object Model (POM) design pattern, with separate folders for feature files, page objects, step definitions, test data, reports, and configuration files. This separation improves code reusability, maintenance and scalability.</p><p><strong>Playwright Configuration:</strong></p><p>The playwright.config.js file is the central configuration file for the framework. It defines browser settings, test execution options, retries, timeouts, reporting and application’s base URL. Centralizing these settings makes it easy to manage the framework without modifying individual test scripts.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/695/1*Yc42fDBI3znSG-T_HChzqg.png" /><figcaption><strong>Figure2 </strong>: Code snippet of config.js</figcaption></figure><p><strong>Base URL</strong> : The <strong>Base URL</strong> specifies the application’s main URL This base URL approach makes it easy to switch between different environments such as Development, QA, UAT, and Production by simply updating the environment variable.</p><p><strong>Headless mode</strong> :Headless mode determines whether the browser UI is displayed during test execution. By keeping it as true improves the test execution speed .</p><p><strong>Screenshots and video</strong> : Playwright can automatically capture screenshots and videos during test execution.</p><p>With the retain-on-failure option:</p><ul><li>A <strong>screenshot</strong> is saved when a test fails, helping identify the application’s state at the point of failure.</li><li>A <strong>video recording</strong> is retained only for failed tests, making it easier to analyze the the failure.</li></ul><p><strong>Page Object Model(POM):</strong></p><p>Page object model is a design pattern that organizes automation code by creating a separate class for each web page. Each page object contains the <strong>page’s locators and reusable methods</strong>, while test scripts focus only on the test scenarios.</p><p>POM separates page interactions from test logic making the framework clean and easy to maintain. If the web elements changes ,only the corresponding Page Object needs to be changed.</p><p><strong>A Simple Analogy 🍽️:</strong></p><p>Just think of a restaurant menu. When you order a pizza or a burger, you don’t tell the chef every ingredient or explain how to cook it — you simply place your order, and the chef takes care of the rest.</p><p>Similarly, in the Page Object Model, the test script simply calls a method like loginAsRegisteredUser(), while the Page Object handles all the underlying locators and browser interactions. This keeps the test scripts clean, reusable, and easy to understand.</p><p>Here is the <strong>Mapping</strong>,</p><p>Restaurant — — — — — -Playwright POM</p><p>Customer — — — — — — Test script</p><p>Order — — — — — — — — loginAsRegisteredUser() method call</p><p>Chef — — — — — — — — — Page Object</p><p>Recipe&amp;Cooking steps — — — Locators and playwright actions</p><p>Finished meal — — — — Successful login</p><p><strong>Benefits:</strong></p><ul><li>Improves code reusability</li><li>Makes test scripts easier to read</li><li>Easy maintenance</li><li>Supports scalable automation framework</li><li>Reduces code duplication</li></ul><p><strong>Example:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/867/1*Ogm28fZgf068yGxx_R7uTA.png" /><figcaption><strong>Figure3</strong>: A reusable loginAsRegisteredUser() method encapsulates all the login steps inside a Page Object.</figcaption></figure><p>await loginPage.loginAsRegisteredUser();</p><p>This single method call improves readability and eliminates duplicate login code across multiple test cases.</p><p><strong>Feature Files(BDD):</strong></p><p>Feature files are in Gherkin syntax format and describes application behavior in a simple ,human readable format. They use key words like <strong>Feature</strong>, <strong>Scenario</strong>, <strong>Given</strong>, <strong>When</strong>, <strong>Then</strong>, <strong>And </strong>and <strong>But </strong>making them easy for developers, testers and business stakeholders to understand.</p><p><strong>Benefits:</strong></p><ul><li>Easy to read and understand</li><li>clearly defines application behavior</li><li>Encourages collaboration between business and technical teams</li></ul><p><strong>Example:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/565/1*RJUBc6_b3qpoe8dokzTvUw.png" /><figcaption><strong>Figure4</strong>: Feature file with Gherkin syntax format.</figcaption></figure><p>This feature defines the application behavior using Gherkin syntax.</p><p><strong>Step Definitions :</strong></p><p>Step definition files connect the steps written in the feature file to the actual Playwright automation code. Each Given, When, and Then statement is implemented using JavaScript .</p><p><strong>Benefits :</strong></p><ul><li>Keeps feature files clean and readable</li><li>Reuses automation code across multiple scenarios</li><li>Separates business logic from implementation</li><li>Improves framework maintainability</li></ul><p><strong>Example:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/756/1*hT4GkhxvVG4WanzX60kAAQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/752/1*GRFer4PdERJS-9C4nkwKNg.png" /><figcaption><strong>Figure 5</strong>: Step definition file</figcaption></figure><p><strong>Test Execution :</strong></p><p>Once the framework is set up, Playwright tests can be executed using npm commands. Depending on the requirement, tests can be run on a specific browser or across multiple browsers. Below are the command to run tests,</p><p>To Run all tests:<br><strong>npm playwright test</strong><br>To Run tests on Chromium:<br><strong>npm playwright test — project=chromium</strong><br>To Run a specific feature:<br><strong>npm playwright test tests/login.spec.js</strong><br>To View the HTML Report:<br><strong>npm playwright show-report</strong></p><p>The HTML report provides a detailed summary of the test execution, including passed and failed test cases, execution time, screenshots, videos, and trace files for debugging.</p><p><strong>Test Reports:</strong></p><p>Playwright provides built-in reporting that helps analyze test execution results. The HTML report displays the status of each test case, execution time, and detailed error messages for failed tests. It also includes screenshots, videos, and trace files, making it easier to identify and troubleshoot issues.</p><p>The test report can be viewed using the following command:</p><p><strong>npm playwright show-report</strong></p><p><strong>Best Practices:</strong></p><p>While building a Playwright automation framework, consider the following best practices:</p><ul><li>Follow the Page Object Model (POM)<strong> </strong>to improve code reusability.</li><li>Keep test data separate from test scripts.</li><li>Store sensitive information in the .env file instead of hardcoding credentials.</li><li>Use meaningful locators to create stable and reliable tests.</li><li>Execute tests across multiple browsers to ensure compatibility.</li><li>Generate reports to analyze test execution and troubleshoot failures.</li></ul><p><strong>Conclusion:</strong></p><p>Building a scalable Playwright automation framework involves more than just writing automated test scripts. A well-structured framework with clear folder organization, reusable Page Objects, BDD feature files, centralized configuration, and reporting makes test automation easier to maintain and extend. With its speed, reliability, and rich feature set, Playwright is an excellent choice for modern web application testing.</p><p>Thank you for reading! Hope you find this article useful.</p><p><strong>References</strong> : <a href="https://playwright.dev/docs/">https://playwright.dev/docs/</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b1e9b1d9b297" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>