21. Complete Beginner Example: Automating Login

Now let’s put everything together.

Imagine a website has this login flow:

Login Page

Username: __________

Password: __________

[ Login ]

After successful login:

Welcome to Dashboard

Your manual test case:

Test Case: Successful Login

Precondition: User has valid credentials.

Steps:

  1. Open login page.
  2. Enter username.
  3. Enter password.
  4. Click Login.
  5. Verify Dashboard.

Step 1: Open the Website

Playwright:

await page.goto('https://example.com/login');

Ask AI:

“Explain page.goto to me in simple language.”


Step 2: Enter Username

await page.getByLabel('Username').fill('testuser');

Ask AI:

“Why are we using getByLabel here?”

Understand the locator before moving ahead.


Step 3: Enter Password

await page.getByLabel('Password').fill('Test@123');

Again, understand what fill() is doing.


Step 4: Click Login

await page.getByRole('button', { name: 'Login' }).click();

Ask:

“Explain getByRole and click in this line.”


Step 5: Verify Dashboard

await expect(page.getByText('Dashboard')).toBeVisible();

This is your verification.

Think:

Manual testing:

Dashboard should be visible.

Automation:

await expect(page.getByText('Dashboard')).toBeVisible();

Now you can see how manual testing knowledge maps to automation.


22. Turn This Into a Negative Test

Now let’s test invalid credentials.

Manual Test

  1. Open login page.
  2. Enter valid username.
  3. Enter incorrect password.
  4. Click Login.
  5. Verify error message.

Automation might look like:

await page.goto('https://example.com/login');

await page.getByLabel('Username').fill('testuser');

await page.getByLabel('Password').fill('WrongPassword');

await page.getByRole('button', { name: 'Login' }).click();

await expect(page.getByText('Invalid credentials')).toBeVisible();

Again, AI can help explain every line.


23. How to Ask AI the Right Way

The quality of your AI response often depends on the quality of your question.

Instead of:

“Write Playwright code.”

Give AI context.

For example:

“I am a manual tester with no programming background. I am learning Playwright with TypeScript. I have a login page with Username, Password and Login button. I want to automate successful login. First explain the approach, then give me a small code example, and finally explain every line.”

This gives AI enough information to teach you.


24. Useful AI Prompts for Playwright Beginners

Here are prompts you can save.

Prompt 1 — Learn a concept

“Explain [Playwright concept] in very simple language for a manual tester. Give me a real-world example and a small code example.”

Prompt 2 — Understand code

“Explain this Playwright code line by line. Assume I don’t know programming.”

Prompt 3 — Locator help

“I have this element on my page. Suggest suitable Playwright locators and explain why you recommend them.”

Prompt 4 — Debugging

“I received this Playwright error. Explain the likely reason and give me a debugging checklist. Don’t immediately give me the final solution.”

Prompt 5 — Practice

“Give me a beginner Playwright challenge. Don’t provide the solution unless I ask.”

Prompt 6 — Interview

“Act as a Playwright interviewer. Ask me one question at a time and evaluate my answers.”

Prompt 7 — Code review

“Review my Playwright code as a senior QA engineer. Explain what is good, what can be improved, and why.”

Prompt 8 — Manual to automation

“Convert this manual test case into a Playwright automation approach. Explain the mapping between each manual step and the automation code.”


25. Don’t Ask AI to Do Everything

This is one of the most important lessons.

Imagine you ask:

“Create a complete Playwright framework with POM, fixtures, utilities, reporting, parallel execution and CI/CD.”

AI may generate hundreds of lines.

You may feel:

“Wow! I know Playwright now.”

But you don’t.

You only received code.

If someone asks you:

“Why did you create this fixture?”

You may not know.

Instead, learn step by step:

Playwright basics
       ↓
Locators
       ↓
Actions
       ↓
Assertions
       ↓
Test organization
       ↓
Fixtures
       ↓
Page Object Model
       ↓
Reporting
       ↓
Git
       ↓
CI/CD

This gives you a stronger foundation.


26. Common Mistakes When Using AI for Automation

Mistake 1: Copy-Paste Everything

Don’t copy code without understanding it.


Mistake 2: Asking AI to Fix Everything

If every error is solved by AI, you won’t develop debugging skills.

Try solving the problem first.


Mistake 3: Not Testing AI’s Code

AI-generated code can be wrong.

Always run it.


Mistake 4: Using Outdated Code

Automation tools change.

If code doesn’t work, ask:

“Is this Playwright syntax compatible with the current version? Explain what has changed.”


Mistake 5: Giving Confidential Information

Never share sensitive company data with AI tools.

Use dummy data when practicing.


Mistake 6: Learning Too Many Things at Once

Don’t learn:

Playwright + TypeScript + Python + Selenium + API + JMeter + CI/CD

all at the same time.

Pick one path.

For example:

TypeScript → Playwright → Git → API basics → CI/CD

Then expand.


27. What Should You Learn Yourself?

AI can help you write code.

But some things should come from you.

You should understand:

Testing knowledge

Automation knowledge

Programming basics

Framework concepts

AI can support you, but you need to understand the concepts.


Pages: 1 2 3 4 5 6

Leave a Reply

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