Automation Testing Journey as a Beginner: Exploring Playwright and Cypress

Mohamed Amaan
5 Min Read

Starting my journey in automation testing has been a mix of curiosity and learning. As a beginner, I want to share my experiences, research, and practical insights on using two popular tools: Playwright and Cypress. This blog is for anyone who’s also starting their journey and looking for a relatable guide.

1. Why Automation Testing?

When I first heard about automation testing, I thought, “Isn’t manual testing enough?” But as I explored more, I realized its importance:

  • Efficiency: Automating repetitive tests saves a lot of time.
  • Accuracy: Automation eliminates human errors in testing.
  • Faster Feedback: Especially in agile projects, automation gives quick insights into the quality of the application.

This sparked my interest to dive deeper into this field and explore the tools that could help.

2. Choosing My Tools: Playwright and Cypress

As I started researching, two tools kept popping up — Playwright and Cypress. I chose to try both, and here’s what I found based on my beginner-level experience:

Playwright:

  • Multi-Browser Support: It can test across different browsers like Chromium, Firefox, and WebKit, which is great for ensuring compatibility.
  • Parallel Testing: Playwright can run tests in parallel, making it faster for larger test suites.
  • API Testing: It also supports API testing, which adds flexibility.
  • Learning Curve: It’s powerful but might take some time to fully understand, especially for a beginner like me.

Cypress:

  • Beginner-Friendly: Its user-friendly interface and easy setup make it great for someone starting out.
  • Real-Time Reloading: I loved how Cypress automatically reloads tests when I make changes.
  • Debugging Made Easy: The ability to see screenshots and logs during test execution made debugging intuitive.
  • Browser Limitation: It primarily supports Chromium-based browsers, which might be a constraint for some projects.

3. How I Got Started

With Playwright

  1. Installation:
npm install -D @playwright/test
npx playwright install

2. Writing My First Test:

const { test, expect } = require('@playwright/test');

test('Visit Google and search', async ({ page }) => {
await page.goto('https://google.com');
await page.fill('input[name="q"]', 'Playwright');
await page.press('input[name="q"]', 'Enter');
await expect(page).toHaveTitle(/Playwright/);
});

3. Running the Test:

npx playwright test

With Cypress

  1. Installation:
npm install cypress --save-dev

2. Opening Cypress

npx cypress open

3. Writing My First Test: Inside the cypress/e2e folder, I created google.cy.js :

describe('Google Search Test', () => {
it('Search using Google', () => {
cy.visit('https://google.com');
cy.get('input[name="q"]').type('Cypress{enter}');
cy.title().should('include', 'Cypress');
});
});

4. Running the Test: I selected my test from the Cypress UI and run it.

4. Challenges I Faced as a Beginner

  1. Understanding Locators: Both tools rely on selectors to interact with elements, and learning CSS selectors was a bit tricky at first.
  2. Dealing with Errors: Debugging failures in tests required patience. I learned to read error logs carefully and search for solutions online.
  3. Time Management: Balancing learning with practice was tough. Setting small goals helped me stay on track.
  4. API Testing and Folder Structuring: Figuring out how to test API responses efficiently and structuring test files for APIs is still challenging. I’m exploring best practices to organize folders and make tests maintainable.

5. What I Learned

6. Which Tool Should Beginners Choose?

Choosing the right tool depends on where you are in your automation testing journey. If you’re completely new, start by understanding the basics — locatorsassertions, and writing simple scripts. Once you have a foundation, let your project requirements guide you:

  • Need multi-browser and advanced features? Go for Playwright.
  • Focused on front-end UI testingCypress might fit better.

Instead of picking a tool first, focus on growing your automation skills. As you progress, both tools will become valuable assets in your toolkit.

https://playwright.dev/
https://docs.cypress.io/app/get-started/why-cypress

My Final Thoughts

Automation testing is a rewarding skill, and tools like Playwright and Cypress make it accessible. As a beginner myself, I focus on mastering the fundamentals and experimenting to find what fits my needs. The journey is all about continuous learning and growth!

Share This Article
Leave a Comment

Leave a Reply

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