Selenium WebDriver Basics (Java)

Selenium WebDriver Basics (Java)

This article will show you some basic information for getting started with Selenium WebDriver. It will be assumed that you have completed the set-up process for the selenium server and the WebDriver.

Navigating to a Webpage - To navigate to a specific URL you need to use driver.get(URL); Where driver is the instance of the WebDriver you have instantiated and URL is your chosen URL surrounded with quote marks.

Finding elements on the page - To locate an element use the line driver.findElement(locator); where locator is the element locator for your specific element (The class used for locators is "By").

Locators are commands that tell the WebDriver where to find elements on the page. The two most popular types of locators are CSS selectors and XPath expressions. The choice between the two is usually down to preference but in general CSS locators are slightly easier to learn whereas XPath locators are slightly more versatile.

Interacting with elements - Once you have used the driver to capture an element from a page, you can interact with it in multiple ways. This can range from clicking on the element with element.click(); to checking if an input is disabled with element.isEnabled();

This should be enough information to get started with writing automated tests using Selenium with Java.

Leave a reply

Your email address will not be published. Required fields are marked*

CAPTCHA
This question is for testing whether or not you are a human visitor and to prevent automated spam submissions.