capybara 3.14.0 → 3.15.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/History.md +13 -0
- data/README.md +2 -1
- data/lib/capybara/node/actions.rb +37 -6
- data/lib/capybara/node/matchers.rb +10 -2
- data/lib/capybara/selector.rb +117 -1
- data/lib/capybara/selector/selector.rb +7 -0
- data/lib/capybara/selector/xpath_extensions.rb +9 -0
- data/lib/capybara/selenium/driver.rb +13 -2
- data/lib/capybara/selenium/driver_specializations/safari_driver.rb +15 -0
- data/lib/capybara/selenium/extensions/find.rb +2 -1
- data/lib/capybara/selenium/node.rb +1 -1
- data/lib/capybara/selenium/nodes/firefox_node.rb +1 -1
- data/lib/capybara/selenium/nodes/safari_node.rb +145 -0
- data/lib/capybara/spec/session/attach_file_spec.rb +46 -27
- data/lib/capybara/spec/session/click_button_spec.rb +65 -60
- data/lib/capybara/spec/session/element/matches_selector_spec.rb +40 -39
- data/lib/capybara/spec/session/fill_in_spec.rb +3 -3
- data/lib/capybara/spec/session/find_spec.rb +5 -0
- data/lib/capybara/spec/session/has_table_spec.rb +120 -0
- data/lib/capybara/spec/session/node_spec.rb +3 -3
- data/lib/capybara/spec/session/reset_session_spec.rb +8 -7
- data/lib/capybara/spec/session/window/become_closed_spec.rb +20 -17
- data/lib/capybara/spec/session/window/window_spec.rb +44 -48
- data/lib/capybara/spec/views/form.erb +5 -0
- data/lib/capybara/spec/views/tables.erb +67 -0
- data/lib/capybara/spec/views/with_html.erb +2 -2
- data/lib/capybara/spec/views/with_js.erb +1 -0
- data/lib/capybara/version.rb +1 -1
- data/spec/capybara_spec.rb +4 -4
- data/spec/css_builder_spec.rb +2 -0
- data/spec/dsl_spec.rb +13 -17
- data/spec/rack_test_spec.rb +77 -85
- data/spec/rspec/features_spec.rb +2 -0
- data/spec/rspec/shared_spec_matchers.rb +34 -35
- data/spec/rspec_spec.rb +11 -13
- data/spec/selector_spec.rb +31 -0
- data/spec/selenium_spec_chrome.rb +25 -25
- data/spec/selenium_spec_firefox.rb +62 -35
- data/spec/selenium_spec_firefox_remote.rb +2 -0
- data/spec/selenium_spec_safari.rb +148 -0
- data/spec/server_spec.rb +40 -44
- data/spec/shared_selenium_session.rb +27 -21
- data/spec/spec_helper.rb +4 -0
- data/spec/xpath_builder_spec.rb +2 -0
- metadata +7 -3
@@ -178,10 +178,10 @@ Capybara::SpecHelper.spec '#fill_in' do
|
|
178
178
|
it 'should only trigger onchange once' do
|
179
179
|
@session.visit('/with_js')
|
180
180
|
# Click somewhere on the page to ensure focus is acquired. Without this FF won't generate change events for some reason???
|
181
|
-
@session.find(:css, '
|
181
|
+
@session.find(:css, 'h1', text: 'FooBar').click
|
182
182
|
@session.fill_in('with_change_event', with: 'some value')
|
183
183
|
# click outside the field to trigger the change event
|
184
|
-
@session.find(:css, '
|
184
|
+
@session.find(:css, 'h1', text: 'FooBar').click
|
185
185
|
expect(@session.find(:css, '.change_event_triggered', match: :one)).to have_text 'some value'
|
186
186
|
end
|
187
187
|
|
@@ -189,7 +189,7 @@ Capybara::SpecHelper.spec '#fill_in' do
|
|
189
189
|
@session.visit('/with_js')
|
190
190
|
@session.fill_in('with_change_event', with: '')
|
191
191
|
# click outside the field to trigger the change event
|
192
|
-
@session.find(:css, '
|
192
|
+
@session.find(:css, 'h1', text: 'FooBar').click
|
193
193
|
expect(@session).to have_selector(:css, '.change_event_triggered', match: :one)
|
194
194
|
end
|
195
195
|
end
|
@@ -468,5 +468,10 @@ Capybara::SpecHelper.spec '#find' do
|
|
468
468
|
Capybara.test_id = 'data-other-test-id'
|
469
469
|
expect(@session.find(:field, 'test_id')[:id]).to eq 'normal'
|
470
470
|
end
|
471
|
+
|
472
|
+
it 'should find a link with the test_id' do
|
473
|
+
Capybara.test_id = 'data-test-id'
|
474
|
+
expect(@session.find(:link, 'test-foo')[:id]).to eq 'foo'
|
475
|
+
end
|
471
476
|
end
|
472
477
|
end
|
@@ -11,9 +11,115 @@ Capybara::SpecHelper.spec '#has_table?' do
|
|
11
11
|
expect(@session).to have_table(:villain_table)
|
12
12
|
end
|
13
13
|
|
14
|
+
it 'should accept rows with column header hashes' do
|
15
|
+
expect(@session).to have_table('Horizontal Headers', with_rows:
|
16
|
+
[
|
17
|
+
{ 'First Name' => 'Vern', 'Last Name' => 'Konopelski', 'City' => 'Everette' },
|
18
|
+
{ 'First Name' => 'Palmer', 'Last Name' => 'Sawayn', 'City' => 'West Trinidad' }
|
19
|
+
])
|
20
|
+
end
|
21
|
+
|
22
|
+
it 'should accept rows with partial column header hashses' do
|
23
|
+
expect(@session).to have_table('Horizontal Headers', with_rows:
|
24
|
+
[
|
25
|
+
{ 'First Name' => 'Thomas' },
|
26
|
+
{ 'Last Name' => 'Sawayn', 'City' => 'West Trinidad' }
|
27
|
+
])
|
28
|
+
end
|
29
|
+
|
30
|
+
it 'should accept rows with array of cell values' do
|
31
|
+
expect(@session).to have_table('Horizontal Headers', with_rows:
|
32
|
+
[
|
33
|
+
%w[Thomas Walpole Oceanside],
|
34
|
+
['Ratke', 'Lawrence', 'East Sorayashire']
|
35
|
+
])
|
36
|
+
end
|
37
|
+
|
38
|
+
it 'should consider order of cells in each row' do
|
39
|
+
expect(@session).not_to have_table('Horizontal Headers', with_rows:
|
40
|
+
[
|
41
|
+
%w[Thomas Walpole Oceanside],
|
42
|
+
['Lawrence', 'Ratke', 'East Sorayashire']
|
43
|
+
])
|
44
|
+
end
|
45
|
+
|
46
|
+
it 'should accept all rows with array of cell values' do
|
47
|
+
expect(@session).to have_table('Horizontal Headers', rows:
|
48
|
+
[
|
49
|
+
%w[Thomas Walpole Oceanside],
|
50
|
+
%w[Danilo Wilkinson Johnsonville],
|
51
|
+
%w[Vern Konopelski Everette],
|
52
|
+
["Ratke", "Lawrence", "East Sorayashire"],
|
53
|
+
["Palmer", "Sawayn", "West Trinidad"]
|
54
|
+
])
|
55
|
+
end
|
56
|
+
|
57
|
+
it 'should match with vertical headers' do
|
58
|
+
expect(@session).to have_table('Vertical Headers', with_cols:
|
59
|
+
[
|
60
|
+
{ 'First Name' => 'Thomas' },
|
61
|
+
{ 'First Name' => 'Danilo', 'Last Name' => 'Wilkinson', 'City' => 'Johnsonville' },
|
62
|
+
{ 'Last Name' => 'Sawayn', 'City' => 'West Trinidad' }
|
63
|
+
])
|
64
|
+
end
|
65
|
+
|
66
|
+
it 'should match col with array of cell values' do
|
67
|
+
expect(@session).to have_table('Vertical Headers', with_cols:
|
68
|
+
[
|
69
|
+
%w[Vern Konopelski Everette]
|
70
|
+
])
|
71
|
+
end
|
72
|
+
|
73
|
+
it 'should match cols with array of cell values' do
|
74
|
+
expect(@session).to have_table('Vertical Headers', with_cols:
|
75
|
+
[
|
76
|
+
%w[Danilo Wilkinson Johnsonville],
|
77
|
+
%w[Vern Konopelski Everette]
|
78
|
+
])
|
79
|
+
end
|
80
|
+
|
81
|
+
it 'should match all cols with array of cell values' do
|
82
|
+
expect(@session).to have_table('Vertical Headers', cols:
|
83
|
+
[
|
84
|
+
%w[Thomas Walpole Oceanside],
|
85
|
+
%w[Danilo Wilkinson Johnsonville],
|
86
|
+
%w[Vern Konopelski Everette],
|
87
|
+
["Ratke", "Lawrence", "East Sorayashire"],
|
88
|
+
["Palmer", "Sawayn", "West Trinidad"]
|
89
|
+
])
|
90
|
+
end
|
91
|
+
|
92
|
+
it "should not match if the order of cell values doesn't match" do
|
93
|
+
expect(@session).not_to have_table('Vertical Headers', with_cols:
|
94
|
+
[
|
95
|
+
%w[Vern Everette Konopelski]
|
96
|
+
])
|
97
|
+
end
|
98
|
+
|
99
|
+
it "should not match with vertical headers if the columns don't match" do
|
100
|
+
expect(@session).not_to have_table('Vertical Headers', with_cols:
|
101
|
+
[
|
102
|
+
{ 'First Name' => 'Thomas' },
|
103
|
+
{ 'First Name' => 'Danilo', 'Last Name' => 'Walpole', 'City' => 'Johnsonville' },
|
104
|
+
{ 'Last Name' => 'Sawayn', 'City' => 'West Trinidad' }
|
105
|
+
])
|
106
|
+
end
|
107
|
+
|
14
108
|
it 'should be false if the table is not on the page' do
|
15
109
|
expect(@session).not_to have_table('Monkey')
|
16
110
|
end
|
111
|
+
|
112
|
+
it 'should find row by header and cell values' do
|
113
|
+
expect(@session.find(:table, 'Horizontal Headers')).to have_selector(:table_row, 'First Name' => 'Thomas', 'Last Name' => 'Walpole')
|
114
|
+
expect(@session.find(:table, 'Horizontal Headers')).to have_selector(:table_row, 'Last Name' => 'Walpole')
|
115
|
+
expect(@session.find(:table, 'Horizontal Headers')).not_to have_selector(:table_row, 'First Name' => 'Walpole')
|
116
|
+
end
|
117
|
+
|
118
|
+
it 'should find row by cell values' do
|
119
|
+
expect(@session.find(:table, 'Horizontal Headers')).to have_selector(:table_row, %w[Thomas Walpole])
|
120
|
+
expect(@session.find(:table, 'Horizontal Headers')).not_to have_selector(:table_row, %w[Walpole Thomas])
|
121
|
+
expect(@session.find(:table, 'Horizontal Headers')).not_to have_selector(:table_row, %w[Other])
|
122
|
+
end
|
17
123
|
end
|
18
124
|
|
19
125
|
Capybara::SpecHelper.spec '#has_no_table?' do
|
@@ -29,4 +135,18 @@ Capybara::SpecHelper.spec '#has_no_table?' do
|
|
29
135
|
it 'should be true if the table is not on the page' do
|
30
136
|
expect(@session).to have_no_table('Monkey')
|
31
137
|
end
|
138
|
+
|
139
|
+
it 'should consider rows' do
|
140
|
+
expect(@session).to have_no_table('Horizontal Headers', with_rows:
|
141
|
+
[
|
142
|
+
{ 'First Name' => 'Thomas', 'City' => 'Los Angeles' }
|
143
|
+
])
|
144
|
+
end
|
145
|
+
|
146
|
+
it 'should consider columns' do
|
147
|
+
expect(@session).to have_no_table('Vertical Headers', with_cols:
|
148
|
+
[
|
149
|
+
{ 'First Name' => 'Joe' }
|
150
|
+
])
|
151
|
+
end
|
32
152
|
end
|
@@ -25,9 +25,9 @@ Capybara::SpecHelper.spec 'node' do
|
|
25
25
|
|
26
26
|
describe '#query_scope' do
|
27
27
|
it 'should have a reference to the element the query was evaluated on if there is one' do
|
28
|
-
|
29
|
-
expect(
|
30
|
-
expect(
|
28
|
+
node = @session.find(:css, '#first')
|
29
|
+
expect(node.query_scope).to eq(node.session.document)
|
30
|
+
expect(node.find(:css, '#foo').query_scope).to eq(node)
|
31
31
|
end
|
32
32
|
end
|
33
33
|
|
@@ -96,25 +96,26 @@ Capybara::SpecHelper.spec '#reset_session!' do
|
|
96
96
|
end
|
97
97
|
|
98
98
|
context 'When reuse_server == false' do
|
99
|
+
let!(:orig_reuse_server) { Capybara.reuse_server }
|
100
|
+
|
99
101
|
before do
|
100
|
-
@reuse_server = Capybara.reuse_server
|
101
102
|
Capybara.reuse_server = false
|
102
103
|
end
|
103
104
|
|
104
105
|
after do
|
105
|
-
Capybara.reuse_server =
|
106
|
+
Capybara.reuse_server = orig_reuse_server
|
106
107
|
end
|
107
108
|
|
108
109
|
it 'raises any standard errors caught inside the server during a second session', requires: [:server] do
|
109
110
|
Capybara.using_driver(@session.mode) do
|
110
111
|
Capybara.using_session(:another_session) do
|
111
|
-
|
112
|
-
quietly {
|
112
|
+
another_session = Capybara.current_session
|
113
|
+
quietly { another_session.visit('/error') }
|
113
114
|
expect do
|
114
|
-
|
115
|
+
another_session.reset_session!
|
115
116
|
end.to raise_error(TestApp::TestAppError)
|
116
|
-
|
117
|
-
expect(
|
117
|
+
another_session.visit('/')
|
118
|
+
expect(another_session.current_path).to eq('/')
|
118
119
|
end
|
119
120
|
end
|
120
121
|
end
|
@@ -1,38 +1,41 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
Capybara::SpecHelper.spec '#become_closed', requires: %i[windows js] do
|
4
|
-
|
5
|
-
|
6
|
-
@session.
|
7
|
-
@other_window = @session.window_opened_by do
|
4
|
+
let!(:window) { @session.current_window }
|
5
|
+
let(:other_window) do
|
6
|
+
@session.window_opened_by do
|
8
7
|
@session.find(:css, '#openWindow').click
|
9
8
|
end
|
10
9
|
end
|
11
10
|
|
11
|
+
before do
|
12
|
+
@session.visit('/with_windows')
|
13
|
+
end
|
14
|
+
|
12
15
|
after do
|
13
16
|
@session.document.synchronize(5, errors: [Capybara::CapybaraError]) do
|
14
17
|
raise Capybara::CapybaraError if @session.windows.size != 1
|
15
18
|
end
|
16
|
-
@session.switch_to_window(
|
19
|
+
@session.switch_to_window(window)
|
17
20
|
end
|
18
21
|
|
19
22
|
context 'with :wait option' do
|
20
23
|
it 'should wait if value of :wait is more than timeout' do
|
21
|
-
@session.within_window
|
24
|
+
@session.within_window other_window do
|
22
25
|
@session.execute_script('setTimeout(function(){ window.close(); }, 500);')
|
23
26
|
end
|
24
27
|
Capybara.using_wait_time 0.1 do
|
25
|
-
expect(
|
28
|
+
expect(other_window).to become_closed(wait: 5)
|
26
29
|
end
|
27
30
|
end
|
28
31
|
|
29
32
|
it 'should raise error if value of :wait is less than timeout' do
|
30
|
-
@session.within_window
|
33
|
+
@session.within_window other_window do
|
31
34
|
@session.execute_script('setTimeout(function(){ window.close(); }, 1000);')
|
32
35
|
end
|
33
36
|
Capybara.using_wait_time 2 do
|
34
37
|
expect do
|
35
|
-
expect(
|
38
|
+
expect(other_window).to become_closed(wait: 0.2)
|
36
39
|
end.to raise_error(RSpec::Expectations::ExpectationNotMetError, /\Aexpected #<Window @handle=".+"> to become closed after 0.2 seconds\Z/)
|
37
40
|
end
|
38
41
|
end
|
@@ -40,21 +43,21 @@ Capybara::SpecHelper.spec '#become_closed', requires: %i[windows js] do
|
|
40
43
|
|
41
44
|
context 'without :wait option' do
|
42
45
|
it 'should wait if value of default_max_wait_time is more than timeout' do
|
43
|
-
@session.within_window
|
46
|
+
@session.within_window other_window do
|
44
47
|
@session.execute_script('setTimeout(function(){ window.close(); }, 500);')
|
45
48
|
end
|
46
49
|
Capybara.using_wait_time 5 do
|
47
|
-
expect(
|
50
|
+
expect(other_window).to become_closed
|
48
51
|
end
|
49
52
|
end
|
50
53
|
|
51
54
|
it 'should raise error if value of default_max_wait_time is less than timeout' do
|
52
|
-
@session.within_window
|
55
|
+
@session.within_window other_window do
|
53
56
|
@session.execute_script('setTimeout(function(){ window.close(); }, 900);')
|
54
57
|
end
|
55
58
|
Capybara.using_wait_time 0.4 do
|
56
59
|
expect do
|
57
|
-
expect(
|
60
|
+
expect(other_window).to become_closed
|
58
61
|
end.to raise_error(RSpec::Expectations::ExpectationNotMetError, /\Aexpected #<Window @handle=".+"> to become closed after 0.4 seconds\Z/)
|
59
62
|
end
|
60
63
|
end
|
@@ -62,23 +65,23 @@ Capybara::SpecHelper.spec '#become_closed', requires: %i[windows js] do
|
|
62
65
|
|
63
66
|
context 'with not_to' do
|
64
67
|
it "should not raise error if window doesn't close before default_max_wait_time" do
|
65
|
-
@session.within_window
|
68
|
+
@session.within_window other_window do
|
66
69
|
@session.execute_script('setTimeout(function(){ window.close(); }, 1000);')
|
67
70
|
end
|
68
71
|
Capybara.using_wait_time 0.3 do
|
69
72
|
expect do
|
70
|
-
expect(
|
73
|
+
expect(other_window).not_to become_closed
|
71
74
|
end.not_to raise_error
|
72
75
|
end
|
73
76
|
end
|
74
77
|
|
75
78
|
it 'should raise error if window closes before default_max_wait_time' do
|
76
|
-
@session.within_window
|
79
|
+
@session.within_window other_window do
|
77
80
|
@session.execute_script('setTimeout(function(){ window.close(); }, 700);')
|
78
81
|
end
|
79
82
|
Capybara.using_wait_time 3.1 do
|
80
83
|
expect do
|
81
|
-
expect(
|
84
|
+
expect(other_window).not_to become_closed
|
82
85
|
end.to raise_error(RSpec::Expectations::ExpectationNotMetError, /\Aexpected #<Window @handle=".+"> not to become closed after 3.1 seconds\Z/)
|
83
86
|
end
|
84
87
|
end
|
@@ -5,89 +5,87 @@
|
|
5
5
|
# using Capybara provided assertions with builtin waiting behavior.
|
6
6
|
|
7
7
|
Capybara::SpecHelper.spec Capybara::Window, requires: [:windows] do
|
8
|
+
let!(:orig_window) { @session.current_window }
|
8
9
|
before do
|
9
|
-
@window = @session.current_window
|
10
10
|
@session.visit('/with_windows')
|
11
11
|
end
|
12
12
|
|
13
13
|
after do
|
14
|
-
(@session.windows - [
|
14
|
+
(@session.windows - [orig_window]).each do |w|
|
15
15
|
@session.switch_to_window w
|
16
16
|
w.close
|
17
17
|
end
|
18
|
-
@session.switch_to_window(
|
18
|
+
@session.switch_to_window(orig_window)
|
19
19
|
end
|
20
20
|
|
21
21
|
describe '#exists?' do
|
22
|
-
|
23
|
-
|
22
|
+
it 'should become false after window was closed' do
|
23
|
+
other_window = @session.window_opened_by do
|
24
24
|
@session.find(:css, '#openWindow').click
|
25
25
|
end
|
26
|
-
end
|
27
26
|
|
28
|
-
it 'should become false after window was closed' do
|
29
27
|
expect do
|
30
|
-
@session.switch_to_window
|
31
|
-
|
32
|
-
end.to change
|
28
|
+
@session.switch_to_window other_window
|
29
|
+
other_window.close
|
30
|
+
end.to change(other_window, :exists?).from(true).to(false)
|
33
31
|
end
|
34
32
|
end
|
35
33
|
|
36
34
|
describe '#closed?' do
|
37
35
|
it 'should become true after window was closed' do
|
38
|
-
|
36
|
+
other_window = @session.window_opened_by do
|
39
37
|
@session.find(:css, '#openWindow').click
|
40
38
|
end
|
41
39
|
expect do
|
42
|
-
@session.switch_to_window
|
43
|
-
|
44
|
-
end.to change {
|
40
|
+
@session.switch_to_window other_window
|
41
|
+
other_window.close
|
42
|
+
end.to change { other_window.closed? }.from(false).to(true)
|
45
43
|
end
|
46
44
|
end
|
47
45
|
|
48
46
|
describe '#current?' do
|
49
|
-
|
50
|
-
@
|
47
|
+
let(:other_window) do
|
48
|
+
@session.window_opened_by do
|
51
49
|
@session.find(:css, '#openWindow').click
|
52
50
|
end
|
53
51
|
end
|
54
52
|
|
55
53
|
it 'should become true after switching to window' do
|
56
54
|
expect do
|
57
|
-
@session.switch_to_window(
|
58
|
-
end.to change
|
55
|
+
@session.switch_to_window(other_window)
|
56
|
+
end.to change(other_window, :current?).from(false).to(true)
|
59
57
|
end
|
60
58
|
|
61
59
|
it 'should return false if window is closed' do
|
62
|
-
@session.switch_to_window(
|
63
|
-
|
64
|
-
expect(
|
60
|
+
@session.switch_to_window(other_window)
|
61
|
+
other_window.close
|
62
|
+
expect(other_window.current?).to eq(false)
|
65
63
|
end
|
66
64
|
end
|
67
65
|
|
68
66
|
describe '#close' do
|
69
|
-
|
70
|
-
@
|
67
|
+
let!(:other_window) do
|
68
|
+
@session.window_opened_by do
|
71
69
|
@session.find(:css, '#openWindow').click
|
72
70
|
end
|
73
71
|
end
|
74
72
|
|
75
73
|
it 'should switch to original window if invoked not for current window' do
|
76
74
|
expect(@session.windows.size).to eq(2)
|
77
|
-
expect(@session.current_window).to eq(
|
78
|
-
|
75
|
+
expect(@session.current_window).to eq(orig_window)
|
76
|
+
other_window.close
|
79
77
|
expect(@session.windows.size).to eq(1)
|
80
|
-
expect(@session.current_window).to eq(
|
78
|
+
expect(@session.current_window).to eq(orig_window)
|
81
79
|
end
|
82
80
|
|
83
81
|
it 'should make subsequent invocations of other methods raise no_such_window_error if invoked for current window' do
|
84
|
-
@session.switch_to_window(
|
85
|
-
expect(@session.current_window).to eq(
|
86
|
-
|
82
|
+
@session.switch_to_window(other_window)
|
83
|
+
expect(@session.current_window).to eq(other_window)
|
84
|
+
other_window.close
|
87
85
|
expect do
|
88
86
|
@session.find(:css, '#some_id')
|
89
87
|
end.to raise_error(@session.driver.no_such_window_error)
|
90
|
-
@session.switch_to_window(
|
88
|
+
@session.switch_to_window(orig_window)
|
91
89
|
end
|
92
90
|
end
|
93
91
|
|
@@ -101,43 +99,41 @@ Capybara::SpecHelper.spec Capybara::Window, requires: [:windows] do
|
|
101
99
|
end
|
102
100
|
|
103
101
|
it 'should switch to original window if invoked not for current window' do
|
104
|
-
|
102
|
+
other_window = @session.window_opened_by do
|
105
103
|
@session.find(:css, '#openWindow').click
|
106
104
|
end
|
107
105
|
sleep 1
|
108
|
-
size = @session.within_window(
|
106
|
+
size = @session.within_window(other_window) do
|
109
107
|
win_size
|
110
108
|
end
|
111
|
-
expect(
|
112
|
-
expect(@session.current_window).to eq(
|
109
|
+
expect(other_window.size).to eq(size)
|
110
|
+
expect(@session.current_window).to eq(orig_window)
|
113
111
|
end
|
114
112
|
end
|
115
113
|
|
116
114
|
describe '#resize_to' do
|
117
|
-
|
118
|
-
@initial_size = @session.current_window.size
|
119
|
-
end
|
115
|
+
let!(:initial_size) { @session.current_window.size }
|
120
116
|
|
121
117
|
after do
|
122
|
-
@session.current_window.resize_to(
|
118
|
+
@session.current_window.resize_to(*initial_size)
|
123
119
|
sleep 1
|
124
120
|
end
|
125
121
|
|
126
122
|
it 'should be able to resize window', requires: %i[windows js] do
|
127
|
-
width, height =
|
123
|
+
width, height = initial_size
|
128
124
|
@session.current_window.resize_to(width - 100, height - 100)
|
129
125
|
sleep 1
|
130
126
|
expect(@session.current_window.size).to eq([width - 100, height - 100])
|
131
127
|
end
|
132
128
|
|
133
129
|
it 'should stay on current window if invoked not for current window', requires: %i[windows js] do
|
134
|
-
|
130
|
+
other_window = @session.window_opened_by do
|
135
131
|
@session.find(:css, '#openWindow').click
|
136
132
|
end
|
137
|
-
|
138
|
-
expect(@session.current_window).to eq(
|
133
|
+
other_window.resize_to(600, 300)
|
134
|
+
expect(@session.current_window).to eq(orig_window)
|
139
135
|
|
140
|
-
@session.within_window(
|
136
|
+
@session.within_window(other_window) do
|
141
137
|
expect(@session.current_window.size).to eq([600, 300])
|
142
138
|
end
|
143
139
|
end
|
@@ -169,19 +165,19 @@ Capybara::SpecHelper.spec Capybara::Window, requires: [:windows] do
|
|
169
165
|
end
|
170
166
|
|
171
167
|
it 'should stay on current window if invoked not for current window', requires: %i[windows js] do
|
172
|
-
|
168
|
+
other_window = @session.window_opened_by do
|
173
169
|
@session.find(:css, '#openWindow').click
|
174
170
|
end
|
175
|
-
|
171
|
+
other_window.resize_to(400, 300)
|
176
172
|
sleep 0.5
|
177
|
-
|
173
|
+
other_window.maximize
|
178
174
|
sleep 0.5 # The timing on maximize is finicky on Travis -- wait a bit for maximize to occur
|
179
175
|
|
180
|
-
expect(@session.current_window).to eq(
|
176
|
+
expect(@session.current_window).to eq(orig_window)
|
181
177
|
# Maximizing the browser affects all tabs so this may not be valid in real browsers
|
182
178
|
# expect(@session.current_window.size).to eq(@initial_size)
|
183
179
|
|
184
|
-
ow_width, ow_height =
|
180
|
+
ow_width, ow_height = other_window.size
|
185
181
|
expect(ow_width).to be > 400
|
186
182
|
expect(ow_height).to be > 300
|
187
183
|
end
|