Skip to content

Commit

Permalink
[rb] Add macos coverage to Ruby CI Github Action (#12556)
Browse files Browse the repository at this point in the history
* 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 <titusfortner@users.noreply.github.com>
Co-authored-by: titusfortner <titus.fortner@gmail.com>
  • Loading branch information
3 people committed Sep 13, 2023
1 parent 4092a86 commit e518273
Show file tree
Hide file tree
Showing 14 changed files with 73 additions and 45 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/bazel.yml
Expand Up @@ -119,6 +119,9 @@ jobs:
uses: browser-actions/setup-edge@latest
with:
edge-version: ${{ inputs.browser-version || 'stable' }}
- name: Setup Safari
if: inputs.browser == 'safari'
run: sudo safaridriver --enable
- name: Run Bazel
run: ${{ inputs.run }}
- name: Start SSH session
Expand Down
18 changes: 18 additions & 0 deletions .github/workflows/ci-ruby.yml
Expand Up @@ -45,6 +45,8 @@ jobs:
os: windows
- ruby-version: 3.2.0
os: ubuntu
- ruby-version: 3.2.0
os: macos
- ruby-version: jruby-9.4.0.0
os: ubuntu
- ruby-version: truffleruby-22.3.0
Expand All @@ -67,12 +69,20 @@ jobs:
- chrome
- edge
- firefox
- safari
os:
- ubuntu
- windows
- macos
exclude:
- browser: edge
os: ubuntu
- browser: edge
os: macos
- browser: safari
os: ubuntu
- browser: safari
os: windows
with:
name: Local Tests (${{ matrix.browser }}, ${{ matrix.os }})
browser: ${{ matrix.browser }}
Expand All @@ -96,12 +106,20 @@ jobs:
- chrome
- edge
- firefox
- safari
os:
- ubuntu
- windows
- macos
exclude:
- browser: edge
os: ubuntu
- browser: edge
os: macos
- browser: safari
os: ubuntu
- browser: safari
os: windows
with:
name: Remote Tests (${{ matrix.browser }}, ${{ matrix.os }})
browser: ${{ matrix.browser }}
Expand Down
20 changes: 10 additions & 10 deletions rb/spec/integration/selenium/webdriver/action_builder_spec.rb
Expand Up @@ -163,7 +163,7 @@ module WebDriver
expect(element.attribute(:value)).to eq('DoubleClicked')
end

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

Expand Down Expand Up @@ -203,8 +203,7 @@ module WebDriver
end

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

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

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

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

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

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

Expand Down
8 changes: 5 additions & 3 deletions rb/spec/integration/selenium/webdriver/bidi_spec.rb
Expand Up @@ -36,7 +36,7 @@ module WebDriver
expect(status.message).not_to be_empty
end

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

expect(browsing_context.id).not_to be_nil
expect(info.navigation_id).to be_nil
expect(info.navigation_id).not_to be_nil
expect(info.url).to include('/bidi/logEntryAdded.html')

driver.find_element(id: 'jsException').click
js_exception = wait.until { driver.find_element(id: 'jsException') }
js_exception.click

wait.until { !log_entry.nil? }

expect(log_entry).to have_attributes(
Expand Down
6 changes: 2 additions & 4 deletions rb/spec/integration/selenium/webdriver/chrome/driver_spec.rb
Expand Up @@ -52,10 +52,8 @@ module Chrome
end

describe 'PrintsPage' do
before(:all) do
@headless = ENV.delete('HEADLESS')
reset_driver!(args: ['--headless'])
end
before(:all) { @headless = ENV.delete('HEADLESS') }
before { reset_driver!(args: ['--headless']) }

after(:all) do
quit_driver
Expand Down
5 changes: 3 additions & 2 deletions rb/spec/integration/selenium/webdriver/driver_spec.rb
Expand Up @@ -24,7 +24,7 @@ module WebDriver
describe Driver do
it_behaves_like 'driver that can be started concurrently', exclude: {browser: %i[safari safari_preview]}

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

it 'raises if invalid locator' do
it 'raises if invalid locator',
exclude: {browser: %i[safari safari_preview], reason: 'Safari raises TimeoutError'} do
driver.navigate.to url_for('xhtmlTest.html')
expect {
driver.find_element(xpath: '*?//-')
Expand Down
Expand Up @@ -44,11 +44,9 @@ module Firefox
page: {width: 30})).to include(magic_number)
end

it 'prints full page', except: [{ci: :github,
platform: :windows,
it 'prints full page', except: [{platform: :windows,
reason: 'Some issues with resolution?'},
{platform: :macosx,
headless: true,
reason: 'showing half resolution of what expected'}] do
viewport_width = driver.execute_script('return window.innerWidth;')
viewport_height = driver.execute_script('return window.innerHeight;')
Expand Down
4 changes: 2 additions & 2 deletions rb/spec/integration/selenium/webdriver/manager_spec.rb
Expand Up @@ -134,15 +134,15 @@ module WebDriver
end

describe 'sameSite' do
it 'allows adding with value Strict', only: {browser: %i[chrome edge firefox]} do
it 'allows adding with value Strict' do
driver.manage.add_cookie name: 'samesite',
value: 'strict',
same_site: 'Strict'

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

it 'allows adding with value Lax', only: {browser: %i[chrome edge firefox]} do
it 'allows adding with value Lax' do
driver.manage.add_cookie name: 'samesite',
value: 'lax',
same_site: 'Lax'
Expand Down
4 changes: 2 additions & 2 deletions rb/spec/integration/selenium/webdriver/safari/driver_spec.rb
Expand Up @@ -36,13 +36,13 @@ module Safari
Safari.use_technology_preview = nil
end

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

it 'sets after options' do
it 'sets after options', exclusive: {browser: :safari_preview} do
options = Options.safari
Safari.technology_preview!
local_driver = WebDriver.for :safari, options: options
Expand Down
21 changes: 14 additions & 7 deletions rb/spec/integration/selenium/webdriver/select_spec.rb
Expand Up @@ -109,7 +109,8 @@ module Support
expect(selected_options).to include(driver.find_element(css: 'option[value="onion gravy"]'))
end

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

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

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

it 'errors when option disabled' do
it 'errors when option disabled',
exclude: {browser: :safari, reason: 'Safari raises no exception with disabled'} do
expect {
multi_disabled.select_by(:value, 'disabled')
}.to raise_exception(Error::UnsupportedOperationError)
Expand Down Expand Up @@ -197,7 +200,8 @@ module Support
expect(select.selected_options).to eq([expected_option])
end

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

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

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

it 'errors when option disabled' do
it 'errors when option disabled',
exclude: {browser: :safari, reason: 'Safari raises no exception with disabled'} do
expect {
single_disabled.select_by(:value, 'disabled')
}.to raise_exception(Error::UnsupportedOperationError)
Expand Down Expand Up @@ -345,7 +351,8 @@ module Support
expect { select.select_all }.to raise_exception(Error::UnsupportedOperationError)
end

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

expect { select.select_all }.to raise_exception(Error::UnsupportedOperationError)
Expand Down
15 changes: 8 additions & 7 deletions rb/spec/integration/selenium/webdriver/shadow_root_spec.rb
Expand Up @@ -21,7 +21,7 @@

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

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

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

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

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

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

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

it 'by tag name', except: {browser: %i[chrome edge firefox],
it 'by tag name', except: {browser: %i[chrome edge firefox safari],
reason: 'https://bugs.chromium.org/p/chromedriver/issues/detail?id=4097'} do
shadow_root = custom_element.shadow_root
elements = shadow_root.find_elements(tag_name: 'input')
Expand Down
Expand Up @@ -23,7 +23,8 @@

before { quit_driver }

after do
after do |example|
skip if example.metadata[:skip]
drivers.each(&:quit)
threads.select(&:alive?).each(&:kill)
create_driver!
Expand Down
Expand Up @@ -95,11 +95,9 @@ def save_screenshot_and_assert(source, path)
expect(height).to be <= viewport_height
end

it 'takes full page screenshot', except: [{ci: :github,
platform: :windows,
it 'takes full page screenshot', except: [{platform: :windows,
reason: 'Some issues with resolution?'},
{platform: :macosx,
headless: true,
reason: 'showing half resolution of what expected'}],
exclusive: {browser: :firefox} do
viewport_width = driver.execute_script('return window.innerWidth;')
Expand Down

0 comments on commit e518273

Please sign in to comment.