spec: fix focus/blur issues, don't use buggy native events
native event/no_focus stuff is buggy (which is why it's normally not enabled by default), so let's try a different approach... ensure each runner has its own framebuffer (and thus its firefox should run in the foreground). additionally, ensure the viewport has focus when specs start so that blur/focus events fire normally. this ensures that specs like spec/selenium/wiki_pages_spec.rb:429 pass when run on jenkins without following another alert-accepting spec (like spec/selenium/wiki_pages_spec:422). test plan: * full selenium build should pass on this commit, faster and w/ fewer reruns * non-testbot test-queue selenium build should pass on dependent commit (running spec/selenium/wiki_pages_spec.rb w/ 5 runners concurrently) Change-Id: Ic1bd09ab3ca8f483611201198025cdf4858d51dc Reviewed-on: https://gerrit.instructure.com/69663 Reviewed-by: Simon Williams <simon@instructure.com> Tested-by: Jenkins Product-Review: Jon Jensen <jon@instructure.com> QA-Review: Jon Jensen <jon@instructure.com>
This commit is contained in:
parent
3ad44cc4ba
commit
e879ac39c5
|
@ -38,6 +38,7 @@ group :test do
|
|||
gem 'yard-appendix', '>=0.1.8'
|
||||
gem 'timecop', '0.6.3'
|
||||
gem 'jira_ref_parser', '1.0.0'
|
||||
gem 'headless', '2.2.0', require: false
|
||||
|
||||
unless CANVAS_RAILS4_0
|
||||
gem 'rails-dom-testing', '1.0.7'
|
||||
|
|
|
@ -11,6 +11,9 @@ module SeleniumDriverSetup
|
|||
Selenium::WebDriver.const_get(browser.to_s.capitalize).path = path
|
||||
end
|
||||
|
||||
run_headless = ENV.key?("TEST_ENV_NUMBER")
|
||||
set_up_display_buffer if run_headless
|
||||
|
||||
driver = if browser == :firefox
|
||||
firefox_driver
|
||||
elsif browser == :chrome
|
||||
|
@ -19,11 +22,36 @@ module SeleniumDriverSetup
|
|||
ie_driver
|
||||
end
|
||||
|
||||
focus_viewport driver if run_headless
|
||||
|
||||
driver.manage.timeouts.implicit_wait = 3
|
||||
driver.manage.timeouts.script_timeout = 60
|
||||
|
||||
driver
|
||||
end
|
||||
|
||||
def set_up_display_buffer
|
||||
require "headless"
|
||||
|
||||
test_number = ENV["TEST_ENV_NUMBER"]
|
||||
# it'll be '', '2', '3', '4'...
|
||||
test_number = test_number.blank? ? 1 : test_number.to_i
|
||||
# start at 21 to avoid conflicts with other test runner Xvfb stuff
|
||||
|
||||
display = 20 + test_number
|
||||
Headless.new(display: display, dimensions: "2000x2000x24").start
|
||||
puts "Setting up DISPLAY=#{ENV['DISPLAY']}"
|
||||
end
|
||||
|
||||
def focus_viewport(driver)
|
||||
# force the viewport to have focus right away; otherwise certain specs
|
||||
# will fail unless they follow another dialog accepting/dismissing spec,
|
||||
# since they rely on focus/blur events, which don't fire if the window
|
||||
# doesn't have focus
|
||||
driver.execute_script "alert('yolo')"
|
||||
driver.switch_to.alert.accept
|
||||
end
|
||||
|
||||
def ie_driver
|
||||
require 'testingbot'
|
||||
require 'testingbot/tunnel'
|
||||
|
@ -151,8 +179,6 @@ module SeleniumDriverSetup
|
|||
|
||||
def firefox_profile
|
||||
profile = Selenium::WebDriver::Firefox::Profile.new
|
||||
profile.load_no_focus_lib=(true)
|
||||
profile.native_events = true
|
||||
profile.add_extension Rails.root.join("spec/selenium/test_setup/JSErrorCollector.xpi")
|
||||
|
||||
if $selenium_config[:firefox_profile].present?
|
||||
|
|
Loading…
Reference in New Issue