capybara 2.5.0 → 2.18.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (205) hide show
  1. checksums.yaml +5 -5
  2. data/.yard/templates_custom/default/class/html/selectors.erb +38 -0
  3. data/.yard/templates_custom/default/class/html/setup.rb +17 -0
  4. data/.yard/yard_extensions.rb +78 -0
  5. data/.yardopts +1 -0
  6. data/History.md +413 -10
  7. data/License.txt +1 -1
  8. data/README.md +237 -130
  9. data/lib/capybara/config.rb +132 -0
  10. data/lib/capybara/cucumber.rb +3 -1
  11. data/lib/capybara/driver/base.rb +27 -6
  12. data/lib/capybara/driver/node.rb +14 -5
  13. data/lib/capybara/dsl.rb +2 -3
  14. data/lib/capybara/helpers.rb +13 -65
  15. data/lib/capybara/minitest/spec.rb +177 -0
  16. data/lib/capybara/minitest.rb +278 -0
  17. data/lib/capybara/node/actions.rb +180 -24
  18. data/lib/capybara/node/base.rb +17 -5
  19. data/lib/capybara/node/document.rb +5 -0
  20. data/lib/capybara/node/document_matchers.rb +15 -14
  21. data/lib/capybara/node/element.rb +55 -7
  22. data/lib/capybara/node/finders.rb +179 -67
  23. data/lib/capybara/node/matchers.rb +301 -105
  24. data/lib/capybara/node/simple.rb +15 -4
  25. data/lib/capybara/queries/ancestor_query.rb +25 -0
  26. data/lib/capybara/queries/base_query.rb +69 -3
  27. data/lib/capybara/queries/current_path_query.rb +17 -8
  28. data/lib/capybara/queries/match_query.rb +19 -0
  29. data/lib/capybara/queries/selector_query.rb +251 -0
  30. data/lib/capybara/queries/sibling_query.rb +25 -0
  31. data/lib/capybara/queries/text_query.rb +67 -16
  32. data/lib/capybara/queries/title_query.rb +4 -2
  33. data/lib/capybara/query.rb +3 -131
  34. data/lib/capybara/rack_test/browser.rb +14 -5
  35. data/lib/capybara/rack_test/css_handlers.rb +1 -0
  36. data/lib/capybara/rack_test/driver.rb +15 -8
  37. data/lib/capybara/rack_test/form.rb +34 -12
  38. data/lib/capybara/rack_test/node.rb +29 -12
  39. data/lib/capybara/rails.rb +3 -3
  40. data/lib/capybara/result.rb +104 -9
  41. data/lib/capybara/rspec/compound.rb +95 -0
  42. data/lib/capybara/rspec/features.rb +17 -6
  43. data/lib/capybara/rspec/matcher_proxies.rb +45 -0
  44. data/lib/capybara/rspec/matchers.rb +199 -80
  45. data/lib/capybara/rspec.rb +4 -2
  46. data/lib/capybara/selector/css.rb +30 -0
  47. data/lib/capybara/selector/filter.rb +20 -0
  48. data/lib/capybara/selector/filter_set.rb +74 -0
  49. data/lib/capybara/selector/filters/base.rb +33 -0
  50. data/lib/capybara/selector/filters/expression_filter.rb +40 -0
  51. data/lib/capybara/selector/filters/node_filter.rb +27 -0
  52. data/lib/capybara/selector/selector.rb +276 -0
  53. data/lib/capybara/selector.rb +452 -157
  54. data/lib/capybara/selenium/driver.rb +282 -81
  55. data/lib/capybara/selenium/node.rb +144 -46
  56. data/lib/capybara/server.rb +59 -16
  57. data/lib/capybara/session/config.rb +114 -0
  58. data/lib/capybara/session/matchers.rb +29 -19
  59. data/lib/capybara/session.rb +378 -143
  60. data/lib/capybara/spec/fixtures/no_extension +1 -0
  61. data/lib/capybara/spec/public/jquery-ui.js +13 -791
  62. data/lib/capybara/spec/public/jquery.js +4 -9045
  63. data/lib/capybara/spec/public/test.js +45 -11
  64. data/lib/capybara/spec/session/accept_alert_spec.rb +30 -7
  65. data/lib/capybara/spec/session/accept_confirm_spec.rb +14 -2
  66. data/lib/capybara/spec/session/accept_prompt_spec.rb +35 -6
  67. data/lib/capybara/spec/session/all_spec.rb +45 -32
  68. data/lib/capybara/spec/session/ancestor_spec.rb +85 -0
  69. data/lib/capybara/spec/session/assert_all_of_selectors_spec.rb +110 -0
  70. data/lib/capybara/spec/session/assert_current_path.rb +15 -2
  71. data/lib/capybara/spec/session/assert_selector.rb +29 -28
  72. data/lib/capybara/spec/session/assert_text.rb +59 -20
  73. data/lib/capybara/spec/session/assert_title.rb +25 -11
  74. data/lib/capybara/spec/session/attach_file_spec.rb +42 -4
  75. data/lib/capybara/spec/session/body_spec.rb +1 -0
  76. data/lib/capybara/spec/session/check_spec.rb +90 -14
  77. data/lib/capybara/spec/session/choose_spec.rb +31 -5
  78. data/lib/capybara/spec/session/click_button_spec.rb +20 -9
  79. data/lib/capybara/spec/session/click_link_or_button_spec.rb +15 -9
  80. data/lib/capybara/spec/session/click_link_spec.rb +39 -15
  81. data/lib/capybara/spec/session/current_scope_spec.rb +2 -1
  82. data/lib/capybara/spec/session/current_url_spec.rb +12 -3
  83. data/lib/capybara/spec/session/dismiss_confirm_spec.rb +6 -5
  84. data/lib/capybara/spec/session/dismiss_prompt_spec.rb +4 -3
  85. data/lib/capybara/spec/session/element/assert_match_selector.rb +36 -0
  86. data/lib/capybara/spec/session/element/match_css_spec.rb +23 -0
  87. data/lib/capybara/spec/session/element/match_xpath_spec.rb +23 -0
  88. data/lib/capybara/spec/session/element/matches_selector_spec.rb +106 -0
  89. data/lib/capybara/spec/session/evaluate_async_script_spec.rb +22 -0
  90. data/lib/capybara/spec/session/evaluate_script_spec.rb +23 -1
  91. data/lib/capybara/spec/session/execute_script_spec.rb +22 -3
  92. data/lib/capybara/spec/session/fill_in_spec.rb +50 -32
  93. data/lib/capybara/spec/session/find_button_spec.rb +43 -2
  94. data/lib/capybara/spec/session/find_by_id_spec.rb +3 -2
  95. data/lib/capybara/spec/session/find_field_spec.rb +42 -6
  96. data/lib/capybara/spec/session/find_link_spec.rb +22 -3
  97. data/lib/capybara/spec/session/find_spec.rb +103 -57
  98. data/lib/capybara/spec/session/first_spec.rb +34 -18
  99. data/lib/capybara/spec/session/frame/switch_to_frame_spec.rb +103 -0
  100. data/lib/capybara/spec/session/{within_frame_spec.rb → frame/within_frame_spec.rb} +44 -2
  101. data/lib/capybara/spec/session/go_back_spec.rb +2 -1
  102. data/lib/capybara/spec/session/go_forward_spec.rb +2 -1
  103. data/lib/capybara/spec/session/has_all_selectors_spec.rb +69 -0
  104. data/lib/capybara/spec/session/has_button_spec.rb +17 -8
  105. data/lib/capybara/spec/session/has_css_spec.rb +85 -73
  106. data/lib/capybara/spec/session/has_current_path_spec.rb +91 -7
  107. data/lib/capybara/spec/session/has_field_spec.rb +93 -58
  108. data/lib/capybara/spec/session/has_link_spec.rb +9 -8
  109. data/lib/capybara/spec/session/has_none_selectors_spec.rb +76 -0
  110. data/lib/capybara/spec/session/has_select_spec.rb +159 -59
  111. data/lib/capybara/spec/session/has_selector_spec.rb +64 -28
  112. data/lib/capybara/spec/session/has_table_spec.rb +1 -0
  113. data/lib/capybara/spec/session/has_text_spec.rb +27 -12
  114. data/lib/capybara/spec/session/has_title_spec.rb +22 -4
  115. data/lib/capybara/spec/session/has_xpath_spec.rb +32 -29
  116. data/lib/capybara/spec/session/headers.rb +2 -1
  117. data/lib/capybara/spec/session/html_spec.rb +4 -3
  118. data/lib/capybara/spec/session/node_spec.rb +198 -38
  119. data/lib/capybara/spec/session/refresh_spec.rb +28 -0
  120. data/lib/capybara/spec/session/reset_session_spec.rb +46 -5
  121. data/lib/capybara/spec/session/response_code.rb +2 -1
  122. data/lib/capybara/spec/session/save_and_open_page_spec.rb +1 -0
  123. data/lib/capybara/spec/session/save_and_open_screenshot_spec.rb +6 -5
  124. data/lib/capybara/spec/session/save_page_spec.rb +34 -2
  125. data/lib/capybara/spec/session/save_screenshot_spec.rb +31 -1
  126. data/lib/capybara/spec/session/screenshot_spec.rb +4 -2
  127. data/lib/capybara/spec/session/select_spec.rb +34 -32
  128. data/lib/capybara/spec/session/selectors_spec.rb +65 -0
  129. data/lib/capybara/spec/session/sibling_spec.rb +52 -0
  130. data/lib/capybara/spec/session/text_spec.rb +4 -4
  131. data/lib/capybara/spec/session/title_spec.rb +2 -1
  132. data/lib/capybara/spec/session/uncheck_spec.rb +42 -2
  133. data/lib/capybara/spec/session/unselect_spec.rb +17 -16
  134. data/lib/capybara/spec/session/visit_spec.rb +77 -2
  135. data/lib/capybara/spec/session/window/become_closed_spec.rb +12 -11
  136. data/lib/capybara/spec/session/window/current_window_spec.rb +1 -0
  137. data/lib/capybara/spec/session/window/open_new_window_spec.rb +1 -0
  138. data/lib/capybara/spec/session/window/switch_to_window_spec.rb +16 -11
  139. data/lib/capybara/spec/session/window/window_opened_by_spec.rb +7 -4
  140. data/lib/capybara/spec/session/window/window_spec.rb +36 -29
  141. data/lib/capybara/spec/session/window/windows_spec.rb +1 -0
  142. data/lib/capybara/spec/session/window/within_window_spec.rb +31 -7
  143. data/lib/capybara/spec/session/within_spec.rb +14 -6
  144. data/lib/capybara/spec/spec_helper.rb +37 -4
  145. data/lib/capybara/spec/test_app.rb +15 -3
  146. data/lib/capybara/spec/views/buttons.erb +1 -0
  147. data/lib/capybara/spec/views/fieldsets.erb +2 -1
  148. data/lib/capybara/spec/views/form.erb +169 -9
  149. data/lib/capybara/spec/views/frame_child.erb +10 -2
  150. data/lib/capybara/spec/views/frame_one.erb +2 -1
  151. data/lib/capybara/spec/views/frame_parent.erb +3 -2
  152. data/lib/capybara/spec/views/frame_two.erb +2 -1
  153. data/lib/capybara/spec/views/header_links.erb +1 -0
  154. data/lib/capybara/spec/views/host_links.erb +1 -0
  155. data/lib/capybara/spec/views/initial_alert.erb +10 -0
  156. data/lib/capybara/spec/views/path.erb +1 -0
  157. data/lib/capybara/spec/views/popup_one.erb +1 -0
  158. data/lib/capybara/spec/views/popup_two.erb +1 -0
  159. data/lib/capybara/spec/views/postback.erb +2 -1
  160. data/lib/capybara/spec/views/tables.erb +1 -0
  161. data/lib/capybara/spec/views/with_base_tag.erb +1 -0
  162. data/lib/capybara/spec/views/with_count.erb +2 -1
  163. data/lib/capybara/spec/views/with_fixed_header_footer.erb +17 -0
  164. data/lib/capybara/spec/views/with_hover.erb +7 -1
  165. data/lib/capybara/spec/views/with_html.erb +40 -2
  166. data/lib/capybara/spec/views/with_html_entities.erb +1 -0
  167. data/lib/capybara/spec/views/with_js.erb +32 -1
  168. data/lib/capybara/spec/views/with_scope.erb +1 -0
  169. data/lib/capybara/spec/views/with_simple_html.erb +2 -1
  170. data/lib/capybara/spec/views/with_slow_unload.erb +17 -0
  171. data/lib/capybara/spec/views/with_title.erb +2 -1
  172. data/lib/capybara/spec/views/with_unload_alert.erb +14 -0
  173. data/lib/capybara/spec/views/with_windows.erb +7 -0
  174. data/lib/capybara/spec/views/within_frames.erb +3 -2
  175. data/lib/capybara/version.rb +2 -1
  176. data/lib/capybara/window.rb +20 -3
  177. data/lib/capybara.rb +189 -93
  178. data/spec/basic_node_spec.rb +7 -6
  179. data/spec/capybara_spec.rb +90 -4
  180. data/spec/dsl_spec.rb +3 -1
  181. data/spec/filter_set_spec.rb +28 -0
  182. data/spec/fixtures/capybara.csv +1 -0
  183. data/spec/fixtures/selenium_driver_rspec_failure.rb +5 -1
  184. data/spec/fixtures/selenium_driver_rspec_success.rb +5 -1
  185. data/spec/minitest_spec.rb +130 -0
  186. data/spec/minitest_spec_spec.rb +135 -0
  187. data/spec/per_session_config_spec.rb +67 -0
  188. data/spec/rack_test_spec.rb +50 -7
  189. data/spec/result_spec.rb +76 -0
  190. data/spec/rspec/features_spec.rb +21 -8
  191. data/spec/rspec/scenarios_spec.rb +21 -0
  192. data/spec/rspec/{matchers_spec.rb → shared_spec_matchers.rb} +160 -54
  193. data/spec/rspec/views_spec.rb +5 -0
  194. data/spec/rspec_matchers_spec.rb +46 -0
  195. data/spec/rspec_spec.rb +79 -1
  196. data/spec/selector_spec.rb +199 -0
  197. data/spec/selenium_spec_chrome.rb +54 -9
  198. data/spec/selenium_spec_firefox.rb +68 -0
  199. data/spec/selenium_spec_marionette.rb +127 -0
  200. data/spec/server_spec.rb +102 -14
  201. data/spec/session_spec.rb +54 -0
  202. data/spec/shared_selenium_session.rb +215 -0
  203. data/spec/spec_helper.rb +7 -0
  204. metadata +140 -15
  205. data/spec/selenium_spec.rb +0 -128
