Skip to content

Commit

Permalink
Optimised some of the calls to some ruby integration tests
Browse files Browse the repository at this point in the history
Note the plan was to migrate more of these over, but after reading some comments I opted against it. This change should only remove the need for the duplicate window creation on a few tests, where it was un-necessary

Signed-off-by: Alex Rodionov <p0deje@gmail.com>
  • Loading branch information
luke-hill authored and p0deje committed Feb 2, 2018
1 parent e18a249 commit 4969102
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,15 +56,15 @@ def driver_instance
def reset_driver!(time = 0)
quit_driver
sleep time
@driver_instance = create_driver!
driver_instance
end

def ensure_single_window
@driver_instance.window_handles[1..-1].each do |handle|
@driver_instance.switch_to.window(handle)
@driver_instance.close
driver_instance.window_handles[1..-1].each do |handle|
driver_instance.switch_to.window(handle)
driver_instance.close
end
@driver_instance.switch_to.window @driver_instance.window_handles.first
driver_instance.switch_to.window(driver_instance.window_handles.first)
end

def quit_driver
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,7 @@ module WebDriver
end

context 'window switching' do

after { reset_driver! }
after { quit_driver }

it 'should switch to a window and back when given a block' do
driver.navigate.to url_for('xhtmlTest.html')
Expand Down
10 changes: 6 additions & 4 deletions rb/spec/integration/selenium/webdriver/window_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ module WebDriver
describe Window do
after do
sleep 1 if ENV['TRAVIS']
reset_driver!
quit_driver
end

let(:window) { driver.manage.window }
Expand Down Expand Up @@ -50,7 +50,7 @@ module WebDriver
end

it 'gets the position of the current window' do
pos = driver.manage.window.position
pos = window.position

expect(pos).to be_a(Point)

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

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

expect(rect).to be_a(Rectangle)

Expand Down Expand Up @@ -121,8 +121,10 @@ module WebDriver
old_size = window.size

window.full_screen

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
end

Expand Down

0 comments on commit 4969102

Please sign in to comment.