Skip to content

Instantly share code, notes, and snippets.

@fletcherm
Created January 22, 2013 22:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fletcherm/4599303 to your computer and use it in GitHub Desktop.
Save fletcherm/4599303 to your computer and use it in GitHub Desktop.
module MakeFirefoxLaunchInBackground
module_function
def run
webdriver_path = `bundle show selenium-webdriver`.chomp
launcher_path = "#{webdriver_path}/lib/selenium/webdriver/firefox/launcher.rb"
if !File.exist?(launcher_path)
raise "Couldn't find the Firefox launcher file at [#{launcher_path}]."
end
expected_launch_line = '@binary.start_with @profile, @profile_dir, "-foreground"'
new_launch_line = '@binary.start_with @profile, @profile_dir#, "-foreground"'
launcher_content = File.read(launcher_path)
if !launcher_content.match(expected_launch_line)
raise "Didn't see the expected launcher code [#{expected_launch_line}]"
end
new_launcher_content = launcher_content.gsub(expected_launch_line, new_launch_line)
File.open(launcher_path, 'w') do |f|
f.print new_launcher_content
end
puts 'done hacking selenium-webdriver Firefox launcher file'
end
end
MakeFirefoxLaunchInBackground.run
@exupero
Copy link

exupero commented Feb 4, 2013

Why the module boilerplate? Why not make the body of run be the entire script?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment