Skip to content

Commit

Permalink
[rb] get Safari tests passing on Mac, including correctly specifying …
Browse files Browse the repository at this point in the history
…browser name for technology preview
  • Loading branch information
titusfortner committed Jul 11, 2020
1 parent b30f9a6 commit dd7090c
Show file tree
Hide file tree
Showing 8 changed files with 18 additions and 9 deletions.
4 changes: 3 additions & 1 deletion rb/lib/selenium/webdriver/remote/capabilities.rb
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,10 @@ def firefox(opts = {})
alias_method :ff, :firefox

def safari(opts = {})
browser = Selenium::WebDriver::Safari.technology_preview? ? "Safari Technology Preview" : 'safari'

new({
browser_name: 'safari',
browser_name: browser,
platform_name: :mac
}.merge(opts))
end
Expand Down
7 changes: 7 additions & 0 deletions rb/lib/selenium/webdriver/safari.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,19 @@ module Safari
autoload :Service, 'selenium/webdriver/safari/service'

class << self
attr_accessor :use_technology_preview

def technology_preview
"/Applications/Safari\ Technology\ Preview.app/Contents/MacOS/safaridriver"
end

def technology_preview!
Service.driver_path = technology_preview
@use_technology_preview = true
end

def technology_preview?
use_technology_preview
end

def path=(path)
Expand Down
4 changes: 2 additions & 2 deletions rb/spec/integration/selenium/webdriver/action_builder_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ module WebDriver
expect(keylogger.text.strip).to match(/^(focus )?keydown keydown keypress keyup keydown keypress keyup keyup$/)
end

it 'can press and release modifier keys', except: {browser: %i[edge safari_preview]} do
it 'can press and release modifier keys', except: {browser: %i[edge safari]} do
driver.navigate.to url_for('javascriptPage.html')

event_input = driver.find_element(id: 'theworks')
Expand Down Expand Up @@ -102,7 +102,7 @@ module WebDriver
expect(input.attribute(:value)).to eq('abcd')
end

it 'can release pressed keys via release action', except: {browser: :safari_preview} do
it 'can release pressed keys via release action', except: {browser: :safari} do
driver.navigate.to url_for('javascriptPage.html')

event_input = driver.find_element(id: 'theworks')
Expand Down
2 changes: 1 addition & 1 deletion rb/spec/integration/selenium/webdriver/manager_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ module WebDriver

types = %i[tab window]
types.each do |type|
it "should be able to open a new #{type}", only: {browser: %i[safari_preview firefox ie chrome edge_chrome]} do
it "should be able to open a new #{type}" do
before_window_handles = driver.window_handles.length
driver.manage.new_window(type)
expect(driver.window_handles.length).to eq(before_window_handles + 1)
Expand Down
4 changes: 2 additions & 2 deletions rb/spec/integration/selenium/webdriver/remote/element_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ module WebDriver
driver.file_detector = nil
end

context 'when uploading one file', only: {browser: %i[chrome firefox ie]} do
context 'when uploading one file', only: {browser: %i[chrome firefox ie safari]} do
it 'uses the file detector' do
driver.navigate.to url_for('upload.html')

Expand All @@ -46,7 +46,7 @@ module WebDriver
end
end

context 'when uploading multiple files', only: {browser: %i[chrome firefox]} do
context 'when uploading multiple files', only: {browser: %i[chrome firefox safari]} do
it 'uses the file detector' do
driver.navigate.to url_for('upload_multiple.html')

Expand Down
2 changes: 1 addition & 1 deletion rb/spec/integration/selenium/webdriver/storage_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
module Selenium
module WebDriver
module DriverExtensions
describe HasWebStorage, only: {browser: %i[edge edge_chrome chrome ie firefox safari]} do
describe HasWebStorage do
shared_examples 'web storage' do
before do
driver.navigate.to url_for('clicks.html')
Expand Down
2 changes: 1 addition & 1 deletion rb/spec/integration/selenium/webdriver/timeout_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ module WebDriver
expect { driver.navigate.to url_for('sleep?time=3') }.to raise_error(WebDriver::Error::TimeoutError)
end

it 'should timeout if page takes too long to load after click' do
it 'should timeout if page takes too long to load after click', except: {browser: %i[safari safari_preview]} do
driver.navigate.to url_for('page_with_link_to_slow_loading_page.html')

expect { driver.find_element(id: 'link-to-slow-loading-page').click }.to raise_error(WebDriver::Error::TimeoutError)
Expand Down
2 changes: 1 addition & 1 deletion rb/spec/integration/selenium/webdriver/window_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ module WebDriver

# Edge: Not Yet - https://dev.windows.com/en-us/microsoft-edge/platform/status/webdriver/details/
# https://github.com/mozilla/geckodriver/issues/1281
it 'can make window full screen', only: {window_manager: true, browser: %i[chrome edge_chrome ie firefox safari_preview]},
it 'can make window full screen', only: {window_manager: true},
exclude: [{driver: :remote, browser: :firefox, platform: :linux},
{browser: %i[chrome edge_chrome]}] do
window.size = old_size = Dimension.new(700, 700)
Expand Down

0 comments on commit dd7090c

Please sign in to comment.