run canvas specs on saucelabs

Test Plan
a) Verify that canvas specs runs successfuly for
 chrome
 internet explorer
 safari
 firefox
b) Verify existing local browsers i.e. firefox and chrome work

refs
CNVS-28701

Change-Id: Ia1fe17c0bb0097f20ad60e49015cb458b92c8e0b
Reviewed-on: https://gerrit.instructure.com/76868
Tested-by: Jenkins
Reviewed-by: Jon Jensen <jon@instructure.com>
QA-Review: Santosh Natarajan <snatarajan@instructure.com>
Product-Review: Santosh Natarajan <snatarajan@instructure.com>
This commit is contained in:
Santosh Natarajan 2016-04-12 11:03:44 -06:00
parent 6d9dbf726b
commit 5f04437356
2 changed files with 36 additions and 77 deletions

View File

@ -1,7 +1,9 @@
test:
host: "localhost"
port: 4444
browser: "firefox"
#version: "45.0"
#platform: "Windows 10"
#remote_url: "https://instructure:secret_key@ondemand.saucelabs.com:80/wd/hub"
#tunnel_id: "canvas_firefox"
paths:
# setting path works for opera, chrome, and firefox
# firefox: "/Applications/Firefox7.app/Contents/MacOS/firefox"

View File

@ -10,9 +10,7 @@ module SeleniumDriverSetup
IMPLICIT_WAIT_TIMEOUT = 15
def setup_selenium
browser = $selenium_config[:browser].try(:to_sym) || :firefox
host_and_port
path = $selenium_config[:paths].try(:[], browser)
if path
@ -25,8 +23,10 @@ module SeleniumDriverSetup
firefox_driver
elsif browser == :chrome
chrome_driver
elsif browser == :ie
elsif browser == :internet_explorer
ie_driver
elsif browser == :safari
safari_driver
end
focus_viewport driver if run_headless?
@ -102,44 +102,23 @@ module SeleniumDriverSetup
end
def ie_driver
require 'testingbot'
require 'testingbot/tunnel'
puts "using IE driver"
selenium_remote_driver
end
caps = Selenium::WebDriver::Remote::Capabilities.ie
caps.version = "10"
caps.platform = :WINDOWS
caps[:unexpectedAlertBehaviour] = 'ignore'
Selenium::WebDriver.for(
:remote,
:url => "http://#{$selenium_config[:testingbot_key]}:" +
"#{$selenium_config[:testingbot_secret]}@hub.testingbot.com:4444/wd/hub",
:desired_capabilities => caps)
def safari_driver
puts "using safari driver"
selenium_remote_driver
end
def firefox_driver
puts "using FIREFOX driver"
profile = firefox_profile
caps = Selenium::WebDriver::Remote::Capabilities.firefox(:unexpectedAlertBehaviour => 'ignore')
if $selenium_config[:host_and_port]
caps.firefox_profile = profile
stand_alone_server_firefox_driver(caps)
else
ruby_firefox_driver(profile: profile, desired_capabilities: caps)
end
selenium_url ? selenium_remote_driver : ruby_firefox_driver
end
def chrome_driver
puts "using CHROME driver"
if $selenium_config[:host_and_port]
stand_alone_server_chrome_driver
else
ruby_chrome_driver
end
selenium_url ? selenium_remote_driver : ruby_chrome_driver
end
def ruby_chrome_driver
@ -156,31 +135,33 @@ module SeleniumDriverSetup
driver
end
def stand_alone_server_chrome_driver
driver = nil
3.times do |times|
begin
driver = Selenium::WebDriver.for(
:remote,
:url => 'http://' + ($selenium_config[:host_and_port] || "localhost:4444") + '/wd/hub',
:desired_capabilities => :chrome
)
break
rescue StandardError => e
puts "Error attempting to start remote webdriver: #{e}"
raise e if times == 2
end
end
driver
def selenium_remote_driver
Selenium::WebDriver.for(
:remote,
:url => selenium_url,
:desired_capabilities => desired_capabilities
)
end
def ruby_firefox_driver(options)
def desired_capabilities
caps = Selenium::WebDriver::Remote::Capabilities.send($selenium_config[:browser].try(:to_sym))
caps.version = $selenium_config[:version] unless $selenium_config[:version].nil?
caps.platform = $selenium_config[:platform] unless $selenium_config[:platform].nil?
caps["tunnel-identifier"] = $selenium_config[:tunnel_id] unless $selenium_config[:tunnel_id].nil?
caps[:unexpectedAlertBehaviour] = 'ignore'
caps
end
def selenium_url
$selenium_config[:remote_url]
end
def ruby_firefox_driver
try ||= 1
puts "Thread: provisioning selenium ruby firefox driver (#{options.inspect})"
# dup is necessary for retries because selenium deletes out of the options
# TODO: we could try a random port here instead of relying on the default for retries
# (or killing firefox may be the best move)
driver = Selenium::WebDriver.for(:firefox, options.dup)
driver = Selenium::WebDriver.for(:firefox,
desired_capabilities: desired_capabilities)
rescue StandardError => e
puts <<-ERROR
Thread #{THIS_ENV}
@ -202,24 +183,6 @@ module SeleniumDriverSetup
end
end
def stand_alone_server_firefox_driver(caps)
driver = nil
3.times do |times|
begin
driver = Selenium::WebDriver.for(
:remote,
:url => 'http://' + ($selenium_config[:host_and_port] || "localhost:4444") + '/wd/hub',
:desired_capabilities => caps
)
break
rescue StandardError => e
puts "Error attempting to start remote webdriver: #{e}"
raise e if times == 2
end
end
driver
end
def selenium_driver
$selenium_driver ||= setup_selenium
end
@ -236,12 +199,6 @@ module SeleniumDriverSetup
profile
end
def host_and_port
if $selenium_config[:host] && $selenium_config[:port] && !$selenium_config[:host_and_port]
$selenium_config[:host_and_port] = "#{$selenium_config[:host]}:#{$selenium_config[:port]}"
end
end
def set_native_events(setting)
driver.instance_variable_get(:@bridge).instance_variable_get(:@capabilities).instance_variable_set(:@native_events, setting)
end