<?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 Divya Kandpal on Medium]]></title>
        <description><![CDATA[Stories by Divya Kandpal on Medium]]></description>
        <link>https://medium.com/@divyakandpal93?source=rss-562e472a3384------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*jJaN8LqxTrbbMnnUBzF_9g.jpeg</url>
            <title>Stories by Divya Kandpal on Medium</title>
            <link>https://medium.com/@divyakandpal93?source=rss-562e472a3384------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 19 Nov 2026 16:24:45 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@divyakandpal93/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[Managing Environment & Login Credentials in Playwright (Made Simple & Scalable)]]></title>
            <link>https://medium.com/@divyakandpal93/managing-environment-login-credentials-in-playwright-made-simple-scalable-c241d2a548cd?source=rss-562e472a3384------2</link>
            <guid isPermaLink="false">https://medium.com/p/c241d2a548cd</guid>
            <dc:creator><![CDATA[Divya Kandpal]]></dc:creator>
            <pubDate>Mon, 04 May 2026 04:36:01 GMT</pubDate>
            <atom:updated>2026-05-04T04:36:01.549Z</atom:updated>
            <content:encoded><![CDATA[<p>When building a Playwright test framework, one question always comes up:</p><p><em>“Where should we store environment details and login credentials?”</em></p><p>If you’ve ever hardcoded URLs or passwords inside your test files, you already know — it works… but only for a while.</p><p>As your framework grows, this quickly becomes:</p><ul><li>Hard to manage</li><li>Risky (security issues)</li><li>Painful to scale</li></ul><p>In this blog, we’ll break it down in a <strong>simple, beginner-friendly way</strong>, and then show how to <strong>scale it like a pro</strong> 🚀</p><h3>First, Understand the Problem</h3><p>Let’s say your test needs:</p><ul><li>A website URL</li><li>A username</li><li>A password</li></ul><h3>The Wrong Way (Hardcoding)</h3><pre>await page.goto(&#39;https://qa.myapp.com&#39;);<br>await loginPage.login(&#39;admin&#39;, &#39;password123&#39;);</pre><p>Problem:</p><ul><li>What if URL changes?</li><li>What if you need another environment (dev/prod)?</li><li>What if credentials are sensitive?</li></ul><p>The Right Idea: Use a .env File</p><p>Think of .env as a <strong>settings file</strong> for your project.</p><p>Instead of writing values inside code, you store them in one place.</p><h3>Step 1: Create a .env File</h3><p>Create a file in your project root:</p><pre>.env</pre><p>Add your details:</p><pre>BASE_URL=https://qa.myapp.com<br>USERNAME=admin_user<br>PASSWORD=admin_password</pre><p>Simple key-value format. No complex coding needed.</p><h3>Step 2: Connect It to Playwright</h3><p>Install dotenv:</p><pre>npm install dotenv</pre><p>Update playwright.config.ts:</p><pre>import * as dotenv from &#39;dotenv&#39;;<br>dotenv.config();</pre><pre>export default defineConfig({<br>  use: {<br>    baseURL: process.env.BASE_URL,<br>  },<br>});</pre><p>Now Playwright can read values from .env.</p><h3>Step 3: Use It in Your Tests</h3><pre>await loginPage.login(<br>  process.env.USERNAME!,<br>  process.env.PASSWORD!<br>);</pre><p>That’s it! You’ve removed hardcoding.</p><h3>Real-Life Analogy</h3><p>Think of .env like:</p><p>A sticky note with important info<br>Instead of rewriting details everywhere, you:</p><ul><li>Write once</li><li>Use everywhere</li></ul><p><strong>One Important Rule:</strong></p><p>Never upload .env to GitHub</p><p>Add this in .gitignore:</p><pre>.env</pre><h3>✅ When a Single .env is Enough</h3><p>You can <strong>absolutely use just one </strong><strong>.env file</strong> if:</p><ul><li>You’re working on one environment (like QA)</li><li>You’re a beginner</li><li>Your project is small</li><li>You don’t switch environments ofte</li></ul><p>This is the <strong>simplest and most practical starting point</strong></p><h3>When Things Start Growing…</h3><p>Now imagine you need:</p><ul><li>Dev environment</li><li>QA environment</li><li>Staging environment</li><li>Production</li></ul><p>Using one .env becomes messy because you’ll keep editing it again and again ❌</p><h3>Scalable Approach: Multiple .env Files</h3><p>Create separate files:</p><pre>.env.dev<br>.env.qa<br>.env.stage<br>.env.prod</pre><p>Example:</p><pre># .env.qa<br>BASE_URL=https://qa.myapp.com<br>USERNAME=qa_user<br>PASSWORD=qa_password</pre><h3>Load Environment Dynamically</h3><p>Update config:</p><pre>import * as dotenv from &#39;dotenv&#39;;</pre><pre>dotenv.config({<br>  path: `.env.${process.env.ENV || &#39;qa&#39;}`<br>});</pre><p>Run tests like:</p><pre>ENV=qa npx playwright test<br>ENV=dev npx playwright test</pre><p>👉 One command = switch environment 🔥</p><h3>🔒 Handling Credentials Securely</h3><p>Let’s be clear:</p><h3>❌ Avoid:</h3><ul><li>Hardcoding credentials</li><li>Pushing .env to GitHub</li></ul><h3>Better Options:</h3><h3>1. .env (Basic &amp; Common)</h3><p>Good for local testing</p><h3>2. JSON File (For Test Data Only)</h3><pre>{<br>  &quot;qa&quot;: {<br>    &quot;username&quot;: &quot;qa_user&quot;,<br>    &quot;password&quot;: &quot;qa_pass&quot;<br>  }<br>}</pre><h3>3. CI/CD Secrets (Best Practice)</h3><p>In tools like GitHub Actions:</p><pre>env:<br>  USERNAME: ${{ secrets.QA_USERNAME }}<br>  PASSWORD: ${{ secrets.QA_PASSWORD }}</pre><p>Keeps credentials safe and hidden</p><h3>Bonus: Avoid Logging In Again &amp; Again</h3><p>Use Playwright’s storageState:</p><pre>await page.context().storageState({ path: &#39;auth.json&#39; });</pre><p>Reuse:</p><pre>use: {<br>  storageState: &#39;auth.json&#39;,<br>}</pre><p>Faster tests 🚀</p><h3>Pro Tip: Centralize Everything</h3><p>Create a helper:</p><pre>// utils/env.ts<br>export const ENV = {<br>  baseUrl: process.env.BASE_URL!,<br>  username: process.env.USERNAME!,<br>  password: process.env.PASSWORD!,<br>};</pre><p>Use anywhere:</p><pre>await loginPage.login(ENV.username, ENV.password);</pre><h3>📁 Final Structure (Clean &amp; Scalable)</h3><pre>├── tests/<br>├── pages/<br>├── utils/<br>│   └── env.ts<br>├── data/<br>├── .env / .env.qa / .env.dev<br>├── playwright.config.ts</pre><h3>Final Thoughts</h3><p>👉 Start simple with <strong>one </strong><strong>.env file</strong><br>👉 Scale to <strong>multiple environments when needed</strong><br>👉 Never hardcode credentials<br>👉 Use secure storage for sensitive data</p><p>A well-managed config setup makes your framework:</p><p>✔ Easy to maintain<br>✔ Secure<br>✔ Scalable</p><h3>💬 Over to You</h3><p>How are you managing environments in your Playwright framework?</p><ul><li>Still hardcoding?</li><li>Using .env?</li><li>Or fully automated with CI/CD secrets?</li></ul><p>Let’s discuss in the comments 👇</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c241d2a548cd" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Shadow DOM in Automation Testing — Explained Like You’ve Never Seen Before (Beginner Friendly)]]></title>
            <link>https://medium.com/@divyakandpal93/shadow-dom-in-automation-testing-explained-like-youve-never-seen-before-beginner-friendly-e8f9695d1c94?source=rss-562e472a3384------2</link>
            <guid isPermaLink="false">https://medium.com/p/e8f9695d1c94</guid>
            <category><![CDATA[mastering-shadow-dom]]></category>
            <dc:creator><![CDATA[Divya Kandpal]]></dc:creator>
            <pubDate>Sun, 12 Apr 2026 05:52:13 GMT</pubDate>
            <atom:updated>2026-04-12T05:52:13.819Z</atom:updated>
            <content:encoded><![CDATA[<p>If you’ve ever felt confused about <strong>Shadow DOM</strong>, you’re not alone.</p><p>Most people struggle because:<br>❌ It sounds technical<br>❌ Examples are too complex<br>❌ No real-life explanation</p><p>So let’s fix that — step by step, in <strong>simple language</strong> 👇</p><h3>What is DOM? (Start from Basics)</h3><p>Before Shadow DOM, understand <strong>DOM</strong></p><p>👉 DOM = <strong>structure of a webpage</strong></p><h3>Real-Life Example</h3><p>Think of a website like a <strong>house</strong>:</p><ul><li>Room = Page</li><li>Furniture = Buttons, inputs</li><li>Layout = Structure</li></ul><p>👉 DOM is like the <strong>map of the house</strong></p><h3>🌑 What is Shadow DOM?</h3><p>Now imagine…</p><p>Inside your house, there is a <strong>locked room</strong> 🔒</p><ul><li>You can see it exists</li><li>But you cannot directly access inside</li></ul><p>👉 That locked room = <strong>Shadow DOM</strong></p><h3>Simple Definition</h3><blockquote><em>Shadow DOM is a hidden part of the webpage where elements are encapsulated and protected.</em></blockquote><h3>❌ Why XPath Doesn’t Work?</h3><p>Normally, we use XPath like:</p><pre>//button[@id=&#39;login&#39;]</pre><p>👉 This works for normal DOM</p><p>But in Shadow DOM:</p><p>👉 XPath cannot “enter the locked room”</p><p>So it fails ❌</p><h3>🔓 How Do We Access Shadow DOM?</h3><p>We follow <strong>2 steps</strong>:</p><h3>Step 1: Find the Shadow Host</h3><p>👉 The outer element (door of the room)</p><h3>Step 2: Enter Shadow Root</h3><p>👉 Go inside the room</p><p>Then…</p><h3>Step 3: Find element inside</h3><h4>Let’s See a Simple Example</h4><h4>HTML Structure (Don’t worry, just understand visually)</h4><pre>&lt;custom-element&gt;<br>  #shadow-root (open)<br>    &lt;button&gt;Click Me&lt;/button&gt;<br>&lt;/custom-element&gt;</pre><h3>What’s Happening Here?</h3><ul><li>custom-element → Shadow Host</li><li>#shadow-root → Hidden area</li><li>button → Inside shadow DOM</li></ul><h3>How to Handle This in Playwright</h3><h3>Simple Code</h3><pre>const button = page.locator(&#39;custom-element &gt;&gt; shadow=button&#39;);<br>await button.click();</pre><h3>Let’s Break This Line</h3><p><strong>🔹 </strong>custom-element</p><p>This is the <strong>shadow host</strong> (entry point)<br>🔹 &gt;&gt; shadow=button</p><p>Means:</p><ul><li>Go inside shadow DOM</li><li>Find button</li></ul><h3>In Simple Words</h3><blockquote><em>“Go to this element → enter its hidden area → find button”</em></blockquote><h3>Visibility Check</h3><pre>await expect(button).toBeVisible();</pre><p>Same as normal elements<br>No special handling needed after entering shadow</p><h3>Real-Life Analogy (Very Important)</h3><p>Imagine:</p><p>You go to a <strong>hotel room</strong></p><ol><li>First → enter hotel</li><li>Then → open your room</li><li>Then → use items inside</li></ol><p>Same in Shadow DOM:</p><ol><li>Find host</li><li>Enter shadow root</li><li>Access elements</li></ol><h3>Common Mistakes Beginners Make</h3><p>❌ Trying XPath directly<br>❌ Ignoring shadow root<br>❌ Thinking element doesn’t exist</p><p>Reality: Element exists… just hidden</p><h3>How to Identify Shadow DOM in Browser</h3><h3>Step-by-Step:</h3><ol><li>Right click → Inspect</li><li>Look for:</li></ol><pre>#shadow-root (open)</pre><p>👉 This confirms Shadow DOM</p><h3>Multiple Shadow DOM (Advanced but Simple)</h3><p>Sometimes:<br>One shadow inside another</p><h3>Example Thinking:</h3><p>House → Room → Cupboard → Drawer<br>You go step by step<br>Example (Concept)</p><pre>page.locator(&#39;parent &gt;&gt; shadow=child &gt;&gt; shadow=button&#39;);</pre><h3>🎯 Where You’ll See Shadow DOM</h3><ul><li>Modern UI frameworks</li><li>Web components</li><li>Chrome settings page</li></ul><h3>Real Testing Scenario</h3><h3>🔐 Login Button Inside Shadow DOM</h3><p>You cannot do:</p><p>❌ XPath</p><p>Instead:</p><pre>page.locator(&#39;login-component &gt;&gt; shadow=button&#39;);</pre><h3>Interview Answer (Important)</h3><p>If asked:</p><p>👉 “How do you handle Shadow DOM?”</p><p>✅ Answer:</p><blockquote><em>XPath does not work inside Shadow DOM.<br>We first access the shadow host, then enter shadow root, and then locate elements using supported locators like CSS or Playwright shadow selectors.</em></blockquote><h3>Final Understanding</h3><p>Normal DOM = Open house<br>Shadow DOM = Locked room</p><p>To access:</p><blockquote><em>Find → Enter → Locate</em></blockquote><h3>Simple Takeaway</h3><blockquote><em>“You cannot jump inside… you have to enter step by step.</em></blockquote><h3>If You’re Learning Testing</h3><p>Mastering Shadow DOM means:</p><ul><li>You can handle modern UI</li><li>You stand out in interviews</li><li>You solve real-world problems</li></ul><p>Happy Learning 🙂</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e8f9695d1c94" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[ How to Use AI in Automation Testing (With Real Prompts + Reusable Templates)]]></title>
            <link>https://medium.com/@divyakandpal93/how-to-use-ai-in-automation-testing-with-real-prompts-reusable-templates-4a2b1a0b27cc?source=rss-562e472a3384------2</link>
            <guid isPermaLink="false">https://medium.com/p/4a2b1a0b27cc</guid>
            <dc:creator><![CDATA[Divya Kandpal]]></dc:creator>
            <pubDate>Sun, 12 Apr 2026 05:25:13 GMT</pubDate>
            <atom:updated>2026-04-12T05:25:13.577Z</atom:updated>
            <content:encoded><![CDATA[<p>Automation testing becomes <strong>10x faster</strong> when you stop thinking in code… and start thinking in <strong>prompts</strong>.</p><p>This guide gives you <strong>ready-to-use prompts + templates</strong> you can copy daily in tools like ChatGPT or Copilot.</p><p>👉 Even if you’re a beginner, you can start immediately.</p><h3>Golden Rule of Using AI</h3><blockquote><em>“The quality of your output depends on the quality of your prompt.”</em></blockquote><p>So instead of:<br>❌ “Write test”<br>Use:<br>✅ “Write Playwright test for login page with invalid password and show error message”</p><h3>Test Case Generation Prompts</h3><h3>Template 1: Basic Feature Testing</h3><p><strong>Prompt:</strong></p><pre>Generate detailed test cases for [FEATURE NAME].</pre><pre>Include:<br>- Positive scenarios<br>- Negative scenarios<br>- Edge cases<br>- UI validation<br>- Error messages</pre><pre>Keep it simple and structured in table format.</pre><p><strong>Example:</strong></p><pre>Generate test cases for login page with email and password.</pre><h3>Template 2: Real-World Scenario Testing</h3><pre>Act as a QA tester.</pre><pre>Generate real-world test scenarios for [FEATURE].</pre><pre>Consider:<br>- User mistakes<br>- Network issues<br>- Invalid inputs<br>- Security cases</pre><h3>Automation Script Generation Prompts (Playwright)</h3><h3>Template 3: Basic Script</h3><pre>Write a Playwright test script for:</pre><pre>Feature: [FEATURE NAME]</pre><pre>Steps:<br>1. Open URL: [URL]<br>2. Perform action: [ACTION]<br>3. Validate: [EXPECTED RESULT]</pre><pre>Use simple JavaScript and add comments for each step.</pre><h3>Template 4: Login Script (Reusable Daily)</h3><pre>Write a Playwright test for login functionality.</pre><pre>Requirements:<br>- Open login page<br>- Enter username and password<br>- Click login button<br>- Validate successful login (dashboard visible)</pre><pre>Use reusable functions and proper selectors.</pre><h3>Template 5: Form Submission</h3><pre>Write Playwright automation script for form submission.</pre><pre>Fields:<br>- Name<br>- Email<br>- Phone</pre><pre>Steps:<br>- Fill all fields<br>- Submit form<br>- Validate success message</pre><h3>🔍 Debugging Prompts (Save Hours)</h3><h3>Template 6: Fix My Code</h3><pre>Here is my Playwright test code:</pre><pre>[PASTE CODE]</pre><pre>Error:<br>[PASTE ERROR]</pre><pre>Explain the issue in simple terms and provide a fixed version of the code.</pre><h3>Template 7: Why Test Fails</h3><pre>Why is this Playwright test failing?</pre><pre>[PASTE CODE + ERROR]</pre><pre>Give root cause and step-by-step fix.</pre><h3>Locator Optimization Prompts</h3><h3>Template 8: Better Selectors</h3><pre>Suggest stable and reliable selectors for this HTML:</pre><pre>[PASTE HTML]</pre><pre>Prefer:<br>- text-based selectors<br>- role-based selectors<br>- avoid dynamic IDs</pre><h3>Test Data Generation Prompts</h3><h3>Template 9: Dummy Data</h3><pre>Generate test data for:</pre><pre>- Name<br>- Email<br>- Phone<br>- Address</pre><pre>Provide 10 realistic entries in table format.</pre><h3>Template 10: Edge Case Data</h3><pre>Generate edge case test data for input field:</pre><pre>Field: [FIELD NAME]</pre><pre>Include:<br>- Empty<br>- Special characters<br>- Long values<br>- Invalid formats</pre><h3>API Testing Prompts</h3><h3>Template 11: API Test Cases</h3><pre>Generate API test cases for:</pre><pre>Endpoint: [API URL]</pre><pre>Include:<br>- Status code validation<br>- Response validation<br>- Negative scenarios</pre><h3>Template 12: JSON Validation</h3><pre>Validate this API response:</pre><pre>[PASTE JSON]</pre><pre>Write assertions for Playwright API testing.</pre><h3>Visual Testing Prompts</h3><h3>Template 13: UI Validation Checklist</h3><pre>Create UI validation checklist for:</pre><pre>Page: [PAGE NAME]</pre><pre>Include:<br>- Alignment<br>- Fonts<br>- Buttons<br>- Responsiveness</pre><h3>Test Optimization Prompts</h3><h3>Template 14: Smart Execution</h3><pre>Suggest which test cases should run first based on:</pre><pre>- High priority features<br>- Recent code changes<br>- Risk areas</pre><h3>Framework Design Prompts (Advanced)</h3><h3>Template 15: Framework Setup</h3><pre>Create a Playwright automation framework structure.</pre><pre>Include:<br>- Page Object Model<br>- Utilities<br>- Test folder<br>- Config setup</pre><pre>Keep it beginner-friendly.</pre><h3>DAILY USE MASTER PROMPT (Most Powerful)</h3><p>Use this when you’re working on ANY task:</p><pre>Act as a senior QA automation engineer.</pre><pre>Help me with:<br>[YOUR TASK]</pre><pre>Requirements:<br>- Use Playwright with JavaScript<br>- Keep solution simple<br>- Add comments<br>- Suggest best practices<br>- Explain in layman terms</pre><p>👉 This one prompt can solve almost everything.</p><h3>⚠️ Pro Tips (Very Important)</h3><p>✔ Always review AI output<br>✔ Never copy blindly<br>✔ Modify as per your application<br>✔ Keep improving your prompts</p><h3>Real Daily Workflow Using AI</h3><ol><li>Write feature → Use Template 1</li><li>Generate script → Use Template 3</li><li>Run test → If fails → Use Template 6</li><li>Improve selectors → Use Template 8</li></ol><p>Done faster, smarter, better.</p><h3>Final Thoughts</h3><p>AI is not magic…<br>👉 It’s a tool — and prompts are your power.</p><p>Once you start using these templates daily:</p><ul><li>Your work becomes faster</li><li>Your learning becomes easier</li><li>Your confidence increases</li></ul><h3>Simple Takeaway</h3><blockquote><em>“Don’t write everything from scratch… reuse smart prompts.”</em></blockquote><h3>Follow for More</h3><p>I share practical content on:</p><ul><li>Playwright Automation</li><li>AI in Testing</li><li>Real-world QA tips</li></ul><p>Happy Testing !!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4a2b1a0b27cc" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Playwright Advanced Automation Concepts: Shadow DOM, API Mocking, Parallel Execution & Scalable…]]></title>
            <link>https://medium.com/@divyakandpal93/playwright-advanced-automation-concepts-shadow-dom-api-mocking-parallel-execution-scalable-e214e9f40e4b?source=rss-562e472a3384------2</link>
            <guid isPermaLink="false">https://medium.com/p/e214e9f40e4b</guid>
            <dc:creator><![CDATA[Divya Kandpal]]></dc:creator>
            <pubDate>Mon, 23 Feb 2026 15:32:49 GMT</pubDate>
            <atom:updated>2026-02-23T15:32:49.624Z</atom:updated>
            <content:encoded><![CDATA[<h3>Playwright Advanced Automation Concepts: Shadow DOM, API Mocking, Parallel Execution &amp; Scalable Framework Design</h3><p>If you are learning automation testing using Playwright, then sooner or later you will face real-world challenges.</p><p>Writing simple locators is easy.</p><p>But professional automation engineers also handle:</p><p>👉 Shadow DOM elements<br> 👉 API mocking<br> 👉 Parallel execution<br> 👉 Scalable framework design</p><p>Don’t worry — I will explain everything in very simple language.</p><h3>1️⃣ Handling Shadow DOM (The Hidden Room Problem )</h3><h3>What is Shadow DOM?</h3><p>Think of Shadow DOM like this:</p><p>Imagine a house.</p><p>Inside the house, there is a locked private room.</p><p>👉 You cannot directly enter it.<br> 👉 You need a special access path.</p><p>Shadow DOM is similar.</p><p>It is a protected area inside webpage structure where normal locators cannot directly reach.</p><h3>Why Shadow DOM is Used?</h3><p>Developers use Shadow DOM to:</p><p>✅ Protect component styling<br> ✅ Avoid CSS conflicts<br> ✅ Build reusable UI components</p><p>Many modern UI frameworks use this.</p><h3>How Playwright Handles Shadow DOM?</h3><p>Good news!</p><p>You don’t need complicated code.</p><p>Playwright can automatically traverse Shadow DOM.</p><h3>Example Syntax</h3><pre>await page.locator(&#39;shadow-root-selector&#39;).click();</pre><p>Or use nested locator approach.</p><p>Unlike older tools like Selenium, Playwright makes shadow handling easier.</p><h3>💡 Pro Tip</h3><p>If element is inside shadow DOM:</p><p>👉 Avoid long XPath<br> 👉 Use role-based locators if possible</p><h3>2️⃣ API Mocking in Playwright (The Smart Testing Method )</h3><h3>What is API Mocking?</h3><p>Normally:</p><p>Browser → Sends request → Server responds</p><p>In mocking:</p><p>Browser → Fake response → Testing continues</p><p>Think of it like:</p><p>👉 Practicing cricket with a bowling machine instead of a real bowler.</p><h3>Why API Mocking is Useful?</h3><p>✅ Faster testing<br> ✅ Independent frontend testing<br> ✅ No dependency on backend availability<br> ✅ Good for error scenario testing</p><h3>Playwright Mocking Syntax</h3><pre>await page.route(&#39;/api/users&#39;, route =&gt; {<br>  route.fulfill({<br>    status: 200,<br>    body: JSON.stringify({ name: &#39;Test User&#39; })<br>  });<br>});</pre><p>Simple idea:</p><p>👉 Instead of real server response, we send fake response.</p><h3>3️⃣ Parallel Execution Strategy (Run Tests Faster )</h3><h3>What is Parallel Execution?</h3><p>Instead of running tests one by one:</p><p>Run multiple tests together.</p><p>Like watching 3 movies on 3 screens simultaneously.</p><h3>Why Parallel Testing?</h3><p>✅ Saves time<br> ✅ Faster feedback<br> ✅ Useful for large projects</p><h3>How Playwright Supports Parallel Testing?</h3><p>Playwright test runner supports multi-worker execution.</p><p>Example configuration:</p><pre>workers: 4</pre><p>This means:</p><p>👉 4 tests can run at the same time.</p><p>Careful though!</p><p>Too many workers can cause resource overload.</p><h3>4️⃣ Designing Scalable Playwright Framework (The Professional Level )</h3><p>If you are working in real projects, writing tests is not enough.</p><p>You must design structure.</p><h3>Think Like Building a House</h3><p>Bad Framework = Random rooms<br> Good Framework = Proper architecture</p><h3>Recommended Framework Structure</h3><pre>tests/<br>pages/<br>utils/<br>config/<br>fixtures/<br>reports/</pre><h3>Page Object Model (POM) Concept</h3><p>Create separate page classes.</p><p>Example:</p><p>Login Page → login functions<br> Dashboard Page → dashboard functions</p><p>This avoids duplication.</p><h3>Reusable Utility Functions</h3><p>Create common helpers like:</p><p>✅ Dropdown selection<br> ✅ Date picker handling<br> ✅ Button click functions</p><p>This is called DRY principle:</p><p>👉 Don’t Repeat Yourself.</p><h3>5️⃣ Real Professional Best Practices ⭐</h3><p>✔ Use role-based locators<br> ✔ Create reusable utilities<br> ✔ Avoid hardcoded waits<br> ✔ Mock APIs when possible<br> ✔ Run tests in parallel<br> ✔ Maintain clean project structure</p><h3>6️⃣ Why Playwright is Modern?</h3><p>Compared to traditional tools like Selenium, Playwright provides:</p><p>👉 Auto waiting mechanism<br> 👉 Better browser context isolation<br> 👉 Built-in parallel execution<br> 👉 Easy API mocking</p><p>That’s why many QA teams are shifting.</p><h3>Final Thoughts</h3><p>Automation testing is not just about writing scripts.</p><p>It is about thinking like a user and designing smart systems.</p><p>If you master:</p><p>✅ Shadow DOM handling<br> ✅ API mocking<br> ✅ Parallel execution<br> ✅ Scalable framework design</p><p>You are moving from <strong>beginner QA</strong> → <strong>professional automation engineer</strong>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e214e9f40e4b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Dynamic Dropdowns, iFrames & Reusable Locators]]></title>
            <link>https://medium.com/@divyakandpal93/dynamic-dropdowns-iframes-reusable-locators-2c9255c7dc65?source=rss-562e472a3384------2</link>
            <guid isPermaLink="false">https://medium.com/p/2c9255c7dc65</guid>
            <dc:creator><![CDATA[Divya Kandpal]]></dc:creator>
            <pubDate>Sun, 22 Feb 2026 05:19:20 GMT</pubDate>
            <atom:updated>2026-02-22T05:19:20.076Z</atom:updated>
            <content:encoded><![CDATA[<p>If you’ve already understood locators in Playwright, congratulations 🎉<br> You’ve completed the foundation.</p><p>Now let’s move to the <strong>real-world challenges</strong> testers actually face:</p><p>👉 Dynamic dropdowns<br> 👉 iFrames<br> 👉 Reusable locator utilities</p><p>Don’t worry — no heavy technical jargon.<br> Even if you’re non-technical, you’ll understand the logic behind it.</p><h3>1️⃣ Handling Dynamic Dropdowns (The Tricky One)</h3><h3>First, What is a Dynamic Dropdown?</h3><p>Imagine this:</p><p>You click on a country dropdown.<br> It loads options from the server.<br> Sometimes options appear after 1–2 seconds.<br> Sometimes they change based on what you typed.</p><p>That’s a <strong>dynamic dropdown</strong>.</p><p>It is not fixed in HTML.<br> It loads data dynamically.</p><p>That’s why beginners struggle with it.</p><h3>Real Life Example</h3><p>Think of Zomato or Swiggy.</p><p>When you type:</p><blockquote><em>“Pan”</em></blockquote><p>It suggests:</p><ul><li>Paneer</li><li>Pancake</li><li>Panipuri</li></ul><p>That’s dynamic behavior.</p><h3>✅ How to Handle It in Playwright</h3><h3>Case 1: Normal Select Dropdown</h3><p>If it’s a basic HTML &lt;select&gt;:</p><pre>await page.selectOption(&#39;#country&#39;, &#39;India&#39;);</pre><p>Simple.</p><h3>Case 2: Searchable / Custom Dropdown (Most Common Case)</h3><p>Steps usually are:</p><ol><li>Click dropdown</li><li>Type value</li><li>Click matching option</li></ol><h3>Syntax:</h3><pre>await page.getByRole(&#39;combobox&#39;).click();<br>await page.getByRole(&#39;option&#39;, { name: &#39;India&#39; }).click();</pre><p>Or if typing is required:</p><pre>await page.getByRole(&#39;combobox&#39;).fill(&#39;Ind&#39;);<br>await page.getByRole(&#39;option&#39;, { name: &#39;India&#39; }).click();</pre><h3>💡 Pro Tip</h3><p>Sometimes options take time to load.</p><p>Playwright automatically waits — unlike older tools like Selenium.</p><p>That’s why it feels smoother.</p><h3>⚠️ Common Mistake</h3><p>❌ Using hardcoded XPath<br> ❌ Using nth(2) blindly<br> ❌ Clicking without waiting for options</p><p>Always try to select using visible text.</p><h3>2️⃣ Working with iFrames (The Confusing Box Inside a Box 📦)</h3><h3>What is an iFrame?</h3><p>An iFrame is like:</p><p>👉 A webpage inside another webpage.</p><p>Imagine:</p><p>You are in a house.<br> Inside the house, there is a locked glass room.</p><p>You cannot touch anything inside that room unless you enter it first.</p><p>That’s exactly how an iFrame behaves.</p><h3>Why It Causes Issues?</h3><p>Because Playwright cannot directly access elements inside an iframe.</p><p>You must first switch context.</p><h3>✅ How to Handle iFrames in Playwright</h3><h3>Step 1: Locate the frame</h3><pre>const frame = page.frameLocator(&#39;#payment-frame&#39;);</pre><h3>Step 2: Interact inside it</h3><pre>await frame.getByPlaceholder(&#39;Card number&#39;).fill(&#39;4111111111111111&#39;);<br>await frame.getByRole(&#39;button&#39;, { name: &#39;Pay&#39; }).click();</pre><p>See the difference?</p><p>We don’t use page anymore.<br> We use frame.</p><h3>Simple Rule to Remember</h3><p>Normal page → use page<br> Inside iframe → use frameLocator</p><p>That’s it.</p><h3>3️⃣ Building Reusable Locator Utilities (Smart QA Move 🚀)</h3><p>Now we move to something powerful.</p><p>If you’re working in a real company, writing locators again and again is:</p><p>❌ Time consuming<br> ❌ Hard to maintain<br> ❌ Error prone</p><p>So what do smart automation engineers do?</p><p>They create <strong>utility functions</strong>.</p><h3>Real-Life Example</h3><p>Instead of saying:</p><p>“Turn on the TV, change channel to 45, increase volume to 20”</p><p>You create a remote with buttons.</p><p>Reusable. Simple.</p><p>Same logic here.</p><h3>🎯 Example: Common Dropdown Function</h3><p>Instead of writing:</p><pre>await page.getByRole(&#39;combobox&#39;).click();<br>await page.getByRole(&#39;option&#39;, { name: value }).click();</pre><p>Again and again…</p><p>You create a function:</p><pre>async function selectDropdown(page, value) {<br>  await page.getByRole(&#39;combobox&#39;).click();<br>  await page.getByRole(&#39;option&#39;, { name: value }).click();<br>}</pre><p>Now in test:</p><pre>await selectDropdown(page, &#39;India&#39;);</pre><p>Clean. Reusable. Professional.</p><h3>🎯 Example: Common Click by Role</h3><pre>async function clickButton(page, buttonName) {<br>  await page.getByRole(&#39;button&#39;, { name: buttonName }).click();<br>}</pre><p>Usage:</p><pre>await clickButton(page, &#39;Submit&#39;);</pre><p>Your framework instantly looks structured.</p><h3>💡 Why This is Powerful?</h3><p>If UI changes:</p><p>You update locator in ONE place.</p><p>Not 50 test files.</p><p>That’s scalability.</p><h3>🔥 Combining All Three in Real Scenario</h3><p>Imagine this flow:</p><ol><li>Select country from dynamic dropdown</li><li>Enter card details inside iframe</li><li>Click submit button using utility</li></ol><p>That’s real-world automation.</p><p>And now you know how to handle all three.</p><h3>Best Practices Summary</h3><p>✅ Prefer getByRole()<br> ✅ Avoid long CSS chains<br> ✅ Use frameLocator for iframes<br> ✅ Create reusable utility functions<br> ✅ Avoid hardcoded index values</p><h3>Final Thoughts</h3><p>Automation is not about writing long code.</p><p>It’s about:</p><p>✔ Writing clean logic<br> ✔ Thinking like a user<br> ✔ Making scripts stable<br> ✔ Making your future life easier</p><p>Dynamic dropdowns test your patience.<br> iFrames test your understanding.<br> Reusable utilities test your maturity as an automation engineer.</p><p>Master these — and you move from beginner to confident QA 🚀</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2c9255c7dc65" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Playwright Locators — From Basic to Advanced (With Syntax, Explained Simply)]]></title>
            <link>https://medium.com/@divyakandpal93/playwright-locators-from-basic-to-advanced-with-syntax-explained-simply-ee6d30654fb9?source=rss-562e472a3384------2</link>
            <guid isPermaLink="false">https://medium.com/p/ee6d30654fb9</guid>
            <dc:creator><![CDATA[Divya Kandpal]]></dc:creator>
            <pubDate>Sat, 21 Feb 2026 12:08:10 GMT</pubDate>
            <atom:updated>2026-02-21T12:08:10.759Z</atom:updated>
            <content:encoded><![CDATA[<p>When people hear <em>automation testing</em>, they imagine complicated code and scary developer stuff.</p><p>But let me simplify it for you.</p><p>Today we’re talking about <strong>Locators in Playwright</strong> — what they are, why they matter, and how to use them with proper syntax (don’t worry, I’ll explain it in simple words).</p><h3>What is Playwright?</h3><p>Playwright is a browser automation tool created by Microsoft.</p><p>In simple terms:</p><p>👉 It controls the browser like a human<br> 👉 It clicks buttons<br> 👉 It fills forms<br> 👉 It validates text</p><p>But here’s the main question:</p><p><strong>How does it know what to click?</strong></p><p>Answer: <strong>Locators.</strong></p><h3>What is a Locator? (Super Simple Definition)</h3><p>A locator is a way to identify an element on a webpage.</p><p>Think of it like giving directions:</p><p>Instead of saying:</p><blockquote><em>“Click something.”</em></blockquote><p>You say:</p><blockquote><em>“Click the Login button on the top right.”</em></blockquote><p>That clarity is a locator.</p><h3>Level 1: Basic Locators (Beginner Friendly)</h3><p>Let’s start with the most commonly used ones.</p><h3>Locate by Text</h3><p>If a button says:</p><p><strong>Login<br></strong>Syntax:</p><pre>await page.getByText(&#39;Login&#39;).click();</pre><p>What this means:</p><blockquote><em>Find the element that contains text “Login” and click it.</em></blockquote><p>Simple and readable.</p><h3>Locate by ID</h3><p>If an element has:</p><pre>&lt;input id=&quot;username&quot; /&gt;</pre><h3>Syntax:</h3><pre>await page.locator(&#39;#username&#39;).fill(&#39;Divya&#39;);</pre><p>Explanation:</p><ul><li># represents ID in CSS.</li><li>It fills the input field.</li></ul><p>IDs are usually stable and reliable.</p><h3>Locate by Class</h3><p>If element has:</p><pre>&lt;button class=&quot;submit-btn&quot;&gt;</pre><h3>Syntax:</h3><pre>await page.locator(&#39;.submit-btn&#39;).click();</pre><p>Explanation:</p><ul><li>. represents class in CSS.</li></ul><p>⚠️ Be careful: Classes sometimes change frequently.</p><h3>Locate by CSS Selector (More Control)</h3><p>Example:</p><pre>&lt;div class=&quot;login-form&quot;&gt;<br>  &lt;button type=&quot;submit&quot;&gt;Login&lt;/button&gt;<br>&lt;/div&gt;</pre><h3>Syntax:</h3><pre>await page.locator(&#39;.login-form button[type=&quot;submit&quot;]&#39;).click();</pre><p>This means:</p><blockquote><em>Inside login-form, find submit button.</em></blockquote><p>More powerful. Slightly technical.</p><h3>Level 2: Recommended &amp; Smarter Locators (Modern Approach)</h3><p>Playwright encourages using user-focused locators.</p><p>These are cleaner and more stable.</p><h3>getByRole() — The Best Practice</h3><p>Roles are based on accessibility.</p><p>Example:</p><pre>await page.getByRole(&#39;button&#39;, { name: &#39;Login&#39; }).click();</pre><p>Explanation:</p><ul><li>Find a button</li><li>Whose visible name is “Login”</li></ul><p>This is highly recommended.</p><p>Why?</p><p>Because even if UI structure changes, role usually remains stable.</p><h3>getByLabel() — Best for Forms</h3><p>If HTML looks like:</p><pre>&lt;label&gt;Email&lt;/label&gt;<br>&lt;input type=&quot;text&quot; /&gt;</pre><h3>Syntax:</h3><pre>await page.getByLabel(&#39;Email&#39;).fill(&#39;test@gmail.com&#39;);</pre><p>This works beautifully for:</p><ul><li>Forms</li><li>Login pages</li><li>Registration pages</li></ul><h3>getByPlaceholder()</h3><p>If input has:</p><pre>&lt;input placeholder=&quot;Enter your email&quot; /&gt;</pre><h3>Syntax:</h3><pre>await page.getByPlaceholder(&#39;Enter your email&#39;).fill(&#39;abc@gmail.com&#39;);</pre><p>Very clean and readable.</p><h3>getByTestId()</h3><p>Sometimes developers add:</p><pre>&lt;div data-testid=&quot;login-button&quot;&gt;</pre><h3>Syntax:</h3><pre>await page.getByTestId(&#39;login-button&#39;).click();</pre><p>This is extremely stable if team follows test-id strategy.</p><h3>Level 3: Advanced Locators (Pro Level 🚀)</h3><p>Now we move beyond basics.</p><h3>Chaining Locators</h3><p>When element is inside another element.</p><p>Example:</p><p>Click Delete button inside a specific card.</p><h3>Syntax:</h3><pre>const card = page.locator(&#39;.card&#39;, { hasText: &#39;Premium Plan&#39; });<br>await card.getByRole(&#39;button&#39;, { name: &#39;Delete&#39; }).click();</pre><p>Explanation:</p><ul><li>First find card containing “Premium Plan”</li><li>Then find Delete button inside it</li></ul><p>This makes test precise.</p><h3>Filtering with hasText</h3><h3>✅ Syntax:</h3><pre>await page.locator(&#39;.card&#39;, { hasText: &#39;Gold Plan&#39; }).click();</pre><p>Means:</p><blockquote><em>Find card that contains text “Gold Plan”</em></blockquote><p>Very powerful for dynamic UI.</p><h3>nth() — When Multiple Elements Exist</h3><p>If there are 3 Edit buttons:</p><h3>✅ Syntax:</h3><pre>await page.getByRole(&#39;button&#39;, { name: &#39;Edit&#39; }).nth(1).click();</pre><p>Explanation:</p><ul><li>nth(0) → first</li><li>nth(1) → second</li></ul><p>⚠️ Use carefully. Index can change.</p><h3>XPath (Use Only If Necessary)</h3><p>Example:</p><pre>await page.locator(&#39;//button[text()=&quot;Login&quot;]&#39;).click();</pre><p>XPath is powerful but can make tests messy.</p><p>Modern approach prefers:</p><ul><li>getByRole</li><li>getByLabel</li><li>getByTestId</li></ul><h3>Bonus: Auto Waiting (Why Playwright is Smart)</h3><p>Unlike older tools like Selenium,<br> Playwright automatically waits for elements to be:</p><ul><li>Visible</li><li>Enabled</li><li>Ready for action</li></ul><p>That’s why locators in Playwright feel smoother and more reliable.</p><h3>Best Practices (Very Important)</h3><p>✅ Prefer getByRole()<br> ✅ Use getByLabel() for forms<br> ✅ Use getByTestId() if available<br> ✅ Avoid long CSS chains<br> ✅ Avoid hardcoded indexes<br> ✅ Write readable locators</p><p>Remember:</p><p>Good locator = Stable test<br> Bad locator = Flaky test</p><p>And flaky tests are every QA’s nightmare 😅</p><h3>Final Thoughts</h3><p>Locators are not just syntax.</p><p>They are the <strong>eyes of your automation script</strong>.</p><p>If you master locators:</p><ul><li>Your scripts become stable</li><li>Your framework becomes scalable</li><li>Your debugging becomes easier</li><li>Your confidence increases</li></ul><p>Whether you’re:</p><ul><li>A manual tester moving to automation</li><li>A beginner starting with Playwright</li><li>Or someone exploring modern testing tools</li></ul><p>Understanding locators deeply is your foundation.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ee6d30654fb9" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[What is Playwright MCP? The Bridge Between AI and Website Testing (Explained Simply)]]></title>
            <link>https://medium.com/@divyakandpal93/what-is-playwright-mcp-the-bridge-between-ai-and-website-testing-explained-simply-93d768e7ebca?source=rss-562e472a3384------2</link>
            <guid isPermaLink="false">https://medium.com/p/93d768e7ebca</guid>
            <dc:creator><![CDATA[Divya Kandpal]]></dc:creator>
            <pubDate>Wed, 08 Oct 2025 17:34:12 GMT</pubDate>
            <atom:updated>2025-10-08T17:34:12.017Z</atom:updated>
            <content:encoded><![CDATA[<p>Have you ever wished your AI assistant could actually <strong>test a website</strong> instead of just talking about it?</p><p>That’s exactly what <strong>Playwright MCP</strong> makes possible.</p><p>But before we dive into what it does — let’s take a small step back.</p><h3>Imagine This</h3><p>You’re sitting in front of your computer, and you ask your AI assistant:</p><blockquote><em>“Hey, can you open this website, log in, and check if the form works properly?”</em></blockquote><p>Normally, the assistant would only tell you <em>how</em> to do it — it couldn’t actually <em>do</em> it.</p><p>Now imagine if that assistant could <strong>open the website</strong>, <strong>click buttons</strong>, <strong>type into fields</strong>, and <strong>report back</strong> saying —</p><blockquote><em>“Everything works fine. All tests passed!”</em></blockquote><p>Sounds magical, right?</p><p>That’s the magic of <strong>Playwright MCP (Model Context Protocol)</strong>.</p><h3>So, What Is Playwright MCP in Simple Terms?</h3><p>Let’s break it down:</p><ul><li><strong>Playwright</strong> is a popular tool that helps you <strong>automate and test websites</strong> — like a robot that clicks, types, and checks things for you.</li><li><strong>MCP (Model Context Protocol)</strong> is a <strong>bridge or translator</strong> that allows an <strong>AI model (like ChatGPT)</strong> to <strong>talk to tools</strong> like Playwright.</li></ul><p>Together, they create a connection that lets an AI <strong>actually perform actions on websites</strong> — not just describe them.</p><h3>A Real-World Analogy</h3><p>Think of Playwright as a <strong>car</strong> — fast, reliable, and built for action.<br> And think of AI as a <strong>driver</strong> — smart, but it needs the right <strong>steering controls</strong> to move the car.</p><p>MCP is the <strong>steering wheel and pedals</strong> that connect them.<br> Without it, the driver can only talk about driving. With it, the driver can <strong>actually drive</strong>.</p><h3>Why It’s a Big Deal</h3><p>In the past, developers had to write long, detailed scripts to test websites — for example:</p><ul><li>Open a browser</li><li>Go to the login page</li><li>Enter username and password</li><li>Click login</li><li>Check if it worked</li></ul><p>Now, with <strong>MCP</strong>, an AI assistant can do these things simply through conversation.</p><p>You can literally say:</p><blockquote><em>“Run a Playwright test for the login page.”</em></blockquote><p>And the AI, through MCP, knows exactly what to do.</p><h3>Safe and Controlled Connection</h3><p>MCP doesn’t just give the AI random access to everything.<br> It sets <strong>safe boundaries</strong> — so the AI can only perform allowed actions through approved tools.</p><p>It’s like giving your assistant a key that opens only one specific door, not the entire house. 🔑</p><h3>In One Line:</h3><blockquote><strong><em>Playwright MCP allows AI assistants to run real browser tests — acting like a human tester, but faster and safer.</em></strong></blockquote><h3>The Future of Testing</h3><p>This technology opens exciting doors:</p><ul><li>Testers can describe what they want, and AI will execute it.</li><li>AI can automatically detect UI issues using Playwright’s visual testing.</li><li>Companies can save time by letting AI handle repetitive QA tasks.</li></ul><p>It’s a small step in automation — but a giant leap toward <strong>AI-powered testing</strong>.</p><h3>Final Thoughts</h3><p>Playwright MCP isn’t just another tech acronym — it’s a <strong>bridge</strong> that connects intelligence (AI) with action (Playwright).</p><p>It gives our AI assistants the <strong>hands</strong> to do what they could only <strong>talk about</strong> before.</p><p>And that, in the simplest words, is why <strong>Playwright MCP</strong> is one of the most exciting steps toward the future of automated web testing. 🌟</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=93d768e7ebca" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Master Playwright Basics: Handling Inputs, Clicks, and Keyboard Actions — Made Super Simple!]]></title>
            <link>https://medium.com/@divyakandpal93/master-playwright-basics-handling-inputs-clicks-and-keyboard-actions-made-super-simple-b032b9f61613?source=rss-562e472a3384------2</link>
            <guid isPermaLink="false">https://medium.com/p/b032b9f61613</guid>
            <dc:creator><![CDATA[Divya Kandpal]]></dc:creator>
            <pubDate>Wed, 08 Oct 2025 07:24:48 GMT</pubDate>
            <atom:updated>2025-10-08T07:24:48.116Z</atom:updated>
            <content:encoded><![CDATA[<h3>Master Playwright Basics: Handling Inputs, Clicks, and Keyboard Actions — Made Super Simple!</h3><p>If you’ve ever wondered <em>how automated testing tools actually type, click, or upload files just like a real human</em>, then you’re about to learn it the easiest way possible!</p><p>In this blog, we’ll explore how <strong>Playwright</strong> helps you interact with websites — from typing text to clicking buttons — using just a few simple commands.</p><p>Let’s go step-by-step 👇</p><h3>📝 1. Filling Text Fields (Typing Automatically)</h3><p>When you fill a form manually, you click on a text box and start typing, right?<br> In Playwright, you can do this automatically using the <strong>.fill()</strong> method.</p><p>It focuses on the input box and types the given text — just like a real user.</p><pre>await page.getByRole(&#39;textbox&#39;).fill(&#39;John Doe&#39;);</pre><p>👉 This command will:</p><ul><li>Click on the text box</li><li>Type “John Doe”</li><li>Trigger the same events as a real user typing</li></ul><p>It works perfectly with:</p><ul><li>&lt;input&gt; (text boxes)</li><li>&lt;textarea&gt; (multi-line text boxes)</li><li>[contenteditable] (editable text areas)</li></ul><h3>☑️ 2. Checking Checkboxes and Radio Buttons</h3><p>Checkboxes and radio buttons are those little circles or squares you click on forms.</p><p>With Playwright, you don’t need to click manually — you can use <strong>.check()</strong> and <strong>.uncheck()</strong> easily.</p><pre>await page.getByLabel(&#39;Accept Terms &amp; Conditions&#39;).check();<br>await expect(page.getByLabel(&#39;Accept Terms &amp; Conditions&#39;)).toBeChecked();</pre><p>This means:</p><ul><li>It will <em>tick the checkbox</em></li><li>You can also <em>verify</em> if it’s ticked</li></ul><p>If you want to untick it (for checkboxes), you can use:</p><pre>await page.getByLabel(&#39;Accept Terms &amp; Conditions&#39;).uncheck();</pre><h3>🎨 3. Selecting from Dropdowns</h3><p>When you see a dropdown like <em>“Select your Country”</em>, you can use <strong>.selectOption()</strong> to pick one of the values.</p><pre>await page.getByLabel(&#39;Select Country&#39;).selectOption(&#39;India&#39;);</pre><p>✅ You can also select multiple options (for multi-select dropdowns):</p><pre>await page.getByLabel(&#39;Choose Languages&#39;).selectOption([&#39;English&#39;, &#39;Hindi&#39;]);</pre><h3>🖱️ 4. Mouse Interactions (Click, Hover, Right-click, etc.)</h3><p>Playwright makes mouse actions super easy.<br> Let’s look at a few simple examples 👇</p><p><strong>👉 Click a button</strong></p><pre>await page.getByRole(&#39;button&#39;, { name: &#39;Submit&#39; }).click();</pre><p><strong>👉 Double-click an element</strong></p><pre>await page.getByText(&#39;Profile Picture&#39;).dblclick();</pre><p><strong>👉 Right-click on something</strong></p><pre>await page.getByText(&#39;Document&#39;).click({ button: &#39;right&#39; });</pre><p><strong>👉 Hold Shift while clicking</strong></p><pre>await page.getByText(&#39;Item 1&#39;).click({ modifiers: [&#39;Shift&#39;] });</pre><p><strong>👉 Hover over an element (like showing a tooltip)</strong></p><pre>await page.getByText(&#39;Help Icon&#39;).hover();</pre><p><strong>👉 Click at a specific position inside an element</strong></p><pre>await page.getByText(&#39;Canvas Area&#39;).click({<br>  position: { x: 10, y: 10 }<br>});</pre><h3>⌨️ 5. Typing Like a Real Human (Character by Character)</h3><p>Want your automation to <em>look like a real user typing slowly</em>?<br> Use <strong>.pressSequentially()</strong> — it types one letter at a time and triggers every keyboard event (keydown, keyup, etc.)</p><pre>await page.locator(&#39;#messageBox&#39;).pressSequentially(&#39;Hello there!&#39;);</pre><p>You can even add a delay between each key press:</p><pre>await page.locator(&#39;#messageBox&#39;).pressSequentially(&#39;Typing slowly...&#39;, { delay: 200 });</pre><h3>🎯 6. Keyboard Shortcuts</h3><p>Sometimes you just need to press <strong>Enter</strong>, <strong>Tab</strong>, or other keys — just like shortcuts.<br> You can do this easily using .press().</p><pre>await page.getByText(&#39;Send&#39;).press(&#39;Enter&#39;);</pre><p>You can also combine keys:</p><pre>await page.keyboard.press(&#39;Control+S&#39;); // Like saving a file</pre><h3>📁 7. Uploading Files</h3><p>If a page asks you to upload something (like a profile photo or resume), you can use <strong>.setInputFiles()</strong>.</p><pre>await page.getByLabel(&#39;Upload Resume&#39;).setInputFiles(&#39;files/resume.pdf&#39;);</pre><p>You can also upload multiple files:</p><pre>await page.getByLabel(&#39;Upload Photos&#39;).setInputFiles([<br>  &#39;files/photo1.jpg&#39;,<br>  &#39;files/photo2.jpg&#39;<br>]);</pre><h3>🔍 8. Focusing and Drag-and-Drop</h3><p><strong>👉 Focus on a field</strong><br> It simply places the cursor inside the input field:</p><pre>await page.getByLabel(&#39;Username&#39;).focus();</pre><p><strong>👉 Drag and drop items</strong><br> Perfect for moving cards, files, or images from one place to another:</p><pre>await page.locator(&#39;div#dragItem&#39;).dragTo(page.locator(&#39;div#dropZone&#39;));</pre><h3>💡 Final Thoughts</h3><p>All these small commands — typing, clicking, selecting, dragging — are the <strong>building blocks</strong> of Playwright automation.</p><p>With just a few lines of code, you can make your automation behave exactly like a real person interacting with the website.</p><p>So next time you fill a form or click a button in your tests — you’ll know exactly what’s happening behind the scenes! 😄</p><p><strong>✨ Summary Table</strong></p><pre>| Action        | Method                    | Example                                                          |<br>| ------------- | ------------------------- | ---------------------------------------------------------------- |<br>| Fill Text     | `.fill()`                 | `await page.getByRole(&#39;textbox&#39;).fill(&#39;John Doe&#39;);`              |<br>| Check/Uncheck | `.check()` / `.uncheck()` | `await page.getByLabel(&#39;Accept Terms&#39;).check();`                 |<br>| Select Option | `.selectOption()`         | `await page.getByLabel(&#39;Select Country&#39;).selectOption(&#39;India&#39;);` |<br>| Click         | `.click()`                | `await page.getByRole(&#39;button&#39;).click();`                        |<br>| Hover         | `.hover()`                | `await page.getByText(&#39;Help&#39;).hover();`                          |<br>| Type Slowly   | `.pressSequentially()`    | `await page.locator(&#39;#msg&#39;).pressSequentially(&#39;Hello!&#39;);`        |<br>| Shortcut      | `.press()`                | `await page.getByText(&#39;Send&#39;).press(&#39;Enter&#39;);`                   |<br>| Upload File   | `.setInputFiles()`        | `await page.getByLabel(&#39;Upload&#39;).setInputFiles(&#39;file.txt&#39;);`     |<br>| Drag &amp; Drop   | `.dragTo()`               | `await page.locator(&#39;#drag&#39;).dragTo(page.locator(&#39;#drop&#39;));`     |</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b032b9f61613" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Master JavaScript from Scratch (Part 3): JavaScript Objects Made Super Simple]]></title>
            <link>https://medium.com/@divyakandpal93/master-javascript-from-scratch-part-3-javascript-objects-made-super-simple-30e2a9ea3d9c?source=rss-562e472a3384------2</link>
            <guid isPermaLink="false">https://medium.com/p/30e2a9ea3d9c</guid>
            <dc:creator><![CDATA[Divya Kandpal]]></dc:creator>
            <pubDate>Tue, 07 Oct 2025 10:02:26 GMT</pubDate>
            <atom:updated>2025-10-07T10:02:26.123Z</atom:updated>
            <content:encoded><![CDATA[<p>In this blog, you’ll finally understand <strong>Objects</strong> — one of the most important parts of JavaScript.</p><p>If you ever heard people say, “Everything in JavaScript is an object,” don’t worry — by the end of this blog, you’ll know what that means, even if you’ve never coded before.</p><h3>1. What Is an Object?</h3><p>In real life, an <strong>object</strong> is anything that has <strong>properties</strong> (details) and <strong>actions</strong> (things it can do).</p><p>Example:<br> 🪄 Think about a <strong>car</strong>.<br> It has:</p><ul><li>Properties → color, brand, model</li><li>Actions → start(), stop(), honk()</li></ul><p>In JavaScript, it’s the same idea.<br> We create an object to group related information together.</p><p>Example:</p><pre>let car = {<br>  brand: &#39;Tesla&#39;,<br>  color: &#39;Red&#39;,<br>  year: 2024<br>};</pre><p>Let’s understand it line by line:</p><ul><li>let car = { ... } → We create an object named car.</li><li>Inside { } we put information as <strong>key-value pairs</strong>.</li><li><strong>key</strong> → name of the property (like brand)</li><li><strong>value</strong> → the actual data (like &#39;Tesla&#39;)</li></ul><p>So this object tells JavaScript that:</p><blockquote><em>The car’s brand is Tesla, color is Red, and year is 2024.</em></blockquote><h3>2. How to Access Object Data</h3><p>We can get data from an object in two easy ways:</p><h4>✅ Dot Notation</h4><pre>console.log(car.brand);   // Tesla<br>console.log(car.color);   // Red</pre><h4>✅ Bracket Notation</h4><pre>console.log(car[&#39;year&#39;]);  // 2024</pre><p>📘 Dot notation is simpler and more common.<br> Use bracket notation only when the key has spaces or special characters.</p><h3>3. How to Add, Change, or Delete Properties</h3><p>You can update objects easily after creating them.</p><pre>let user = { name: &#39;Divya&#39;, city: &#39;Delhi&#39; };</pre><p>✅ Add new property:</p><pre>user.age = 25;</pre><p>✅ Change existing property:</p><pre>user.city = &#39;Bangalore&#39;;</pre><p>✅ Delete a property:</p><pre>delete user.city;</pre><p>Now your user looks like this:</p><pre>{ name: &#39;Divya&#39;, age: 25 }</pre><h3>4. Objects with Functions (Actions)</h3><p>Objects can also do actions — called <strong>methods</strong>.</p><p>Example:</p><pre>let car = {<br>  brand: &#39;Tesla&#39;,<br>  start: function() {<br>    console.log(&#39;Car started&#39;);<br>  }<br>};<br>car.start();  // Car started</pre><p>Word by word:</p><ul><li>start: function() → a function stored inside an object.</li><li>When we call car.start(), the car performs its action.</li></ul><h3>5. Why Are Objects Important?</h3><p>Objects are everywhere in JavaScript — they hold data, settings, and results.</p><p>Here’s why they matter in <strong>automation</strong> 👇</p><pre>| Use Case            | Example Object                                          |<br>| ------------------- | ------------------------------------------------------- |<br>| Store page locators | `{ usernameInput: &#39;#user&#39;, loginBtn: &#39;#login&#39; }`        |<br>| Store test data     | `{ name: &#39;Jai&#39;, role: &#39;QA Tester&#39; }`                    |<br>| Store API response  | `{ status: 200, message: &#39;Success&#39; }`                   |<br>| Store project info  | `{ title: &#39;Medium&#39;, owner: &#39;Divya&#39;, status: &#39;Active&#39; }` |</pre><p>Objects help you organize all the moving parts in your automation framework in one clean structure.</p><h3>💡 6. Objects Inside Arrays (Most Common in Real Projects)</h3><p>You can keep many objects together in a list — called an <strong>array of objects</strong>.</p><p>Example:</p><pre>let users = [<br>  { name: &#39;Divya&#39;, role: &#39;QA&#39; },<br>  { name: &#39;Jai&#39;, role: &#39;Tester&#39; },<br>  { name: &#39;Sonaali&#39;, role: &#39;HR&#39; }<br>];</pre><p>To access them:</p><pre>console.log(users[0].name);  // Divya<br>console.log(users[1].role);  // Tester</pre><p>👉 In real life, this is how you store multiple users, test cases, or project details in your automation data.</p><h3>7. Loop Through an Object</h3><p>You can use a <strong>for…in</strong> loop to go through every property inside an object.</p><p>Example:</p><pre>let user = { name: &#39;Divya&#39;, city: &#39;Delhi&#39;, age: 25 };</pre><pre>for (let key in user) {<br>  console.log(key + &#39;: &#39; + user[key]);<br>}</pre><p>Output:</p><pre>name: Divya  <br>city: Delhi  <br>age: 25</pre><p>💬 Explanation:</p><ul><li>key → each property name (like name, city, age).</li><li>user[key] → the value of that property.</li></ul><h3>8. Nested Objects (Object Inside Object)</h3><p>You can also keep one object inside another — just like folders inside folders.</p><p>Example:</p><pre>let employee = {<br>  name: &#39;Divya&#39;,<br>  address: {<br>    city: &#39;Delhi&#39;,<br>    country: &#39;India&#39;<br>  }<br>};</pre><p>To access the nested value:</p><pre>console.log(employee.address.city);  // Delhi</pre><p>This is very common in API responses and automation data files.</p><h3>9. Real Automation Example</h3><p>Here’s how an object might look in a <strong>Playwright test utility file</strong> 👇</p><pre>const loginLocators = {<br>  emailField: &#39;#email&#39;,<br>  passwordField: &#39;#password&#39;,<br>  submitBtn: &#39;button[type=&quot;submit&quot;]&#39;<br>};</pre><pre>await page.fill(loginLocators.emailField, &#39;user@example.com&#39;);<br>await page.fill(loginLocators.passwordField, &#39;pass123&#39;);<br>await page.click(loginLocators.submitBtn);</pre><p>🧩 One neat object — and your entire login test becomes clean and reusable.</p><ul><li>const loginLocators = {...} → We are <strong>creating a “map” of the fields we need</strong>.</li><li>emailField: &#39;#email&#39; → This means <strong>the email box on the webpage</strong> has an ID of email.</li><li>passwordField: &#39;#password&#39; → The password box has an ID of password.</li><li>submitBtn: &#39;button[type=&quot;submit&quot;]&#39; → The login button is a &lt;button&gt; element with type=&quot;submit&quot;.</li></ul><p>Think of <strong>loginLocators</strong> as a <strong>cheat sheet</strong> that tells the script <strong>where to type email, password, and click login</strong>.</p><pre>await page.fill(loginLocators.emailField, &#39;user@example.com&#39;);</pre><ul><li>page.fill(...) → This is like saying: <strong>“Type this text into this box”</strong>.</li><li>loginLocators.emailField → Refers to the <strong>email input box</strong>.</li><li>&#39;user@example.com&#39; → This is the email we are typing.</li></ul><p>So this line means:<br><em>Type </em><strong><em>user@example.com</em></strong><em> into the email box.</em></p><pre>await page.fill(loginLocators.passwordField, &#39;pass123&#39;);</pre><ul><li>Same as above, but now we are typing <strong>the password</strong> into the password box.</li></ul><pre>await page.click(loginLocators.submitBtn);</pre><p>page.click(...) → Click on a button.</p><p>loginLocators.submitBtn → Refers to the <strong>login button</strong>.</p><p>So this line means:</p><p>Click the Login button to submit the form.</p><h3>10. Pro Tips for Working with Objects</h3><ol><li>Always give <strong>clear, short names</strong> to keys (e.g., userName, not uN).</li><li>Use <strong>dot notation</strong> whenever possible — it’s simple and readable.</li><li>Group related data together — it keeps your code organized.</li><li>For large data, use <strong>array of objects</strong> (common in test data).</li><li>Practice by building small real-world examples — like user data or project info.</li></ol><h3>Quick Practice</h3><p>Try creating these yourself:</p><ol><li>A student object with name, age, and course.</li><li>An employee object with name, department, and salary, and add a function called getDetails().</li><li>An array of 3 employee objects and print all their names using a loop.</li></ol><h3>Final Thoughts</h3><p>Objects are like <strong>folders for your data</strong> — they hold everything in one place neatly.</p><p>Once you understand how to create, access, and use them, you’re ready for <strong>Arrays + Objects together</strong>, which is exactly how test data, JSON files, and APIs work in real-world automation.</p><h3>Next Blog Preview</h3><blockquote><strong><em>“Master JavaScript from Scratch (Part 4): Arrays Made Easy — Learn How to Handle Multiple Data in One Go.”</em></strong></blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=30e2a9ea3d9c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Master JavaScript from Scratch (Part 2): Understand Functions Step by Step]]></title>
            <link>https://medium.com/@divyakandpal93/master-javascript-from-scratch-part-2-understand-functions-step-by-step-6b56f4adade5?source=rss-562e472a3384------2</link>
            <guid isPermaLink="false">https://medium.com/p/6b56f4adade5</guid>
            <dc:creator><![CDATA[Divya Kandpal]]></dc:creator>
            <pubDate>Mon, 06 Oct 2025 17:28:27 GMT</pubDate>
            <atom:updated>2025-10-06T17:28:27.598Z</atom:updated>
            <content:encoded><![CDATA[<p>In this blog, we’ll learn what a <strong>function</strong> really is, why we use it, and how it makes your JavaScript (and automation) code clean, short, and smart.</p><h3>1. What is a Function?</h3><p>A <strong>function</strong> is like a <strong>small machine</strong> inside your code.<br> You give it some input, it does some work, and it gives you an output.</p><p>Example:</p><pre>function add(a, b) {<br>  return a + b;<br>}</pre><p><strong>Let’s break it down word by word:</strong></p><ul><li><strong>function</strong> → tells JavaScript we’re making a new function.</li><li><strong>add</strong> → the name of our function (you can pick any clear name).</li><li><strong>(a, b)</strong> → these are <strong>inputs</strong>, also called <strong>parameters</strong>.</li><li><strong>{ }</strong> → curly braces hold the steps or instructions.</li><li><strong>return</strong> → sends the final answer back.</li></ul><p>When we run:</p><pre>console.log(add(5, 3));</pre><p>We’ll get: <strong>8</strong></p><p>So, this function adds two numbers and gives us the total.</p><h3>2. Why Do We Use Functions?</h3><p>Imagine writing the same line 10 times — tiring, right?<br> Functions help us <strong>write it once</strong> and <strong>use it again</strong> whenever needed.</p><p>Example:</p><pre>function greetUser(name) {<br>  console.log(&#39;Hello, &#39; + name);<br>}<br>greetUser(&#39;Divya&#39;);<br>greetUser(&#39;Nishita&#39;);</pre><p>Here the same function greets two different people — no need to copy-paste code!</p><h3>3. Types of Functions in JavaScript</h3><p>Let’s learn the three main ways to create a function.<br> We’ll go slowly and understand what each means.</p><h4>1️⃣ Function Declaration (Old but Gold)</h4><pre>function greet() {<br>  console.log(&#39;Hello World!&#39;);<br>}<br>greet();</pre><p>🟢 You can call this type of function <strong>anywhere</strong> in your code — even before writing it.<br> Why? Because JavaScript quietly moves it to the top when it runs your code.</p><p>Just remember:</p><blockquote><em>Function Declaration = Can be used before or after it’s written.</em></blockquote><h4>2️⃣ Function Expression (Stored in a Variable)</h4><pre>const greet = function() {<br>  console.log(&#39;Hello again!&#39;);<br>};<br>greet();</pre><p>Let’s explain slowly:</p><ul><li>const greet → we make a <strong>variable (a container)</strong> named greet.</li><li>= function() { ... } → we <strong>put a function inside</strong> that container.</li><li>greet(); → we <strong>open the box</strong> and use the function.</li></ul><p>🧩 Important rule:<br> JavaScript reads your code <strong>from top to bottom</strong>, so you must <strong>create this function first and then use it</strong>.</p><p>Example:<br> ❌ Wrong</p><pre>sayHi(); // Doesn’t work<br>const sayHi = function() { console.log(&#39;Hi!&#39;); };</pre><p>✅ Right</p><pre>const sayHi = function() { console.log(&#39;Hi!&#39;); };<br>sayHi();</pre><p>That’s why we simply say:</p><blockquote><em>“Write it first, then use it.”</em></blockquote><h4>3️⃣ Arrow Function (Modern and Short)</h4><pre>const multiply = (a, b) =&gt; a * b;<br>console.log(multiply(4, 5)); // 20</pre><p>🪄 Arrow functions are a <strong>shorter way</strong> to write the same thing.<br> They’re used a lot in modern automation frameworks because they look clean and simple.</p><p>Example in automation:</p><pre>const fillForm = (field, value) =&gt; {<br>  console.log(`Filling ${field} with ${value}`);<br>};</pre><h3>4. Parameters vs Arguments</h3><pre>function sayHello(name) {     // name → parameter<br>  console.log(`Hello, ${name}`);<br>}</pre><pre>sayHello(&#39;Divya&#39;);            // &#39;Divya&#39; → argument</pre><ul><li><strong>Parameter</strong> → the placeholder in the function (like a label).</li><li><strong>Argument</strong> → the real value you send when you call the function.</li></ul><h3>5. The return Keyword — Giving Back a Result</h3><pre>function add(a, b) {<br>  return a + b;<br>}<br>let total = add(10, 5);<br>console.log(total); // 15</pre><ul><li>If you use return, the function <strong>gives you something back</strong>.</li><li>If you don’t, it just <strong>does a task</strong> (like printing a message).</li></ul><h3>6. How Functions Help in Automation</h3><p>Think of automation like a list of repeated steps — login, click, fill, submit.<br> Instead of writing them again and again, we make one function for each step.</p><pre>| Task              | Function Example            |<br>| ----------------- | --------------------------- |<br>| Login to app      | `login(username, password)` |<br>| Fill form         | `fillForm(field, value)`    |<br>| Click button      | `clickButton(locator)`      |<br>| Get data from API | `getApiData(url)`           |</pre><p>💡 Pro Tip:<br> In Playwright or Selenium, your <strong>utility files</strong> are full of such reusable functions.</p><h3>7. Nested Functions (Function Inside Another)</h3><p>Yes, a function can live inside another function.</p><pre>function mainTask() {<br>  function subTask() {<br>    console.log(&#39;Doing a sub-task&#39;);<br>  }<br>  subTask();<br>  console.log(&#39;Main task done!&#39;);<br>}<br>mainTask();</pre><p>👉 This helps when one step depends on another, like login → then fill form.</p><h3>8. Best Practices for Writing Functions</h3><ol><li>Give <strong>clear names</strong> → calculateSalary() not doTask().</li><li>Keep them <strong>short</strong> → one function = one job.</li><li>Always use return if you need a result.</li><li>Use <strong>arrow functions</strong> for small utilities.</li><li><strong>Reuse</strong> your functions everywhere — don’t copy-paste code.</li></ol><h3>9. Small Practice Tasks</h3><p>Try these on your own:</p><ol><li>Make a function to check if a number is even or odd.</li><li>Make a function that adds all numbers in an array.</li><li>Make a function that prints all fruit names from a list.</li></ol><p>Doing small hands-on tasks helps you remember the concept forever!</p><h3>✨ Final Thoughts</h3><p>Functions are the <strong>building blocks</strong> of your JavaScript logic.<br> They let you take one big problem and break it into tiny, reusable parts — just like an engineer builds a machine from small components.</p><p>Once you understand functions fully, you’re ready to learn <strong>Objects, Classes, and Async JavaScript</strong>, which power real-world automation frameworks.</p><h3>Next Blog Preview</h3><blockquote><strong><em>“JavaScript Objects Explained Simply — Handling Real Data in Automation.”</em></strong></blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6b56f4adade5" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>