Skip to content

Commit acda925

Browse files
committed
[rb] update tests for safari and firefox on mac
1 parent 808d4b6 commit acda925

13 files changed

Lines changed: 204 additions & 188 deletions

File tree

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

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -195,10 +195,13 @@ module WebDriver
195195
expect(driver.execute_script('return true;')).to eq(true)
196196
end
197197

198-
not_compliant_on browser: [:chrome, :phantomjs, :edge] do
199-
it 'should raise if the script is bad' do
200-
driver.navigate.to url_for('xhtmlTest.html')
201-
expect { driver.execute_script('return squiggle();') }.to raise_error(Selenium::WebDriver::Error::JavascriptError)
198+
# https://github.com/SeleniumHQ/selenium/issues/3337
199+
not_compliant_on driver: :remote, platform: :macosx do
200+
not_compliant_on browser: [:chrome, :phantomjs, :edge] do
201+
it 'should raise if the script is bad' do
202+
driver.navigate.to url_for('xhtmlTest.html')
203+
expect { driver.execute_script('return squiggle();') }.to raise_error(Selenium::WebDriver::Error::JavascriptError)
204+
end
202205
end
203206
end
204207

@@ -270,13 +273,16 @@ module WebDriver
270273
end
271274

272275
# Edge BUG - https://connect.microsoft.com/IE/feedback/details/1849991/
276+
# https://bugzilla.mozilla.org/show_bug.cgi?id=1329559
273277
not_compliant_on browser: :edge do
274-
not_compliant_on driver: :remote, browser: :firefox do
275-
it 'times out if the callback is not invoked' do
276-
expect do
277-
# Script is expected to be async and explicitly callback, so this should timeout.
278-
driver.execute_async_script 'return 1 + 2;'
279-
end.to raise_error(Selenium::WebDriver::Error::ScriptTimeoutError)
278+
not_compliant_on browser: :firefox do
279+
not_compliant_on driver: :remote, platform: :macosx do
280+
it 'times out if the callback is not invoked' do
281+
expect do
282+
# Script is expected to be async and explicitly callback, so this should timeout.
283+
driver.execute_async_script 'return 1 + 2;'
284+
end.to raise_error(Selenium::WebDriver::Error::ScriptTimeoutError)
285+
end
280286
end
281287
end
282288
end

rb/spec/integration/selenium/webdriver/element_spec.rb

Lines changed: 26 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,14 @@ module WebDriver
2828
end
2929

3030
compliant_on browser: [:chrome, :ff_legacy] do
31-
it 'should raise if different element receives click' do
32-
driver.navigate.to url_for('click_tests/overlapping_elements.html')
33-
element_error = 'Other element would receive the click: <div id="over"><\/div>'
34-
error = /is not clickable at point \(\d+, \d+\)\. #{element_error}/
35-
expect { driver.find_element(id: 'contents').click }
36-
.to raise_error(Selenium::WebDriver::Error::UnknownError, error)
31+
not_compliant_on driver: :remote, platform: :macosx do
32+
it 'should raise if different element receives click' do
33+
driver.navigate.to url_for('click_tests/overlapping_elements.html')
34+
element_error = 'Other element would receive the click: <div id="over"><\/div>'
35+
error = /is not clickable at point \(\d+, \d+\)\. #{element_error}/
36+
expect { driver.find_element(id: 'contents').click }
37+
.to raise_error(Selenium::WebDriver::Error::UnknownError, error)
38+
end
3739
end
3840
end
3941

@@ -140,32 +142,29 @@ module WebDriver
140142
end
141143
end
142144

143-
# Remote w3c bug: https://github.com/SeleniumHQ/selenium/issues/2857
144-
not_compliant_on driver: :remote, browser: :firefox do
145-
context 'size and location' do
146-
it 'should get current location' do
147-
driver.navigate.to url_for('xhtmlTest.html')
148-
loc = driver.find_element(class: 'header').location
145+
context 'size and location' do
146+
it 'should get current location' do
147+
driver.navigate.to url_for('xhtmlTest.html')
148+
loc = driver.find_element(class: 'header').location
149149

150-
expect(loc.x).to be >= 1
151-
expect(loc.y).to be >= 1
152-
end
150+
expect(loc.x).to be >= 1
151+
expect(loc.y).to be >= 1
152+
end
153153

154-
it 'should get location once scrolled into view' do
155-
driver.navigate.to url_for('javascriptPage.html')
156-
loc = driver.find_element(id: 'keyUp').location_once_scrolled_into_view
154+
it 'should get location once scrolled into view' do
155+
driver.navigate.to url_for('javascriptPage.html')
156+
loc = driver.find_element(id: 'keyUp').location_once_scrolled_into_view
157157

