@@ -69,7 +69,6 @@ class DriverTest < ActiveSupport::TestCase
69
69
option . add_preference ( :detach , true )
70
70
end
71
71
driver . use
72
- browser_options = driver . __send__ ( :browser_options )
73
72
74
73
expected = {
75
74
"goog:chromeOptions" => {
@@ -79,7 +78,7 @@ class DriverTest < ActiveSupport::TestCase
79
78
} ,
80
79
"browserName" => "chrome"
81
80
}
82
- assert_equal expected , browser_options [ :capabilities ] . as_json
81
+ assert_driver_capabilities driver , expected
83
82
end
84
83
85
84
test "define extra capabilities using headless_chrome" do
@@ -89,7 +88,6 @@ class DriverTest < ActiveSupport::TestCase
89
88
option . add_preference ( :detach , true )
90
89
end
91
90
driver . use
92
- browser_options = driver . __send__ ( :browser_options )
93
91
94
92
expected = {
95
93
"goog:chromeOptions" => {
@@ -99,7 +97,7 @@ class DriverTest < ActiveSupport::TestCase
99
97
} ,
100
98
"browserName" => "chrome"
101
99
}
102
- assert_equal expected , browser_options [ :capabilities ] . as_json
100
+ assert_driver_capabilities driver , expected
103
101
end
104
102
105
103
test "define extra capabilities using firefox" do
@@ -108,7 +106,6 @@ class DriverTest < ActiveSupport::TestCase
108
106
option . add_argument ( "--host=127.0.0.1" )
109
107
end
110
108
driver . use
111
- browser_options = driver . __send__ ( :browser_options )
112
109
113
110
expected = {
114
111
"moz:firefoxOptions" => {
@@ -117,7 +114,7 @@ class DriverTest < ActiveSupport::TestCase
117
114
} ,
118
115
"browserName" => "firefox"
119
116
}
120
- assert_equal expected , browser_options [ :capabilities ] . as_json
117
+ assert_driver_capabilities driver , expected
121
118
end
122
119
123
120
test "define extra capabilities using headless_firefox" do
@@ -126,7 +123,6 @@ class DriverTest < ActiveSupport::TestCase
126
123
option . add_argument ( "--host=127.0.0.1" )
127
124
end
128
125
driver . use
129
- browser_options = driver . __send__ ( :browser_options )
130
126
131
127
expected = {
132
128
"moz:firefoxOptions" => {
@@ -135,7 +131,7 @@ class DriverTest < ActiveSupport::TestCase
135
131
} ,
136
132
"browserName" => "firefox"
137
133
}
138
- assert_equal expected , browser_options [ :capabilities ] . as_json
134
+ assert_driver_capabilities driver , expected
139
135
end
140
136
141
137
test "does not define extra capabilities" do
@@ -176,4 +172,11 @@ class DriverTest < ActiveSupport::TestCase
176
172
driver = ActionDispatch ::SystemTesting ::Driver . new ( :selenium , options : { name : :best_driver } )
177
173
assert_equal :best_driver , driver . name
178
174
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
179
182
end
0 commit comments