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-complaint driver, including Chrome, Safari, Internet Explorer, Microsoft Edge, and Firefox.
What browsers can be tested with Selenium WebDriver?
HTMLUnit Headless Browser
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.
What is the difference between Selenium WebDriver, Selenium IDE
and Selenium RC?
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.
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.
How to get started with Selenium WebDriver
Selenium WebDriver is built into the Ranorex