module Elements
Helpers for finding elements.
Definitions
def find_element(locator)
Find an element using the given locator. If no element is found, an exception is raised.
Signature
-
parameter
locator
Locator
The locator to use.
-
returns
Element
The element.
-
raises
NoSuchElementError
If the element does not exist.
Implementation
def find_element(locator)
current_scope.post("element", locator)
end
def find_element_by_css(css)
Find an element using the given CSS selector.
Signature
-
parameter
css
String
The CSS selector to use.
-
returns
Element
The element.
-
raises
NoSuchElementError
If the element does not exist.
Implementation
def find_element_by_css(css)
find_element({using: "css selector", value: css})
end
def find_element_by_link_text(text)
Find an element using the given link text.
Signature
-
parameter
text
String
The link text to use.
-
returns
Element
The element.
-
raises
NoSuchElementError
If the element does not exist.
Implementation
def find_element_by_link_text(text)
find_element({using: "link text", value: text})
end
def find_element_by_partial_link_text(text)
Find an element using the given partial link text.
Signature
-
parameter
text
String
The partial link text to use.
-
returns
Element
The element.
-
raises
NoSuchElementError
If the element does not exist.
Implementation
def find_element_by_partial_link_text(text)
find_element({using: "partial link text", value: text})
end
def find_element_by_tag_name(name)
Find an element using the given tag name.
Signature
-
parameter
name
String
The tag name to use.
-
returns
Element
The element.
-
raises
NoSuchElementError
If the element does not exist.
Implementation
def find_element_by_tag_name(name)
find_element({using: "tag name", value: name})
end
def find_element_by_xpath(xpath)
Find an element using the given XPath expression.
Signature
-
parameter
xpath
String
The XPath expression to use.
-
returns
Element
The element.
-
raises
NoSuchElementError
If the element does not exist.
Implementation
def find_element_by_xpath(xpath)
find_element({using: "xpath", value: xpath})
end
def find_elements(locator)
Find all elements using the given locator. If no elements are found, an empty array is returned.
Signature
-
parameter
locator
Locator
The locator to use.
-
returns
Array(Element)
The elements.
Implementation
def find_elements(locator)
current_scope.post("elements", locator)
end
def find_elements_by_css(css)
Find all elements using the given CSS selector.
Signature
-
parameter
css
String
The CSS selector to use.
-
returns
Array(Element)
The elements.
Implementation
def find_elements_by_css(css)
find_elements({using: "css selector", value: css})
end
def find_elements_by_link_text(text)
Find all elements using the given link text.
Signature
-
parameter
text
String
The link text to use.
-
returns
Array(Element)
The elements.
Implementation
def find_elements_by_link_text(text)
find_elements({using: "link text", value: text})
end
def find_elements_by_partial_link_text(text)
Find all elements using the given partial link text.
Signature
-
parameter
text
String
The partial link text to use.
-
returns
Array(Element)
The elements.
Implementation
def find_elements_by_partial_link_text(text)
find_elements({using: "partial link text", value: text})
end
def find_elements_by_tag_name(name)
Find all elements using the given tag name.
Signature
-
parameter
name
String
The tag name to use.
-
returns
Array(Element)
The elements.
Implementation
def find_elements_by_tag_name(name)
find_elements({using: "tag name", value: name})
end
def find_elements_by_xpath(xpath)
Find all elements using the given XPath expression.
Signature
-
parameter
xpath
String
The XPath expression to use.
-
returns
Array(Element)
The elements.
Implementation
def find_elements_by_xpath(xpath)
find_elements({using: "xpath", value: xpath})
end
def children
Find all children of the current element.
Signature
-
returns
Array(Element)
The children of the current element.
Implementation
def children
find_elements_by_xpath("./child::*")
end