Browser Regular commands
get() – opens a specified URL in the browser window.
Syntax: driverName.get("URL");getTitle() – Returns the current browser title.
Syntax: System.out.println(driverName.getTitle());getCurrentUrl() – Return current URL of the browser window.
Syntax: System.out.println(driverName.getCurrentUrl());close() – It closes the focused browser window.
Syntax: driver.close();quite() – It closes all browser that opened by Selenium WebDriver during execution.
Syntax: driver.quite();
Browser Navigation commands
navigate().to() – It lands a new page in the current browser window. We can also user get() instead of navigate().to() but best practice is use to navigate().to() in single script for better readability.
Syntax: driver.navigate().to("URL");navigate().back() – It moves a single item back in the browser history.
Syntax: driver.navigate().back();navigate().forward() – It moves a single item forward in the browser history.
Syntax: driver.navigate().forward();navigate().refresh() – Its refresh the current window.
Syntax: driver.navigate().forward();
Command for Web Elements
findElement() – It find first element with the current web using given locator.
Syntax: driver.findElement(By.locator("value");sendKeys() – It send keys on edit box or text box.
Syntax: driver.findElement(By.id("id")).sendKeys("arg");clear() – It clear the value form edit box or text box.
Syntax: driver.findElement(By.id("id")).clear();click() – It clicks an element like button, link, checkbox etc..
Syntax: driver.findElement(By.id("id")).click();
Verification Commands
isDisplayed() – It is applicable on all web elements. It checks weather an element is displaying or not in the current web page and return Boolean result.
Syntax: driver.findElement(By.id("id")).isDisplayed();isEnabled()– It checks weather an element is enabled or not in the current web page and return Boolean result.
Syntax: driver.findElement(By.id("id")).isEnabled();isSelected() – It checks weather an element is selected or not in the current web page and return Boolean result.
Syntax: driver.findElement(By.id("id")).isSelected();