Module: Selenium::WebDriver::Find
- Included in:
- Driver, Element, Remote::Bridge
- Defined in:
- lib/selenium/webdriver/common/find.rb
Constant Summary collapse
- FINDERS =
{ :class => 'ClassName', :class_name => 'ClassName', :css => 'CssSelector', :id => 'Id', :link => 'LinkText', :link_text => 'LinkText', :name => 'Name', :partial_link_text => 'PartialLinkText', :tag_name => 'TagName', :xpath => 'Xpath', }
Instance Method Summary collapse
-
#find_element(*args) ⇒ WebDriver::Element
Find the first element matching the given arguments.
-
#find_elements(*args) ⇒ Array<WebDriver::Element>
Find all elements matching the given arguments.
Instance Method Details
#find_element(*args) ⇒ WebDriver::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.
34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/selenium/webdriver/common/find.rb', line 34 def find_element(*args) how, what = extract_args(args) unless by = FINDERS[how.to_sym] raise ArgumentError, "cannot find element by #{how.inspect}" end meth = "findElementBy#{by}" what = what.to_s bridge.send meth, ref, what end |
#find_elements(*args) ⇒ Array<WebDriver::Element>
Find all elements matching the given arguments
57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/selenium/webdriver/common/find.rb', line 57 def find_elements(*args) how, what = extract_args(args) unless by = FINDERS[how.to_sym] raise ArgumentError, "cannot find elements by #{how.inspect}" end meth = "findElementsBy#{by}" what = what.to_s bridge.send meth, ref, what end |