WebDriver.Element

This module handles WebDriver calls directed at specific DOM elements.

They all take an WebDriver.Element struct as the first argument. The WebDriver.Element struct is supposed to be an opaque data type and is not meant to be manipulated. It contains the internal id of the element used by the webdriver client and a the session name.

Elements are associated with a particular session and have no meaning outside that WedDriver session.

Accessing an element that does not exist on the page will return a response of { :stale_element_reference, response }

All the command functions will return {:ok, response} or {error, response} where error is one of those listed in WebDriver.Error.

Source

Summary

attribute(element, attribute_name)

Returns the value of the given element’s attribute

clear(element)

Clears the specified form field or textarea element

click(element)

Click on the specified element

css(element, property_name)

Get the computed value of an element’s CSS property. https://code.google.com/p/selenium/wiki/JsonWireProtocol#/session/:sessionId/element/:id/css/:propertyName

displayed?(element)

Returns a boolean denoting if the element is currently visible

enabled?(element)

Returns a boolean denoting if the element is enabled or not

equals?(element, other_element)

Determine if two element ids refer to the same DOM element

location(element)

Returns the current location of the specified element in pixels from the top left corner

location_in_view(element)

Determine an element’s location once it has been scrolled into view

name(element)

Get the name of the specified element

selected?(element)

Returns a boolean denoting if the element is selected or not. Returns {:element_not_selectable, response} if it is not able to be selected

size(element)

Returns size in pixels of the specified element

submit(element)

Submit a FORM element. May be applied to any descendent of a FORM element

text(element)

Retreives the visible text of the element. Returns a string

value(element, value)

Send a list of keystrokes to the specified element

Functions

attribute(element, attribute_name)
Source
clear(element)
Source
css(element, property_name)

Get the computed value of an element’s CSS property. https://code.google.com/p/selenium/wiki/JsonWireProtocol#/session/:sessionId/element/:id/css/:propertyName

Returns a string.

Source
displayed?(element)

Returns a boolean denoting if the element is currently visible.

https://code.google.com/p/selenium/wiki/JsonWireProtocol#/session/:sessionId/element/:id/displayed

Source
enabled?(element)
Source
equals?(element, other_element)
Source
location(element)

Returns the current location of the specified element in pixels from the top left corner.

https://code.google.com/p/selenium/wiki/JsonWireProtocol#/session/:sessionId/element/:id/location

Returns %{x: x, y: y}

Source
location_in_view(element)

Determine an element’s location once it has been scrolled into view.

https://code.google.com/p/selenium/wiki/JsonWireProtocol#/session/:sessionId/element/:id/location_in_view

Returns %{x: x, y: y}

Source
name(element)
Source
selected?(element)

Returns a boolean denoting if the element is selected or not. Returns {:element_not_selectable, response} if it is not able to be selected.

https://code.google.com/p/selenium/wiki/JsonWireProtocol#/session/:sessionId/element/:id/selected

Source
size(element)

Returns size in pixels of the specified element.

https://code.google.com/p/selenium/wiki/JsonWireProtocol#/session/:sessionId/element/:id/size

Returns %{width: w, height: h}

Source
submit(element)

Submit a FORM element. May be applied to any descendent of a FORM element.

https://code.google.com/p/selenium/wiki/JsonWireProtocol#/session/:sessionId/element/:id/submit

Source
text(element)

Retreives the visible text of the element. Returns a string.

https://code.google.com/p/selenium/wiki/JsonWireProtocol#/session/:sessionId/element/:id/text

Source
value(element, value)

Send a list of keystrokes to the specified element.

https://code.google.com/p/selenium/wiki/JsonWireProtocol#POST_/session/:sessionId/element/:id/value

Parameters: %{value: String}

Source