Skip to content

Instantly share code, notes, and snippets.

@timlinquist
Created March 5, 2012 23:38
Show Gist options
  • Save timlinquist/1982097 to your computer and use it in GitHub Desktop.
Save timlinquist/1982097 to your computer and use it in GitHub Desktop.
Custom listener for the selenium webdriver
#Used in the common/driver.rb of selenium-webdriver
L45 def for(browser, opts = {})
.....
class SeleniumListener
attr_reader :file
def initialize
@file = File.new('output.log', 'w+')
end
[:get, :goForward, :goBack, :clickElement, :clearElement, :navigate_to, :find, :click, :change_value_of,
:sendKeysToElement, :execute_script, :find_element_by, :find_elements_by, :executeScript, :quit, :close].each do |method|
define_method("before_#{method}") do |*args|
file.puts "\n\nAbout to call #{method}: #{args}\n\n"
end
define_method("after_#{method}") do |*args|
file.puts "\n\nCompleted call of #{method}\n\n"
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment