Skip to content

Commit 9aecf3c

Browse files
Merge pull request rails#46153 from jonathanhefner/ci-selenium_webdriver-4_5_0
Fix tests for `selenium-webdriver` v4.5.0
2 parents c41e2f1 + 6a0ec0e commit 9aecf3c

File tree

2 files changed

+14
-10
lines changed

2 files changed

+14
-10
lines changed

Gemfile.lock

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -455,10 +455,11 @@ GEM
455455
fugit (~> 1.1, >= 1.1.6)
456456
sdoc (2.4.0)
457457
rdoc (>= 5.0)
458-
selenium-webdriver (4.1.0)
458+
selenium-webdriver (4.5.0)
459459
childprocess (>= 0.5, < 5.0)
460460
rexml (~> 3.2, >= 3.2.5)
461-
rubyzip (>= 1.2.2)
461+
rubyzip (>= 1.2.2, < 3.0)
462+
websocket (~> 1.0)
462463
sequel (5.52.0)
463464
serverengine (2.0.7)
464465
sigdump (~> 0.2.2)

actionpack/test/dispatch/system_testing/driver_test.rb

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,6 @@ class DriverTest < ActiveSupport::TestCase
6969
option.add_preference(:detach, true)
7070
end
7171
driver.use
72-
browser_options = driver.__send__(:browser_options)
7372

7473
expected = {
7574
"goog:chromeOptions" => {
@@ -79,7 +78,7 @@ class DriverTest < ActiveSupport::TestCase
7978
},
8079
"browserName" => "chrome"
8180
}
82-
assert_equal expected, browser_options[:capabilities].as_json
81+
assert_driver_capabilities driver, expected
8382
end
8483

8584
test "define extra capabilities using headless_chrome" do
@@ -89,7 +88,6 @@ class DriverTest < ActiveSupport::TestCase
8988
option.add_preference(:detach, true)
9089
end
9190
driver.use
92-
browser_options = driver.__send__(:browser_options)
9391

9492
expected = {
9593
"goog:chromeOptions" => {
@@ -99,7 +97,7 @@ class DriverTest < ActiveSupport::TestCase
9997
},
10098
"browserName" => "chrome"
10199
}
102-
assert_equal expected, browser_options[:capabilities].as_json
100+
assert_driver_capabilities driver, expected
103101
end
104102

105103
test "define extra capabilities using firefox" do
@@ -108,7 +106,6 @@ class DriverTest < ActiveSupport::TestCase
108106
option.add_argument("--host=127.0.0.1")
109107
end
110108
driver.use
111-
browser_options = driver.__send__(:browser_options)
112109

113110
expected = {
114111
"moz:firefoxOptions" => {
@@ -117,7 +114,7 @@ class DriverTest < ActiveSupport::TestCase
117114
},
118115
"browserName" => "firefox"
119116
}
120-
assert_equal expected, browser_options[:capabilities].as_json
117+
assert_driver_capabilities driver, expected
121118
end
122119

123120
test "define extra capabilities using headless_firefox" do
@@ -126,7 +123,6 @@ class DriverTest < ActiveSupport::TestCase
126123
option.add_argument("--host=127.0.0.1")
127124
end
128125
driver.use
129-
browser_options = driver.__send__(:browser_options)
130126

131127
expected = {
132128
"moz:firefoxOptions" => {
@@ -135,7 +131,7 @@ class DriverTest < ActiveSupport::TestCase
135131
},
136132
"browserName" => "firefox"
137133
}
138-
assert_equal expected, browser_options[:capabilities].as_json
134+
assert_driver_capabilities driver, expected
139135
end
140136

141137
test "does not define extra capabilities" do
@@ -176,4 +172,11 @@ class DriverTest < ActiveSupport::TestCase
176172
driver = ActionDispatch::SystemTesting::Driver.new(:selenium, options: { name: :best_driver })
177173
assert_equal :best_driver, driver.name
178174
end
175+
176+
private
177+
def assert_driver_capabilities(driver, expected_capabilities)
178+
capabilities = driver.__send__(:browser_options)[:capabilities].as_json
179+
180+
assert_equal expected_capabilities, capabilities.slice(*expected_capabilities.keys)
181+
end
179182
end

0 commit comments

Comments
 (0)