Cheat Sheets

QA Cheat Sheets 2026: Selenium, Playwright, SQL, HTTP Codes & Git

Six one-page cheat sheets every tester needs before an interview or a sprint — Selenium locators & commands, Playwright, SQL queries, HTTP status codes, Git and TestNG. Save any of them as a free PDF.

✍️ By QA Jobs India📅 16 Oct 2026⏱ 15 min read

Cheat sheets are the fastest way to revise before an interview, a live coding round or your first week on a new automation project. We have put the commands and syntax testers use every day on one page, with short notes on when to use each one.

Use the contents below to jump to a sheet. Tap Download PDF to save the whole page as a PDF (choose “Save as PDF” in the print dialog) and keep it on your phone or laptop.

1. Selenium locators cheat sheet (Java)

LocatorSyntaxUse when
IDBy.id("email")Unique, stable id exists — fastest and first choice
NameBy.name("password")Form fields with a name attribute
Class nameBy.className("btn-primary")Single class only (no spaces)
Tag nameBy.tagName("a")Collect all links, rows, inputs
Link textBy.linkText("Forgot password?")Exact visible text of a link
Partial link textBy.partialLinkText("Forgot")Part of a link’s text
CSS selectorBy.cssSelector("input#email")Fast, readable; preferred over XPath
XPathBy.xpath("//button[text()='Login']")Text-based, parent/sibling navigation

CSS selector syntax

PatternExampleMeaning
#id#emailElement with id=”email”
.class.card.activeElement with both classes
tag[attr=value]input[type='submit']Attribute equals
[attr^=]a[href^='https']Starts with
[attr$=]img[src$='.png']Ends with
[attr*=]div[class*='error']Contains
parent > childform > buttonDirect child
ancestor descendanttable tdAny descendant
A + Blabel + inputNext sibling
:nth-child(n)tr:nth-child(2) tdPosition among siblings

XPath syntax