158-
expect(loc.x).to be >= 1
159-
expect(loc.y).to be >= 0 # can be 0 if scrolled to the top
160-
end
158+
expect(loc.x).to be >= 1
159+
expect(loc.y).to be >= 0 # can be 0 if scrolled to the top
160+
end
161161

162-
it 'should get size' do
163-
driver.navigate.to url_for('xhtmlTest.html')
164-
size = driver.find_element(class: 'header').size
162+
it 'should get size' do
163+
driver.navigate.to url_for('xhtmlTest.html')
164+
size = driver.find_element(class: 'header').size
165165

166-
expect(size.width).to be > 0
167-
expect(size.height).to be > 0
168-
end
166+
expect(size.width).to be > 0
167+
expect(size.height).to be > 0
169168
end
170169
end
171170

rb/spec/integration/selenium/webdriver/error_spec.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@
2121

2222
module Selenium
2323
module WebDriver
24-
not_compliant_on driver: :remote, browser: :firefox do
24+
# https://github.com/SeleniumHQ/selenium/issues/3338
25+
not_compliant_on driver: :remote, platform: :macosx do
2526
describe Error do
2627
it 'should raise an appropriate error' do
2728
driver.navigate.to url_for('xhtmlTest.html')
@@ -31,8 +32,7 @@ module WebDriver
3132
end.to raise_error(WebDriver::Error::NoSuchElementError)
3233
end
3334

34-
compliant_on({browser: :ff_legacy},
35-
{driver: :remote, browser: :firefox}) do
35+
compliant_on browser: :ff_legacy do
3636
it 'should show stack trace information' do
3737
driver.navigate.to url_for('xhtmlTest.html')
3838

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

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -110,11 +110,8 @@ def restart_remote_server
110110
end
111111
end
112112

113-
# https://github.com/mozilla/geckodriver/issues/58
114-
not_compliant_on browser: :not_firefox do
115-
context 'when shared example' do
116-
it_behaves_like 'driver that can be started concurrently', :firefox
117-
end
113+
context 'when shared example' do
114+
it_behaves_like 'driver that can be started concurrently', :firefox
118115
end
119116
end
120117
end

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

Lines changed: 24 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -154,30 +154,33 @@ def profile_opts
154154
expect(string).to include('user_pref("network.proxy.type", 4)')
155155
end
156156

157-
describe 'with browser' do
158-
before(:each) do
159-
profile['browser.startup.homepage'] = url_for('simpleTest.html')
160-
profile['browser.startup.page'] = 1
161-
end
157+
# https://github.com/SeleniumHQ/selenium/issues/3338
158+
not_compliant_on driver: :remote, platform: :macosx do
159+
describe 'with browser' do
160+
before(:each) do
161+
profile['browser.startup.homepage'] = url_for('simpleTest.html')
162+
profile['browser.startup.page'] = 1
163+
end
162164

163-
it 'should instantiate the browser with the correct profile' do
164-
begin
165-
driver1 = WebDriver.for(browser, profile_opts.dup)
166-
expect { wait(5).until { driver1.find_element(id: 'oneline') } }.to_not raise_error
167-
ensure
168-
driver1.quit
165+
it 'should instantiate the browser with the correct profile' do
166+
begin
167+
driver1 = WebDriver.for(browser, profile_opts.dup)
168+
expect { wait(5).until { driver1.find_element(id: 'oneline') } }.to_not raise_error
169+
ensure
170+
driver1.quit
171+
end
169172
end
170-
end
171173

172-
it 'should be able to use the same profile more than once' do
173-
begin
174-
driver1 = WebDriver.for(browser, profile_opts.dup)
175-
expect { wait(5).until { driver1.find_element(id: 'oneline') } }.to_not raise_error
176-
driver2 = WebDriver.for(browser, profile_opts.dup)
177-
expect { wait(5).until { driver2.find_element(id: 'oneline') } }.to_not raise_error
178-
ensure
179-
driver1.quit if driver1
180-
driver2.quit if driver2
174+
it 'should be able to use the same profile more than once' do
175+
begin
176+
driver1 = WebDriver.for(browser, profile_opts.dup)
177+
expect { wait(5).until { driver1.find_element(id: 'oneline') } }.to_not raise_error
178+
driver2 = WebDriver.for(browser, profile_opts.dup)
179+
expect { wait(5).until { driver2.find_element(id: 'oneline') } }.to_not raise_error
180+
ensure
181+
driver1.quit if driver1
182+
driver2.quit if driver2
183+
end
181184
end
182185
end
183186
end

