Skip to content

Commit e518273

Browse files
[rb] Add macos coverage to Ruby CI Github Action (#12556)
* Add macos coverage to Ruby CI (#12397) * guard is not present in before all hook so do not set driver * after hook still executes even when guard disposition of the test is skip so explicitly skip it too --------- Co-authored-by: Titus Fortner <[email protected]> Co-authored-by: titusfortner <[email protected]>
1 parent 4092a86 commit e518273

File tree

14 files changed

+73
-45
lines changed

14 files changed

+73
-45
lines changed

Diff for: .github/workflows/bazel.yml

+3
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,9 @@ jobs:
119119
uses: browser-actions/setup-edge@latest
120120
with:
121121
edge-version: ${{ inputs.browser-version || 'stable' }}
122+
- name: Setup Safari
123+
if: inputs.browser == 'safari'
124+
run: sudo safaridriver --enable
122125
- name: Run Bazel
123126
run: ${{ inputs.run }}
124127
- name: Start SSH session

Diff for: .github/workflows/ci-ruby.yml

+18
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ jobs:
4545
os: windows
4646
- ruby-version: 3.2.0
4747
os: ubuntu
48+
- ruby-version: 3.2.0
49+
os: macos
4850
- ruby-version: jruby-9.4.0.0
4951
os: ubuntu
5052
- ruby-version: truffleruby-22.3.0
@@ -67,12 +69,20 @@ jobs:
6769
- chrome
6870
- edge
6971
- firefox
72+
- safari
7073
os:
7174
- ubuntu
7275
- windows
76+
- macos
7377
exclude:
7478
- browser: edge
7579
os: ubuntu
80+
- browser: edge
81+
os: macos
82+
- browser: safari
83+
os: ubuntu
84+
- browser: safari
85+
os: windows
7686
with:
7787
name: Local Tests (${{ matrix.browser }}, ${{ matrix.os }})
7888
browser: ${{ matrix.browser }}
@@ -96,12 +106,20 @@ jobs:
96106
- chrome
97107
- edge
98108
- firefox
109+
- safari
99110
os:
100111
- ubuntu
101112
- windows
113+
- macos
102114
exclude:
103115
- browser: edge
104116
os: ubuntu
117+
- browser: edge
118+
os: macos
119+
- browser: safari
120+
os: ubuntu
121+
- browser: safari
122+
os: windows
105123
with:
106124
name: Remote Tests (${{ matrix.browser }}, ${{ matrix.os }})
107125
browser: ${{ matrix.browser }}

Diff for: rb/spec/integration/selenium/webdriver/action_builder_spec.rb

+10-10
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ module WebDriver
163163
expect(element.attribute(:value)).to eq('DoubleClicked')
164164
end
165165

166-
it 'executes with equivalent pointer methods' do
166+
it 'executes with equivalent pointer methods', except: {browser: %i[safari safari_preview]} do
167167
driver.navigate.to url_for('javascriptPage.html')
168168
element = driver.find_element(id: 'doubleClickField')
169169

@@ -203,8 +203,7 @@ module WebDriver
203203
end
204204

205205
it 'moves to element with offset', except: {browser: :firefox,
206-
ci: :github,
207-
platform: :windows,
206+
platform: %i[windows macosx],
208207
reason: 'Some issues with resolution?'} do
209208
driver.navigate.to url_for('javascriptPage.html')
210209
origin = driver.find_element(id: 'keyUpArea')
@@ -263,7 +262,8 @@ module WebDriver
263262
end
264263
end
265264

266-
describe 'pen stylus', except: {browser: :firefox, reason: 'Unknown pointerType'} do
265+
describe 'pen stylus', except: [{browser: :firefox, reason: 'Unknown pointerType'},
266+
{browser: :safari, reason: 'Some issues with resolution?'}] do
267267
it 'sets pointer event properties' do
268268
driver.navigate.to url_for('pointerActionsPage.html')
269269
pointer_area = driver.find_element(id: 'pointerArea')
@@ -318,10 +318,9 @@ module WebDriver
318318
end
319319
end
320320

321-
describe '#scroll_by', only: {browser: %i[chrome edge firefox]} do
321+
describe '#scroll_by' do
322322
it 'scrolls by given amount', except: {browser: :firefox,
323323
platform: :macosx,
324-
headless: false,
325324
reason: 'scrolls insufficient number of pixels'} do
326325
driver.navigate.to url_for('scrolling_tests/frame_with_nested_scrolling_frame_out_of_view.html')
327326
footer = driver.find_element(tag_name: 'footer')
@@ -334,9 +333,9 @@ module WebDriver
334333
end
335334
end
336335

337-
describe '#scroll_from', only: {browser: %i[chrome edge firefox]} do
336+
describe '#scroll_from' do
338337
it 'scrolls from element by given amount',
339-
except: {browser: :firefox, reason: 'incorrect MoveTargetOutOfBoundsError'} do
338+
except: {browser: %i[firefox safari], reason: 'incorrect MoveTargetOutOfBoundsError'} do
340339
driver.navigate.to url_for('scrolling_tests/frame_with_nested_scrolling_frame_out_of_view.html')
341340
iframe = driver.find_element(tag_name: 'iframe')
342341
scroll_origin = WheelActions::ScrollOrigin.element(iframe)
@@ -350,7 +349,7 @@ module WebDriver
350349
end
351350

352351
it 'scrolls from element by given amount with offset',
353-
except: {browser: :firefox, reason: 'incorrect MoveTargetOutOfBoundsError'} do
352+
except: {browser: %i[firefox safari], reason: 'incorrect MoveTargetOutOfBoundsError'} do
354353
driver.navigate.to url_for('scrolling_tests/frame_with_nested_scrolling_frame_out_of_view.html')
355354
footer = driver.find_element(tag_name: 'footer')
356355
scroll_origin = WheelActions::ScrollOrigin.element(footer, 0, -50)
@@ -387,7 +386,8 @@ module WebDriver
387386
expect(in_viewport?(checkbox)).to be true
388387
end
389388

390-
it 'raises MoveTargetOutOfBoundsError when origin offset is out of viewport' do
389+
it 'raises MoveTargetOutOfBoundsError when origin offset is out of viewport',
390+
only: {browser: %i[chrome edge firefox]} do
391391
driver.navigate.to url_for('scrolling_tests/frame_with_nested_scrolling_frame.html')
392392
scroll_origin = WheelActions::ScrollOrigin.viewport(-10, -10)
393393

Diff for: rb/spec/integration/selenium/webdriver/bidi_spec.rb

+5-3
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ module WebDriver
3636
expect(status.message).not_to be_empty
3737
end
3838

39-
it 'can navigate and listen to errors', except: {browser: %i[chrome edge], reason: 'not yet implemented'} do
39+
it 'can navigate and listen to errors' do
4040
log_entry = nil
4141
log_inspector = BiDi::LogInspector.new(driver)
4242
log_inspector.on_javascript_exception { |log| log_entry = log }
@@ -45,10 +45,12 @@ module WebDriver
4545
info = browsing_context.navigate(url: url_for('/bidi/logEntryAdded.html'))
4646

4747
expect(browsing_context.id).not_to be_nil
48-
expect(info.navigation_id).to be_nil
48+
expect(info.navigation_id).not_to be_nil
4949
expect(info.url).to include('/bidi/logEntryAdded.html')
5050

51-
driver.find_element(id: 'jsException').click
51+
js_exception = wait.until { driver.find_element(id: 'jsException') }
52+
js_exception.click
53+
5254
wait.until { !log_entry.nil? }
5355

5456
expect(log_entry).to have_attributes(

Diff for: rb/spec/integration/selenium/webdriver/chrome/driver_spec.rb

+2-4
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,8 @@ module Chrome
5252
end
5353

5454
describe 'PrintsPage' do
55-
before(:all) do
56-
@headless = ENV.delete('HEADLESS')
57-
reset_driver!(args: ['--headless'])
58-
end
55+
before(:all) { @headless = ENV.delete('HEADLESS') }
56+
before { reset_driver!(args: ['--headless']) }
5957

6058
after(:all) do
6159
quit_driver

Diff for: rb/spec/integration/selenium/webdriver/driver_spec.rb

+3-2
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ module WebDriver
2424
describe Driver do
2525
it_behaves_like 'driver that can be started concurrently', exclude: {browser: %i[safari safari_preview]}
2626

27-
it 'creates default capabilities' do
27+
it 'creates default capabilities', exclude: {browser: %i[safari safari_preview]} do
2828
reset_driver! do |driver|
2929
caps = driver.capabilities
3030
expect(caps.proxy).to be_nil
@@ -147,7 +147,8 @@ module WebDriver
147147
}.to raise_error(Error::NoSuchElementError, /errors#no-such-element-exception/)
148148
end
149149

150-
it 'raises if invalid locator' do
150+
it 'raises if invalid locator',
151+
exclude: {browser: %i[safari safari_preview], reason: 'Safari raises TimeoutError'} do
151152
driver.navigate.to url_for('xhtmlTest.html')
152153
expect {
153154
driver.find_element(xpath: '*?//-')

Diff for: rb/spec/integration/selenium/webdriver/firefox/driver_spec.rb

+1-3
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,9 @@ module Firefox
4444
page: {width: 30})).to include(magic_number)
4545
end
4646

47-
it 'prints full page', except: [{ci: :github,
48-
platform: :windows,
47+
it 'prints full page', except: [{platform: :windows,
4948
reason: 'Some issues with resolution?'},
5049
{platform: :macosx,
51-
headless: true,
5250
reason: 'showing half resolution of what expected'}] do
5351
viewport_width = driver.execute_script('return window.innerWidth;')
5452
viewport_height = driver.execute_script('return window.innerHeight;')

Diff for: rb/spec/integration/selenium/webdriver/manager_spec.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -134,15 +134,15 @@ module WebDriver
134134
end
135135

136136
describe 'sameSite' do
137-
it 'allows adding with value Strict', only: {browser: %i[chrome edge firefox]} do
137+
it 'allows adding with value Strict' do
138138
driver.manage.add_cookie name: 'samesite',
139139
value: 'strict',
140140
same_site: 'Strict'
141141

142142
expect(driver.manage.cookie_named('samesite')[:same_site]).to eq('Strict')
143143
end
144144

145-
it 'allows adding with value Lax', only: {browser: %i[chrome edge firefox]} do
145+
it 'allows adding with value Lax' do
146146
driver.manage.add_cookie name: 'samesite',
147147
value: 'lax',
148148
same_site: 'Lax'

Diff for: rb/spec/integration/selenium/webdriver/safari/driver_spec.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,13 @@ module Safari
3636
Safari.use_technology_preview = nil
3737
end
3838

39-
it 'sets before options', exclusive: {browser: :safari} do
39+
it 'sets before options', exclusive: {browser: :safari_preview} do
4040
Safari.technology_preview!
4141
local_driver = WebDriver.for :safari
4242
expect(local_driver.capabilities.browser_name).to eq 'Safari Technology Preview'
4343
end
4444

45-
it 'sets after options' do
45+
it 'sets after options', exclusive: {browser: :safari_preview} do
4646
options = Options.safari
4747
Safari.technology_preview!
4848
local_driver = WebDriver.for :safari, options: options

Diff for: rb/spec/integration/selenium/webdriver/select_spec.rb

+14-7
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,8 @@ module Support
109109
expect(selected_options).to include(driver.find_element(css: 'option[value="onion gravy"]'))
110110
end
111111

112-
it 'errors when option disabled' do
112+
it 'errors when option disabled',
113+
exclude: {browser: :safari, reason: 'Safari raises no exception with disabled'} do
113114
expect {
114115
multi_disabled.select_by(:text, 'Disabled')
115116
}.to raise_exception(Error::UnsupportedOperationError)
@@ -137,7 +138,8 @@ module Support
137138
expect(selected_options).to include(driver.find_element(css: 'option[value=ham]'))
138139
end
139140

140-
it 'errors when option disabled' do
141+
it 'errors when option disabled',
142+
exclude: {browser: :safari, reason: 'Safari raises no exception with disabled'} do
141143
expect { multi_disabled.select_by(:index, 1) }.to raise_exception(Error::UnsupportedOperationError)
142144
end
143145

@@ -163,7 +165,8 @@ module Support
163165
expect(selected_options).to include(driver.find_element(css: 'option[value=ham]'))
164166
end
165167

166-
it 'errors when option disabled' do
168+
it 'errors when option disabled',
169+
exclude: {browser: :safari, reason: 'Safari raises no exception with disabled'} do
167170
expect {
168171
multi_disabled.select_by(:value, 'disabled')
169172
}.to raise_exception(Error::UnsupportedOperationError)
@@ -197,7 +200,8 @@ module Support
197200
expect(select.selected_options).to eq([expected_option])
198201
end
199202

200-
it 'errors when option disabled' do
203+
it 'errors when option disabled',
204+
exclude: {browser: :safari, reason: 'Safari raises no exception with disabled'} do
201205
expect {
202206
single_disabled.select_by(:text, 'Disabled')
203207
}.to raise_exception(Error::UnsupportedOperationError)
@@ -223,7 +227,8 @@ module Support
223227
expect(selected_options).to eq([driver.find_element(css: 'option[value="two"]')])
224228
end
225229

226-
it 'errors when option disabled' do
230+
it 'errors when option disabled',
231+
exclude: {browser: :safari, reason: 'Safari raises no exception with disabled'} do
227232
expect { single_disabled.select_by(:index, 1) }.to raise_exception(Error::UnsupportedOperationError)
228233
end
229234

@@ -247,7 +252,8 @@ module Support
247252
expect(selected_options).to eq([driver.find_element(css: 'option[value="two"]')])
248253
end
249254

250-
it 'errors when option disabled' do
255+
it 'errors when option disabled',
256+
exclude: {browser: :safari, reason: 'Safari raises no exception with disabled'} do
251257
expect {
252258
single_disabled.select_by(:value, 'disabled')
253259
}.to raise_exception(Error::UnsupportedOperationError)
@@ -345,7 +351,8 @@ module Support
345351
expect { select.select_all }.to raise_exception(Error::UnsupportedOperationError)
346352
end
347353

348-
it 'raises exception if select contains disabled options' do
354+
it 'raises exception if select contains disabled options',
355+
exclude: {browser: :safari, reason: 'Safari raises no exception with disabled'} do
349356
select = described_class.new(driver.find_element(name: 'multi_disabled'))
350357

351358
expect { select.select_all }.to raise_exception(Error::UnsupportedOperationError)

Diff for: rb/spec/integration/selenium/webdriver/shadow_root_spec.rb

+8-7
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121

2222
module Selenium
2323
module WebDriver
24-
describe ShadowRoot, only: {browser: %i[chrome firefox edge]} do
24+
describe ShadowRoot, only: {browser: %i[chrome firefox edge safari]} do
2525
before { driver.navigate.to url_for('webComponents.html') }
2626

2727
let(:custom_element) { driver.find_element(css: 'custom-checkbox-element') }
@@ -31,13 +31,14 @@ module WebDriver
3131
expect(shadow_root).to be_a described_class
3232
end
3333

34-
it 'raises error if no shadow root' do
34+
it 'raises error if no shadow root', exclude: {browser: :safari, reason: 'NoMethodError'} do
3535
driver.navigate.to url_for('simpleTest.html')
3636
div = driver.find_element(css: 'div')
3737
expect { div.shadow_root }.to raise_error(Error::NoSuchShadowRootError)
3838
end
3939

40-
it 'gets shadow root from script' do
40+
it 'gets shadow root from script',
41+
exclude: {browser: :safari, reason: 'returns correct node, but references shadow root as a element'} do
4142
shadow_root = custom_element.shadow_root
4243
execute_shadow_root = driver.execute_script('return arguments[0].shadowRoot;', custom_element)
4344
expect(execute_shadow_root).to eq shadow_root
@@ -51,7 +52,7 @@ module WebDriver
5152
expect(element).to be_a Element
5253
end
5354

54-
it 'by xpath', except: {browser: %i[chrome edge firefox],
55+
it 'by xpath', except: {browser: %i[chrome edge firefox safari],
5556
reason: 'https://bugs.chromium.org/p/chromedriver/issues/detail?id=4097'} do
5657
shadow_root = custom_element.shadow_root
5758
element = shadow_root.find_element(xpath: "//input[type='checkbox']")
@@ -73,7 +74,7 @@ module WebDriver
7374
expect(element).to be_a Element
7475
end
7576

76-
it 'by tag name', except: {browser: %i[chrome edge firefox],
77+
it 'by tag name', except: {browser: %i[chrome edge firefox safari],
7778
reason: 'https://bugs.chromium.org/p/chromedriver/issues/detail?id=4097'} do
7879
shadow_root = custom_element.shadow_root
7980
element = shadow_root.find_element(tag_name: 'input')
@@ -97,7 +98,7 @@ module WebDriver
9798
expect(elements.first).to be_a Element
9899
end
99100

100-
it 'by xpath', except: {browser: %i[chrome edge firefox],
101+
it 'by xpath', except: {browser: %i[chrome edge firefox safari],
101102
reason: 'https://bugs.chromium.org/p/chromedriver/issues/detail?id=4097'} do
102103
shadow_root = custom_element.shadow_root
103104
elements = shadow_root.find_elements(xpath: "//input[type='checkbox']")
@@ -122,7 +123,7 @@ module WebDriver
122123
expect(elements.first).to be_a Element
123124
end
124125

125-
it 'by tag name', except: {browser: %i[chrome edge firefox],
126+
it 'by tag name', except: {browser: %i[chrome edge firefox safari],
126127
reason: 'https://bugs.chromium.org/p/chromedriver/issues/detail?id=4097'} do
127128
shadow_root = custom_element.shadow_root
128129
elements = shadow_root.find_elements(tag_name: 'input')

Diff for: rb/spec/integration/selenium/webdriver/spec_support/shared_examples/concurrent_driver.rb

+2-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@
2323

2424
before { quit_driver }
2525

26-
after do
26+
after do |example|
27+
skip if example.metadata[:skip]
2728
drivers.each(&:quit)
2829
threads.select(&:alive?).each(&:kill)
2930
create_driver!

Diff for: rb/spec/integration/selenium/webdriver/takes_screenshot_spec.rb

+1-3
Original file line numberDiff line numberDiff line change
@@ -95,11 +95,9 @@ def save_screenshot_and_assert(source, path)
9595
expect(height).to be <= viewport_height
9696
end
9797

98-
it 'takes full page screenshot', except: [{ci: :github,
99-
platform: :windows,
98+
it 'takes full page screenshot', except: [{platform: :windows,
10099
reason: 'Some issues with resolution?'},
101100
{platform: :macosx,
102-
headless: true,
103101
reason: 'showing half resolution of what expected'}],
104102
exclusive: {browser: :firefox} do
105103
viewport_width = driver.execute_script('return window.innerWidth;')

0 commit comments

Comments
 (0)