@@ -0,0 +1,10 @@
1
+ <html xmlns="http://www.w3.org/1999/xhtml" lang="en">
2
+ <body>
3
+ <div>
4
+ Initial alert page
5
+ </div>
6
+ <script>
7
+ window.alert("Initial alert");
8
+ </script>
9
+ </body>
10
+ </html>
@@ -1,3 +1,4 @@
1
+
1
2
  <html xmlns="http://www.w3.org/1999/xhtml" lang="en">
2
3
  <body>
3
4
  <div>
@@ -1,3 +1,4 @@
1
+
1
2
  <html>
2
3
  <head>
3
4
  <title>Title of the first popup</title>
@@ -1,3 +1,4 @@
1
+
1
2
  <html>
2
3
  <head>
3
4
  <title>Title of popup two</title>
@@ -1,3 +1,4 @@
1
+
1
2
  <h1>Postback</h1>
2
3
 
3
4
  <form method="get">
@@ -10,4 +11,4 @@
10
11
  <p>
11
12
  <input type="submit" value="With blank action">
12
13
  </p>
13
- </form>
14
+ </form>
@@ -1,3 +1,4 @@
1
+
1
2
  <form action="/form" method="post">
2
3
  <table id="agent_table">
3
4
  <caption>Agent</caption>
