Skip to content

Commit d2b6ae1

Browse files
authored
Merge pull request rails#52805 from glaszig/disable-chrome-search-engine-choice-screen
system testing: disable chrome's search engine choice modal
2 parents f52525e + 950907b commit d2b6ae1

File tree

3 files changed

+18
-23
lines changed

3 files changed

+18
-23
lines changed

actionpack/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
* System Testing: Disable Chrome's search engine choice by default in system tests.
2+
3+
*glaszig*
4+
15
* Fix `Request#raw_post` raising `NoMethodError` when `rack.input` is `nil`.
26

37
*Hartley McGuire*

actionpack/lib/action_dispatch/system_testing/browser.rb

Lines changed: 12 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ class Browser # :nodoc:
99

1010
def initialize(name)
1111
@name = name
12-
set_default_options
1312
end
1413

1514
def type
@@ -27,9 +26,9 @@ def options
2726
@options ||=
2827
case type
2928
when :chrome
30-
::Selenium::WebDriver::Chrome::Options.new
29+
default_chrome_options
3130
when :firefox
32-
::Selenium::WebDriver::Firefox::Options.new
31+
default_firefox_options
3332
end
3433
end
3534

@@ -49,26 +48,18 @@ def preload
4948
end
5049

5150
private
52-
def set_default_options
53-
case name
54-
when :headless_chrome
55-
set_headless_chrome_browser_options
56-
when :headless_firefox
57-
set_headless_firefox_browser_options
58-
end
51+
def default_chrome_options
52+
options = ::Selenium::WebDriver::Chrome::Options.new
53+
options.add_argument("--disable-search-engine-choice-screen")
54+
options.add_argument("--headless") if name == :headless_chrome
55+
options.add_argument("--disable-gpu") if Gem.win_platform?
56+
options
5957
end
6058

61-
def set_headless_chrome_browser_options
62-
configure do |capabilities|
63-
capabilities.add_argument("--headless")
64-
capabilities.add_argument("--disable-gpu") if Gem.win_platform?
65-
end
66-
end
67-
68-
def set_headless_firefox_browser_options
69-
configure do |capabilities|
70-
capabilities.add_argument("-headless")
71-
end
59+
def default_firefox_options
60+
options = ::Selenium::WebDriver::Firefox::Options.new
61+
options.add_argument("-headless") if name == :headless_firefox
62+
options
7263
end
7364

7465
def resolve_driver_path(namespace)

actionpack/test/dispatch/system_testing/driver_test.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ class DriverTest < ActiveSupport::TestCase
8282

8383
expected = {
8484
"goog:chromeOptions" => {
85-
"args" => ["start-maximized"],
85+
"args" => ["--disable-search-engine-choice-screen", "start-maximized"],
8686
"mobileEmulation" => { "deviceName" => "iphone 6" },
8787
"prefs" => { "detach" => true }
8888
},
@@ -101,7 +101,7 @@ class DriverTest < ActiveSupport::TestCase
101101

102102
expected = {
103103
"goog:chromeOptions" => {
104-
"args" => ["--headless", "start-maximized"],
104+
"args" => ["--disable-search-engine-choice-screen", "--headless", "start-maximized"],
105105
"mobileEmulation" => { "deviceName" => "iphone 6" },
106106
"prefs" => { "detach" => true }
107107
},

0 commit comments

Comments
 (0)