Browser Automation Atoms

Shared JavaScript building blocks used across Selenium driver implementations.

This documentation previously located on the wiki

Browser Automation Atoms are building blocks intended to be used by Selenium implementations. By using the same pieces throughout the codebase, rather than reimplementing required functionality in multiple places, the project can reduce the number of bugs found, and can simplify the process of adding new functionality and drivers.

Using Atoms

There are two ways to make use of the automation atoms.

  1. Using Google Closure
  2. As compiled fragments

The first of these approaches is useful when constructing a monolithic application, such as Selenium Core. The second approach is used in those drivers that are implemented natively and wish to use the atoms to interrogate the DOM (such as the InternetExplorerDriver).

Testing Atoms

If you’re developing the Atoms, then the easiest way to test them is:

# Start the server
./go debug-server &

Now point a browser at http://localhost:2310/javascript/atoms/test and select the test you’d like to run. As you edit the atoms, so long as you don’t change the “goog.require” or “goog.provides” statements then you can just refresh the page to see the tests run with your changes. If you do change either of those settings, kill the server and then run

./go calcdeps
./go debug-server &

Atoms Summary

Each of the atoms listed here is exposed via the list method name, which delegates directly through to the implementation method. For information about the order in which arguments are to be passed, and for additional documentation, view the jsdoc of the implementation method.

Method NameDescriptionImplementation Method
clear
click
executeScript
findElementFind the first matching element in the DOMbot.locators.findElement
findElementsFind all matching elements in the DOMbot.locators.findElements
fireFire a specific, synthesized eventbot.events.fire
getAttributeGet the value of an attribute or property of an elementbot.dom.getAttribute
getLocationGet the absolute location of an element in the DOMbot.dom.getLocation
getSizeGet the size of an elementbot.dom.getSize
isDisplayed
isEnabled
isSelectedWould a user consider this element selected?bot.dom.isSelected
setSelected
submit
toggle
type

The canonical list of atoms that are implemented for the webdriver APIs are located in this build file. The names of the fragment rules relate to the names of the methods.