@@ -1,3 +1,4 @@
1
+
1
2
  <html xmlns="http://www.w3.org/1999/xhtml" lang="en">
2
3
  <head>
3
4
  <meta http-equiv="Content-type" content="text/html; charset=utf-8"/>
@@ -1,7 +1,8 @@
1
+
1
2
  <h1>This page is used for testing number options of has_text?</h1>
2
3
 
3
4
  <p>count1</p>
4
5
  <div>
5
6
  <p>2 count</p>
6
7
  <p>Count</p>
7
- </div>
8
+ </div>
@@ -0,0 +1,17 @@
1
+ <html>
2
+ <head>
3
+ <style>
4
+ header { height: 45px; position: fixed; top: 0; background-color: red; width: 100%;}
5
+ footer { height: 45px; position: fixed; bottom: 0; background-color: red; width: 100%;}
6
+ #main { margin: 45px;}
7
+ #tall { display: block; height: 2000px;}
8
+ </style>
9
+ </head>
10
+ <body>
11
+ <header>My headers</header>
12
+ <div id="main">
13
+ <div id="tall">A tall block</div>
14
+ <a href="/">Go to root</a>
15
+ </div>
16
+ <footer>My footer</footer>
17
+ </body>
@@ -1,3 +1,4 @@
1
+
1
2
  <html xmlns="http://www.w3.org/1999/xhtml" lang="en">
2
3
  <head>
3
4
  <meta http-equiv="Content-type" content="text/html; charset=utf-8"/>
@@ -13,5 +14,10 @@
13
14
  Some text here so the wrapper has size
14
15
  <div class="hidden_until_hover">Here I am</div>
15
16
  </div>
17
+ <div style="display: block; height: 1000px; width: 100%"></div>
18
+ <div class="wrapper scroll_needed" >
19
+ Some text here so the wrapper has size
20
+ <div class="hidden_until_hover">Here I am</div>
21
+ </div>
16
22
  </body>
17
- </html>
23
+ </html>
@@ -1,3 +1,4 @@
1
+
1
2
  <div id="referrer"><%= referrer %></div>
2
3
  <h1>This is a test</h1>
3
4
 
@@ -10,14 +11,15 @@
10
11
  <h2 class="head">Header Class Test Five</h2>
11
12
 
12
13
  <span class="number">42</span>
14
+ <span>Other span</span>
13
15
 
14
- <p class="para" id="first">
16
+ <p class="para" id="first" data-random="abc\def">
15
17
  Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
16
18
  tempor incididunt ut <a href="/with_simple_html" title="awesome title" class="simple">labore</a>
17
19
  et dolore magna aliqua. Ut enim ad minim veniam,
18
20
  quis nostrud exercitation <a href="/foo" id="foo">ullamco</a> laboris nisi
