capybara 2.2.1 → 2.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (107) hide show
  1. checksums.yaml +4 -4
  2. data/History.md +26 -0
  3. data/README.md +36 -14
  4. data/lib/capybara.rb +6 -3
  5. data/lib/capybara/driver/base.rb +37 -1
  6. data/lib/capybara/driver/node.rb +10 -2
  7. data/lib/capybara/helpers.rb +21 -13
  8. data/lib/capybara/node/base.rb +12 -7
  9. data/lib/capybara/node/element.rb +17 -1
  10. data/lib/capybara/node/finders.rb +22 -1
  11. data/lib/capybara/node/matchers.rb +26 -5
  12. data/lib/capybara/node/simple.rb +9 -2
  13. data/lib/capybara/rack_test/css_handlers.rb +3 -1
  14. data/lib/capybara/rack_test/form.rb +3 -2
  15. data/lib/capybara/rack_test/node.rb +3 -3
  16. data/lib/capybara/rspec.rb +1 -0
  17. data/lib/capybara/rspec/features.rb +2 -1
  18. data/lib/capybara/rspec/matchers.rb +50 -5
  19. data/lib/capybara/selenium/driver.rb +76 -12
  20. data/lib/capybara/selenium/node.rb +8 -0
  21. data/lib/capybara/server.rb +1 -1
  22. data/lib/capybara/session.rb +234 -29
  23. data/lib/capybara/spec/public/jquery.js +1 -1
  24. data/lib/capybara/spec/public/test.js +7 -0
  25. data/lib/capybara/spec/session/all_spec.rb +88 -17
  26. data/lib/capybara/spec/session/assert_selector.rb +6 -0
  27. data/lib/capybara/spec/session/attach_file_spec.rb +15 -15
  28. data/lib/capybara/spec/session/body_spec.rb +4 -4
  29. data/lib/capybara/spec/session/check_spec.rb +16 -16
  30. data/lib/capybara/spec/session/choose_spec.rb +5 -5
  31. data/lib/capybara/spec/session/click_button_spec.rb +93 -84
  32. data/lib/capybara/spec/session/click_link_or_button_spec.rb +8 -8
  33. data/lib/capybara/spec/session/click_link_spec.rb +26 -19
  34. data/lib/capybara/spec/session/current_scope_spec.rb +3 -3
  35. data/lib/capybara/spec/session/current_url_spec.rb +8 -8
  36. data/lib/capybara/spec/session/evaluate_script_spec.rb +1 -1
  37. data/lib/capybara/spec/session/execute_script_spec.rb +2 -2
  38. data/lib/capybara/spec/session/fill_in_spec.rb +22 -22
  39. data/lib/capybara/spec/session/find_button_spec.rb +4 -4
  40. data/lib/capybara/spec/session/find_by_id_spec.rb +3 -3
  41. data/lib/capybara/spec/session/find_field_spec.rb +7 -7
  42. data/lib/capybara/spec/session/find_link_spec.rb +4 -4
  43. data/lib/capybara/spec/session/find_spec.rb +46 -46
  44. data/lib/capybara/spec/session/first_spec.rb +23 -23
  45. data/lib/capybara/spec/session/go_back_spec.rb +3 -3
  46. data/lib/capybara/spec/session/go_forward_spec.rb +4 -4
  47. data/lib/capybara/spec/session/has_button_spec.rb +13 -13
  48. data/lib/capybara/spec/session/has_css_spec.rb +87 -87
  49. data/lib/capybara/spec/session/has_field_spec.rb +87 -87
  50. data/lib/capybara/spec/session/has_link_spec.rb +11 -11
  51. data/lib/capybara/spec/session/has_select_spec.rb +58 -58
  52. data/lib/capybara/spec/session/has_selector_spec.rb +48 -48
  53. data/lib/capybara/spec/session/has_table_spec.rb +7 -7
  54. data/lib/capybara/spec/session/has_text_spec.rb +73 -73
  55. data/lib/capybara/spec/session/has_title_spec.rb +10 -10
  56. data/lib/capybara/spec/session/has_xpath_spec.rb +44 -44
  57. data/lib/capybara/spec/session/headers.rb +1 -1
  58. data/lib/capybara/spec/session/html_spec.rb +9 -9
  59. data/lib/capybara/spec/session/node_spec.rb +81 -65
  60. data/lib/capybara/spec/session/reset_session_spec.rb +15 -15
  61. data/lib/capybara/spec/session/response_code.rb +1 -1
  62. data/lib/capybara/spec/session/save_and_open_screenshot_spec.rb +46 -0
  63. data/lib/capybara/spec/session/save_page_spec.rb +9 -9
  64. data/lib/capybara/spec/session/{screenshot.rb → screenshot_spec.rb} +4 -2
  65. data/lib/capybara/spec/session/select_spec.rb +22 -22
  66. data/lib/capybara/spec/session/text_spec.rb +15 -10
  67. data/lib/capybara/spec/session/title_spec.rb +2 -2
  68. data/lib/capybara/spec/session/uncheck_spec.rb +7 -7
  69. data/lib/capybara/spec/session/unselect_spec.rb +14 -14
  70. data/lib/capybara/spec/session/visit_spec.rb +24 -17
  71. data/lib/capybara/spec/session/window/become_closed_spec.rb +84 -0
  72. data/lib/capybara/spec/session/window/current_window_spec.rb +25 -0
  73. data/lib/capybara/spec/session/window/open_new_window_spec.rb +28 -0
  74. data/lib/capybara/spec/session/window/switch_to_window_spec.rb +114 -0
  75. data/lib/capybara/spec/session/window/window_opened_by_spec.rb +83 -0
  76. data/lib/capybara/spec/session/window/window_spec.rb +141 -0
  77. data/lib/capybara/spec/session/window/windows_spec.rb +31 -0
  78. data/lib/capybara/spec/session/window/within_window_spec.rb +188 -0
  79. data/lib/capybara/spec/session/within_frame_spec.rb +9 -9
  80. data/lib/capybara/spec/session/within_spec.rb +16 -16
  81. data/lib/capybara/spec/spec_helper.rb +14 -4
  82. data/lib/capybara/spec/views/form.erb +7 -0
  83. data/lib/capybara/spec/views/popup_one.erb +1 -1
  84. data/lib/capybara/spec/views/popup_two.erb +1 -1
  85. data/lib/capybara/spec/views/with_js.erb +2 -0
  86. data/lib/capybara/spec/views/with_windows.erb +38 -0
  87. data/lib/capybara/version.rb +1 -1
  88. data/lib/capybara/window.rb +123 -0
  89. data/spec/basic_node_spec.rb +32 -32
  90. data/spec/capybara_spec.rb +6 -7
  91. data/spec/dsl_spec.rb +48 -48
  92. data/spec/fixtures/selenium_driver_rspec_failure.rb +2 -2
  93. data/spec/fixtures/selenium_driver_rspec_success.rb +2 -2
  94. data/spec/rack_test_spec.rb +33 -19
  95. data/spec/result_spec.rb +13 -13
  96. data/spec/rspec/features_spec.rb +20 -15
  97. data/spec/rspec/matchers_spec.rb +109 -109
  98. data/spec/rspec_spec.rb +10 -10
  99. data/spec/selenium_spec.rb +31 -6
  100. data/spec/selenium_spec_chrome.rb +2 -2
  101. data/spec/server_spec.rb +13 -13
  102. metadata +51 -62
  103. checksums.yaml.gz.sig +0 -0
  104. data.tar.gz.sig +0 -0
  105. data/lib/capybara/spec/session/within_window_spec.rb +0 -45
  106. data/lib/capybara/spec/views/within_popups.erb +0 -25
  107. metadata.gz.sig +0 -0
