capybara 2.5.0 → 2.18.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.yard/templates_custom/default/class/html/selectors.erb +38 -0
- data/.yard/templates_custom/default/class/html/setup.rb +17 -0
- data/.yard/yard_extensions.rb +78 -0
- data/.yardopts +1 -0
- data/History.md +413 -10
- data/License.txt +1 -1
- data/README.md +237 -130
- data/lib/capybara/config.rb +132 -0
- data/lib/capybara/cucumber.rb +3 -1
- data/lib/capybara/driver/base.rb +27 -6
- data/lib/capybara/driver/node.rb +14 -5
- data/lib/capybara/dsl.rb +2 -3
- data/lib/capybara/helpers.rb +13 -65
- data/lib/capybara/minitest/spec.rb +177 -0
- data/lib/capybara/minitest.rb +278 -0
- data/lib/capybara/node/actions.rb +180 -24
- data/lib/capybara/node/base.rb +17 -5
- data/lib/capybara/node/document.rb +5 -0
- data/lib/capybara/node/document_matchers.rb +15 -14
- data/lib/capybara/node/element.rb +55 -7
- data/lib/capybara/node/finders.rb +179 -67
- data/lib/capybara/node/matchers.rb +301 -105
- data/lib/capybara/node/simple.rb +15 -4
- data/lib/capybara/queries/ancestor_query.rb +25 -0
- data/lib/capybara/queries/base_query.rb +69 -3
- data/lib/capybara/queries/current_path_query.rb +17 -8
- data/lib/capybara/queries/match_query.rb +19 -0
- data/lib/capybara/queries/selector_query.rb +251 -0
- data/lib/capybara/queries/sibling_query.rb +25 -0
- data/lib/capybara/queries/text_query.rb +67 -16
- data/lib/capybara/queries/title_query.rb +4 -2
- data/lib/capybara/query.rb +3 -131
- data/lib/capybara/rack_test/browser.rb +14 -5
- data/lib/capybara/rack_test/css_handlers.rb +1 -0
- data/lib/capybara/rack_test/driver.rb +15 -8
- data/lib/capybara/rack_test/form.rb +34 -12
- data/lib/capybara/rack_test/node.rb +29 -12
- data/lib/capybara/rails.rb +3 -3
- data/lib/capybara/result.rb +104 -9
- data/lib/capybara/rspec/compound.rb +95 -0
- data/lib/capybara/rspec/features.rb +17 -6
- data/lib/capybara/rspec/matcher_proxies.rb +45 -0
- data/lib/capybara/rspec/matchers.rb +199 -80
- data/lib/capybara/rspec.rb +4 -2
- data/lib/capybara/selector/css.rb +30 -0
- data/lib/capybara/selector/filter.rb +20 -0
- data/lib/capybara/selector/filter_set.rb +74 -0
- data/lib/capybara/selector/filters/base.rb +33 -0
- data/lib/capybara/selector/filters/expression_filter.rb +40 -0
- data/lib/capybara/selector/filters/node_filter.rb +27 -0
- data/lib/capybara/selector/selector.rb +276 -0
- data/lib/capybara/selector.rb +452 -157
- data/lib/capybara/selenium/driver.rb +282 -81
- data/lib/capybara/selenium/node.rb +144 -46
- data/lib/capybara/server.rb +59 -16
- data/lib/capybara/session/config.rb +114 -0
- data/lib/capybara/session/matchers.rb +29 -19
- data/lib/capybara/session.rb +378 -143
- data/lib/capybara/spec/fixtures/no_extension +1 -0
- data/lib/capybara/spec/public/jquery-ui.js +13 -791
- data/lib/capybara/spec/public/jquery.js +4 -9045
- data/lib/capybara/spec/public/test.js +45 -11
- data/lib/capybara/spec/session/accept_alert_spec.rb +30 -7
- data/lib/capybara/spec/session/accept_confirm_spec.rb +14 -2
- data/lib/capybara/spec/session/accept_prompt_spec.rb +35 -6
- data/lib/capybara/spec/session/all_spec.rb +45 -32
- data/lib/capybara/spec/session/ancestor_spec.rb +85 -0
- data/lib/capybara/spec/session/assert_all_of_selectors_spec.rb +110 -0
- data/lib/capybara/spec/session/assert_current_path.rb +15 -2
- data/lib/capybara/spec/session/assert_selector.rb +29 -28
- data/lib/capybara/spec/session/assert_text.rb +59 -20
- data/lib/capybara/spec/session/assert_title.rb +25 -11
- data/lib/capybara/spec/session/attach_file_spec.rb +42 -4
- data/lib/capybara/spec/session/body_spec.rb +1 -0
- data/lib/capybara/spec/session/check_spec.rb +90 -14
- data/lib/capybara/spec/session/choose_spec.rb +31 -5
- data/lib/capybara/spec/session/click_button_spec.rb +20 -9
- data/lib/capybara/spec/session/click_link_or_button_spec.rb +15 -9
- data/lib/capybara/spec/session/click_link_spec.rb +39 -15
- data/lib/capybara/spec/session/current_scope_spec.rb +2 -1
- data/lib/capybara/spec/session/current_url_spec.rb +12 -3
- data/lib/capybara/spec/session/dismiss_confirm_spec.rb +6 -5
- data/lib/capybara/spec/session/dismiss_prompt_spec.rb +4 -3
- data/lib/capybara/spec/session/element/assert_match_selector.rb +36 -0
- data/lib/capybara/spec/session/element/match_css_spec.rb +23 -0
- data/lib/capybara/spec/session/element/match_xpath_spec.rb +23 -0
- data/lib/capybara/spec/session/element/matches_selector_spec.rb +106 -0
- data/lib/capybara/spec/session/evaluate_async_script_spec.rb +22 -0
- data/lib/capybara/spec/session/evaluate_script_spec.rb +23 -1
- data/lib/capybara/spec/session/execute_script_spec.rb +22 -3
- data/lib/capybara/spec/session/fill_in_spec.rb +50 -32
- data/lib/capybara/spec/session/find_button_spec.rb +43 -2
- data/lib/capybara/spec/session/find_by_id_spec.rb +3 -2
- data/lib/capybara/spec/session/find_field_spec.rb +42 -6
- data/lib/capybara/spec/session/find_link_spec.rb +22 -3
- data/lib/capybara/spec/session/find_spec.rb +103 -57
- data/lib/capybara/spec/session/first_spec.rb +34 -18
- data/lib/capybara/spec/session/frame/switch_to_frame_spec.rb +103 -0
- data/lib/capybara/spec/session/{within_frame_spec.rb → frame/within_frame_spec.rb} +44 -2
- data/lib/capybara/spec/session/go_back_spec.rb +2 -1
- data/lib/capybara/spec/session/go_forward_spec.rb +2 -1
- data/lib/capybara/spec/session/has_all_selectors_spec.rb +69 -0
- data/lib/capybara/spec/session/has_button_spec.rb +17 -8
- data/lib/capybara/spec/session/has_css_spec.rb +85 -73
- data/lib/capybara/spec/session/has_current_path_spec.rb +91 -7
- data/lib/capybara/spec/session/has_field_spec.rb +93 -58
- data/lib/capybara/spec/session/has_link_spec.rb +9 -8
- data/lib/capybara/spec/session/has_none_selectors_spec.rb +76 -0
- data/lib/capybara/spec/session/has_select_spec.rb +159 -59
- data/lib/capybara/spec/session/has_selector_spec.rb +64 -28
- data/lib/capybara/spec/session/has_table_spec.rb +1 -0
- data/lib/capybara/spec/session/has_text_spec.rb +27 -12
- data/lib/capybara/spec/session/has_title_spec.rb +22 -4
- data/lib/capybara/spec/session/has_xpath_spec.rb +32 -29
- data/lib/capybara/spec/session/headers.rb +2 -1
- data/lib/capybara/spec/session/html_spec.rb +4 -3
- data/lib/capybara/spec/session/node_spec.rb +198 -38
- data/lib/capybara/spec/session/refresh_spec.rb +28 -0
- data/lib/capybara/spec/session/reset_session_spec.rb +46 -5
- data/lib/capybara/spec/session/response_code.rb +2 -1
- data/lib/capybara/spec/session/save_and_open_page_spec.rb +1 -0
- data/lib/capybara/spec/session/save_and_open_screenshot_spec.rb +6 -5
- data/lib/capybara/spec/session/save_page_spec.rb +34 -2
- data/lib/capybara/spec/session/save_screenshot_spec.rb +31 -1
- data/lib/capybara/spec/session/screenshot_spec.rb +4 -2
- data/lib/capybara/spec/session/select_spec.rb +34 -32
- data/lib/capybara/spec/session/selectors_spec.rb +65 -0
- data/lib/capybara/spec/session/sibling_spec.rb +52 -0
- data/lib/capybara/spec/session/text_spec.rb +4 -4
- data/lib/capybara/spec/session/title_spec.rb +2 -1
- data/lib/capybara/spec/session/uncheck_spec.rb +42 -2
- data/lib/capybara/spec/session/unselect_spec.rb +17 -16
- data/lib/capybara/spec/session/visit_spec.rb +77 -2
- data/lib/capybara/spec/session/window/become_closed_spec.rb +12 -11
- data/lib/capybara/spec/session/window/current_window_spec.rb +1 -0
- data/lib/capybara/spec/session/window/open_new_window_spec.rb +1 -0
- data/lib/capybara/spec/session/window/switch_to_window_spec.rb +16 -11
- data/lib/capybara/spec/session/window/window_opened_by_spec.rb +7 -4
- data/lib/capybara/spec/session/window/window_spec.rb +36 -29
- data/lib/capybara/spec/session/window/windows_spec.rb +1 -0
- data/lib/capybara/spec/session/window/within_window_spec.rb +31 -7
- data/lib/capybara/spec/session/within_spec.rb +14 -6
- data/lib/capybara/spec/spec_helper.rb +37 -4
- data/lib/capybara/spec/test_app.rb +15 -3
- data/lib/capybara/spec/views/buttons.erb +1 -0
- data/lib/capybara/spec/views/fieldsets.erb +2 -1
- data/lib/capybara/spec/views/form.erb +169 -9
- data/lib/capybara/spec/views/frame_child.erb +10 -2
- data/lib/capybara/spec/views/frame_one.erb +2 -1
- data/lib/capybara/spec/views/frame_parent.erb +3 -2
- data/lib/capybara/spec/views/frame_two.erb +2 -1
- data/lib/capybara/spec/views/header_links.erb +1 -0
- data/lib/capybara/spec/views/host_links.erb +1 -0
- data/lib/capybara/spec/views/initial_alert.erb +10 -0
- data/lib/capybara/spec/views/path.erb +1 -0
- data/lib/capybara/spec/views/popup_one.erb +1 -0
- data/lib/capybara/spec/views/popup_two.erb +1 -0
- data/lib/capybara/spec/views/postback.erb +2 -1
- data/lib/capybara/spec/views/tables.erb +1 -0
- data/lib/capybara/spec/views/with_base_tag.erb +1 -0
- data/lib/capybara/spec/views/with_count.erb +2 -1
- data/lib/capybara/spec/views/with_fixed_header_footer.erb +17 -0
- data/lib/capybara/spec/views/with_hover.erb +7 -1
- data/lib/capybara/spec/views/with_html.erb +40 -2
- data/lib/capybara/spec/views/with_html_entities.erb +1 -0
- data/lib/capybara/spec/views/with_js.erb +32 -1
- data/lib/capybara/spec/views/with_scope.erb +1 -0
- data/lib/capybara/spec/views/with_simple_html.erb +2 -1
- data/lib/capybara/spec/views/with_slow_unload.erb +17 -0
- data/lib/capybara/spec/views/with_title.erb +2 -1
- data/lib/capybara/spec/views/with_unload_alert.erb +14 -0
- data/lib/capybara/spec/views/with_windows.erb +7 -0
- data/lib/capybara/spec/views/within_frames.erb +3 -2
- data/lib/capybara/version.rb +2 -1
- data/lib/capybara/window.rb +20 -3
- data/lib/capybara.rb +189 -93
- data/spec/basic_node_spec.rb +7 -6
- data/spec/capybara_spec.rb +90 -4
- data/spec/dsl_spec.rb +3 -1
- data/spec/filter_set_spec.rb +28 -0
- data/spec/fixtures/capybara.csv +1 -0
- data/spec/fixtures/selenium_driver_rspec_failure.rb +5 -1
- data/spec/fixtures/selenium_driver_rspec_success.rb +5 -1
- data/spec/minitest_spec.rb +130 -0
- data/spec/minitest_spec_spec.rb +135 -0
- data/spec/per_session_config_spec.rb +67 -0
- data/spec/rack_test_spec.rb +50 -7
- data/spec/result_spec.rb +76 -0
- data/spec/rspec/features_spec.rb +21 -8
- data/spec/rspec/scenarios_spec.rb +21 -0
- data/spec/rspec/{matchers_spec.rb → shared_spec_matchers.rb} +160 -54
- data/spec/rspec/views_spec.rb +5 -0
- data/spec/rspec_matchers_spec.rb +46 -0
- data/spec/rspec_spec.rb +79 -1
- data/spec/selector_spec.rb +199 -0
- data/spec/selenium_spec_chrome.rb +54 -9
- data/spec/selenium_spec_firefox.rb +68 -0
- data/spec/selenium_spec_marionette.rb +127 -0
- data/spec/server_spec.rb +102 -14
- data/spec/session_spec.rb +54 -0
- data/spec/shared_selenium_session.rb +215 -0
- data/spec/spec_helper.rb +7 -0
- metadata +140 -15
- data/spec/selenium_spec.rb +0 -128
@@ -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,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 +1,2 @@
|
|
1
|
-
|
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,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>
|
data/lib/capybara/version.rb
CHANGED
data/lib/capybara/window.rb
CHANGED
@@ -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<(
|
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."
|