19
21
  ut aliquip ex ea commodo consequat.
20
- <a href="/with_simple_html"><img width="20" height="20" alt="awesome image" /></a>
22
+ <a href="/with_simple_html" aria-label="Go to simple"><img id="first_image" width="20" height="20" alt="awesome image" /></a>
21
23
  </p>
22
24
 
23
25
  <p class="para" id="second">
@@ -77,6 +79,10 @@ banana</textarea>
77
79
  Some of this text is <em style="display:none">hidden!</em>
78
80
  </div>
79
81
 
82
+ <div id="some-hidden-text">
83
+ Some of this text is not hidden <em style="display:none">and some is hidden</em>
84
+ </div>
85
+
80
86
  <div style="display: none;">
81
87
  <a id="first_invisble" class="hidden">first hidden link</a>
82
88
  </div>
@@ -109,7 +115,39 @@ banana</textarea>
109
115
  </div>
110
116
 
111
117
  <input type="text" disabled="disabled" name="disabled_text" value="This is disabled"/>
118
+ <input type="hidden" id="hidden_input" name="hidden_input" value="This is a hidden input"/>
112
119
 
113
120
  <div>
114
121
  <a id="link_placeholder">No href</a>
122
+ <a id="link_blank_href" href="">Blank href</a>
123
+ </div>
124
+
125
+ <div id="uppercase" style="text-transform: uppercase;">
126
+ text here
127
+ </div>
128
+
129
+ <div id="ancestor3">
130
+ Ancestor
131
+ <div id="ancestor2">
132
+ Ancestor
133
+ <div id="ancestor1">
134
+ Ancestor
135
+ <div id="child">Child</div>
136
+ </div>
137
+ </div>
138
+ <button id="ancestor_button" type="submit" disabled>
139
+ <img id="button_img" width="20" height="20" alt="button img"/>
140
+ </button>
115
141
  </div>
