Skip to content

Commit 4969102

Browse files
luke-hillp0deje
authored andcommitted
Optimised some of the calls to some ruby integration tests
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>
1 parent e18a249 commit 4969102

File tree

3 files changed

+12
-11
lines changed

3 files changed

+12
-11
lines changed

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,15 +56,15 @@ def driver_instance
5656
def reset_driver!(time = 0)
5757
quit_driver
5858
sleep time
59-
@driver_instance = create_driver!
59+
driver_instance
6060
end
6161

6262
def ensure_single_window
63-
@driver_instance.window_handles[1..-1].each do |handle|
64-
@driver_instance.switch_to.window(handle)
65-
@driver_instance.close
63+
driver_instance.window_handles[1..-1].each do |handle|
64+
driver_instance.switch_to.window(handle)
65+
driver_instance.close
6666
end
67-
@driver_instance.switch_to.window @driver_instance.window_handles.first
67+
driver_instance.switch_to.window(driver_instance.window_handles.first)
6868
end
6969

7070
def quit_driver

rb/spec/integration/selenium/webdriver/target_locator_spec.rb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,7 @@ module WebDriver
6363
end
6464

6565
context 'window switching' do
66-
67-
after { reset_driver! }
66+
after { quit_driver }
6867

6968
it 'should switch to a window and back when given a block' do
7069
driver.navigate.to url_for('xhtmlTest.html')

rb/spec/integration/selenium/webdriver/window_spec.rb

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ module WebDriver
2222
describe Window do
2323
after do
2424
sleep 1 if ENV['TRAVIS']
25-
reset_driver!
25+
quit_driver
2626
end
2727

2828
let(:window) { driver.manage.window }
@@ -50,7 +50,7 @@ module WebDriver
5050
end
5151

5252
it 'gets the position of the current window' do
53-
pos = driver.manage.window.position
53+
pos = window.position
5454

5555
expect(pos).to be_a(Point)
5656

@@ -74,7 +74,7 @@ module WebDriver
7474
end
7575

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

7979
expect(rect).to be_a(Rectangle)
8080

@@ -121,8 +121,10 @@ module WebDriver
121121
old_size = window.size
122122

123123
window.full_screen
124-
124+
wait.until { window.size != old_size }
125125
new_size = window.size
126+
127+
expect(new_size.width).to be > old_size.width
126128
expect(new_size.height).to be > old_size.height
127129
end
128130

0 commit comments

Comments
 (0)