support local browsers

This commit is contained in:
John Bintz 2012-02-28 11:52:25 -05:00
parent 4d048cb148
commit 8f14e1643a
2 changed files with 37 additions and 11 deletions

View File

@ -1,6 +1,6 @@
# Hollandaise sauce is a delicious delicacy. # Hollandaise sauce is a delicious delicacy.
TODO: Easily take a bunch of screenshots using Sauce Labs TODO: Easily take a bunch of screenshots using Sauce Labs or with your local browsers
FIXME: The method for instantiating Sauce Labs Selenium WebDriver browsers FIXME: The method for instantiating Sauce Labs Selenium WebDriver browsers
TODO: Run all the screenshot taking in parallel for SPEEDS TODO: Run all the screenshot taking in parallel for SPEEDS
BUG: Find them and destroy them! BUG: Find them and destroy them!
@ -17,6 +17,13 @@ BUG: Find them and destroy them!
Currently have three browsers available: Currently have three browsers available:
Locally, using Selenium:
* `firefox`
* `chrome`
On Sauce labs:
* `ie7` * `ie7`
* `ie8` * `ie8`
* `ie9` * `ie9`

View File

@ -21,23 +21,31 @@ module Hollandaise
end end
def ie7 def ie7
[ 'iexplore', '7', 'Windows 2003' ] [ :sauce, 'iexplore', '7', 'Windows 2003' ]
end end
def ie8 def ie8
[ 'iexplore', '8', 'Windows 2003' ] [ :sauce, 'iexplore', '8', 'Windows 2003' ]
end end
def ie9 def ie9
[ 'iexplore', '9', 'Windows 2008' ] [ :sauce, 'iexplore', '9', 'Windows 2008' ]
end end
def ffwin10 def ffwin10
[ 'firefox', '10', 'Windows 2008' ] [ :sauce, 'firefox', '10', 'Windows 2008' ]
end end
def chromewin def chromewin
[ 'chrome', '', 'Windows 2008' ] [ :sauce, 'chrome', '', 'Windows 2008' ]
end
def firefox
[ :selenium, :firefox ]
end
def chrome
[ :selenium, :chrome ]
end end
end end
end end
@ -66,7 +74,7 @@ class Hollandaise::CLI < Thor
Hollandaise::Browsers.for(browsers).each do |browser| Hollandaise::Browsers.for(browsers).each do |browser|
info = { :browser_url => url, :job_name => "#{url}" } info = { :browser_url => url, :job_name => "#{url}" }
[ :browser, :browser_version, :os ].each_with_index { |key, index| info[key] = browser[index] } [ :type, :browser, :browser_version, :os ].each_with_index { |key, index| info[key] = browser[index] }
thread = Thread.new do thread = Thread.new do
selenium = nil selenium = nil
@ -79,9 +87,15 @@ class Hollandaise::CLI < Thor
mutex.synchronize { puts "#{target}..." } mutex.synchronize { puts "#{target}..." }
selenium = case Thread.current[:browser].first
when :sauce
require 'sauce/selenium' require 'sauce/selenium'
selenium = Sauce::Selenium2.new(Thread.current[:info]) Sauce::Selenium2.new(Thread.current[:info])
when :selenium
Selenium::WebDriver.for Thread.current[:browser].last
end
selenium.navigate.to url selenium.navigate.to url
sleep options[:delay].to_i sleep options[:delay].to_i
selenium.execute_script %{window.resizeTo(1280, 1024)} selenium.execute_script %{window.resizeTo(1280, 1024)}
@ -89,7 +103,7 @@ class Hollandaise::CLI < Thor
mutex.synchronize { puts "#{target} done!" } mutex.synchronize { puts "#{target} done!" }
ensure ensure
selenium.stop if selenium selenium.quit if selenium
end end
end end
@ -135,7 +149,12 @@ class Hollandaise::CLI < Thor
end end
def screenshot_target_for(browser) def screenshot_target_for(browser)
File.join(dir, browser[2], "#{browser[0]} #{browser[1]}.png") case browser.first
when :sauce
File.join(dir, browser[3], "#{browser[1]} #{browser[2]}.png")
when :selenium
File.join(dir, "#{browser[1]}.png")
end
end end
end end
end end