Mistake 7: Hardcoding Test Data Everywhere
Beginners sometimes write:
Contents
await page.getByLabel('Email').fill('mrunal123@gmail.com');
Then another test uses:
await page.getByLabel('Email').fill('mrunal456@gmail.com');
And another:
await page.getByLabel('Email').fill('testuser789@gmail.com');
Soon your test data becomes difficult to manage.
Problems :
Hardcoded data can cause:
- Duplicate data
- Environment issues
- Difficult maintenance
- Test failures
Better approach :
Separate test data from test logic.
For example:
const user = {
email: 'testuser@example.com',
password: 'Password123'
};
Then:
await page.getByLabel('Email').fill(user.email);
As your framework grows, you can move toward:
- JSON test data
- Fixtures
- Environment variables
- API-generated data
- Database/API setup
Mistake 8: Ignoring API and Network Behavior
Playwright isn’t only about clicking buttons.
Modern applications heavily depend on APIs.
Imagine you click:
Place Order
The UI shows a spinner.
Behind the scenes:
UI → API → Database → Response → UI
If you’re only checking the UI, you may miss important problems.
Playwright can help you inspect network activity.
For example:
const responsePromise = page.waitForResponse(
response => response.url().includes('/api/orders')
);
await page.getByRole('button', { name: 'Place Order' }).click();
const response = await responsePromise;
expect(response.status()).toBe(200);
Now you’re validating more than just the UI.
QA Tip :
For critical workflows, think about:
UI + API + Network + Data
Not just clicks.