Skip to content

Commit 85d6c25

Browse files
committed
[rb] add headless guard to tests
1 parent e984b30 commit 85d6c25

File tree

6 files changed

+24
-12
lines changed

6 files changed

+24
-12
lines changed

rb/spec/integration/selenium/webdriver/action_builder_spec.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -321,6 +321,7 @@ module WebDriver
321321
describe '#scroll_by', only: {browser: %i[chrome edge firefox]} do
322322
it 'scrolls by given amount', except: {browser: :firefox,
323323
platform: :macosx,
324+
headless: false,
324325
reason: 'scrolls insufficient number of pixels'} do
325326
driver.navigate.to url_for('scrolling_tests/frame_with_nested_scrolling_frame_out_of_view.html')
326327
footer = driver.find_element(tag_name: 'footer')

rb/spec/integration/selenium/webdriver/chrome/driver_spec.rb

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,15 @@ module Chrome
5454
end
5555

5656
describe 'PrintsPage' do
57-
before(:all) { reset_driver!(args: ['--headless']) }
57+
before(:all) do
58+
@headless = ENV.delete('HEADLESS')
59+
reset_driver!(args: ['--headless'])
60+
end
5861

59-
after(:all) { reset_driver! }
62+
after(:all) do
63+
quit_driver
64+
ENV['HEADLESS'] = @headless
65+
end
6066

6167
let(:magic_number) { 'JVBER' }
6268

rb/spec/integration/selenium/webdriver/firefox/driver_spec.rb

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,12 @@ module Firefox
4444
page: {width: 30})).to include(magic_number)
4545
end
4646

47-
it 'should print full page', except: {ci: :github,
48-
platform: :windows,
49-
reason: 'Some issues with resolution?'} do
47+
it 'should print full page', except: [{ ci: :github,
48+
platform: :windows,
49+
reason: 'Some issues with resolution?' },
50+
{platform: :macosx,
51+
headless: true,
52+
reason: 'showing half resolution of what expected'}] do
5053
viewport_width = driver.execute_script("return window.innerWidth;")
5154
viewport_height = driver.execute_script("return window.innerHeight;")
5255

rb/spec/integration/selenium/webdriver/spec_helper.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@
5353
guards.add_condition(:browser, GlobalTestEnv.browser)
5454
guards.add_condition(:ci, WebDriver::Platform.ci)
5555
guards.add_condition(:platform, WebDriver::Platform.os)
56+
guards.add_condition(:headless, !!ENV['HEADLESS'])
5657

5758
results = guards.disposition
5859
send(*results) if results

rb/spec/integration/selenium/webdriver/takes_screenshot_spec.rb

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -92,11 +92,12 @@ def save_screenshot_and_assert(source, path)
9292
end
9393

9494
it 'takes full page screenshot', exclusive: {browser: :firefox},
95-
except: {
96-
ci: :github,
97-
platform: :windows,
98-
reason: 'Some issues with resolution?'
99-
} do
95+
except: [{ci: :github,
96+
platform: :windows,
97+
reason: 'Some issues with resolution?'},
98+
{platform: :macosx,
99+
headless: true,
100+
reason: 'showing half resolution of what expected'}] do
100101
viewport_width = driver.execute_script("return window.innerWidth;")
101102
viewport_height = driver.execute_script("return window.innerHeight;")
102103

rb/spec/integration/selenium/webdriver/window_spec.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ module WebDriver
113113
expect(new_size.height).to be > old_size.height
114114
end
115115

116-
it 'can make window full screen' do
116+
it 'can make window full screen', except: {browser: %i[chrome edge], headless: true} do
117117
window.size = old_size = Dimension.new(700, 700)
118118

119119
window.full_screen
@@ -124,7 +124,7 @@ module WebDriver
124124
expect(new_size.height).to be > old_size.height
125125
end
126126

127-
it 'can minimize the window' do
127+
it 'can minimize the window', except: {browser: %i[chrome edge], headless: true} do
128128
window.minimize
129129
expect(driver.execute_script('return document.hidden;')).to be true
130130
end

0 commit comments

Comments
 (0)