How I Built a Real Automation Framework from Scratch Using Vibe Coding (Part 2)

AI part 2

Welcome to Part 2 of our Vibe Coding series where we build a real-life automation framework using Generative AI tools.

In the previous part, we successfully created a product requirement document (PRD), a detailed test plan, and test cases using Perplexity AI with Claude 4.7 Sonnet model. Now, it’s time to move to the next step: building the actual automation framework using Cursor AI.

Contents

What is Cursor AI?

Cursor AI is an AI-powered code editor that allows you to build projects using natural language prompts. You can literally talk to the tool and it writes the code for you. It’s a perfect fit for testers, especially if you’re not confident in coding yet.

There’s a free version available with 1500 prompt requests and 200 compilations more than enough to build a complete automation framework. Students even get additional discounts!

Getting Started with Cursor AI

We created a new Maven project and gave it a name, for example, “SeleniumAutomationFramework”. The interface shows a folder structure and a chat section where you can talk to the AI.

To help the AI understand the context, I uploaded a few screenshots of the login page (both valid and invalid scenarios). Then I gave a detailed prompt:

Prompt Example:

“Create a Maven project with dependencies for Selenium (Java), TestNG, Allure Report, Log4j, and Apache POI. Add pom.xml, .gitignore, and JenkinsFile for CI/CD. Use Page Object Model structure. Include folders for DriverManager, Pages, Utils, and add a data.properties file. We’ll test two scenarios: valid and invalid login.”

This detailed prompt allowed Cursor AI to understand exactly what we needed, not just code but the entire project structure.

What Cursor AI Generated:

Cursor AI generated:

  • pom.xml with all dependencies
  • Project folder structure
  • testng.xml file
  • data.properties file with test credentials
  • Page Object classes for login and dashboard
  • Utility classes for reading data and managing the driver
  • Base test class and test cases for valid/invalid login

Everything was done without writing a single line of code manually.

Debugging & Fixing Errors

Like with any code, AI-generated scripts also need review. Some issues we faced:

  • Locator mismatches (incorrect XPath/CSS)
  • Empty class files
  • Assertion mismatches
  • Timing issues (missing waits)

We used basic debugging skills to:

  • Inspect locators via browser
  • Add Thread.sleep() (just for demo, you should use explicit waits)
  • Use proper assertions like Assert.assertEquals() instead of generic ones

Fixing these issues gave us a better understanding of what the AI was doing behind the scenes.

Test Execution

Once everything was ready, we ran our test cases using: mvn clean install

We also generated test reports using Allure, which gave us a clean visual summary of test results.

Bonus: Pushing Code to GitHub

Cursor AI also helped us with GitHub commands. We asked:

“How to push this project to GitHub?”

It gave us all the steps:

  1. Initialize Git
  2. Connect to remote repository
  3. Commit and push changes

You can also join our free GitHub learning community where 700+ learners are mastering version control step by step. Just type “invite to SDET Club” and we’ll send you the access link.

Final Thoughts

This was a complete journey from creating a PRD to building and debugging a live Selenium TestNG automation framework using Cursor AI.

AI tools are amazing — but your understanding of testing concepts, locators, and debugging is still essential. With practice, you’ll learn how to guide AI to generate clean and working frameworks.

Let me know if you’d like Part 3, where we’ll expand the framework with more test cases and real-world scenarios.

Thanks for reading. 🚀

Similar Posts

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.