Skip to content

Commit

Permalink
Update tests for Safari 12.1 and Safari Technology Preview build 80
Browse files Browse the repository at this point in the history
  • Loading branch information
p0deje committed Apr 25, 2019
1 parent 22a0f94 commit d3834b5
Show file tree
Hide file tree
Showing 10 changed files with 27 additions and 21 deletions.
2 changes: 1 addition & 1 deletion rb/lib/selenium/webdriver/safari.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def technology_preview
end

def technology_preview!
self.driver_path = technology_preview
Service.driver_path = technology_preview
end

def path=(path)
Expand Down
6 changes: 3 additions & 3 deletions rb/spec/integration/selenium/webdriver/action_builder_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ module WebDriver
end

describe 'Key actions' do
it 'sends keys to the active element', except: {browser: :safari} do
it 'sends keys to the active element', except: {browser: %i[safari safari_preview]} do
driver.navigate.to url_for('bodyTypingTest.html')
keylogger = driver.find_element(id: 'body_result')

Expand All @@ -44,7 +44,7 @@ module WebDriver
expect(driver.find_element(id: 'result').text.strip).to be_empty
end

it 'can send keys with shift pressed', except: {browser: :safari} do
it 'can send keys with shift pressed', except: {browser: %i[safari safari_preview]} do
driver.navigate.to url_for('javascriptPage.html')

event_input = driver.find_element(id: 'theworks')
Expand Down Expand Up @@ -149,7 +149,7 @@ module WebDriver
expect(text).to eq('Dropped!')
end

it 'double clicks an element', except: {browser: :chrome} do
it 'double clicks an element', except: {browser: %i[chrome safari safari_preview]} do
driver.navigate.to url_for('javascriptPage.html')
element = driver.find_element(id: 'doubleClickField')

Expand Down
5 changes: 3 additions & 2 deletions rb/spec/integration/selenium/webdriver/driver_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ module Selenium
module WebDriver
describe Driver do
it_behaves_like 'driver that can be started concurrently', except: [{browser: :edge},
{driver: :safari},
{browser: :safari},
{browser: :safari_preview}]

it 'should get the page title' do
Expand Down Expand Up @@ -293,7 +293,8 @@ def save_screenshot_and_assert(path)
end

