Back to Cheat SheetsAutomation · Beginner
Selenium WebDriver cheat sheet
Driver setup, locators, waits and the APIs that appear in every interview.
Setup and navigation
Create driver
WebDriver driver = new ChromeDriver();Navigate
driver.get("https://example.com");Quit
quit() closes the session, close() only the window
driver.quit();Locators and actions
Find element
driver.findElement(By.cssSelector("#login"))Type / click
el.sendKeys("qa"); el.click();Dropdown
new Select(el).selectByVisibleText("India");Actions
new Actions(driver).moveToElement(el).click().perform();Waits
Implicit
Do not mix with explicit waits
driver.manage().timeouts().implicitlyWait(ofSeconds(10));Explicit
new WebDriverWait(driver, ofSeconds(10)).until(elementToBeClickable(by));Fluent
new FluentWait<>(driver).withTimeout(...).pollingEvery(...).ignoring(...)Frames, windows, alerts
Frame
driver.switchTo().frame("name"); driver.switchTo().defaultContent();Window
driver.switchTo().window(handle);Alert
driver.switchTo().alert().accept();Go beyond the reference
Book a free demo class and apply these commands on live project work.