PatternExample
Attribute//input[@id='email']
Exact text//button[text()='Login']
Contains//div[contains(@class,'error')]
Starts with//input[starts-with(@id,'user_')]
AND / OR//input[@type='text' and @name='q']
Index(//table//tr)[3]
Parent//span[text()='Price']/..
Following sibling//label[text()='Email']/following-sibling::input
Ancestor//td[text()='Asha']/ancestor::tr
Normalize space//h2[normalize-space()='My Orders']

Selenium 4 relative locators

import static org.openqa.selenium.support.locators.RelativeLocator.with;

WebElement password = driver.findElement(with(By.tagName("input")).below(By.id("email")));
WebElement cancel   = driver.findElement(with(By.tagName("button")).toLeftOf(By.id("submit")));
// also: above(), toRightOf(), near()

2. Selenium WebDriver commands cheat sheet

TaskCode (Java)
Start Chrome (Selenium Manager)WebDriver driver = new ChromeDriver();
Open URL / back / refreshdriver.get(url); driver.navigate().back(); driver.navigate().refresh();
Title / URLdriver.getTitle(); driver.getCurrentUrl();
Type / click / clearel.sendKeys("text"); el.click(); el.clear();
Read text / attributeel.getText(); el.getAttribute("value"); el.getDomAttribute("href");
State checksel.isDisplayed(); el.isEnabled(); el.isSelected();
Implicit waitdriver.manage().timeouts().implicitlyWait(Duration.ofSeconds(5));
Explicit waitnew WebDriverWait(driver, Duration.ofSeconds(10)).until(ExpectedConditions.elementToBeClickable(By.id("pay")));
Dropdownnew Select(el).selectByVisibleText("India");
Mouse hover / dragnew Actions(driver).moveToElement(menu).perform(); new Actions(driver).dragAndDrop(src, dst).perform();
Right / double clicknew Actions(driver).contextClick(el).doubleClick(el).perform();
AlertAlert a = driver.switchTo().alert(); a.getText(); a.accept();
Framedriver.switchTo().frame("payFrame"); driver.switchTo().defaultContent();
New window / tabdriver.switchTo().newWindow(WindowType.TAB); for (String h : driver.getWindowHandles()) driver.switchTo().window(h);
JavaScript click / scroll((JavascriptExecutor) driver).executeScript("arguments[0].scrollIntoView(true);", el);
ScreenshotFile f = ((TakesScreenshot) driver).getScreenshotAs(OutputType.FILE);
Upload filedriver.findElement(By.id("cv")).sendKeys("C:/data/cv.pdf");
Cookiesdriver.manage().getCookies(); driver.manage().deleteAllCookies();
HeadlessChromeOptions o = new ChromeOptions(); o.addArguments("--headless=new");
Close vs quitdriver.close(); // current window driver.quit(); // whole session
Common exceptions: NoSuchElementException (wrong locator or not loaded — add an explicit wait), StaleElementReferenceException (DOM refreshed — find the element again), ElementClickInterceptedException (overlay on top — wait for it to disappear), TimeoutException (condition never met).

🚀 Revised? Now apply to today’s QA jobs

QA Jobs India shares 100+ fresh QA & software testing openings every morning — manual, automation, API and remote roles.

See today’s QA jobs →

3. Playwright cheat sheet (TypeScript)

CLI commands

CommandWhat it does
npm init playwright@latestCreate a new project with config and example test
npx playwright install --with-depsInstall browsers and OS dependencies
npx playwright testRun all tests (headless, in parallel)
npx playwright test login.spec.ts --headedRun one file with a visible browser
npx playwright test --project=chromiumRun one project/browser
npx playwright test --grep @smokeRun tagged tests
npx playwright test --uiUI mode with watch and time-travel
npx playwright test --debugStep through with the Inspector
npx playwright codegen https://site.comRecord actions and generate code
npx playwright show-reportOpen the last HTML report
npx playwright show-trace trace.zipOpen a trace file
npx playwright test --shard=1/3Run one shard of the suite on CI

Locators, actions and assertions

// locators (preferred order)
page.getByRole('button', { name: 'Login' })
page.getByLabel('Email')
page.getByPlaceholder('Search jobs')
page.getByText('Welcome back')
page.getByTestId('cart-count')
page.locator('#id, .class, [data-x="1"]')
page.getByRole('row').filter({ hasText: 'Asha' }).getByRole('button')

// actions
await page.goto('/login');
await locator.click();            await locator.dblclick();
await locator.fill('text');       await locator.press('Enter');
await locator.check();            await locator.selectOption('India');
await locator.hover();            await locator.setInputFiles('cv.pdf');
await locator.dragTo(target);

// web-first assertions (auto-retry)
await expect(page).toHaveURL(/dashboard/);
await expect(page).toHaveTitle('Orders');
await expect(locator).toBeVisible();
await expect(locator).toHaveText('Paid');
await expect(locator).toContainText('Order');
await expect(locator).toHaveValue('qa@test.com');
await expect(locator).toHaveCount(5);
await expect(locator).toBeEnabled();
await expect.soft(locator).toHaveAttribute('aria-checked', 'true');

// network
await page.route('**/api/jobs', r => r.fulfill({ json: [] }));
const resp = page.waitForResponse('**/api/cart');

// frames, popups, dialogs
page.frameLocator('#pay').getByLabel('Card');
const popup = page.waitForEvent('popup');
page.once('dialog', d => d.accept());

4. SQL cheat sheet for testers

NeedQuery
All columnsSELECT * FROM users;
FilterSELECT name, city FROM users WHERE city = 'Pune' AND status = 'ACTIVE';
Pattern matchSELECT * FROM users WHERE email LIKE '%@gmail.com';
Range / listWHERE salary BETWEEN 30000 AND 60000; WHERE city IN ('Pune','Mumbai');
NULL checkSELECT * FROM orders WHERE delivered_at IS NULL;
Sort and limitSELECT * FROM orders ORDER BY created_at DESC LIMIT 10;
Count / sum / avgSELECT COUNT(*), SUM(amount), AVG(amount) FROM orders;
Group with filterSELECT city, COUNT(*) FROM users GROUP BY city HAVING COUNT(*) > 100;
DistinctSELECT DISTINCT status FROM orders;
Inner joinSELECT o.id, u.name FROM orders o JOIN users u ON u.id = o.user_id;
Left join (find missing)SELECT u.id FROM users u LEFT JOIN orders o ON o.user_id = u.id WHERE o.id IS NULL;
DuplicatesSELECT email, COUNT(*) FROM users GROUP BY email HAVING COUNT(*) > 1;
2nd highest salarySELECT MAX(salary) FROM emp WHERE salary < (SELECT MAX(salary) FROM emp);
Nth highest (window)SELECT salary FROM (SELECT salary, DENSE_RANK() OVER (ORDER BY salary DESC) r FROM emp) t WHERE r = 3;
Insert / update / deleteINSERT INTO users(name) VALUES('Asha'); UPDATE users SET status='X' WHERE id=5; DELETE FROM users WHERE id=5;
Remember: WHERE filters rows before grouping, HAVING filters groups after. DELETE removes rows (can roll back, WHERE allowed), TRUNCATE empties the table quickly, DROP removes the table itself. Practise more with our SQL interview questions for testers.

5. HTTP status codes cheat sheet

CodeNameWhat a tester should check
200OKSuccessful GET/PUT; validate response body and schema
201CreatedPOST created a resource; check Location header / returned id
202AcceptedRequest queued for async processing; poll for the result
204No ContentSuccess with empty body (often DELETE)
301 / 302Moved / FoundRedirects; check target URL and SEO redirects
304Not ModifiedCaching works (ETag / If-Modified-Since)
400Bad RequestInvalid input — negative tests should return clear errors
401UnauthorizedMissing/invalid token — test expired and wrong tokens
403ForbiddenLogged in but no permission — role-based access tests
404Not FoundWrong id or URL — must not leak stack traces
405Method Not AllowedWrong HTTP method for the endpoint
409ConflictDuplicate record or version conflict
415Unsupported Media TypeWrong Content-Type header
422Unprocessable EntityValid JSON but failed business validation
429Too Many RequestsRate limiting; check Retry-After header
500Internal Server ErrorServer bug — always report with request/response
502 / 503 / 504Bad Gateway / Unavailable / TimeoutDownstream or infra issues; test retries and error pages

HTTP methods

MethodPurposeIdempotent
GETRead a resourceYes
POSTCreate / trigger an actionNo
PUTReplace a resource fullyYes
PATCHUpdate part of a resourceNot guaranteed
DELETERemove a resourceYes
HEAD / OPTIONSHeaders only / allowed methods (CORS preflight)Yes

6. Git commands cheat sheet

CommandWhat it does
git clone <url>Copy a remote repository
git statusSee changed, staged and untracked files
git switch -c feature/login-testsCreate and switch to a new branch
git add . / git add fileStage changes
git commit -m "Add login tests"Save staged changes with a message
git push -u origin feature/login-testsPush a new branch and set upstream
git pull --rebaseGet latest changes and replay yours on top
git fetchDownload remote changes without merging
git merge mainMerge main into the current branch
git log --oneline --graphCompact history
git diff / git diff --stagedShow unstaged / staged changes
git stash / git stash popPark work temporarily and bring it back
git restore fileDiscard local changes in a file
git reset --soft HEAD~1Undo last commit, keep changes staged
git revert <commit>Create a new commit that undoes one (safe on shared branches)
git cherry-pick <commit>Apply one commit to the current branch
git branch -d nameDelete a merged local branch
Interview favourites: merge vs rebase (merge keeps history with a merge commit; rebase rewrites your commits on top for a linear history — never rebase shared branches), fetch vs pull (pull = fetch + merge/rebase), reset vs revert (reset moves history, revert adds an undo commit). Add target/, node_modules/, reports and .env to .gitignore.

Bonus: TestNG annotations and order

AnnotationRuns
@BeforeSuite / @AfterSuiteOnce before / after the whole suite
@BeforeTest / @AfterTestBefore / after each <test> tag in testng.xml
@BeforeClass / @AfterClassBefore / after the first / last method in a class
@BeforeMethod / @AfterMethodBefore / after every @Test method
@Test(priority, groups, dependsOnMethods, dataProvider, invocationCount, enabled)The test itself
@DataProviderSupplies data sets to a test
@ParametersReads values from testng.xml

Order: BeforeSuite → BeforeTest → BeforeClass → BeforeMethod → Test → AfterMethod → AfterClass → AfterTest → AfterSuite.

FAQs

How do I download these cheat sheets as a PDF?

Tap the Download PDF button at the top, then choose “Save as PDF” as the printer. Headers, menus and buttons are hidden automatically in the PDF.

Are these cheat sheets enough for an interview?

They are for quick revision. Pair them with the full interview question banks linked below and one hands-on project.

Which cheat sheet should a fresher start with?

SQL, HTTP status codes and Selenium locators — these are asked in almost every fresher QA interview.

Will you add more cheat sheets?

Yes. We will keep adding sheets such as Postman, Linux commands and Appium on the QA Study Material hub.

💎 Get every QA opening, every day

Join QA Jobs India Premium for 100+ verified QA jobs daily with HR contact details.

✓ You're subscribed — job alerts arrive daily at 9 AM
Scroll to Top