Skip to content

Commit

Permalink
[rb] update headless! deprecations
Browse files Browse the repository at this point in the history
  • Loading branch information
titusfortner committed Jan 14, 2023
1 parent 9923060 commit 6c847fb
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 5 deletions.
5 changes: 4 additions & 1 deletion rb/lib/selenium/webdriver/chromium/options.rb
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,9 @@ def add_preference(name, value)

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

def headless!
WebDriver.logger.deprecate('`Options#headless!`',
"`options = Selenium::WebDriver::Options.chrome(args: ['--headless=chrome'])`",
"`Options#add_argument('--headless=new')`",
id: :headless)
add_argument '--headless'
end
Expand Down
2 changes: 1 addition & 1 deletion rb/lib/selenium/webdriver/firefox/options.rb
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ def add_preference(name, value)

def headless!
WebDriver.logger.deprecate('`Options#headless!`',
"`options = Selenium::WebDriver::Options.firefox(args: ['-headless'])`",
"`Options#add_argument('-headless')`",
id: :headless)
add_argument '-headless'
end
Expand Down
4 changes: 3 additions & 1 deletion rb/spec/unit/selenium/webdriver/chrome/options_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,9 @@ module Chrome

describe '#headless!' do
it 'adds necessary command-line arguments' do
options.headless!
expect {
options.headless!
}.to have_deprecated(:headless)
expect(options.args).to eql(['--headless'])
end
end
Expand Down
4 changes: 3 additions & 1 deletion rb/spec/unit/selenium/webdriver/edge/options_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,9 @@ module Edge

describe '#headless!' do
it 'adds necessary command-line arguments' do
options.headless!
expect {
options.headless!
}.to have_deprecated(:headless)
expect(options.args.to_a).to eql(['--headless'])
end
end
Expand Down
4 changes: 3 additions & 1 deletion rb/spec/unit/selenium/webdriver/firefox/options_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,9 @@ module Firefox

describe '#headless!' do
it 'adds the -headless command-line flag' do
options.headless!
expect {
options.headless!
}.to have_deprecated(:headless)
expect(options.as_json['moz:firefoxOptions']['args']).to include('-headless')
end
end
Expand Down

0 comments on commit 6c847fb

Please sign in to comment.