Skip to content

Commit

Permalink
rb - update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
titusfortner committed Oct 2, 2016
1 parent 3bfa1f7 commit 7e2cca5
Show file tree
Hide file tree
Showing 6 changed files with 97 additions and 86 deletions.
5 changes: 5 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ env:
- TASK=rb TARGET=firefox-test
- TASK=rb TARGET=ff-legacy-test
- TASK=rb TARGET=phantomjs-test
- TASK=rb TARGET=remote-chrome-test
- TASK=rb TARGET=remote-firefox-test
- TASK=rb TARGET=remote-ff-legacy-test
- TASK=rb TARGET=remote-phantomjs-test
- TASK=py TOXENV=py27-chrome
- TASK=py TOXENV=py27-firefox
- TASK=py TOXENV=py27-marionette
Expand All @@ -31,6 +35,7 @@ matrix:
- env: TASK=py TOXENV=py27-chrome
- env: TASK=py TOXENV=py27-firefox
- env: TASK=py TOXENV=py27-marionette
- env: TASK=rb TARGET=remote-firefox-test
before_script:
- sh -e /etc/init.d/xvfb start
script:
Expand Down
4 changes: 1 addition & 3 deletions rb/spec/integration/selenium/webdriver/driver_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -273,9 +273,7 @@ module WebDriver
end

# Edge BUG - https://connect.microsoft.com/IE/feedback/details/1849991/
# Firefox - https://github.com/SeleniumHQ/selenium/issues/2554
not_compliant_on({driver: :remote, browser: :firefox},
{browser: :edge}) do
not_compliant_on browser: :edge do
it 'times out if the callback is not invoked' do
expect do
# Script is expected to be async and explicitly callback, so this should timeout.
Expand Down
49 changes: 27 additions & 22 deletions rb/spec/integration/selenium/webdriver/element_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -133,28 +133,33 @@ module WebDriver
end
end

it 'should get location' do
driver.navigate.to url_for('xhtmlTest.html')
loc = driver.find_element(class: 'header').location

expect(loc.x).to be >= 1
expect(loc.y).to be >= 1
end

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

expect(loc.x).to be >= 1
expect(loc.y).to be >= 0 # can be 0 if scrolled to the top
end

it 'should get size' do
driver.navigate.to url_for('xhtmlTest.html')
size = driver.find_element(class: 'header').size

expect(size.width).to be > 0
expect(size.height).to be > 0
# Remote w3c bug: https://github.com/SeleniumHQ/selenium/issues/2857
not_compliant_on driver: :remote, browser: :firefox do
context 'size and location' do
it 'should get current location' do
driver.navigate.to url_for('xhtmlTest.html')
loc = driver.find_element(class: 'header').location

expect(loc.x).to be >= 1
expect(loc.y).to be >= 1
end

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

expect(loc.x).to be >= 1
expect(loc.y).to be >= 0 # can be 0 if scrolled to the top
end

it 'should get size' do
driver.navigate.to url_for('xhtmlTest.html')
size = driver.find_element(class: 'header').size

expect(size.width).to be > 0
expect(size.height).to be > 0
end
end
end

# Firefox - "Actions Endpoint Not Yet Implemented"
Expand Down
8 changes: 4 additions & 4 deletions rb/spec/integration/selenium/webdriver/firefox/driver_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ def restart_remote_server
it 'takes a binary path as an argument' do
pending "Set ENV['ALT_FIREFOX_BINARY'] to test this" unless ENV['ALT_FIREFOX_BINARY']
begin
@path = Firefox::Binary.path
driver1 = Selenium::WebDriver.for GlobalTestEnv.driver, @opt.dup

default_version = driver1.capabilities.version
Expand All @@ -82,13 +83,14 @@ def restart_remote_server
expect { driver2.capabilities.browser_version }.to_not raise_exception NoMethodError
driver2.quit
ensure
Firefox::Binary.reset_path!
Firefox::Binary.path = @path
end
end

it 'gives precedence to firefox options versus argument switch' do
pending "Set ENV['ALT_FIREFOX_BINARY'] to test this" unless ENV['ALT_FIREFOX_BINARY']
begin
@path = Firefox::Binary.path
driver1 = Selenium::WebDriver.for GlobalTestEnv.driver, @opt.dup

default_path = Firefox::Binary.path
Expand All @@ -104,11 +106,9 @@ def restart_remote_server
expect { driver2.capabilities.browser_version }.to_not raise_exception NoMethodError
driver2.quit
ensure
Firefox::Binary.reset_path!
Firefox::Binary.path = @path
end

end

end

# https://github.com/mozilla/geckodriver/issues/58
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -227,8 +227,8 @@ def create_phantomjs_driver
end

