Playwright & Selenium Locator Practice Lab [SDET ADDA]
Playwright & Selenium Locator Practice Lab
Automation Playground
Use this page to practice robust locator strategies, synchronization, actions, frames, dynamic DOM changes, keyboard and mouse interactions.
Role, label, placeholder, text, test id, CSS, XPath and chaining.
ID, name, class, tag, link text, CSS, XPath, waits and Actions.
Stable attributes are preferred; deliberately duplicated values are included for teaching.
1. Login & Form Locator Practice
2. Text, Role, Attribute & CSS/XPath Examples
Locator Practice Heading
This paragraph contains important training text for getByText and CSS demonstrations.
Duplicate training text
Duplicate training text
Useful links: Automation Documentation · Table Practice
3. Ordered & Unordered Lists — nth(), first(), last(), filter()
Unordered Test Tools
- Playwright
- Selenium
- Cypress
- Playwright
- Appium
- Selenium
- Postman
- RestAssured
- Jenkins
- Docker
- Kubernetes
Execution Steps
- Open application
- Locate element
- Fill test data
- Click action
- Verify result
- Capture evidence
- Generate report
- Review logs
- Cleanup
- Publish results
4. Data Table — Row-Level Locators
5. Dropdowns & Advanced Form Controls
6. Mouse Events
Click this box.
Double-click this box.
Use contextmenu.
Move your mouse here.
Scrollable container — use mouse wheel or Playwright/Selenium scroll.
You reached the bottom.
7. Keyboard Events
Waiting for keyboard input...
8. Dynamic Elements & DOM Changes
9. Synchronization: Modal, Toast, Dialog & Loading
10. Iframe / Frame Locator Practice
11. Nested Components — Chaining, Filtering, hasText(), has(), nth()
Playwright Pro
Enterprise browser automation
PopularPlaywright Basic
Beginner automation training
BeginnerSelenium Pro
WebDriver automation training
Popular12. Locator Examples Cheat Sheet
| HTML element | Recommended Playwright | Selenium | Why |
|---|---|---|---|
<button>Login</button> | getByRole('button', {name:'Login'}) | By.ID('loginSubmit') | Prefer semantic role/name or stable ID. |
input#username | getByLabel('Username') | By.ID('username') | Label is user-facing and readable. |
input placeholder | getByPlaceholder('Enter username') | By.CSS_SELECTOR('[placeholder="Enter username"]') | Useful when placeholder is stable. |
data-testid | getByTestId('username-input') | By.CSS_SELECTOR('[data-testid="username-input"]') | Excellent automation contract. |
| Visible text | getByText('Automation Documentation') | By.LINK_TEXT('Automation Documentation') | Good for stable user-visible content. |
| CSS | locator('#userTable tbody tr') | By.CSS_SELECTOR('#userTable tbody tr') | Precise structural selection. |
| XPath | locator('//table[@id="userTable"]//tr') | By.XPATH('//table[@id="userTable"]//tr') | Useful for relationships and complex structures. |
| Repeated list item | locator('#toolList li').nth(3) | findElements(By.CSS_SELECTOR(...)).get(3) | Index only when uniqueness is impossible. |
| Filtered row | getByRole('row').filter({hasText:'Aarav'}) | By.XPATH('//tr[.//td="Aarav"]') | Row-level context reduces ambiguity. |
13. Complete Automation Scripts
Copy the scripts below into your Playwright TypeScript and Selenium Python projects. The Playwright script intentionally covers the locator and action APIs used throughout this page.
Locator Practice Modal
This modal is dynamically displayed.
Comments
Post a Comment