Skip to main content
← TesterRank/Automation Cheatsheet
Quick Reference · 5 Master Cheatsheets · 100% Free

QA Automation Cheatsheets

Instant syntax reference for Selenium WebDriver, Playwright, XPath, CSS Selectors, Waits, and Exception Handling. Copy-paste runnable code directly into your test suites.

Core Syntax

Locators Cheatsheet

Complete reference for ID, Name, Class, CSS Selector, Relative XPath, and data-testid locator strategies. Includes Selenium and Playwright code syntax.

Key Topics Covered:
  • ✓By.id vs By.cssSelector
  • ✓data-testid best practices
  • ✓Resilient selector hierarchy
  • ✓Playwright getBy* methods
Open Cheatsheet →
WebDriver API

Selenium Commands

Browser control, navigation, window management, alert handling, dropdown selection with Select class, and Actions class mouse interactions.

Key Topics Covered:
  • ✓driver.navigate() vs get()
  • ✓Select dropdown handling
  • ✓Actions hover and drag
  • ✓Switching browser tabs
Open Cheatsheet →
Comparison

XPath & CSS Selectors

Side-by-side comparison of XPath vs CSS Selectors. Master text matching, contains(), starts-with(), axes (following, preceding, ancestor), and nth-child.

Key Topics Covered:
  • ✓XPath axes navigation
  • ✓CSS pseudo-classes
  • ✓Text matching syntax
  • ✓Performance comparisons
Open Cheatsheet →
Stability

Waits & Synchronization

Never use Thread.sleep(). Learn Implicit Wait, Explicit Wait (WebDriverWait), FluentWait, and every ExpectedConditions method for rock-solid tests.

Key Topics Covered:
  • ✓WebDriverWait patterns
  • ✓elementToBeClickable()
  • ✓visibilityOfElementLocated()
  • ✓Custom FluentWait polling
Open Cheatsheet →
Troubleshooting

Common Automation Errors

Diagnose and fix StaleElementReferenceException, NoSuchElementException, ElementClickInterceptedException, and TimeoutException with proven recipes.

Key Topics Covered:
  • ✓Stale element retry patterns
  • ✓Click intercepted bypasses
  • ✓JavaScript click fallback
  • ✓Dynamic ID handling
Open Cheatsheet →

Most Frequently Used Locators at a Glance

Keep these production-tested patterns handy when automating our 10 practice portals.

XPath by Exact Text//button[text()='Login']
XPath by Partial Text//div[contains(text(), 'Welcome')]
CSS Selector by data-testidbutton[data-testid='submit-btn']
Explicit Wait in Selenium Javawait.until(ExpectedConditions.elementToBeClickable(By.id('otp')));

Frequently Asked Questions

Should I prefer CSS Selectors or XPath for web automation?

Prefer CSS Selectors for simple class, ID, and attribute matching because browsers evaluate CSS natively faster. Use XPath when you need to navigate up the DOM tree (parent/ancestor navigation) or locate elements by exact inner text, as standard CSS cannot search text content or traverse upward.

What is the locator priority hierarchy recommended for reliable tests?

The industry standard priority is: (1) data-testid or dedicated test attributes, (2) unique semantic ID, (3) name attribute, (4) specific CSS selector, (5) relative XPath with robust attributes, and never use absolute XPath (e.g. /html/body/div[2]/div/span) as it breaks with the slightest layout change.

Why does StaleElementReferenceException occur and how do I prevent it?

It happens when a WebElement was located on the page, but subsequent JavaScript execution, AJAX refresh, or DOM re-rendering detached that element from the active document tree. Fix it by re-locating the element immediately before interacting, or using WebDriverWait with ExpectedConditions.refreshed().