def create_safari_driver
return WebDriver::Driver.for :safari unless ENV['timeout']
WebDriver::Driver.for :safari, timeout: Integer(ENV['timeout'])
WebDriver::Safari.driver_path = ENV['SAFARIDRIVER'] if ENV['SAFARIDRIVER']
WebDriver::Driver.for :safari
end

def keep_alive_client
Expand Down
113 changes: 58 additions & 55 deletions rb/spec/integration/selenium/webdriver/window_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,86 +21,89 @@

module Selenium
module WebDriver
describe Window do
let(:window) { driver.manage.window }
# Remote w3c bug: https://github.com/SeleniumHQ/selenium/issues/2856
not_compliant_on driver: :remote, browser: :firefox do
describe Window do
let(:window) { driver.manage.window }

it 'gets the size of the current window' do
size = window.size
it 'gets the size of the current window' do
size = window.size

expect(size).to be_kind_of(Dimension)
expect(size).to be_kind_of(Dimension)

expect(size.width).to be > 0
expect(size.height).to be > 0
end
expect(size.width).to be > 0
expect(size.height).to be > 0
end

it 'sets the size of the current window' do
size = window.size
it 'sets the size of the current window' do
size = window.size

target_width = size.width - 20
target_height = size.height - 20
target_width = size.width - 20
target_height = size.height - 20

window.size = Dimension.new(target_width, target_height)
window.size = Dimension.new(target_width, target_height)

new_size = window.size
expect(new_size.width).to eq(target_width)
expect(new_size.height).to eq(target_height)
end
new_size = window.size
expect(new_size.width).to eq(target_width)
expect(new_size.height).to eq(target_height)
end

not_compliant_on browser: :firefox do
it 'gets the position of the current window' do
pos = driver.manage.window.position
not_compliant_on browser: :firefox do
it 'gets the position of the current window' do
pos = driver.manage.window.position

expect(pos).to be_kind_of(Point)
expect(pos).to be_kind_of(Point)

expect(pos.x).to be >= 0
expect(pos.y).to be >= 0
expect(pos.x).to be >= 0
expect(pos.y).to be >= 0
end
end
end

not_compliant_on browser: [:phantomjs, :firefox] do
it 'sets the position of the current window' do
pos = window.position
not_compliant_on browser: [:phantomjs, :firefox] do
it 'sets the position of the current window' do
pos = window.position

target_x = pos.x + 10
target_y = pos.y + 10
target_x = pos.x + 10
target_y = pos.y + 10

window.position = Point.new(target_x, target_y)
window.position = Point.new(target_x, target_y)

wait.until { window.position.x != pos.x && window.position.y != pos.y }
wait.until { window.position.x != pos.x && window.position.y != pos.y }

new_pos = window.position
expect(new_pos.x).to eq(target_x)
expect(new_pos.y).to eq(target_y)
new_pos = window.position
expect(new_pos.x).to eq(target_x)
expect(new_pos.y).to eq(target_y)
end
end
end

# TODO: - Create Window Manager guard
not_compliant_on platform: :linux do
it 'can maximize the current window' do
window.size = old_size = Dimension.new(200, 200)
# TODO: - Create Window Manager guard
not_compliant_on platform: :linux do
it 'can maximize the current window' do
window.size = old_size = Dimension.new(200, 200)

window.maximize
window.maximize

wait.until { window.size != old_size }
wait.until { window.size != old_size }

new_size = window.size
expect(new_size.width).to be > old_size.width
expect(new_size.height).to be > old_size.height
new_size = window.size
expect(new_size.width).to be > old_size.width
expect(new_size.height).to be > old_size.height
end
end
end

compliant_on browser: [:firefox, :edge] do
# Firefox - https://bugzilla.mozilla.org/show_bug.cgi?id=1189749
# Edge: Not Yet - https://dev.windows.com/en-us/microsoft-edge/platform/status/webdriver/details/
not_compliant_on browser: [:firefox, :edge] do
it 'can make window full screen' do
window.maximize
old_size = window.size
compliant_on browser: [:firefox, :edge] do
# Firefox - https://bugzilla.mozilla.org/show_bug.cgi?id=1189749
# Edge: Not Yet - https://dev.windows.com/en-us/microsoft-edge/platform/status/webdriver/details/
not_compliant_on browser: [:firefox, :edge] do
it 'can make window full screen' do
window.maximize
old_size = window.size

window.full_screen
window.full_screen

new_size = window.size
expect(new_size.height).to be > old_size.height
new_size = window.size
expect(new_size.height).to be > old_size.height
end
end
end
end
Expand Down

0 comments on commit 7e2cca5

Please sign in to comment.