123456789_123456789_123456789_123456789_123456789_

Class: Selenium::WebDriver::Support::EventFiringBridge Private

Do not use. This class is for internal use only.
Relationships & Source Files
Inherits: Object
Defined in: rb/lib/selenium/webdriver/support/event_firing_bridge.rb

Class Method Summary

Instance Method Summary

Constructor Details

.new(delegate, listener) ⇒ EventFiringBridge

[ GitHub ]

  
# File 'rb/lib/selenium/webdriver/support/event_firing_bridge.rb', line 28

def initialize(delegate, listener)
  @delegate = delegate

  @listener = if listener.respond_to? :call
                BlockEventListener.new(listener)
              else
                listener
              end
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(meth) (private)

[ GitHub ]

  
# File 'rb/lib/selenium/webdriver/support/event_firing_bridge.rb', line 123

def method_missing(meth, ...) # rubocop:disable Style/MissingRespondToMissing
  @delegate.__send__(meth, ...)
end

Instance Method Details

#clear_element(ref)

[ GitHub ]

  
# File 'rb/lib/selenium/webdriver/support/event_firing_bridge.rb', line 62

def clear_element(ref)
  dispatch(:change_value_of, create_element(ref), driver) do
    @delegate.clear_element(ref)
  end
end

#click_element(ref)

[ GitHub ]

  
# File 'rb/lib/selenium/webdriver/support/event_firing_bridge.rb', line 56

def click_element(ref)
  dispatch(:click, create_element(ref), driver) do
    @delegate.click_element(ref)
  end
end

#close

[ GitHub ]

  
# File 'rb/lib/selenium/webdriver/support/event_firing_bridge.rb', line 100

def close
  dispatch(:close, driver) { @delegate.close }
end

#create_element(ref) (private)

[ GitHub ]

  
# File 'rb/lib/selenium/webdriver/support/event_firing_bridge.rb', line 106

def create_element(ref)
  # hmm. we're not passing self here to not fire events for potential calls made by the listener
  Element.new @delegate, ref
end

#dispatch(name, *args) (private)

[ GitHub ]

  
# File 'rb/lib/selenium/webdriver/support/event_firing_bridge.rb', line 115

def dispatch(name, *args)
  @listener.__send__(:"before_#{name}", *args)
  returned = yield
  @listener.__send__(:"after_#{name}", *args)

  returned
end

#driver (private)

[ GitHub ]

  
# File 'rb/lib/selenium/webdriver/support/event_firing_bridge.rb', line 111

def driver
  @driver ||= Driver.new(bridge: self)
end

#execute_script(script, *args)

[ GitHub ]

  
# File 'rb/lib/selenium/webdriver/support/event_firing_bridge.rb', line 90

def execute_script(script, *args)
  dispatch(:execute_script, script, driver) do
    @delegate.execute_script(script, *args)
  end
end

#find_element_by(how, what, parent = nil)

[ GitHub ]

  
# File 'rb/lib/selenium/webdriver/support/event_firing_bridge.rb', line 74

def find_element_by(how, what, parent = nil)
  e = dispatch(:find, how, what, driver) do
    @delegate.find_element_by how, what, parent
  end

  Element.new self, e.ref.last
end

#find_elements_by(how, what, parent = nil)

[ GitHub ]

  
# File 'rb/lib/selenium/webdriver/support/event_firing_bridge.rb', line 82

def find_elements_by(how, what, parent = nil)
  es = dispatch(:find, how, what, driver) do
    @delegate.find_elements_by(how, what, parent)
  end

  es.map { |e| Element.new self, e.ref.last }
end

#get(url)

[ GitHub ]

  
# File 'rb/lib/selenium/webdriver/support/event_firing_bridge.rb', line 38

def get(url)
  dispatch(:navigate_to, url, driver) do
    @delegate.get(url)
  end
end

#go_back

[ GitHub ]

  
# File 'rb/lib/selenium/webdriver/support/event_firing_bridge.rb', line 50

def go_back
  dispatch(:navigate_back, driver) do
    @delegate.go_back
  end
end

#go_forward

[ GitHub ]

  
# File 'rb/lib/selenium/webdriver/support/event_firing_bridge.rb', line 44

def go_forward
  dispatch(:navigate_forward, driver) do
    @delegate.go_forward
  end
end

#quit

[ GitHub ]

  
# File 'rb/lib/selenium/webdriver/support/event_firing_bridge.rb', line 96

def quit
  dispatch(:quit, driver) { @delegate.quit }
end

#send_keys_to_element(ref, keys)

[ GitHub ]

  
# File 'rb/lib/selenium/webdriver/support/event_firing_bridge.rb', line 68

def send_keys_to_element(ref, keys)
  dispatch(:change_value_of, create_element(ref), driver) do
    @delegate.send_keys_to_element(ref, keys)
  end
end