Module: Selenium::WebDriver::SearchContext
- Included in:
- Driver, Element, ShadowRoot
- Defined in:
- rb/lib/selenium/webdriver/common/search_context.rb
Constant Summary collapse
- FINDERS =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
{ class: 'class name', class_name: 'class name', css: 'css selector', id: 'id', link: 'link text', link_text: 'link text', name: 'name', partial_link_text: 'partial link text', relative: 'relative', tag_name: 'tag name', xpath: 'xpath' }.freeze
Class Attribute Summary collapse
-
.extra_finders ⇒ Object
Returns the value of attribute extra_finders.
Class Method Summary collapse
Instance Method Summary collapse
-
#find_element(*args) ⇒ Element
Find the first element matching the given arguments.
-
#find_elements(*args) ⇒ Object
Find all elements matching the given arguments.
Class Attribute Details
.extra_finders ⇒ Object
Returns the value of attribute extra_finders.
39 40 41 |
# File 'rb/lib/selenium/webdriver/common/search_context.rb', line 39 def extra_finders @extra_finders end |
Class Method Details
.finders ⇒ Object
41 42 43 |
# File 'rb/lib/selenium/webdriver/common/search_context.rb', line 41 def finders FINDERS.merge(extra_finders || {}) end |
Instance Method Details
#find_element(how, what) ⇒ Element #find_element(opts) ⇒ Element
Find the first element matching the given arguments
When using Element#find_element with :xpath, be aware that webdriver follows standard conventions: a search prefixed with “//” will search the entire document, not just the children of this current node. Use “.//” to limit your search to the children of the receiving Element.
65 66 67 68 69 70 71 72 |
# File 'rb/lib/selenium/webdriver/common/search_context.rb', line 65 def find_element(*args) how, what = extract_args(args) by = SearchContext.finders[how.to_sym] raise ArgumentError, "cannot find element by #{how.inspect}" unless by bridge.find_element_by by, what, ref end |
#find_elements(*args) ⇒ Object
Find all elements matching the given arguments
80 81 82 83 84 85 86 87 |
# File 'rb/lib/selenium/webdriver/common/search_context.rb', line 80 def find_elements(*args) how, what = extract_args(args) by = SearchContext.finders[how.to_sym] raise ArgumentError, "cannot find elements by #{how.inspect}" unless by bridge.find_elements_by by, what, ref end |