My Playwright Automation Journey with an AI Partner


If you’ve spent more than five minutes on LinkedIn lately, you’ve probably seen some panic. Everyone is talking about how AI is going to take over software testing and replace the rest of us.
Let’s pause for a moment. Whenever I see that post, this is the console output in my head:
console.log(“Deep breath. The AI revolution is just a tool upgrade. It will be the new normal in a few years.”);
Here’s the truth: AI isn’t here to steal your work. It’s here to do the boring work so you can focus on the big picture. I recently tested this by building a complete Playwright automation suite using JavaScript from scratch, aided by the Antigravity inbuilt AI agent.
Here’s how it went down.


Laying the Foundation
Starting a new default framework is often a chore because of all the initial setup. With AI, it was incredibly fast:
Quick Start: We started things off well with a standard
> npm init playwright@latest.
Structured Architecture: AI helped me build a clean Page Object Model (POM) on the spot. We organized the finders into neat files like LoginPage.js again AdminPage.js instead of scattering them everywhere.
Smart Configuration: Because my workflow depends on previous test steps to pass, AI helped to adjust my playwright.config.js. Set the tests to run sequentially (employees: 1 again mode: ‘serial’) to prevent unplanned failures.
Reality Check “Before AI” vs. “After AI”
That’s when things got really interesting. Before using AI, my approach to scripting—let’s take a simple login page, for example—was very basic.
How I used to write it (Before AI):
- Tell Playwright to go to the login URL.
- Throw blindly fill in instructions in the Email and Password fields.
- Click Submit and hope the dashboard loads before the test times out.
javascript
test('Basic Login', async ({ page }) => {
// Just blindly going to the URL and typing
await page.goto('
await page.locator('#email').fill('myEmail@test.com');
await page.locator('#password').fill('myPassword123');
await page.locator('#submitBtn').click();
// Hoping the dashboard loads...
});
How we write now (After AI):
- The script ensures that the page is fully loaded.
- Checks that input fields are visible and enabled before typing.
- It apparently waits for a network response to come back a 200 OK and the dashboard URL that will appear before you continue.
javascript
test('Robust Login with AI', async ({ page }) => {
// Navigation with error handling
await page.goto(' { waitUntil: 'domcontentloaded' });
// Explicitly waiting for the elements to be ready before interacting
const emailInput = page.locator('#email');
const passwordInput = page.locator('#password');
const submitBtn = page.locator('#submitBtn');
await expect(emailInput).toBeVisible();
await expect(emailInput).toBeEnabled();
// Now we interact
await emailInput.fill('myEmail@test.com');
await passwordInput.fill('myPassword123');
// Smart click and wait for the successful network response and dashboard URL
await Promise.all([
page.waitForResponse(response => response.url().includes('/api/auth') && response.status() === 200),
page.waitForURL('**/dashboard'),
submitBtn.click()
]);
});
The AI also handled the dirty parts of my app:
- Data Transfer: Helped me save a dynamically generated registration email to use in a recent admin approval test.
- Smart click: Created custom methods to wait for background loading spinners to disappear before clicking.
- Automatic Cleaning: Wrote scripts that automatically delete test data at the end of time to keep the database clean.
Automating flows with Jenkins
“Works on my machine” means nothing if it doesn’t automatically work on your pipeline. For that, we needed Jenkins.
What is Jenkins?
- Jenkins is a popular integration/continuous delivery (CI/CD) server.
- It acts as a robotic traffic policeman for your code—it automatically triggers, builds, and executes your test scripts every time developers push new updates to the app.
Writing a Jenkinsfile Pipelining a script from scratch can be a headache, but the Antigravity agent can be written in minutes. Our pipeline is now successfully:
- It automatically pulls the latest code.
- Dependent installations and browsers for Playwright.
- It runs the entire test suite without a header.
- Generates a clean HTML report and sends results directly to stakeholders.
Wrapping up
Building this suite has completely opened my eyes to testing, and the numbers speak for themselves.
- Before AI: Creating a framework of this magnitude and complexity used to take me a bit 464 hours for grinding through syntax, debugging weak selectors, and scrolling through StackOverflow.
- Behind the AI: With an AI agent handling the heavy lifting, I completed the exact same automation suite 144 hours.
That’s the whole point of using AI. It doesn’t replace your testing basics—you still need to understand your business logic and tell the AI what to do. But when it comes down to it, it saves a lot of time. It reduces your effort by hundreds of hours and turns difficult documents into a rock-solid automated framework.
If you’re skeptical about the AI wave, fear not. Choose a tool like Playwright, turn on the AI assistant, and start creating. The test is just to get an amazing upgrade.
Enjoy the automation!



