Interview prep

Automation Cheat Sheets

Dense, professional references you can skim the hour before an interview.

Selenium Cheat Sheet

Driver setup, waits, interactions and the Selenium 4 APIs you actually use.

Waits

Explicit wait

new WebDriverWait(driver, Duration.ofSeconds(15))
  .until(ExpectedConditions.visibilityOfElementLocated(by));

Fluent wait

new FluentWait<>(driver).withTimeout(Duration.ofSeconds(30))
  .pollingEvery(Duration.ofMillis(300))
  .ignoring(NoSuchElementException.class);

Disable implicit wait

driver.manage().timeouts().implicitlyWait(Duration.ZERO);

Interactions

Actions chain

new Actions(driver).moveToElement(menu).click(item).perform();

JS click

((JavascriptExecutor) driver).executeScript("arguments[0].click();", el);

Scroll into view

((JavascriptExecutor) driver)
  .executeScript("arguments[0].scrollIntoView({block:'center'});", el);

Select dropdown

new Select(driver.findElement(by)).selectByVisibleText("India");

Selenium 4 extras

Shadow root

host.getShadowRoot().findElement(By.cssSelector("input"));

Element screenshot

el.getScreenshotAs(OutputType.FILE);

New tab

driver.switchTo().newWindow(WindowType.TAB);

Relative locator

driver.findElement(with(By.tagName("input")).below(By.id("email")));