Selenium WebDriver Guide
Welcome to this introduction to Selenium WebDriver. After reading this guide, you will understand what Selenium Webdriver is, how it works, and how to use WebDriver to automate web testing. You will also understand how Ranorex integrates with Selenium WebDriver to provide the full functionality of Ranorex Studio in combination with the power of Selenium WebDriver and Selenium Grids. Before reading this guide, it will be helpful to have a basic understanding of web application testing.
What is Selenium WebDriver?
Selenium WebDriver is a free, open-source framework that provides a common application programming interface (API) for browser automation. Ideally, modern web browsers should all render a web application in the same way. However, each browser has its own rendering engine and handles HTML a little differently, which is why testing is needed to ensure that an application performs consistently across browsers and devices. The same browser compatibility issues that affect web applications could also affect automated web tests. But automated tests that use the Selenium client API can run against any browser with a WebDriver-compliant driver, including Chrome, Safari, Internet Explorer, Microsoft Edge, and Firefox.
The Selenium WebDriver workflow
Looking deeper: For a programming language to work with Selenium, it must include a library that understands either the current Selenium JSON Wire Protocol or the emerging W3C WebDriver protocol. Information about the W3C WebDriver protocol candidate recommendation can be found on GitHub.
What browsers can be tested with Selenium WebDriver?
Selenium WebDriver can automate tests for all popular browsers. Each browser requires its own specific driver to communicate with Selenium tests, as described below. Additional information and download links for the individual browser drivers are available on the SeleniumHQ download page.
Safari 10 provides native support for the WebDriver API, so there is no need to download a driver from the SeleniumHQ website. The Safari Driver can be launched directly from the /
Unlike Safari, running automated tests on the Google Chrome browser requires a separate executable, the ChromeDriver. This executable is maintained by the Chromium team with assistance from Selenium WebDriver
HTMLUnit Headless Browser
The HTMLUnit Headless Browser allows automated web tests to execute without loading a graphical user interface, which can significantly accelerate testing.
Although Microsoft introduced the Edge browser some time ago, many Windows users are still using Internet Explorer, or have switched to another browser, such as Chrome. The Selenium project provides the InternetExplorerDriver.
Testing Firefox browser versions 47.0.1 and above requires the Mozilla GeckoDriver. “Gecko” is the name of the web browser rendering engine used in FireFox as well as other Mozilla applications, such as the Thunderbird email client.
How does Selenium WebDriver work?
Selenium WebDriver consists of a language-specific client, a remote server, and browser-specific drivers. The Selenium WebDriver client API submits a request to the remote server, which forwards it to a browser-specific driver, such as the Chrome Driver or the Safari Driver. The browser driver launches the browser to perform the action, and then returns a response to the client. A list of WebDriver commands can be found on the Mozilla developer site.
To perform an action such as entering data in a field or clicking a button, a client request must find the particular GUI element that is the target of the action. Selenium can use several ways to locate an element, including attributes such as the element ID, name, XPath, link text, or CSS selector. The best locator to use is one that is stable and unique to the web element. While the element’s ID often meets these requirements, be aware that some web elements have dynamic IDs that change each time the page loads. Elements with dynamic IDs require a different locator strategy, such as CSS selector or XPath.
Generating unique and stable locators can be difficult and time-consuming. Ranorex provides a free extension for the Chrome DevTools, Selocity, that automates that process of generating locators. With this browser extension, you can explore the document object model (DOM) of a web page and generate selectors in the DevTools sidebar panel. Selocity applies best practices such as depending on the HTML structure of the page as little as possible, such as preferring data-oriented elements and attributes over layout-oriented ones, and ignoring dynamic IDs.
Web tests can use CSS Selectors to locate UI elements
What is the difference between Selenium WebDriver, Selenium IDE
and Selenium RC?
Selenium IDE is an integrated development environment for automating web tests that includes a record-and-replay tool. It was developed as an add-on for the Firefox browser. Scripts are recorded in the Selenium-specific scripting language Selenese, which has commands for actions such as clicking a link and fetching data from web pages. Because of changes in the FireFox browser, the Selenium IDE no longer works as of Firefox release 55.
Selenium RC is an older version of the Selenium
The Selenium RC project was merged with the separate WebDriver project to create Selenium WebDriver, also known as Selenium 2.0. The latest version, Selenium 3.0, was released in October 2016. This release replaced the original Selenium Core with one based on the
What is a Selenium Grid?
A Selenium grid is a network of devices that
The hub controls the distributed testing process. Each node registers with the hub to identify the specific versions of browsers available on the hub. An automated test must pass a JSON object containing the desired capabilities for the test, such as the OS and browser version, to the remote browser-specific driver. This allows the hub to route the test to a matching node. If there are no matching nodes for the specified capabilities, the test will not run.
Distributed testing with a Selenium Grid
There are several approaches to building a Selenium Grid:
- Build a custom Selenium Grid in-house using one or more physical or virtual servers, each configured with the required operating systems and browsers
- Implement a cloud-hosted solution grid solution such as the ones available from SauceLabs or Browserstack
- Implement a proprietary in-house solution such as Selenium Box from Element34 Solutions
Why use Selenium WebDriver for web testing?
- Selenium Webdriver is free and open-source
- The Selenium project is promoted by leaders in the web development and software testing industries
- It will support the emerging W3C WebDriver standard
- It offers the ability to run tests in parallel using Selenium Grids
- Selenium Webdriver is complex to install and configure
- Building automated tests requires advanced programming knowledge, especially since there is no capture-and-replay functionality
- The Selenium IDE no longer works in Firefox version 55 and later, due to changes in the Firefox browser.
isno built-in test results reporting functionality
Why use Ranorex Studio with Selenium WebDriver?
Selenium WebDriver is part of the Ranorex core
There are many benefits to using Selenium WebDriver from within Ranorex Studio. Ranorex uses the standard WebDriver Wire Protocol to communicate with browser instances via their specific drivers. While the Selenium API sends JSON data over the WebDriver to execute actions on an endpoint, Ranorex uses proprietary automation technology and the RanoreXPath for fast and reliable performance. Ranorex Spy makes it easier to uniquely identify web application elements, which can be stored in the Ranorex Repository and shared with other testers. Ranorex Studio also includes built-in reporting.
Automated testing on multiple Selenium WebDriver endpoints from Ranorex Studio
How to get started with Selenium WebDriver
Selenium WebDriver is built into the Ranorex
To learn more about Ranorex Studio’s deep integration with Selenium WebDriver, watch one of our webinars live or on-demand, or download a free 30-day trial of the full version of Ranorex Studio.