# Edge BUG - https://connect.microsoft.com/IE/feedback/details/1849991/
it 'times out if the callback is not invoked', except: [{browser: :edge}] do
# Safari raises TimeoutError instead
it 'times out if the callback is not invoked', except: {browser: %i[edge safari safari_preview]} do
expect {
# Script is expected to be async and explicitly callback, so this should timeout.
driver.execute_async_script 'return 1 + 2;'
Expand Down
13 changes: 10 additions & 3 deletions rb/spec/integration/selenium/webdriver/element_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,16 @@ module WebDriver
.to raise_error(Selenium::WebDriver::Error::UnknownError, error)
end

it 'should not raise if element is only partially covered', only: {browser: %i[safari]} do
# Safari returns "click intercepted" error instead of "element click intercepted"
it 'should raise if different element receives click', except: {browser: %i[chrome safari safari_preview]} do
driver.navigate.to url_for('click_tests/overlapping_elements.html')
expect { driver.find_element(id: 'other_contents').click }.not_to raise_error
expect { driver.find_element(id: 'contents').click }.to raise_error(Error::ElementClickInterceptedError)
end

# Safari returns "click intercepted" error instead of "element click intercepted"
it 'should raise if element is partially covered', except: {browser: %i[chrome safari safari_preview]} do
driver.navigate.to url_for('click_tests/overlapping_elements.html')
expect { driver.find_element(id: 'other_contents').click }.to raise_error(Error::ElementClickInterceptedError)
end

it 'should submit' do
Expand Down Expand Up @@ -173,7 +180,7 @@ module WebDriver
end

# IE - https://github.com/SeleniumHQ/selenium/pull/4043
it 'should drag and drop', except: {browser: %i[edge ie safari safari_preview]} do
it 'should drag and drop', except: {browser: %i[edge ie]} do
driver.navigate.to url_for('dragAndDropTest.html')

img1 = driver.find_element(id: 'test1')
Expand Down
2 changes: 1 addition & 1 deletion rb/spec/integration/selenium/webdriver/manage_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ module WebDriver
expect(driver.manage.all_cookies).to be_empty
end

it 'should use DateTime for expires', except: {browser: %i[safari safari_preview]} do
it 'should use DateTime for expires' do
driver.navigate.to url_for('xhtmlTest.html')

expected = DateTime.new(2039)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
module Selenium
module WebDriver
module Safari
describe Driver, only: {driver: :safari_preview} do
describe Driver, only: {driver: %i[safari safari_preview]} do
it 'gets and sets permissions' do
driver.permissions = {'getUserMedia' => false}
expect(driver.permissions).to eq('getUserMedia' => false)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@ def quit_driver

@driver_instance.quit
ensure
`pkill -f "Safari --automation"` if browser == :safari
@driver_instance = nil
end

Expand Down
5 changes: 2 additions & 3 deletions rb/spec/integration/selenium/webdriver/target_locator_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ module WebDriver
end

# Doesn't switch to frame by id directly
it 'should switch to a frame directly', except: {browser: %i[safari safari_preview]} do
it 'should switch to a frame directly', except: {browser: :safari} do
driver.navigate.to url_for('iframes.html')
driver.switch_to.frame('iframe1')

Expand Down Expand Up @@ -295,8 +295,7 @@ module WebDriver
expect { driver.switch_to.alert }.to raise_error(Selenium::WebDriver::Error::NoSuchAlertError)
end

# Safari - Raises wrong error
context 'unhandled alert error', except: {browser: %i[safari safari_preview]} do
context 'unhandled alert error' do
after { reset_driver! }

it 'raises an UnexpectedAlertOpenError if an alert has not been dealt with' do
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 @@ -30,7 +30,7 @@ module WebDriver

after { driver.manage.timeouts.implicit_wait = 0 }

it 'should implicitly wait for a single element', except: {browser: :edge} do
it 'should implicitly wait for a single element', except: {browser: %i[edge safari_preview]} do
driver.manage.timeouts.implicit_wait = 6

driver.find_element(id: 'adder').click
Expand Down
10 changes: 5 additions & 5 deletions rb/spec/integration/selenium/webdriver/window_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ module WebDriver
expect(pos.y).to be >= 0
end

it 'sets the position of the current window', except: {browser: :safari_preview} do
it 'sets the position of the current window' do
pos = window.position

target_x = pos.x + 10
Expand All @@ -75,7 +75,7 @@ module WebDriver
expect(new_pos.y).to eq(target_y)
end

it 'gets the rect of the current window', only: {browser: %i[firefox ie chrome]} do
it 'gets the rect of the current window', only: {browser: %i[firefox ie chrome safari safari_preview]} do
rect = window.rect

expect(rect).to be_a(Rectangle)
Expand All @@ -86,7 +86,7 @@ module WebDriver
expect(rect.height).to be >= 0
end

it 'sets the rect of the current window', only: {browser: %i[firefox ie chrome]} do
it 'sets the rect of the current window', only: {browser: %i[firefox ie chrome safari safari_preview]} do
rect = window.rect

target_x = rect.x + 10
Expand Down 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 ie firefox]},
it 'can make window full screen', only: {window_manager: true, browser: %i[chrome ie firefox safari_preview]},
exclude: [{driver: :remote, browser: :firefox, platform: :linux}, {browser: :chrome}] do
window.size = old_size = Dimension.new(200, 200)

Expand All @@ -132,7 +132,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 minimize the window', only: {window_manager: true, browser: %i[ie firefox]},
it 'can minimize the window', only: {window_manager: true, browser: %i[ie firefox safari safari_preview]},
exclude: {driver: :remote, browser: :firefox, platform: :linux} do
window.minimize
expect(driver.execute_script('return document.hidden;')).to be true
Expand Down

0 comments on commit d3834b5

Please sign in to comment.