Selenium Webdriver Commands
Selenium Webdriver Commands
1. Browser Commands
2. Navigation Commands
3. Element Interaction Commands
4. Wait Commands
5. Alert Commands
6. Window Handling Commands
7. Frame Handling Commands
8. Action Commands
9. Cookie Commands
10. Screenshot Commands
11. Dropdown Handling Commands
12. Keyboard Events Commands
13. Mouse Events Commands
14. Multiple Window Handling Commands
15. Logging Commands
Here are the most important and frequently used Browser Commands in
Selenium:
Here are the most important and frequently used Action Commands in Selenium:
Here are the most important and frequently used Cookie Commands in Selenium:
Here are the most important and frequently used Screenshot Commands in
Selenium:
Here are the most important and frequently used Dropdown Handling Commands
in Selenium:
Here are the most important and frequently used Keyboard Events Commands in
Selenium:
Here are the most important and frequently used Mouse Events Commands in
Selenium:
Here are the most important and frequently used Multiple Window Handling
Commands in Selenium:
Here are the most important and frequently used Logging Commands in
Selenium:
Here are the most important and frequently used Navigation Commands in
Selenium:
Here are the most important and frequently used Element Interaction Commands
in Selenium:
findElement(By locator) – Finds the first web element matching the given locator.
findElements(By locator) – Finds all web elements matching the given locator.
click() – Clicks on the web element.
sendKeys(CharSequence... keysToSend) – Sends the specified keys to the web
element.
clear() – Clears the text from the web element.
getText() – Retrieves the visible text of the web element.
getAttribute(String name) – Retrieves the value of the specified attribute of the web
element.
isDisplayed() – Checks if the web element is visible on the page.
isEnabled() – Checks if the web element is enabled.
isSelected() – Checks if the web element is selected
(useful for checkboxes and radio buttons).
submit() – Submits the form associated with the web element.
getCssValue(String propertyName) – Retrieves the value of the specified CSS
property of the web element.
Here are the most important and frequently used Wait Commands in Selenium:
implicitlyWait(long time, TimeUnit unit) – Sets the default wait time for finding
elements.
WebDriverWait(driver, Duration duration) – Creates an explicit wait instance for the
specified duration.
until(ExpectedCondition<T> condition) – Waits until the specified condition is met.
setScriptTimeout(long time, TimeUnit unit) – Sets the maximum time to wait for an
asynchronous script to finish executing.
setPageLoadTimeout(long time, TimeUnit unit) – Sets the maximum time to wait for
a page to load completely.
fluentWait(By locator, long timeout, long pollingTime) – Waits for a specified
condition while ignoring specific exceptions during the polling interval.
Here are the most important and frequently used Alert Commands in Selenium:
Here are the most important and frequently used Window Handling Commands in
Selenium:
Here are the most important and frequently used Frame Handling Commands in
Selenium:
switchTo().frame(int index) – Switches the focus to the frame at the specified index.
switchTo().frame(String nameOrId) – Switches the focus to the frame using its name
or ID.
switchTo().frame(WebElement frameElement) – Switches the focus to the specified
frame element.
switchTo().defaultContent() – Switches the focus back to the main document from a
frame.
switchTo().parentFrame() – Switches the focus to the parent frame of the current
frame.
Here are the most important and frequently used Session Handling Commands in
Selenium:
Here are the most important and frequently used JavaScript Execution Commands
in Selenium:
Here are the most important and frequently used Drag and Drop Commands in
Selenium:
Here are the most important and frequently used File Upload Commands in
Selenium:
Here are the most important and frequently used File Download Commands in
Selenium:
For Chrome:
ChromeOptions options = new ChromeOptions();
options.addArguments("download.default_directory", "/path/to/download");
> Sets the default directory for file downloads in Chrome.
For Firefox:
FirefoxProfile profile = new FirefoxProfile();
profile.setPreference("browser.download.dir", "/path/to/download"); >
Configures the download directory for Firefox.
For more complex scenarios, you may need to integrate third-party libraries to
handle file downloads.
Here are the most important and frequently used Popup Handling Commands in
Selenium:
Here are the most important and frequently used Browser Tab Handling
Commands in Selenium:
Here are the most important and frequently used Implicit Wait Commands in
Selenium:
Here are the most important and frequently used Explicit Wait Commands in
Selenium:
Here are the most important and frequently used Fluent Wait Commands in
Selenium:
Here are the most important and frequently used Context Menu Commands in
Selenium:
Here are the most important and frequently used Web Element Property
Commands in Selenium:
String text = element.getText(); > Retrieves the visible text of the web element.
String attribute = element.getAttribute("value"); > Retrieves the value of a
specific attribute of the web element.
boolean isDisplayed = element.isDisplayed(); > Checks whether the element is
visible.
boolean isEnabled = element.isEnabled(); > Checks whether the element is
enabled for interaction.
boolean isSelected = element.isSelected(); > Checks whether the element (like a
checkbox) is selected.
Here are the most important and frequently used Navigation Bar Handling
Commands in Selenium:
Here are the most important and frequently used JavaScript Alerts Handling
Commands in Selenium:
Here are the most important and frequently used Page Source Commands in
Selenium: