Module: Async::WebDriver::Scope::Elements

Included in:
Element, Async::WebDriver::Session
Defined in:
lib/async/webdriver/scope/elements.rb

Overview

Helpers for finding elements.

Instance Method Summary collapse

Instance Method Details

#childrenObject

Find all children of the current element.



105
106
107
# File 'lib/async/webdriver/scope/elements.rb', line 105

def children
  find_elements_by_xpath("./child::*")
end

#find_element(locator) ⇒ Object

Find an element using the given locator. If no element is found, an exception is raised.



17
18
19
# File 'lib/async/webdriver/scope/elements.rb', line 17

def find_element(locator)
  current_scope.post("element", locator)
end

#find_element_by_css(css) ⇒ Object

Find an element using the given CSS selector.



25
26
27
# File 'lib/async/webdriver/scope/elements.rb', line 25

def find_element_by_css(css)
  find_element({using: "css selector", value: css})
end

Find an element using the given link text.



33
34
35
# File 'lib/async/webdriver/scope/elements.rb', line 33

def find_element_by_link_text(text)
  find_element({using: "link text", value: text})
end

Find an element using the given partial link text.



41
42
43
# File 'lib/async/webdriver/scope/elements.rb', line 41

def find_element_by_partial_link_text(text)
  find_element({using: "partial link text", value: text})
end

#find_element_by_tag_name(name) ⇒ Object

Find an element using the given tag name.



49
50
51
# File 'lib/async/webdriver/scope/elements.rb', line 49

def find_element_by_tag_name(name)
  find_element({using: "tag name", value: name})
end

#find_element_by_xpath(xpath) ⇒ Object

Find an element using the given XPath expression.



57
58
59
# File 'lib/async/webdriver/scope/elements.rb', line 57

def find_element_by_xpath(xpath)
  find_element({using: "xpath", value: xpath})
end

#find_elements(locator) ⇒ Object

Find all elements using the given locator. If no elements are found, an empty array is returned.



64
65
66
# File 'lib/async/webdriver/scope/elements.rb', line 64

def find_elements(locator)
  current_scope.post("elements", locator)
end

#find_elements_by_css(css) ⇒ Object

Find all elements using the given CSS selector.



71
72
73
# File 'lib/async/webdriver/scope/elements.rb', line 71

def find_elements_by_css(css)
  find_elements({using: "css selector", value: css})
end

Find all elements using the given link text.



78
79
80
# File 'lib/async/webdriver/scope/elements.rb', line 78

def find_elements_by_link_text(text)
  find_elements({using: "link text", value: text})
end

Find all elements using the given partial link text.



85
86
87
# File 'lib/async/webdriver/scope/elements.rb', line 85

def find_elements_by_partial_link_text(text)
  find_elements({using: "partial link text", value: text})
end

#find_elements_by_tag_name(name) ⇒ Object

Find all elements using the given tag name.



92
93
94
# File 'lib/async/webdriver/scope/elements.rb', line 92

def find_elements_by_tag_name(name)
  find_elements({using: "tag name", value: name})
end

#find_elements_by_xpath(xpath) ⇒ Object

Find all elements using the given XPath expression.



99
100
101
# File 'lib/async/webdriver/scope/elements.rb', line 99

def find_elements_by_xpath(xpath)
  find_elements({using: "xpath", value: xpath})
end