Selenium WebDriver and WebElement commands in the Java API

Swaroop Nadella
2 min readMay 23, 2024

--

Some Important Selenium WebDriver and WebElement commands in Java API, to get started with the Web browser automation.

These are frequently used in day to day basis, which are must learn and try to deep dive on each of the methods. Refer Official docs, learn from blogs, articles to get better understanding.

— — — — WebDriver

Navigation:
to(String url): Navigate to the specified URL.
to(URL url): Navigate to the specified URL.
back(): Navigate back in the browser history.
forward(): Navigate forward in the browser history.
refresh(): Refresh the current page.

Browser-level Commands:
get(String url): Navigate to the specified URL.
getCurrentUrl(): Get the current URL.
getTitle(): Get the title of the current page.
close(): Close the current window.
quit(): Quit the browser.

Searching for Elements:
findElement(By by): Find the first element matching the specified criteria.
findElements(By by): Find all elements matching the specified criteria.

— — — — WebElement

Element Manipulation:
click(): Click on an element.
submit(): Submit a form.
sendKeys(CharSequence… keysToSend): Send the specified keys to an element.
clear(): Clear the text from a text field.

Element Queries:
isSelected(): Check if an element is selected.
isEnabled(): Check if an element is enabled.
getText(): Get the text of an element.
getTagName(): Get the tag name of an element.
getAttribute(String name): Get the value of the specified attribute of an element.

~~~~~~~~~~~~~~~~~~~

Do hands on practice to better understand these concepts.

Swaroop Nadella
Test Automation Engineer, Tech Educator

Subscribe here, to Get an email whenever I publish article on Medium

Core Java and Coding for Automation Testers — Udemy Course

Swaroop Nadella Academy Store — Quizzes and Courses

--

--