rb/spec/integration/selenium/webdriver/mouse_spec.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ module WebDriver
2727
it 'clicks an element' do
2828
driver.navigate.to url_for('formPage.html')
2929
driver.mouse.click driver.find_element(id: 'imageButton')
30+
expect(driver.title).to eq 'We Arrive Here'
3031
end
3132

3233
it 'can drag and drop' do

rb/spec/integration/selenium/webdriver/options_spec.rb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121

2222
module Selenium
2323
module WebDriver
24-
# Safari bug - no logs or cookies
2524
not_compliant_on browser: :safari do
2625
describe Options do
2726
not_compliant_on browser: [:firefox, :ie, :edge] do
@@ -78,7 +77,7 @@ module WebDriver
7877
end
7978

8079
# Firefox - https://bugzilla.mozilla.org/show_bug.cgi?id=1282970
81-
not_compliant_on browser: :firefox do
80+
not_compliant_on driver: :firefox do
8281
it 'should get named cookie' do
8382
driver.navigate.to url_for('xhtmlTest.html')
8483
driver.manage.add_cookie name: 'foo', value: 'bar'

rb/spec/integration/selenium/webdriver/spec_support/shared_examples/concurrent_driver.rb

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -31,20 +31,10 @@
3131
threads = []
3232
drivers = []
3333

34-
opt = {}
35-
driver = if GlobalTestEnv.remote_server?
36-
opt[:url] = GlobalTestEnv.remote_server.webdriver_url
37-
:remote
38-
else
39-
browser_name
40-
end
41-
42-
caps = WebDriver::Remote::Capabilities.send(browser_name, caps_opt)
43-
opt[:desired_capabilities] = caps
4434

4535
5.times do
4636
threads << Thread.new do
47-
drivers << Selenium::WebDriver.for(driver, opt.dup)
37+
drivers << GlobalTestEnv.send(:create_driver)
4838
end
4939
end
5040

rb/spec/integration/selenium/webdriver/spec_support/test_environment.rb

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,12 @@ def initialize
2828
@create_driver_error = nil
2929
@create_driver_error_count = 0
3030

31-
@driver = (ENV['WD_SPEC_DRIVER'] || :chrome).to_sym
31+
@driver = (ENV['WD_SPEC_DRIVER'] || :remote).to_sym
3232
end
3333

3434
def browser
3535
if driver == :remote
36-
(ENV['WD_REMOTE_BROWSER'] || :chrome).to_sym
36+
(ENV['WD_REMOTE_BROWSER'] || :safari).to_sym
3737
else
3838
driver
3939
end
@@ -143,6 +143,11 @@ def remote_capabilities
143143

144144
caps = WebDriver::Remote::Capabilities.send(browser_name, opt)
145145

146+
if browser_name == :safari
147+
tech_preview_driver = "/Applications/Safari\ Technology\ Preview.app/Contents/MacOS/safaridriver"
148+
caps["safari.options"] = {'technologyPreview' => true} if File.exist?(tech_preview_driver)
149+
end
150+
146151
unless caps.is_a? WebDriver::Remote::W3CCapabilities
147152
caps.javascript_enabled = true
148153
caps.css_selectors_enabled = true
@@ -227,8 +232,12 @@ def create_phantomjs_driver
227232
end
228233

229234
def create_safari_driver
230-
WebDriver::Safari.driver_path = ENV['SAFARIDRIVER'] if ENV['SAFARIDRIVER']
231-
WebDriver::Driver.for :safari
235+
driver_path = ENV['SAFARIDRIVER']
236+
tech_preview_driver = "/Applications/Safari\ Technology\ Preview.app/Contents/MacOS/safaridriver"
237+
driver_path ||= tech_preview_driver if File.exist?(tech_preview_driver)
238+
239+
caps = Selenium::WebDriver::Remote::Capabilities.safari
240+
WebDriver::Driver.for :safari, desired_capabilities: caps, driver_path: driver_path
232241
end
233242

234243
def keep_alive_client

rb/spec/integration/selenium/webdriver/storage_spec.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ module WebDriver
2424
module DriverExtensions
2525
describe HasWebStorage do
2626
compliant_on browser: [:chrome, :firefox] do
27+
# TODO - Find out what settings for turning on web storage in remote server
2728
not_compliant_on driver: :remote, browser: :firefox do
2829
shared_examples_for 'web storage' do
2930
before do

0 commit comments

Comments
 (0)