Commit 65a7a20a authored by Lin Jen-Shin's avatar Lin Jen-Shin

Try to reduce testing view port and unify it

Hoping that we don't hit into

    Selenium::WebDriver::Error::NoSuchDriverError:
      invalid session id

Again.
parent 3990e52d
...@@ -17,6 +17,8 @@ JS_CONSOLE_FILTER = Regexp.union([ ...@@ -17,6 +17,8 @@ JS_CONSOLE_FILTER = Regexp.union([
"Download the Vue Devtools extension" "Download the Vue Devtools extension"
]) ])
CAPYBARA_WINDOW_SIZE = [1366, 768].freeze
Capybara.register_driver :chrome do |app| Capybara.register_driver :chrome do |app|
capabilities = Selenium::WebDriver::Remote::Capabilities.chrome( capabilities = Selenium::WebDriver::Remote::Capabilities.chrome(
# This enables access to logs with `page.driver.manage.get_log(:browser)` # This enables access to logs with `page.driver.manage.get_log(:browser)`
...@@ -29,7 +31,7 @@ Capybara.register_driver :chrome do |app| ...@@ -29,7 +31,7 @@ Capybara.register_driver :chrome do |app|
) )
options = Selenium::WebDriver::Chrome::Options.new options = Selenium::WebDriver::Chrome::Options.new
options.add_argument("window-size=1240,1400") options.add_argument("window-size=#{CAPYBARA_WINDOW_SIZE.join(',')}")
# Chrome won't work properly in a Docker container in sandbox mode # Chrome won't work properly in a Docker container in sandbox mode
options.add_argument("no-sandbox") options.add_argument("no-sandbox")
...@@ -78,8 +80,11 @@ RSpec.configure do |config| ...@@ -78,8 +80,11 @@ RSpec.configure do |config|
protocol: 'http') protocol: 'http')
# reset window size between tests # reset window size between tests
unless session.current_window.size == [1240, 1400] unless session.current_window.size == CAPYBARA_WINDOW_SIZE
session.current_window.resize_to(1240, 1400) rescue nil begin
session.current_window.resize_to(*CAPYBARA_WINDOW_SIZE)
rescue # ?
end
end end
end end
......
...@@ -8,7 +8,7 @@ module MobileHelpers ...@@ -8,7 +8,7 @@ module MobileHelpers
end end
def restore_window_size def restore_window_size
resize_window(1366, 768) resize_window(*CAPYBARA_WINDOW_SIZE)
end end
def resize_window(width, height) def resize_window(width, height)
......
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