Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'qa/qa/runtime/browser.rb')
-rw-r--r--qa/qa/runtime/browser.rb23
1 files changed, 22 insertions, 1 deletions
diff --git a/qa/qa/runtime/browser.rb b/qa/qa/runtime/browser.rb
index 9097690de57..0566bc237bb 100644
--- a/qa/qa/runtime/browser.rb
+++ b/qa/qa/runtime/browser.rb
@@ -4,7 +4,6 @@ require 'rspec/core'
require 'rspec/expectations'
require 'capybara/rspec'
require 'capybara-screenshot/rspec'
-require 'selenium-webdriver'
require 'webdrivers/chromedriver'
require 'webdrivers/geckodriver'
@@ -220,6 +219,28 @@ module QA
yield.tap { clear! } if block_given?
end
+ # To redirect the browser to a canary or non-canary web node
+ # after loading a subject test page
+ # @param [Boolean] Send to canary true or false
+ # @example:
+ # Runtime::Browser::Session.target_canary(true)
+ def self.target_canary(enable_canary)
+ if QA::Runtime::Env.qa_cookies.to_s.include?("gitlab_canary=true")
+ QA::Runtime::Logger.warn("WARNING: Setting cookie through QA_COOKIES var is incompatible with this method.")
+ return
+ end
+
+ browser = Capybara.current_session.driver.browser
+
+ if enable_canary
+ browser.manage.add_cookie name: "gitlab_canary", value: "true"
+ else
+ browser.manage.delete_cookie("gitlab_canary")
+ end
+
+ browser.navigate.refresh
+ end
+
##
# Selenium allows to reset session cookies for current domain only.
#