Created
January 22, 2013 22:34
-
-
Save fletcherm/4599303 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Why the module boilerplate? Why not make the body of
run
be the entire script?