142
+
143
+ <div id="sibling_test">
144
+ <div id="sibling_wrapper" data-pre=true>
145
+ <div id="pre_sibling" data-pre=true>Pre Sibling</div>
146
+ <div id="mid_sibling">Mid Sibling</div>
147
+ <div id="post_sibling" data-post=true>Post Sibling</div>
148
+ </div>
149
+ <div id="other_sibling_wrapper" data-post=true>
150
+ <div data-pre=true>Pre Sibling</div>
151
+ <div data-post=true>Post Sibling</div>
152
+ </div>
153
+ </div>
@@ -1 +1,2 @@
1
+
1
2
  Encoding with &mdash; html entities &raquo;
@@ -1,3 +1,4 @@
1
+
1
2
  <html xmlns="http://www.w3.org/1999/xhtml" lang="en">
2
3
  <head>
3
4
  <meta http-equiv="Content-type" content="text/html; charset=utf-8"/>
@@ -39,7 +40,8 @@
39
40
  <p>
40
41
  <div contenteditable='true' id='existing_content_editable'>Editable content</div>
41
42
  <div contenteditable='true' id='blank_content_editable' style='height: 1em;'></div>
42
- <div contenteditable='true' style='height: 1em;'>
43
+ <div contenteditable='true' id='existing_content_editable_child_parent' style='height: 1em;'>
44
+ Some content
43
45
  <div id='existing_content_editable_child' style='height: 1em;'>Content</div>
44
46
  </div>
45
47
  </p>
@@ -74,6 +76,7 @@
74
76
 
75
77
  <p>
76
78
  <a href="#" id="open-alert">Open alert</a>
79
+ <a href="/with_html" id="alert-page-change">Alert page change</a>
77
80
  </p>
78
81
 
79
82
  <p>
@@ -85,18 +88,46 @@
85
88
  <a href="#" id="open-confirm">Open confirm</a>
86
89
  </p>
87
90
 
91
+ <p>
92
+ <a href="#" id="open-twice">Open check twice</a>
93
+ </p>
94
+
88
95
  <p>
89
96
  <a href="#" id="open-prompt">Open prompt</a>
90
97
  </p>
91
98
 
99
+ <p>
100
+ <a href="#" id="open-prompt-with-default">Open defaulted prompt</a>
101
+ </p>
102
+
103
+ <p>
104
+ <input id="disable-on-click"/>
105
+ </p>
106
+ <p>
107
+ <input id="set-storage"/>
108
+ </p>
92
109
  <p>
93
110
  <a href="#" id="delayed-page-change">Change page</a>
111
+ <a href="/with_html?options[]=things">Non-escaped query options</a>
112
+ <a href="/with_html?options%5B%5D=things">Escaped query options</a>
94
113
  </p>
95
114
 
96
115
  <p>
97
116
  <input type="test" name="with-key-events" id="with-key-events">
98
117
  <p id="key-events-output"></p>
99
118
  </p>
119
+
120
+ <p>
121
+ <input type="file" id="hidden_file" style="opacity:0; display: none;">
122
+ </p>
123
+
124
+ <div id="drag_scroll">
125
+ <p>This is a draggable element.</p>
126
+ </div>
127
+ <div id="drop_scroll">
128
+ <p>It should be dropped here.</p>
129
+ </div>
130
+
100
131
  <script type="text/javascript">
101
132
  // a javascript comment
102
133
  var aVar = 123;
@@ -1,3 +1,4 @@
1
+
1
2
  <h1>This page is used for testing various scopes</h1>
2
3
 
3
4
  <p id="for_foo">
@@ -1 +1,2 @@
1
- Bar
1
+
2
+ Bar
@@ -0,0 +1,17 @@
1
+ <html>
2
+ <head>
3
+ <script>
4
+ function delay_unload() {
5
+ var start = new Date();
6
+ var i = 0;
7
+ while ((new Date()) - start < 1000){ i = i + 1; };
8
+ return null;
9
+ }
10
+ window.onbeforeunload = delay_unload;
11
+ window.onunload = delay_unload;
12
+ </script>
13
+ </head>
14
+ <body>
15
+ <div>This delays unload by 2 seconds</div>
16
+ </body>
17
+ </html>
@@ -1,4 +1,5 @@
1
+
1
2
  <title>Test Title</title>