@@ -0,0 +1,83 @@
1
+ Capybara::SpecHelper.spec '#window_opened_by', requires: [:windows] do
2
+ before(:each) do
3
+ @window = @session.current_window
4
+ @session.visit('/with_windows')
5
+ end
6
+ after(:each) do
7
+ (@session.windows - [@window]).each do |w|
8
+ @session.switch_to_window w
9
+ w.close
10
+ end
11
+ @session.switch_to_window(@window)
12
+ end
13
+
14
+ let(:zero_windows_message) { "block passed to #window_opened_by opened 0 windows instead of 1" }
15
+ let(:two_windows_message) { "block passed to #window_opened_by opened 2 windows instead of 1" }
16
+
17
+ context 'with :wait option' do
18
+ it 'should raise error if value of :wait is less than timeout' do
19
+ Capybara.using_wait_time 1 do
20
+ expect do
21
+ @session.window_opened_by(wait: 0.4) do
22
+ @session.find(:css, '#openWindowWithTimeout').click
23
+ end
24
+ end.to raise_error(Capybara::WindowError, zero_windows_message)
25
+ end
26
+ @session.document.synchronize(2, errors: [Capybara::CapybaraError]) do
27
+ raise Capybara::CapybaraError if @session.windows.size != 2
28
+ end
29
+ end
30
+
31
+ it 'should find window if value of :wait is more than timeout' do
32
+ Capybara.using_wait_time 0.1 do
33
+ window = @session.window_opened_by(wait: 1.5) do
34
+ @session.find(:css, '#openWindowWithTimeout').click
35
+ end
36
+ expect(window).to be_instance_of(Capybara::Window)
37
+ end
38
+ end
39
+ end
40
+
41
+ context 'without :wait option' do
42
+ it 'should raise error if default_wait_time is less than timeout' do
43
+ Capybara.using_wait_time 0.4 do
44
+ expect do
45
+ @session.window_opened_by do
46
+ @session.find(:css, '#openWindowWithTimeout').click
47
+ end
48
+ end.to raise_error(Capybara::WindowError, zero_windows_message)
49
+ end
50
+ @session.document.synchronize(2, errors: [Capybara::CapybaraError]) do
51
+ raise Capybara::CapybaraError if @session.windows.size != 2
52
+ end
53
+ end
54
+
55
+ it 'should find window if default_wait_time is more than timeout' do
56
+ Capybara.using_wait_time 1.5 do
57
+ window = @session.window_opened_by do
58
+ @session.find(:css, '#openWindowWithTimeout').click
59
+ end
60
+ expect(window).to be_instance_of(Capybara::Window)
61
+ end
62
+ end
63
+ end
64
+
65
+ it 'should raise error when two windows have been opened by block' do
66
+ expect do
67
+ @session.window_opened_by do
68
+ @session.find(:css, '#openTwoWindows').click
69
+ end
70
+ end.to raise_error(Capybara::WindowError, two_windows_message)
71
+ @session.document.synchronize(2, errors: [Capybara::CapybaraError]) do
72
+ raise Capybara::CapybaraError if @session.windows.size != 3
73
+ end
74
+ end
75
+
76
+ it 'should raise error when no windows were opened by block' do
77
+ expect do
78
+ @session.window_opened_by do
79
+ @session.find(:css, '#doesNotOpenWindows').click
80
+ end
81
+ end.to raise_error(Capybara::WindowError, zero_windows_message)
82
+ end
83
+ end
@@ -0,0 +1,141 @@
1
+ Capybara::SpecHelper.spec Capybara::Window, requires: [:windows] do
2
+ before(:each) do
3
+ @window = @session.current_window
4
+ @session.visit('/with_windows')
5
+ end
6
+ after(:each) do
7
+ (@session.windows - [@window]).each do |w|
8
+ @session.switch_to_window w
9
+ w.close
10
+ end
11
+ @session.switch_to_window(@window)
12
+ end
13
+
14
+ describe '#exists?' do
15
+ before(:each) do
16
+ @other_window = @session.window_opened_by do
17
+ @session.find(:css, '#openWindow').click
18
+ end
19
+ end
20
+
21
+ it "should become false after window was closed" do
22
+ expect do
23
+ @session.switch_to_window @other_window
24
+ @other_window.close
25
+ end.to change { @other_window.exists? }.from(true).to(false)
26
+ end
27
+ end
28
+
29
+ describe '#closed?' do
30
+ it "should become true after window was closed" do
31
+ @other_window = @session.window_opened_by do
32
+ @session.find(:css, '#openWindow').click
33
+ end
34
+ expect do
35
+ @session.switch_to_window @other_window
36
+ @other_window.close
37
+ end.to change { @other_window.closed? }.from(false).to(true)
38
+ end
39
+ end
40
+
41
+ describe '#current?' do
42
+ before(:each) do
43
+ @other_window = @session.window_opened_by do
44
+ @session.find(:css, '#openWindow').click
45
+ end
46
+ end
47
+
48
+ it 'should become true after switching to window' do
49
+ expect do
50
+ @session.switch_to_window(@other_window)
51
+ end.to change { @other_window.current? }.from(false).to(true)
52
+ end
53
+
54
+ it 'should return false if window is closed' do
55
+ @session.switch_to_window(@other_window)
56
+ @other_window.close
57
+ expect(@other_window.current?).to eq(false)
58
+ end
59
+ end
60
+
61
+ describe '#close' do
62
+ before(:each) do
63
+ @other_window = @session.window_opened_by do
64
+ @session.find(:css, '#openWindow').click
65
+ end
66
+ end
67
+
68
+ it 'should switch to original window if invoked not for current window' do
69
+ expect(@session.windows.size).to eq(2)
70
+ expect(@session.current_window).to eq(@window)
71
+ @other_window.close
72
+ expect(@session.windows.size).to eq(1)
73
+ expect(@session.current_window).to eq(@window)
74
+ end
75
+
76
+ it 'should make subsequent invocations of other methods raise no_such_window_error if invoked for current window' do
77
+ @session.switch_to_window(@other_window)
78
+ expect(@session.current_window).to eq(@other_window)
79
+ @other_window.close
80
+ expect do
81
+ @session.find(:css, '#some_id')
82
+ end.to raise_error(@session.driver.no_such_window_error)
83
+ @session.switch_to_window(@window)
84
+ end
85
+ end
86
+
87
+ describe '#size' do
88
+ it 'should return size of whole window', requires: [:js] do
89
+ expect(@session.current_window.size).to eq @session.evaluate_script("[window.outerWidth, window.outerHeight];")
90
+ end
91
+
92
+ it 'should switch to original window if invoked not for current window' do
93
+ @other_window = @session.window_opened_by do
94
+ @session.find(:css, '#openWindow').click
95
+ end
96
+ size =
97
+ @session.within_window @other_window do
98
+ @session.evaluate_script("[window.outerWidth, window.outerHeight];")
99
+ end
100
+ expect(@other_window.size).to eq(size)
101
+ expect(@session.current_window).to eq(@window)
102
+ end
103
+ end
104
+
105
+ describe '#resize_to' do
106
+ it 'should be able to resize window', requires: [:js] do
107
+ width, height = @session.evaluate_script("[window.outerWidth, window.outerHeight];")
108
+ @session.current_window.resize_to(width-10, height-10)
109
+ expect(@session.evaluate_script("[window.outerWidth, window.outerHeight];")).to eq([width-10, height-10])
110
+ end
111
+
112
+ it 'should switch to original window if invoked not for current window' do
113
+ @other_window = @session.window_opened_by do
114
+ @session.find(:css, '#openWindow').click
115
+ end
116
+ @other_window.resize_to(400, 300)
117
+ expect(@session.current_window).to eq(@window)
118
+ expect(@other_window.size).to eq([400, 300])
119
+ end
120
+ end
121
+
122
+ describe '#maximize' do
123
+ it 'should be able to maximize window', requires: [:js] do
124
+ screen_width, screen_height = @session.evaluate_script("[window.screen.availWidth, window.screen.availHeight];")
125
+ window = @session.current_window
126
+ window.resize_to(screen_width-100, screen_height-100)
127
+ expect(@session.evaluate_script("[window.outerWidth, window.outerHeight];")).to eq([screen_width-100, screen_height-100])
128
+ window.maximize
129
+ expect(@session.evaluate_script("[window.outerWidth, window.outerHeight];")).to eq([screen_width, screen_height])
130
+ end
131
+
132
+ it 'should switch to original window if invoked not for current window' do
133
+ @other_window = @session.window_opened_by do
134
+ @session.find(:css, '#openWindow').click
135
+ end
136
+ @other_window.maximize
137
+ expect(@session.current_window).to eq(@window)
138
+ expect(@other_window.size).to eq(@session.evaluate_script("[window.screen.availWidth, window.screen.availHeight];"))
139
+ end
140
+ end
141
+ end
@@ -0,0 +1,31 @@
1
+ Capybara::SpecHelper.spec '#windows', requires: [:windows] do
2
+ before(:each) do
3
+ @window = @session.current_window
4
+ @session.visit('/with_windows')
5
+ @session.find(:css, '#openTwoWindows').click
6
+
7
+ @session.document.synchronize(3, errors: [Capybara::CapybaraError]) do
8
+ raise Capybara::CapybaraError if @session.windows.size != 3
9
+ end
10
+ end
11
+ after(:each) do
12
+ (@session.windows - [@window]).each do |w|
13
+ @session.switch_to_window w
14
+ w.close
15
+ end
16
+ @session.switch_to_window(@window)
17
+ end
18
+
19
+ it 'should return objects of Capybara::Window class' do
20
+ expect(@session.windows.map { |window| window.instance_of?(Capybara::Window) }).to eq([true] * 3)
21
+ end
22
+
23
+ it 'should switchable windows' do
24
+ titles = @session.windows.map do |window|
25
+ @session.within_window(window) { @session.title }
26
+ end
27
+ expect(titles).to match_array([
28
+ 'With Windows', 'Title of the first popup', 'Title of popup two'
29
+ ])
30
+ end
31
+ end
@@ -0,0 +1,188 @@
1
+ Capybara::SpecHelper.spec '#within_window', requires: [:windows] do
2
+ before(:each) do
3
+ @window = @session.current_window
4
+ @session.visit('/with_windows')
5
+ @session.find(:css, '#openTwoWindows').click
6
+
7
+ @session.document.synchronize(3, errors: [Capybara::CapybaraError]) do
8
+ raise Capybara::CapybaraError if @session.windows.size != 3
9
+ end
10
+ end
11
+ after(:each) do
12
+ (@session.windows - [@window]).each do |w|
13
+ @session.switch_to_window w
14
+ w.close
15
+ end
16
+ @session.switch_to_window(@window)
17
+ end
18
+
19
+ context "with an instance of Capybara::Window" do
20
+ it "should not invoke driver#switch_to_window when given current window" do
21
+ # switch_to_window is invoked in after hook
22
+ expect(@session.driver).to receive(:switch_to_window).exactly(3).times.and_call_original
23
+ @session.within_window @window do
24
+ expect(@session.title).to eq('With Windows')
25
+ end
26
+ end
27
+
28
+ it "should be able to switch to another window" do
29
+ window = (@session.windows - [@window]).first
30
+ expect(@session.driver).to receive(:switch_to_window).exactly(5).times.and_call_original
31
+ @session.within_window window do
32
+ expect(['Title of the first popup', 'Title of popup two']).to include(@session.title)
33
+ end
34
+ expect(@session.title).to eq('With Windows')
35
+ end
36
+
37
+ it "returns value from the block" do
38
+ window = (@session.windows - [@window]).first
39
+ value = @session.within_window window do
40
+ 43252003274489856000
41
+ end
42
+ expect(value).to eq(43252003274489856000)
43
+ end
44
+
45
+ it "should switch back if exception was raised inside block" do
46
+ window = (@session.windows - [@window]).first
47
+ expect do
48
+ @session.within_window(window) do
49
+ @session.within 'html' do
50
+ raise 'some error'
51
+ end
52
+ end
53
+ end.to raise_error(StandardError, 'some error')
54
+ expect(@session.current_window).to eq(@window)
55
+ expect(@session).to have_css('#doesNotOpenWindows')
56
+ expect(@session.send(:scopes)).to eq([nil])
57
+ end
58
+
59
+ it "should leave correct scopes after execution in case of error" do
60
+ window = (@session.windows - [@window]).first
61
+ expect do
62
+ @session.within 'html' do
63
+ @session.within_window(window) {}
64
+ end
65
+ end.to raise_error(Capybara::ScopeError)
66
+ expect(@session.current_window).to eq(@window)
67
+ expect(@session).to have_css('#doesNotOpenWindows')
68
+ expect(@session.send(:scopes)).to eq([nil])
69
+ end
70
+
71
+ it 'should raise error if closed window was passed' do
72
+ other_window = (@session.windows - [@window]).first
73
+ @session.within_window other_window do
74
+ other_window.close
75
+ end
76
+ expect do
77
+ @session.within_window(other_window) do
78
+ raise 'should not be invoked'
79
+ end
80
+ end.to raise_error(@session.driver.no_such_window_error)
81
+ expect(@session.current_window).to eq(@window)
82
+ expect(@session).to have_css('#doesNotOpenWindows')
83
+ expect(@session.send(:scopes)).to eq([nil])
84
+ end
85
+ end
86
+
87
+ context "with lambda" do
88
+ it "should find the div in another window" do
89
+ @session.within_window(->{ @session.title == 'Title of the first popup'}) do
90
+ expect(@session).to have_css('#divInPopupOne')
91
+ end
92
+ end
93
+
94
+ it "should find divs in both windows" do
95
+ @session.within_window(->{ @session.title == 'Title of popup two'}) do
96
+ expect(@session).to have_css('#divInPopupTwo')
97
+ end
98
+ @session.within_window(->{ @session.title == 'Title of the first popup'}) do
99
+ expect(@session).to have_css('#divInPopupOne')
100
+ end
101
+ expect(@session.title).to eq('With Windows')
102
+ end
103
+
104
+ it "should raise error if window wasn't found" do
105
+ expect do
106
+ @session.within_window(->{ @session.title == 'Invalid title'}) do
107
+ expect(@session).to have_css('#divInPopupOne')
108
+ end
109
+ end.to raise_error(Capybara::WindowError, "Could not find a window matching block/lambda")
110
+ expect(@session.current_window).to eq(@window)
111
+ expect(@session).to have_css('#doesNotOpenWindows')
112
+ expect(@session.send(:scopes)).to eq([nil])
113
+ end
114
+
115
+ it "returns value from the block" do
116
+ value = @session.within_window(->{ @session.title == 'Title of popup two'}) do
117
+ 42
118
+ end
119
+ expect(value).to eq(42)
120
+ end
121
+
122
+ it "should switch back if exception was raised inside block" do
123
+ expect do
124
+ @session.within_window(->{ @session.title == 'Title of popup two'}) do
125
+ raise 'some error'
126
+ end
127
+ end.to raise_error(StandardError, 'some error')
128
+ expect(@session.current_window).to eq(@window)
129
+ expect(@session.send(:scopes)).to eq([nil])
130
+ end
131
+ end
132
+
133
+ context "with string" do
134
+ it "should warn" do
135
+ expect(@session).to receive(:warn).with("DEPRECATION WARNING: Passing string argument "\
136
+ "to #within_window is deprecated. Pass window object or lambda. "\
137
+ "(called from #{__FILE__}:138)").and_call_original
138
+ @session.within_window('firstPopup') {}
139
+ end
140
+
141
+ it "should find window by handle" do
142
+ window = (@session.windows - [@window]).first
143
+ @session.within_window window.handle do
144
+ expect(['Title of the first popup', 'Title of popup two']).to include(@session.title)
145
+ end
146
+ end
147
+
148
+ it "should find the div in firstPopup" do
149
+ @session.within_window("firstPopup") do
150
+ expect(@session.find("//*[@id='divInPopupOne']").text).to eq 'This is the text of divInPopupOne'
151
+ end
152
+ end
153
+ it "should find the div in secondPopup" do
154
+ @session.within_window("secondPopup") do
155
+ expect(@session.find("//*[@id='divInPopupTwo']").text).to eq 'This is the text of divInPopupTwo'
156
+ end
157
+ end
158
+ it "should find the divs in both popups" do
159
+ @session.within_window("secondPopup") do
160
+ expect(@session.find("//*[@id='divInPopupTwo']").text).to eq 'This is the text of divInPopupTwo'
161
+ end
162
+ @session.within_window("firstPopup") do
163
+ expect(@session.find("//*[@id='divInPopupOne']").text).to eq 'This is the text of divInPopupOne'
164
+ end
165
+ end
166
+ it "should find the div in the main window after finding a div in a popup" do
167
+ @session.within_window("secondPopup") do
168
+ expect(@session.find("//*[@id='divInPopupTwo']").text).to eq 'This is the text of divInPopupTwo'
169
+ end
170
+ expect(@session.find("//*[@id='doesNotOpenWindows']").text).to eq 'Does not open windows'
171
+ end
172
+ it "should reset scope when switching windows" do
173
+ @session.within(:css, '#doesNotOpenWindows') do
174
+ @session.within_window("secondPopup") do
175
+ expect(@session.find("//*[@id='divInPopupTwo']").text).to eq 'This is the text of divInPopupTwo'
176
+ end
177
+ end
178
+ end
179
+ it "should switch back if exception was raised inside block" do
180
+ expect do
181
+ @session.within_window('secondPopup') do
182
+ raise 'some error'
183
+ end
184
+ end.to raise_error(StandardError, 'some error')
185
+ expect(@session.current_window).to eq(@window)
186
+ end
187
+ end
188
+ end
@@ -5,33 +5,33 @@ Capybara::SpecHelper.spec '#within_frame', :requires => [:frames] do
5
5
 
6
6
  it "should find the div in frameOne" do
7
7
  @session.within_frame("frameOne") do
8
- @session.find("//*[@id='divInFrameOne']").text.should eql 'This is the text of divInFrameOne'
8
+ expect(@session.find("//*[@id='divInFrameOne']").text).to eql 'This is the text of divInFrameOne'
9
9
  end
10
10
  end
11
11
  it "should find the div in FrameTwo" do
12
12
  @session.within_frame("frameTwo") do
13
- @session.find("//*[@id='divInFrameTwo']").text.should eql 'This is the text of divInFrameTwo'
13
+ expect(@session.find("//*[@id='divInFrameTwo']").text).to eql 'This is the text of divInFrameTwo'
14
14
  end
15
15
  end
16
16
  it "should find the text div in the main window after finding text in frameOne" do
17
17
  @session.within_frame("frameOne") do
18
- @session.find("//*[@id='divInFrameOne']").text.should eql 'This is the text of divInFrameOne'
18
+ expect(@session.find("//*[@id='divInFrameOne']").text).to eql 'This is the text of divInFrameOne'
19
19
  end
20
- @session.find("//*[@id='divInMainWindow']").text.should eql 'This is the text for divInMainWindow'
20
+ expect(@session.find("//*[@id='divInMainWindow']").text).to eql 'This is the text for divInMainWindow'
21
21
  end
22
22
  it "should find the text div in the main window after finding text in frameTwo" do
23
23
  @session.within_frame("frameTwo") do
24
- @session.find("//*[@id='divInFrameTwo']").text.should eql 'This is the text of divInFrameTwo'
24
+ expect(@session.find("//*[@id='divInFrameTwo']").text).to eql 'This is the text of divInFrameTwo'
25
25
  end
26
- @session.find("//*[@id='divInMainWindow']").text.should eql 'This is the text for divInMainWindow'
26
+ expect(@session.find("//*[@id='divInMainWindow']").text).to eql 'This is the text for divInMainWindow'
27
27
  end
28
28
  it "should return the result of executing the block" do
29
- @session.within_frame("frameOne") { "return value" }.should eql "return value"
29
+ expect(@session.within_frame("frameOne") { "return value" }).to eql "return value"
30
30
  end
31
31
  it "should find the div given Element" do
32
32
  element = @session.find(:id, 'frameOne')
33
33
  @session.within_frame element do
34
- @session.find("//*[@id='divInFrameOne']").text.should eql 'This is the text of divInFrameOne'
34
+ expect(@session.find("//*[@id='divInFrameOne']").text).to eql 'This is the text of divInFrameOne'
35
35
  end
36
36
  end
37
37
  it "should find multiple nested frames" do
@@ -45,7 +45,7 @@ Capybara::SpecHelper.spec '#within_frame', :requires => [:frames] do
45
45
  it "should reset scope when changing frames" do
46
46
  @session.within(:css, '#divInMainWindow') do
47
47
  @session.within_frame 'parentFrame' do
48
- @session.has_selector?(:css, "iframe#childFrame").should be_true
48
+ expect(@session.has_selector?(:css, "iframe#childFrame")).to be true
49
49
  end
50
50
  end
51
51
  end