Commit c60b287f authored by Ramya Authappan's avatar Ramya Authappan

Merge branch 'qa-add-mobile-device-capabilities' into 'master'

Update browser.rb to accept mobile device name

See merge request gitlab-org/gitlab!65061
parents 14208e3f 56ff9e59
...@@ -68,11 +68,12 @@ module QA ...@@ -68,11 +68,12 @@ module QA
Capybara.register_driver QA::Runtime::Env.browser do |app| Capybara.register_driver QA::Runtime::Env.browser do |app|
capabilities = Selenium::WebDriver::Remote::Capabilities.send(QA::Runtime::Env.browser) capabilities = Selenium::WebDriver::Remote::Capabilities.send(QA::Runtime::Env.browser)
case QA::Runtime::Env.browser
when :chrome
if QA::Runtime::Env.accept_insecure_certs? if QA::Runtime::Env.accept_insecure_certs?
capabilities['acceptInsecureCerts'] = true capabilities['acceptInsecureCerts'] = true
end end
if QA::Runtime::Env.browser == :chrome
# set logging preferences # set logging preferences
# this enables access to logs with `page.driver.manage.get_log(:browser)` # this enables access to logs with `page.driver.manage.get_log(:browser)`
capabilities['goog:loggingPrefs'] = { capabilities['goog:loggingPrefs'] = {
...@@ -82,14 +83,11 @@ module QA ...@@ -82,14 +83,11 @@ module QA
server: 'ALL' server: 'ALL'
} }
# size window # Chrome won't work properly in a Docker container in sandbox mode
capabilities['goog:chromeOptions'] = { capabilities['goog:chromeOptions'] = {
args: %w[window-size=1480,2200] args: %w[no-sandbox]
} }
# Chrome won't work properly in a Docker container in sandbox mode
capabilities['goog:chromeOptions'][:args] << 'no-sandbox'
# Run headless by default unless WEBDRIVER_HEADLESS is false # Run headless by default unless WEBDRIVER_HEADLESS is false
if QA::Runtime::Env.webdriver_headless? if QA::Runtime::Env.webdriver_headless?
capabilities['goog:chromeOptions'][:args] << 'headless' capabilities['goog:chromeOptions'][:args] << 'headless'
...@@ -105,6 +103,26 @@ module QA ...@@ -105,6 +103,26 @@ module QA
# Specify the user-agent to allow challenges to be bypassed # Specify the user-agent to allow challenges to be bypassed
# See https://gitlab.com/gitlab-com/gl-infra/infrastructure/-/issues/11938 # See https://gitlab.com/gitlab-com/gl-infra/infrastructure/-/issues/11938
capabilities['goog:chromeOptions'][:args] << "user-agent=#{QA::Runtime::Env.user_agent}" if QA::Runtime::Env.user_agent capabilities['goog:chromeOptions'][:args] << "user-agent=#{QA::Runtime::Env.user_agent}" if QA::Runtime::Env.user_agent
if QA::Runtime::Env.remote_mobile_device_name
capabilities['platformName'] = 'Android'
capabilities['appium:deviceName'] = QA::Runtime::Env.remote_mobile_device_name
capabilities['appium:platformVersion'] = 'latest'
else
capabilities['goog:chromeOptions'][:args] << 'window-size=1480,2200'
end
when :safari
if QA::Runtime::Env.remote_mobile_device_name
capabilities['platformName'] = 'iOS'
capabilities['appium:deviceName'] = QA::Runtime::Env.remote_mobile_device_name
capabilities['appium:platformVersion'] = 'latest'
end
when :firefox
if QA::Runtime::Env.accept_insecure_certs?
capabilities['acceptInsecureCerts'] = true
end
end end
# Use the same profile on QA runs if CHROME_REUSE_PROFILE is true. # Use the same profile on QA runs if CHROME_REUSE_PROFILE is true.
...@@ -120,7 +138,10 @@ module QA ...@@ -120,7 +138,10 @@ module QA
capabilities: capabilities capabilities: capabilities
} }
selenium_options[:url] = QA::Runtime::Env.remote_grid if QA::Runtime::Env.remote_grid if QA::Runtime::Env.remote_grid
selenium_options[:url] = QA::Runtime::Env.remote_grid
capabilities[:browserVersion] = 'latest'
end
Capybara::Selenium::Driver.new( Capybara::Selenium::Driver.new(
app, app,
......
...@@ -144,6 +144,10 @@ module QA ...@@ -144,6 +144,10 @@ module QA
ENV['QA_BROWSER'].nil? ? :chrome : ENV['QA_BROWSER'].to_sym ENV['QA_BROWSER'].nil? ? :chrome : ENV['QA_BROWSER'].to_sym
end end
def remote_mobile_device_name
ENV['QA_REMOTE_MOBILE_DEVICE_NAME']
end
def user_username def user_username
ENV['GITLAB_USERNAME'] ENV['GITLAB_USERNAME']
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment