jenkins-bot has submitted this change and it was merged. Change subject: Moved BROWSER_TIMEOUT implementation to the gem ......................................................................
Moved BROWSER_TIMEOUT implementation to the gem Paired with Tobi Gritschacher. This adds the possibility to specify BROWSER_TIMEOUT in seconds. This change adds support for local as well as remote browsers. If BROWSER_TIMEOUT is set, this will affect (1) Selenium::WebDriver's client.timeout: this specifies the time after which Ruby's Net::HTTP will time out when a page is loaded (default: 60) (2) Firefox dom.max_script_run_time and dom.max_chrome_script_run_time: this specifies after which time period Firefox will consider a JavaScript as unresponsive and shows a modal dialog. At the moment only Firefox is supported though there are plans to make this work with Chromium too. Bug: 61667 Change-Id: If55392d1fc64e1e29d0cdff14ff228718bf290ca --- M README.md M lib/mediawiki_selenium/support/env.rb M lib/mediawiki_selenium/version.rb 3 files changed, 34 insertions(+), 7 deletions(-) Approvals: Zfilipin: Looks good to me, approved jenkins-bot: Verified diff --git a/README.md b/README.md index 5aabc3c..bec7f1e 100644 --- a/README.md +++ b/README.md @@ -93,3 +93,11 @@ 5. Create new Pull Request https://www.mediawiki.org/wiki/QA/Browser_testing#How_to_contribute + +## Release notes + +### 0.2.8 + +#### Enhancements + +* Possibility to set BROWSER_TIMEOUT diff --git a/lib/mediawiki_selenium/support/env.rb b/lib/mediawiki_selenium/support/env.rb index f648935..003d16c 100644 --- a/lib/mediawiki_selenium/support/env.rb +++ b/lib/mediawiki_selenium/support/env.rb @@ -27,8 +27,7 @@ end end def environment - if ENV["BROWSER"] and ENV["BROWSER"] != "phantomjs" and - ENV["SAUCE_ONDEMAND_USERNAME"] and ENV["SAUCE_ONDEMAND_ACCESS_KEY"] + if ENV["SAUCE_ONDEMAND_USERNAME"] and ENV["SAUCE_ONDEMAND_ACCESS_KEY"] and ENV["BROWSER"] != "phantomjs" :saucelabs else :local @@ -41,7 +40,17 @@ browser_name = :firefox end - if language == "default" + if language == "default" && ENV["BROWSER_TIMEOUT"] && browser_name == :firefox + timeout = ENV["BROWSER_TIMEOUT"].to_i + + client = Selenium::WebDriver::Remote::Http::Default.new + client.timeout = timeout + + profile = Selenium::WebDriver::Firefox::Profile.new + profile["dom.max_script_run_time"] = timeout + profile["dom.max_chrome_script_run_time"] = timeout + browser = Watir::Browser.new browser_name, :http_client => client, :profile => profile + elsif language == "default" browser = Watir::Browser.new browser_name else if browser_name == :firefox @@ -77,7 +86,18 @@ def sauce_browser(test_name, language) abort "Environment variables BROWSER, PLATFORM and VERSION have to be set" if (ENV["BROWSER"] == nil) or (ENV["PLATFORM"] == nil) or (ENV["VERSION"] == nil) - if language == "default" + require "selenium/webdriver/remote/http/persistent" # http_client + client = Selenium::WebDriver::Remote::Http::Persistent.new + + if language == "default" && ENV["BROWSER_TIMEOUT"] && ENV["BROWSER"] == "firefox" + timeout = ENV["BROWSER_TIMEOUT"].to_i + client.timeout = timeout + + profile = Selenium::WebDriver::Firefox::Profile.new + profile["dom.max_script_run_time"] = timeout + profile["dom.max_chrome_script_run_time"] = timeout + caps = Selenium::WebDriver::Remote::Capabilities.firefox(:firefox_profile => profile) + elsif language == "default" caps = Selenium::WebDriver::Remote::Capabilities.send(ENV["BROWSER"]) elsif ENV["BROWSER"] == "firefox" profile = Selenium::WebDriver::Firefox::Profile.new @@ -93,10 +113,9 @@ caps.version = ENV["VERSION"] caps[:name] = "#{test_name} #{ENV['JOB_NAME']}##{ENV['BUILD_NUMBER']}" - require "selenium/webdriver/remote/http/persistent" # http_client browser = Watir::Browser.new( :remote, - http_client: Selenium::WebDriver::Remote::Http::Persistent.new, + http_client: client, url: "http://#{ENV['SAUCE_ONDEMAND_USERNAME']}:#{ENV['SAUCE_ONDEMAND_ACCESS_KEY']}@ondemand.saucelabs.com:80/wd/hub", desired_capabilities: caps) browser.wd.file_detector = lambda do |args| diff --git a/lib/mediawiki_selenium/version.rb b/lib/mediawiki_selenium/version.rb index e839c80..2b1be1d 100644 --- a/lib/mediawiki_selenium/version.rb +++ b/lib/mediawiki_selenium/version.rb @@ -10,5 +10,5 @@ =end module MediawikiSelenium - VERSION = "0.2.7" + VERSION = "0.2.8" end -- To view, visit https://gerrit.wikimedia.org/r/114453 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: If55392d1fc64e1e29d0cdff14ff228718bf290ca Gerrit-PatchSet: 8 Gerrit-Project: mediawiki/selenium Gerrit-Branch: master Gerrit-Owner: Zfilipin <zfili...@wikimedia.org> Gerrit-Reviewer: Cmcmahon <cmcma...@wikimedia.org> Gerrit-Reviewer: Jhall <jh...@wikimedia.org> Gerrit-Reviewer: Tobias Gritschacher <tobias.gritschac...@wikimedia.de> Gerrit-Reviewer: Zfilipin <zfili...@wikimedia.org> Gerrit-Reviewer: jenkins-bot <> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits