module Selenium

Defines an object that runs Selenium commands.

Element Locators

Element Locators tell Selenium which HTML element a command refers to. The format of a locator is: locatorType=argument We support the following strategies for locating elements:

Select the element with the specified @id attribute. If no match is found, select the first element whose @name attribute is id. (This is normally the default; see below.)

Select the element with the specified @id attribute.

Select the first element with the specified @name attribute.

The name may optionally be followed by one or more element-filters, separated from the name by whitespace. If the filterType is not specified, value is assumed.

Find an element by evaluating the specified string. This allows you to traverse the HTML Document Object Model using JavaScript. Note that you must not return a value in this string; simply make it the last expression in the block.

Locate an element using an XPath expression.

Select the link (anchor) element which contains text matching the specified pattern.

Select the element using css selectors. Please refer to CSS2 selectors, CSS3 selectors for more information. You can also check the TestCssLocators test in the selenium test suite for an example of usage, which is included in the downloaded selenium core package.

Currently the css selector locator supports all css1, css2 and css3 selectors except namespace in css3, some pseudo classes(:nth-of-type, :nth-last-of-type, :first-of-type, :last-of-type, :only-of-type, :visited, :hover, :active, :focus, :indeterminate) and pseudo elements(::first-line, ::first-letter, ::selection, ::before, ::after).

Locate an element by resolving the UI specifier string to another locator, and evaluating it. See the Selenium UI-Element Reference for more details.

Without an explicit locator prefix, Selenium uses the following default strategies:

Element FiltersElement filters can be used with a locator to refine a list of candidate elements. They are currently used only in the 'name' element-locator.

Filters look much like locators, ie. filterType=argumentSupported element-filters are: value=valuePattern

Matches elements based on their values. This is particularly useful for refining a list of similarly-named toggle-buttons.index=index

Selects a single element based on its position in the list (offset from zero).===String-match Patterns Various Pattern syntaxes are available for matching string values:

Match a string against a “glob” (aka “wildmat”) pattern. “Glob” is a kind of limited regular-expression syntax typically used in command-line shells. In a glob pattern, “*” represents any sequence of characters, and “?” represents any single character. Glob patterns match against the entire string.

Match a string using a regular-expression. The full power of JavaScript regular-expressions is available.

Match a string using a case-insensitive regular-expression.

Match a string exactly, verbatim, without any of that fancy wildcard stuff.

If no pattern prefix is specified, Selenium assumes that it's a “glob” pattern.

For commands that return multiple values (such as verifySelectOptions), the string being matched is a comma-separated list of the return values, where both commas and backslashes in the values are backslash-escaped. When providing a pattern, the optional matching syntax (i.e. glob, regexp, etc.) is specified once, as usual, at the beginning of the pattern.

Defines a mixin module that you can use to write Selenium tests without typing “@selenium.” in front of every command. Every call to a missing method will be automatically sent to the @selenium object.

Constants

DEPRECATED_CONSTANTS

Public Class Methods

const_missing(name) click to toggle source
Calls superclass method
# File lib/selenium/client.rb, line 28
def self.const_missing(name)
  if replacement = DEPRECATED_CONSTANTS[name.to_sym]
    warn "the Selenium::#{name} constant has been deprecated, please use #{replacement} instead"
    replacement
  else
    super
  end
end