Skip to content

Commit 6c847fb

Browse files
committed
[rb] update headless! deprecations
1 parent 9923060 commit 6c847fb

File tree

5 files changed

+14
-5
lines changed

5 files changed

+14
-5
lines changed

rb/lib/selenium/webdriver/chromium/options.rb

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,9 @@ def add_preference(name, value)
161161

162162
#
163163
# Run Chrome in headless mode.
164+
# Old headless uses a non-production browser and is set with `--headless`
165+
# Native headless from v86 - v108 is set with `--headless=chrome`
166+
# Native headless from v109+ is set with `--headless=new`
164167
#
165168
# @example Enable headless mode
166169
# options = Selenium::WebDriver::Chrome::Options.new
@@ -169,7 +172,7 @@ def add_preference(name, value)
169172

170173
def headless!
171174
WebDriver.logger.deprecate('`Options#headless!`',
172-
"`options = Selenium::WebDriver::Options.chrome(args: ['--headless=chrome'])`",
175+
"`Options#add_argument('--headless=new')`",
173176
id: :headless)
174177
add_argument '--headless'
175178
end

rb/lib/selenium/webdriver/firefox/options.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ def add_preference(name, value)
109109

110110
def headless!
111111
WebDriver.logger.deprecate('`Options#headless!`',
112-
"`options = Selenium::WebDriver::Options.firefox(args: ['-headless'])`",
112+
"`Options#add_argument('-headless')`",
113113
id: :headless)
114114
add_argument '-headless'
115115
end

rb/spec/unit/selenium/webdriver/chrome/options_spec.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,9 @@ module Chrome
181181

182182
describe '#headless!' do
183183
it 'adds necessary command-line arguments' do
184-
options.headless!
184+
expect {
185+
options.headless!
186+
}.to have_deprecated(:headless)
185187
expect(options.args).to eql(['--headless'])
186188
end
187189
end

rb/spec/unit/selenium/webdriver/edge/options_spec.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,9 @@ module Edge
136136

137137
describe '#headless!' do
138138
it 'adds necessary command-line arguments' do
139-
options.headless!
139+
expect {
140+
options.headless!
141+
}.to have_deprecated(:headless)
140142
expect(options.args.to_a).to eql(['--headless'])
141143
end
142144
end

rb/spec/unit/selenium/webdriver/firefox/options_spec.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,9 @@ module Firefox
127127

128128
describe '#headless!' do
129129
it 'adds the -headless command-line flag' do
130-
options.headless!
130+
expect {
131+
options.headless!
132+
}.to have_deprecated(:headless)
131133
expect(options.as_json['moz:firefoxOptions']['args']).to include('-headless')
132134
end
133135
end

0 commit comments

Comments
 (0)