Skip to content

Commit

Permalink
Simplify specs for headless Chrome option
Browse files Browse the repository at this point in the history
  • Loading branch information
p0deje committed Feb 13, 2018
1 parent c0688df commit 5c7d155
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 39 deletions.
21 changes: 5 additions & 16 deletions rb/spec/integration/selenium/webdriver/chrome/options_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,23 +48,12 @@ module Chrome
end
end

context 'headless mode' do
it 'should be able to run in headless mode with #headless!' do
subject.headless!
it 'should be able to run in headless mode with #headless!' do
subject.headless!

create_driver!(options: subject) do |driver|
ua = driver.execute_script 'return window.navigator.userAgent'
expect(ua).to match(/HeadlessChrome/)
end
end

it 'should be able to run in headless mode with #add_argument' do
subject.add_argument('--headless')

create_driver!(options: subject) do |driver|
ua = driver.execute_script 'return window.navigator.userAgent'
expect(ua).to match(/HeadlessChrome/)
end
create_driver!(options: subject) do |driver|
ua = driver.execute_script 'return window.navigator.userAgent'
expect(ua).to match(/HeadlessChrome/)
end
end
end
Expand Down
27 changes: 4 additions & 23 deletions rb/spec/unit/selenium/webdriver/chrome/options_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -112,30 +112,11 @@ module Chrome
end

describe '#headless!' do
context 'on windows' do
before(:each) do
allow(WebDriver::Platform).to receive(:windows?).and_return true
end

it 'should add the --headless and --disable-gpu command-line argument' do
subject.headless!
it 'should add necessary command-line arguments' do
subject.headless!
if WebDriver::Platform.windows?
expect(subject.args).to eql(%w[--headless --disable-gpu])
end
end

context 'on non-windows' do
before(:each) do
allow(WebDriver::Platform).to receive(:windows?).and_return false
end

it 'should add the --headless command-line argument' do
subject.headless!
expect(subject.args).to eql(['--headless'])
end

it 'should not add the --headless command-line argument if already present' do
subject.add_argument('--headless')
subject.headless!
else
expect(subject.args).to eql(['--headless'])
end
end
Expand Down

0 comments on commit 5c7d155

Please sign in to comment.