Created
February 12, 2013 20:22
-
-
Save seabre/4773033 to your computer and use it in GitHub Desktop.
Automated, multibrowser 'click through' test to be used with sauce labs.
This file contains 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
require 'rubygems' | |
require 'selenium-webdriver' | |
project = "Some Project" | |
browsers = { | |
"Firefox 18 (Windows)" => {:browser => Selenium::WebDriver::Remote::Capabilities.firefox, :platform => 'Windows 2008', :version => '18'}, | |
"Firefox 6 (Windows)" => {:browser => Selenium::WebDriver::Remote::Capabilities.firefox, :platform => 'Windows 2003', :version => '6'}, | |
"Safari 6 (OS X)" => {:browser => Selenium::WebDriver::Remote::Capabilities.safari, :platform => 'Mac 10.8', :version => '6'}, | |
"Safari 5 (OS X)" => {:browser => Selenium::WebDriver::Remote::Capabilities.safari, :platform => 'Mac 10.6', :version => '5'}, | |
"Android" => {:browser => Selenium::WebDriver::Remote::Capabilities.android, :platform => 'Linux', :version => '4'}, | |
"IE 10 (Windows)" => {:browser => Selenium::WebDriver::Remote::Capabilities.internet_explorer, :platform => 'Windows 2012', :version => '10'}, | |
"IE 9 (Windows)" => {:browser => Selenium::WebDriver::Remote::Capabilities.internet_explorer, :platform => 'Windows 2008', :version => '9'}, | |
"IE 8 (Windows)" => {:browser => Selenium::WebDriver::Remote::Capabilities.internet_explorer, :platform => 'Windows 2003', :version => '8'}, | |
} | |
browsers.each_pair do |k, v| | |
caps = v[:browser] | |
caps.version = v[:version] | |
caps.platform = v[:platform] | |
caps[:name] = "#{project} - #{k}" | |
wd = Selenium::WebDriver.for( | |
:remote, | |
# Selenium host url. Get from sauce labs. | |
:url => "", | |
:desired_capabilities => caps) | |
#List of URLs | |
urls = [ | |
"http://www.google.com/" | |
] | |
urls.each do |u| | |
wd.get u | |
# Closure compiled cross-browser innerHeight function: https://gist.github.com/seabre/4753158 | |
screen_height = wd.execute_script("return (function(){if(void 0!=window.innerWidth)return[window.innerWidth,window.innerHeight];var a=document.body,b=document.documentElement;return[Math.max(b.clientWidth,a.clientWidth),Math.max(b.clientHeight,a.clientHeight)]})()[1];") | |
scroll_height = wd.execute_script("return document.body.scrollHeight;") | |
i = 0 | |
while i < (scroll_height - screen_height) | |
sleep(2) | |
wd.execute_script("window.scrollTo(#{i}, #{i + screen_height});") | |
i += screen_height | |
end | |
sleep(2) | |
end | |
wd.quit | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment