Method: Selenium::WebDriver::Remote::Bridge#find_element_by

Defined in:
lib/selenium/webdriver/remote/bridge.rb

#find_element_by(how, what, parent_ref = []) ⇒ Object


481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
# File 'lib/selenium/webdriver/remote/bridge.rb', line 481

def find_element_by(how, what, parent_ref = [])
  how, what = @locator_converter.convert(how, what)

  return execute_atom(:findElements, Support::RelativeLocator.new(what).as_json).first if how == 'relative'

  parent_type, parent_id = parent_ref
  id = case parent_type
       when :element
         execute :find_child_element, {id: parent_id}, {using: how, value: what.to_s}
       when :shadow_root
         execute :find_shadow_child_element, {id: parent_id}, {using: how, value: what.to_s}
       else
         execute :find_element, {}, {using: how, value: what.to_s}
       end

  Bridge.element_class.new self, element_id_from(id)
end