spec/watirspec/window_switching_spec.rb in watir-7.0.0.beta5 vs spec/watirspec/window_switching_spec.rb in watir-7.0.0
- old
+ new
@@ -400,37 +400,39 @@
end
context 'manipulating size and position', except: {headless: true} do
before do
browser.goto WatirSpec.url_for('window_switching.html')
+ @initial_size = browser.window.size
end
- it 'should get the size of the current window' do
- size = browser.window.size
+ after do
+ browser.window.resize_to @initial_size.width, @initial_size.height
+ end
- expect(size.width).to eq browser.execute_script('return window.outerWidth;')
- expect(size.height).to eq browser.execute_script('return window.outerHeight;')
+ it 'should get the size of the current window' do
+ expect(@initial_size.width).to eq browser.execute_script('return window.outerWidth;')
+ expect(@initial_size.height).to eq browser.execute_script('return window.outerHeight;')
end
it 'should get the position of the current window' do
pos = browser.window.position
expect(pos.x).to eq browser.execute_script('return window.screenX;')
expect(pos.y).to eq browser.execute_script('return window.screenY;')
end
it 'should resize the window' do
- initial_size = browser.window.size
browser.window.resize_to(
- initial_size.width - 20,
- initial_size.height - 20
+ @initial_size.width - 20,
+ @initial_size.height - 20
)
new_size = browser.window.size
- expect(new_size.width).to eq initial_size.width - 20
- expect(new_size.height).to eq initial_size.height - 20
+ expect(new_size.width).to eq @initial_size.width - 20
+ expect(new_size.height).to eq @initial_size.height - 20
end
it 'should move the window' do
initial_pos = browser.window.position
@@ -443,23 +445,47 @@
expect(new_pos.x).to eq initial_pos.x + 2
expect(new_pos.y).to eq initial_pos.y + 2
end
it 'should maximize the window', except: {browser: :firefox, window_manager: false} do
- initial_size = browser.window.size
browser.window.resize_to(
- initial_size.width - 40,
- initial_size.height - 40
+ @initial_size.width - 40,
+ @initial_size.height - 40
)
- browser.wait_until { |b| b.window.size != initial_size }
+ browser.wait_until { |b| b.window.size != @initial_size }
new_size = browser.window.size
browser.window.maximize
browser.wait_until { |b| b.window.size != new_size }
final_size = browser.window.size
expect(final_size.width).to be >= new_size.width
- expect(final_size.height).to be > (new_size.height)
+ expect(final_size.height).to be > new_size.height
+ end
+
+ it 'should make the window full screen', except: {browser: :firefox, window_manager: false} do
+ browser.window.resize_to(
+ @initial_size.width - 40,
+ @initial_size.height - 40
+ )
+ new_size = browser.window.size
+
+ browser.window.full_screen
+ browser.wait_until { |b| b.window.size != new_size }
+
+ final_size = browser.window.size
+ expect(final_size.width).to be >= new_size.width
+ expect(final_size.height).to be > new_size.height
+ end
+
+ it 'should minimize the window', except: {window_manager: false} do
+ expect(browser.execute_script('return document.visibilityState;')).to eq 'visible'
+
+ browser.window.minimize
+
+ browser.wait_until { |b| b.execute_script('return document.visibilityState;') != 'visible' }
+
+ expect(browser.execute_script('return document.visibilityState;')).to eq 'hidden'
end
end
end
describe Watir::WindowCollection do