2
3
  <body>
3
4
  <svg><title>abcdefg</title></svg>
4
- </body>
5
+ </body>
@@ -0,0 +1,14 @@
1
+ <html>
2
+ <head>
3
+ <script>
4
+ window.onbeforeunload = function(e) {
5
+ return 'Unload?';
6
+ };
7
+ </script>
8
+ </head>
9
+ <body>
10
+ <div>This triggers an alert on unload</div>
11
+
12
+ <a href="/">Go away</a>
13
+ </body>
14
+ </html>
@@ -1,3 +1,4 @@
1
+
1
2
  <html>
2
3
  <head>
3
4
  <title>With Windows</title>
@@ -28,6 +29,8 @@
28
29
  window.open('/popup_two', 'secondPopup');
29
30
  return false;
30
31
  });
32
+
33
+ $('body').addClass('loaded');
31
34
  });
32
35
  </script>
33
36
  </head>
@@ -43,5 +46,9 @@
43
46
  <button id="doesNotOpenWindows">Does not open windows</button>
44
47
 
45
48
  <iframe src="/frame_one" id="frameOne"></iframe>
49
+
50
+ <div id="scope">
51
+ <span>My scoped content</span>
52
+ </div>
46
53
  </body>
47
54
  </html>
@@ -1,11 +1,12 @@
1
+
1
2
  <html>
2
3
  <head>
3
4
  <title>With Frames</title>
4
5
  </head>
5
6
  <body>
6
7
  <div id="divInMainWindow">This is the text for divInMainWindow</div>
7
- <iframe src="/frame_one" id="frameOne"></iframe>
8
+ <iframe src="/frame_one" id="frameOne" name="my frame one"></iframe>
8
9
  <iframe src="/frame_two" id="frameTwo"></iframe>
9
10
  <iframe src="/frame_parent" id="parentFrame"></iframe>
10
11
  </body>
11
- </html>
12
+ </html>
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Capybara
2
- VERSION = '2.5.0'
3
+ VERSION = '2.18.0'
3
4
  end
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Capybara
2
3
  ##
3
4
  # The Window class represents a browser window.
@@ -70,7 +71,7 @@ module Capybara
70
71
  # Get window size.
71
72
  #
72
73
  # @macro about_current
73
- # @return [Array<(Fixnum, Fixnum)>] an array with width and height
74
+ # @return [Array<(Integer, Integer)>] an array with width and height
74
75
  #
75
76
  def size
76
77
  @driver.window_size(handle)
@@ -84,7 +85,7 @@ module Capybara
84
85
  # @param height [String] the new window height in pixels
85
86
  #
86
87
  def resize_to(width, height)
87
- @driver.resize_window_to(handle, width, height)
88
+ wait_for_stable_size { @driver.resize_window_to(handle, width, height) }
88
89
  end
89
90
 
90
91
  ##
@@ -96,7 +97,7 @@ module Capybara
96
97
  # @macro about_current
97
98
  #
98
99
  def maximize
99
- @driver.maximize_window(handle)
100
+ wait_for_stable_size { @driver.maximize_window(handle) }
100
101
  end
101
102
 
102
103
  def eql?(other)
@@ -114,6 +115,22 @@ module Capybara
114
115
 
115
116
  private
116
117
 
118
+ def wait_for_stable_size(seconds=session.config.default_max_wait_time)
119
+ res = yield if block_given?
120
+ prev_size = size
121
+ start_time = Capybara::Helpers.monotonic_time
122
+ begin
123
+ sleep 0.05
124
+ cur_size = size
125
+ return res if cur_size == prev_size
126
+ prev_size = cur_size
127
+ end while (Capybara::Helpers.monotonic_time - start_time) < seconds
128
+ #TODO raise error in 3.0
129
+ #raise Capybara::WindowError, "Window size not stable."
130
+ warn "Window size not stable in #{seconds} seconds. This will raise an exception in a future version of Capybara"
131
+ return res
132
+ end
133
+
117
134
  def raise_unless_current(what)
118
135
  unless current?
119
136
  raise Capybara::WindowError, "#{what} not current window is not possible."