watir 6.0.0.beta5 → 6.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (200) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +5 -2
  3. data/CHANGES.md +10 -1
  4. data/Gemfile +4 -0
  5. data/README.md +37 -23
  6. data/Rakefile +6 -10
  7. data/appveyor.yml +13 -0
  8. data/lib/watir.rb +20 -21
  9. data/lib/watir/alert.rb +21 -5
  10. data/lib/watir/browser.rb +9 -3
  11. data/lib/watir/elements/checkbox.rb +0 -1
  12. data/lib/watir/elements/element.rb +92 -50
  13. data/lib/watir/elements/form.rb +1 -2
  14. data/lib/watir/elements/iframe.rb +6 -2
  15. data/lib/watir/elements/image.rb +1 -1
  16. data/lib/watir/elements/option.rb +0 -1
  17. data/lib/watir/elements/radio.rb +0 -1
  18. data/lib/watir/elements/select.rb +1 -10
  19. data/lib/watir/extensions/select_text.rb +1 -1
  20. data/lib/watir/legacy_wait.rb +126 -0
  21. data/lib/watir/locators/text_field/locator.rb +0 -3
  22. data/lib/watir/locators/text_field/selector_builder.rb +1 -4
  23. data/lib/watir/locators/text_field/selector_builder/xpath.rb +0 -2
  24. data/lib/watir/locators/text_field/validator.rb +1 -9
  25. data/lib/watir/row_container.rb +1 -1
  26. data/lib/watir/user_editable.rb +7 -5
  27. data/lib/watir/wait.rb +56 -135
  28. data/lib/watir/wait/timer.rb +29 -2
  29. data/lib/watir/window.rb +11 -1
  30. data/lib/watirspec.rb +81 -0
  31. data/lib/watirspec/guards.rb +58 -0
  32. data/lib/watirspec/implementation.rb +33 -0
  33. data/lib/watirspec/rake_tasks.rb +115 -0
  34. data/lib/watirspec/runner.rb +53 -0
  35. data/lib/watirspec/server.rb +99 -0
  36. data/lib/watirspec/server/app.rb +62 -0
  37. data/spec/browser_spec.rb +5 -5
  38. data/spec/click_spec.rb +1 -1
  39. data/spec/container_spec.rb +1 -1
  40. data/spec/element_locator_spec.rb +1 -1
  41. data/spec/element_spec.rb +20 -34
  42. data/spec/implementation_spec.rb +24 -0
  43. data/spec/input_spec.rb +1 -1
  44. data/spec/spec_helper.rb +35 -3
  45. data/spec/special_chars_spec.rb +1 -1
  46. data/spec/watirspec/.gitignore +2 -0
  47. data/spec/watirspec/after_hooks_spec.rb +179 -0
  48. data/spec/watirspec/alert_spec.rb +101 -0
  49. data/spec/watirspec/browser_spec.rb +291 -0
  50. data/spec/watirspec/cookies_spec.rb +147 -0
  51. data/spec/watirspec/drag_and_drop_spec.rb +49 -0
  52. data/spec/watirspec/element_hidden_spec.rb +65 -0
  53. data/spec/watirspec/elements/area_spec.rb +76 -0
  54. data/spec/watirspec/elements/areas_spec.rb +42 -0
  55. data/spec/watirspec/elements/button_spec.rb +270 -0
  56. data/spec/watirspec/elements/buttons_spec.rb +55 -0
  57. data/spec/watirspec/elements/checkbox_spec.rb +279 -0
  58. data/spec/watirspec/elements/checkboxes_spec.rb +44 -0
  59. data/spec/watirspec/elements/collections_spec.rb +16 -0
  60. data/spec/watirspec/elements/dd_spec.rb +126 -0
  61. data/spec/watirspec/elements/dds_spec.rb +42 -0
  62. data/spec/watirspec/elements/del_spec.rb +128 -0
  63. data/spec/watirspec/elements/dels_spec.rb +40 -0
  64. data/spec/watirspec/elements/div_spec.rb +199 -0
  65. data/spec/watirspec/elements/divs_spec.rb +42 -0
  66. data/spec/watirspec/elements/dl_spec.rb +144 -0
  67. data/spec/watirspec/elements/dls_spec.rb +43 -0
  68. data/spec/watirspec/elements/dt_spec.rb +126 -0
  69. data/spec/watirspec/elements/dts_spec.rb +42 -0
  70. data/spec/watirspec/elements/element_spec.rb +361 -0
  71. data/spec/watirspec/elements/elements_spec.rb +15 -0
  72. data/spec/watirspec/elements/em_spec.rb +100 -0
  73. data/spec/watirspec/elements/ems_spec.rb +43 -0
  74. data/spec/watirspec/elements/filefield_spec.rb +181 -0
  75. data/spec/watirspec/elements/filefields_spec.rb +43 -0
  76. data/spec/watirspec/elements/font_spec.rb +29 -0
  77. data/spec/watirspec/elements/form_spec.rb +70 -0
  78. data/spec/watirspec/elements/forms_spec.rb +44 -0
  79. data/spec/watirspec/elements/frame_spec.rb +121 -0
  80. data/spec/watirspec/elements/frames_spec.rb +41 -0
  81. data/spec/watirspec/elements/hidden_spec.rb +102 -0
  82. data/spec/watirspec/elements/hiddens_spec.rb +43 -0
  83. data/spec/watirspec/elements/hn_spec.rb +96 -0
  84. data/spec/watirspec/elements/hns_spec.rb +38 -0
  85. data/spec/watirspec/elements/iframe_spec.rb +174 -0
  86. data/spec/watirspec/elements/iframes_spec.rb +47 -0
  87. data/spec/watirspec/elements/image_spec.rb +164 -0
  88. data/spec/watirspec/elements/images_spec.rb +40 -0
  89. data/spec/watirspec/elements/ins_spec.rb +129 -0
  90. data/spec/watirspec/elements/inses_spec.rb +40 -0
  91. data/spec/watirspec/elements/label_spec.rb +79 -0
  92. data/spec/watirspec/elements/labels_spec.rb +40 -0
  93. data/spec/watirspec/elements/li_spec.rb +115 -0
  94. data/spec/watirspec/elements/link_spec.rb +174 -0
  95. data/spec/watirspec/elements/links_spec.rb +44 -0
  96. data/spec/watirspec/elements/lis_spec.rb +42 -0
  97. data/spec/watirspec/elements/map_spec.rb +79 -0
  98. data/spec/watirspec/elements/maps_spec.rb +41 -0
  99. data/spec/watirspec/elements/meta_spec.rb +23 -0
  100. data/spec/watirspec/elements/metas_spec.rb +40 -0
  101. data/spec/watirspec/elements/ol_spec.rb +89 -0
  102. data/spec/watirspec/elements/ols_spec.rb +40 -0
  103. data/spec/watirspec/elements/option_spec.rb +152 -0
  104. data/spec/watirspec/elements/p_spec.rb +115 -0
  105. data/spec/watirspec/elements/pre_spec.rb +115 -0
  106. data/spec/watirspec/elements/pres_spec.rb +40 -0
  107. data/spec/watirspec/elements/ps_spec.rb +40 -0
  108. data/spec/watirspec/elements/radio_spec.rb +263 -0
  109. data/spec/watirspec/elements/radios_spec.rb +43 -0
  110. data/spec/watirspec/elements/select_list_spec.rb +379 -0
  111. data/spec/watirspec/elements/select_lists_spec.rb +46 -0
  112. data/spec/watirspec/elements/span_spec.rb +129 -0
  113. data/spec/watirspec/elements/spans_spec.rb +40 -0
  114. data/spec/watirspec/elements/strong_spec.rb +92 -0
  115. data/spec/watirspec/elements/strongs_spec.rb +43 -0
  116. data/spec/watirspec/elements/table_nesting_spec.rb +51 -0
  117. data/spec/watirspec/elements/table_spec.rb +146 -0
  118. data/spec/watirspec/elements/tables_spec.rb +42 -0
  119. data/spec/watirspec/elements/tbody_spec.rb +96 -0
  120. data/spec/watirspec/elements/tbodys_spec.rb +62 -0
  121. data/spec/watirspec/elements/td_spec.rb +71 -0
  122. data/spec/watirspec/elements/tds_spec.rb +53 -0
  123. data/spec/watirspec/elements/text_field_spec.rb +302 -0
  124. data/spec/watirspec/elements/text_fields_spec.rb +44 -0
  125. data/spec/watirspec/elements/textarea_spec.rb +26 -0
  126. data/spec/watirspec/elements/textareas_spec.rb +24 -0
  127. data/spec/watirspec/elements/tfoot_spec.rb +91 -0
  128. data/spec/watirspec/elements/tfoots_spec.rb +68 -0
  129. data/spec/watirspec/elements/thead_spec.rb +91 -0
  130. data/spec/watirspec/elements/theads_spec.rb +68 -0
  131. data/spec/watirspec/elements/tr_spec.rb +80 -0
  132. data/spec/watirspec/elements/trs_spec.rb +61 -0
  133. data/spec/watirspec/elements/ul_spec.rb +79 -0
  134. data/spec/watirspec/elements/uls_spec.rb +39 -0
  135. data/spec/watirspec/html/alerts.html +12 -0
  136. data/spec/watirspec/html/aria_attributes.html +9 -0
  137. data/spec/watirspec/html/class_locator.html +8 -0
  138. data/spec/watirspec/html/clicks.html +19 -0
  139. data/spec/watirspec/html/closeable.html +13 -0
  140. data/spec/watirspec/html/collections.html +15 -0
  141. data/spec/watirspec/html/css/jquery-ui-1.8.17.custom.css +287 -0
  142. data/spec/watirspec/html/data_attributes.html +9 -0
  143. data/spec/watirspec/html/definition_lists.html +48 -0
  144. data/spec/watirspec/html/drag_and_drop.html +106 -0
  145. data/spec/watirspec/html/font.html +10 -0
  146. data/spec/watirspec/html/forms_with_input_elements.html +170 -0
  147. data/spec/watirspec/html/frame_1.html +22 -0
  148. data/spec/watirspec/html/frame_2.html +16 -0
  149. data/spec/watirspec/html/frames.html +11 -0
  150. data/spec/watirspec/html/hover.html +12 -0
  151. data/spec/watirspec/html/iframe_1.html +22 -0
  152. data/spec/watirspec/html/iframes.html +12 -0
  153. data/spec/watirspec/html/images.html +28 -0
  154. data/spec/watirspec/html/images/1.gif +0 -0
  155. data/spec/watirspec/html/images/2.gif +0 -0
  156. data/spec/watirspec/html/images/3.gif +0 -0
  157. data/spec/watirspec/html/images/button.png +0 -0
  158. data/spec/watirspec/html/images/circle.png +0 -0
  159. data/spec/watirspec/html/images/map.gif +0 -0
  160. data/spec/watirspec/html/images/map2.gif +0 -0
  161. data/spec/watirspec/html/images/minus.gif +0 -0
  162. data/spec/watirspec/html/images/originaltriangle.png +0 -0
  163. data/spec/watirspec/html/images/plus.gif +0 -0
  164. data/spec/watirspec/html/images/square.png +0 -0
  165. data/spec/watirspec/html/images/triangle.png +0 -0
  166. data/spec/watirspec/html/inner_outer.html +5 -0
  167. data/spec/watirspec/html/javascript/helpers.js +16 -0
  168. data/spec/watirspec/html/javascript/jquery-1.7.1.min.js +4 -0
  169. data/spec/watirspec/html/javascript/jquery-ui-1.8.17.custom.min.js +68 -0
  170. data/spec/watirspec/html/keylogger.html +15 -0
  171. data/spec/watirspec/html/modal_dialog.html +9 -0
  172. data/spec/watirspec/html/multiple_ids.html +14 -0
  173. data/spec/watirspec/html/nested_frame_1.html +1 -0
  174. data/spec/watirspec/html/nested_frame_2.html +9 -0
  175. data/spec/watirspec/html/nested_frame_3.html +14 -0
  176. data/spec/watirspec/html/nested_frames.html +10 -0
  177. data/spec/watirspec/html/nested_iframe_2.html +12 -0
  178. data/spec/watirspec/html/nested_iframes.html +9 -0
  179. data/spec/watirspec/html/nested_tables.html +203 -0
  180. data/spec/watirspec/html/non_control_elements.html +135 -0
  181. data/spec/watirspec/html/removed_element.html +24 -0
  182. data/spec/watirspec/html/right_click.html +11 -0
  183. data/spec/watirspec/html/special_chars.html +12 -0
  184. data/spec/watirspec/html/tables.html +121 -0
  185. data/spec/watirspec/html/timeout_window_location.html +19 -0
  186. data/spec/watirspec/html/uneven_table.html +20 -0
  187. data/spec/watirspec/html/wait.html +65 -0
  188. data/spec/watirspec/html/watirspec.css +0 -0
  189. data/spec/watirspec/html/window_switching.html +12 -0
  190. data/spec/watirspec/relaxed_locate_spec.rb +214 -0
  191. data/spec/watirspec/screenshot_spec.rb +29 -0
  192. data/spec/watirspec/wait_spec.rb +304 -0
  193. data/spec/watirspec/window_switching_spec.rb +411 -0
  194. data/spec/{implementation.rb → watirspec_helper.rb} +13 -13
  195. data/support/appveyor.cmd +9 -0
  196. data/support/doctest_helper.rb +5 -1
  197. data/support/travis.sh +0 -1
  198. data/watir.gemspec +3 -4
  199. metadata +323 -30
  200. data/.gitmodules +0 -3
@@ -0,0 +1,135 @@
1
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
2
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
3
+ <head>
4
+ <title>Non-control elements</title>
5
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
6
+ <script src="javascript/helpers.js" type="text/javascript" charset="utf-8"></script>
7
+ </head>
8
+ <body>
9
+ <div></div>
10
+ <div id="outer_container">
11
+ <div id="header" title="Header and primary navigation" class="profile">
12
+ <h1 id="first_header" class="primary">Header 1</h1>
13
+ <ul id="navbar" class="navigation">
14
+ <li><a></a></li>
15
+ <li><a id="link_2" title="link_title_2" href="non_control_elements.html" class="external">Link 2</a></li>
16
+ <li><a id="link_3" title="link_title_3" href="forms_with_input_elements.html" name="bad_attribute" value="bad_attribute" class="external">Link 3</a></li>
17
+ <li></li>
18
+ <li id="non_link_1" class="nonlink" title="This is not a link!">Non-link 1</li>
19
+ <li id="non_link_2">Non-link 2</li>
20
+ <li>Non-link 3</li>
21
+ </ul>
22
+ </div>
23
+ <div id="promo" name="invalid_attribute" value="invalid_attribute">
24
+ <h2 id="promo_header">Promo</h2>
25
+ <span id="lead" class="lead" title="Lorem ipsum">Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Curabitur eu pede. Ut justo. Praesent feugiat, elit in feugiat iaculis, sem risus rutrum justo, eget fermentum dolor arcu non nunc.</span>
26
+ <span name="invalid_attribute" value="invalid_attribute">Sed pretium metus et quam. Nullam odio dolor, vestibulum non, tempor ut, vehicula sed, sapien. Vestibulum placerat ligula at quam. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas.</span>
27
+ <span>Suspendisse at ipsum a turpis viverra venenatis. Praesent ut nibh. Nullam eu odio. Donec tempor, elit ut lacinia porttitor, augue neque vehicula diam, in elementum ligula nisi a tellus. Aliquam vestibulum ultricies tortor. </span>
28
+ <span><strong id="descartes" class="descartes">Dubito, <em class="important-class" id="important-id" title="ergo cogito">ergo cogito</em>, ergo sum.</strong></span>
29
+ <span></span>
30
+ <h3>Chemical compounds</h3>
31
+ <ul>
32
+ <li>Abietic acid, <strong>C20H30O2</strong></li>
33
+ <li>Acenaphthene, C12H10</li>
34
+ <li>Acenaphthoquinone, C12H6O2</li>
35
+ <li>Acenaphthylene, C12H8</li>
36
+ <li>Acetaldehyde (ethanal), CH3CHO</li>
37
+ </ul>
38
+ <ol id="favorite_compounds" class="chemistry">
39
+ <li>Propanol, CH3CH2CH2OH</li>
40
+ <li>Ethane, C2H6</li>
41
+ <li>Hexene, C6H12</li>
42
+ <li>Acetone, CH3COCH3</li>
43
+ <li>Ethanol, CH3CH2OH</li>
44
+ </ol>
45
+ <ol>
46
+ <li></li>
47
+ </ol>
48
+ </div>
49
+ <div id="content">
50
+ <h2>Content</h2>
51
+ <p id="lead" class="lead" title="Lorem ipsum">Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Curabitur eu pede. Ut justo. Praesent feugiat, elit in feugiat iaculis, sem risus rutrum justo, eget fermentum dolor arcu non nunc.</p>
52
+ <p name="invalid_attribute" value="invalid_attribute">Sed pretium metus et quam. Nullam odio dolor, vestibulum non, tempor ut, vehicula sed, sapien. Vestibulum placerat ligula at quam. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas.</p>
53
+ <p>Suspendisse at ipsum a turpis viverra venenatis. Praesent ut nibh. Nullam eu odio. Donec tempor, elit ut lacinia porttitor, augue neque vehicula diam, in elementum ligula nisi a tellus. Aliquam vestibulum ultricies tortor. </p>
54
+ <p>Dubito, ergo cogito, ergo sum.</p>
55
+ <p></p>
56
+ <pre></pre>
57
+ <div id="best_language" onclick="this.innerHTML = 'Ruby!'" style="color: red; text-decoration: underline; cursor: pointer;">What's the best programming language?</div>
58
+ <h2>Ruby RSpec example</h2>
59
+ <pre class="ruby" id="rspec">
60
+ browser.pre(id: "rspec").should exist
61
+ </pre>
62
+ <h2>PHP Hello World</h2>
63
+ <pre class="php">
64
+ &lt;?php
65
+ echo "Hello, World!\n";
66
+ ?&gt;
67
+ </pre>
68
+ <h2>Ruby Hello World</h2>
69
+ <pre class="ruby">
70
+ puts "Hello, World!"
71
+ </pre>
72
+ <h2>C++ Hello World</h2>
73
+ <pre class="c-plus-plus">
74
+ main() {
75
+ cout << "Hello World!\n";
76
+ return 0;
77
+ }
78
+ </pre>
79
+ <h2>Haskell</h2>
80
+ <pre class="haskell">main = putStrLn "Hello World"</pre>
81
+ <h2>Brainfuck</h2>
82
+ <pre class="brainfuck" title="The brainfuck language is an esoteric programming language noted for its extreme minimalism">
83
+ ++++++++++
84
+ [>+++++++>++++++++++>+++>+<<<<-] The initial loop to set up useful values in the array
85
+ >++. Print 'H'
86
+ >+. Print 'e'
87
+ +++++++. Print 'l'
88
+ . Print 'l'
89
+ +++. Print 'o'
90
+ >++. Print ' '
91
+ <<+++++++++++++++. Print 'W'
92
+ >. Print 'o'
93
+ +++. Print 'r'
94
+ ------. Print 'l'
95
+ --------. Print 'd'
96
+ >+. Print '!'
97
+ >. Print newline
98
+ </pre>
99
+ </div>
100
+ <div id="html_test" class=some_class title="This is a title" ondblclick="WatirSpec.addMessage('double clicked')">
101
+ <h1 id="header1">Header 1</h1>
102
+ <h2 id="header2">Header 2</h2>
103
+ <h3 id="header3">Header 3</h3>
104
+ <h4 id="header4">Header 4</h4>
105
+ <h5 id="header5">Header 5</h5>
106
+ <h6 id="header6">Header 6</h6>
107
+ <h6 id="empty_header"></h6>
108
+ </div>
109
+ <div id="footer" title="Closing remarks" class="profile">
110
+ <span class="footer" onclick="this.innerHTML = 'This is a footer with text set by Javascript.'">This is a footer.</span>
111
+ </div>
112
+ <a href="strip_space ">Space should be stripped from href</a>
113
+ <div id="hidden" style="display: none;">Not shown</div>
114
+ </div>
115
+
116
+ <div id="messages"></div>
117
+
118
+ <div id="ins_tag_test">
119
+ <ins id="lead" class="lead" title='Lorem ipsum'>This is an inserted text tag 1</ins>
120
+ <ins value="invalid_attribute">This is an inserted text tag 2</ins>
121
+ <ins>This is an inserted text tag 3</ins>
122
+ <ins></ins>
123
+ <ins class="footer" onclick="this.innerHTML = 'This is an ins with text set by Javascript.'">This is an ins.</ins>
124
+ </div>
125
+
126
+ <div id="del_tag_test">
127
+ <del id="lead" class="lead" title='Lorem ipsum'>This is a deleted text tag 1</del>
128
+ <del value="invalid_attribute">This is a deleted text tag 2</del>
129
+ <del>This is a deleted text tag 3</del>
130
+ <del></del>
131
+ <del class="footer" onclick="this.innerHTML = 'This is a del with text set by Javascript.'">This is a del.</del>
132
+ </div>
133
+
134
+ </body>
135
+ </html>
@@ -0,0 +1,24 @@
1
+ <!DOCTYPE HTML>
2
+ <html>
3
+ <head>
4
+ <title>obsolete element</title>
5
+ <script type="text/javascript" charset="utf-8">
6
+ function removeText() {
7
+ var e = document.getElementById("text");
8
+ e.parentNode.removeChild(e);
9
+ }
10
+ </script>
11
+ </head>
12
+
13
+ <body>
14
+ <button id='remove-button' onclick="removeText()">Remove text</button>
15
+ <div id="text">Text</div>
16
+
17
+ <div id='top'>Top Element>
18
+ <div id='middle'>Middle Element>
19
+ <div id='bottom'>Bottom Element</div>
20
+ </div>
21
+ </div>
22
+
23
+ </body>
24
+ </html>
@@ -0,0 +1,11 @@
1
+ <html>
2
+ <head>
3
+ <meta http-equiv="Content-type" content="text/html; charset=utf-8">
4
+ <title>Right Click Test</title>
5
+ <script src="javascript/helpers.js" type="text/javascript" charset="utf-8"></script>
6
+ </head>
7
+ <body>
8
+ <div id="messages"></div>
9
+ <div id="click" oncontextmenu='WatirSpec.addMessage("right-clicked"); return false'>Right click!</div>
10
+ </body>
11
+ </html>
@@ -0,0 +1,12 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
5
+ <title>Special Chars</title>
6
+ </head>
7
+
8
+ <body>
9
+ <div id='single-quote'>single 'quotes'</div>
10
+ <div id='double-quote'>double "quotes"</div>
11
+ </body>
12
+ </html>
@@ -0,0 +1,121 @@
1
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
2
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
3
+ <head>
4
+ <title>Tables</title>
5
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
6
+ <script src="javascript/helpers.js" type="text/javascript" charset="utf-8"></script>
7
+ </head>
8
+ <body>
9
+ <div id="messages"></div>
10
+ <h1>Tables</h1>
11
+ <h2>Semantic table</h2>
12
+ <table cellspacing="0" cellpadding="5" rules="groups" frame="box" border="1" id="axis_example" summary="Hugh Laurie made more money than Gregory House in both March and April of 2008.">
13
+ <caption>Income tax information for Gregory House and Hugh Laurie</caption>
14
+ <colgroup width="25%" align="left"></colgroup>
15
+ <colgroup width="25%" span="3" align="right"></colgroup>
16
+ <thead id="tax_headers">
17
+ <tr style="border-bottom: 1px solid black;" class="dark" id="thead_row_1">
18
+ <th></th>
19
+ <th id="before_tax" axis="cash" abbr="Before tax">Before income tax</th>
20
+ <th id="tax" axis="cash" abbr="Tax">Income tax</th>
21
+ <th id="after_tax" axis="cash" abbr="After tax">After income tax</th>
22
+ </tr>
23
+ </thead>
24
+ <tfoot id="tax_totals">
25
+ <tr class="dark" id="tfoot_row_1">
26
+ <th axis="sum">Sum</th>
27
+ <td headers="before_tax">24 349</td>
28
+ <td headers="tax">5 577</td>
29
+ <td headers="after_tax">18 722</td>
30
+ </tr>
31
+ </tfoot>
32
+ <tbody id="first">
33
+ <tr id="march">
34
+ <th id="d1" axis="date" scope="rowgroup">March 2008</th>
35
+ <th></th>
36
+ <th></th>
37
+ <th></th>
38
+ </tr>
39
+ <tr id="gregory">
40
+ <td id="p1" abbr="Dr. House">Gregory House</td>
41
+ <td headers="before_tax p1 d1">5 934</td>
42
+ <td headers="tax p1 d1">1 347</td>
43
+ <td headers="after_tax p1 d1">4 587</td>
44
+ </tr>
45
+ <tr id="hugh">
46
+ <td id="p2" abbr="Laurie">Hugh Laurie</td>
47
+ <td headers="before_tax p2 d1">6 300</td>
48
+ <td headers="tax p2 d1">1 479</td>
49
+ <td headers="after_tax p2 d1">4 821</td>
50
+ </tr>
51
+ </tbody>
52
+ <tbody name="second" id="second">
53
+ <tr>
54
+ <th id="d2" axis="date" scope="rowgroup">April 2008</th>
55
+ <th></th>
56
+ <th></th>
57
+ <th></th>
58
+ </tr>
59
+ <tr>
60
+ <td id="p3" abbr="Dr. House">Gregory House</td>
61
+ <td headers="before_tax p3 d2">5 863</td>
62
+ <td headers="tax p3 d2">1 331</td>
63
+ <td headers="after_tax p3 d2">4 532</td>
64
+ </tr>
65
+ <tr>
66
+ <td id="p4" abbr="Laurie">Hugh Laurie</td>
67
+ <td headers="before_tax p4 d2">6 252</td>
68
+ <td headers="tax p4 d2">1 420</td>
69
+ <td headers="after_tax p4 d2">4 <span id="cell-child">832</span></td>
70
+ </tr>
71
+ </tbody>
72
+ </table>
73
+ <h2>Table inside a table</h2>
74
+ <table border="1" id="outer">
75
+ <tr id="outer_first">
76
+ <td>
77
+ Table 1, Row 1, Cell 1
78
+ </td>
79
+ <td>
80
+ Table 1, Row 1, Cell 2
81
+ </td>
82
+ </tr>
83
+ <tr id="outer_second">
84
+ <td id="t1_r2_c1">
85
+ Table 1, Row 2, Cell 1
86
+ </td>
87
+ <td id="t1_r2_c2">
88
+ Table 1, Row 2, Cell 2
89
+ <table border="1" id="inner" onclick="WatirSpec.addMessage('table')">
90
+ <tr id="inner_first" onclick="WatirSpec.addMessage('tr')">
91
+ <td id="t2_r1_c1" onclick="WatirSpec.addMessage('td')">
92
+ Table 2, Row 1, Cell 1
93
+ </td>
94
+ <td>
95
+ Table 2, Row 1, Cell 2
96
+ </td>
97
+ </tr>
98
+ </table>
99
+ </td>
100
+ </tr>
101
+ <tr id="outer_last">
102
+ <td>
103
+ Table 1, Row 3, Cell 1
104
+ </td>
105
+ <td>
106
+ Table 1, Row 3, Cell 2
107
+ </td>
108
+ </tr>
109
+ </table>
110
+ <h2>Colspan</h2>
111
+ <table border="1" id="colspan">
112
+ <tr>
113
+ <td colspan="2" id="colspan_2">Colspan 2</td>
114
+ </tr>
115
+ <tr>
116
+ <td id="no_colspan">No colspan attribute</td>
117
+ <td>No colspan attribute</td>
118
+ </tr>
119
+ </table>
120
+ </body>
121
+ </html>
@@ -0,0 +1,19 @@
1
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
2
+ <html lang='en_gb' xml:lang='en_gb' xmlns='http://www.w3.org/1999/xhtml'>
3
+ <head>
4
+ <title>
5
+ Timeout test
6
+ </title>
7
+ <meta content='text/html; charset=utf-8' http-equiv='content-type' />
8
+ <script type='text/javascript'>
9
+ //<![CDATA[
10
+ function move_on() {
11
+ window.location = 'non_control_elements.html';
12
+ }
13
+ //]]>
14
+ </script>
15
+ </head>
16
+ <body onload='setTimeout(move_on, 500)'>
17
+ Wait 500ms for the next page.
18
+ </body>
19
+ </html>
@@ -0,0 +1,20 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <title>Uneven Table</title>
6
+ </head>
7
+ <body>
8
+ <table border="0" cellspacing="5" cellpadding="5">
9
+ <tr>
10
+ <th>Header 1</th>
11
+ <th>Header 2</th>
12
+ <th>Header 3</th>
13
+ </tr>
14
+ <tr>
15
+ <td>Data 1</td>
16
+ <td>Data 2</td>
17
+ </tr>
18
+ </table>
19
+ </body>
20
+ </html>
@@ -0,0 +1,65 @@
1
+ <!DOCTYPE HTML>
2
+ <html>
3
+ <head>
4
+ <title>wait test</title>
5
+ <script type="text/javascript" charset="utf-8">
6
+
7
+ function setTimeoutAddDisplay(id, current_id, timeout) {
8
+ setTimeoutAdd(id, "none", id, current_id, timeout);
9
+ setTimeoutDisplay(id, "block", timeout*2)
10
+ }
11
+
12
+ function setTimeoutDisplay(id, display, timeout) {
13
+ setTimeout(function() {
14
+ document.getElementById(id).style.display = display;
15
+ }, timeout);
16
+ }
17
+
18
+ function setTimeoutAdd(id, display, text, existing_id, timeout) {
19
+ var newDiv = document.createElement("div");
20
+ newDiv.setAttribute("id", id);
21
+ newDiv.style.display = display;
22
+ newDiv.appendChild(document.createTextNode(text));
23
+
24
+ var currentDiv = document.getElementById(existing_id);
25
+
26
+ setTimeout(function() {
27
+ document.body.insertBefore(newDiv, currentDiv);
28
+ }, timeout);
29
+ }
30
+
31
+ function setTimeoutRemove(id, timeout) {
32
+ setTimeout(function() {
33
+ var e = document.getElementById(id);
34
+ e.parentNode.removeChild(e);
35
+ }, timeout);
36
+ }
37
+
38
+ function setDisabled(id, disabled, timeout) {
39
+ setTimeout(function() {
40
+ document.getElementById(id).disabled = disabled;
41
+ }, timeout);
42
+ }
43
+ </script>
44
+ </head>
45
+
46
+ <body>
47
+ <div id="foo" style="display:block;">foo</div>
48
+ <div id="bar" style="display:none;" onclick='this.innerHTML = "changed"'>bar</div>
49
+ <a id="show_bar" href="#" onclick="setTimeoutDisplay('bar', 'block', 500);">show bar</a>
50
+ <a id="hide_foo" href="#" onclick="setTimeoutDisplay('foo', 'none', 500);">hide foo</a>
51
+ <a id="remove_foo" href="#" onclick="setTimeoutRemove('foo', 1000);">remove foo</a>
52
+ <a id="add_foobar" href="#" onclick="setTimeoutAddDisplay('foobar', 'bar', 1000);">add foobar</a>
53
+ <div id="buttons">
54
+ <button id="btn" type="button" onclick="setDisabled('btn', true, 0)" disabled>Click To Disable!</button>
55
+ <a id="enable_btn" href="#" onclick="setDisabled('btn', false, 500);">enable btn</a>
56
+ <button id="btn2" style="display:none;" type="button" disabled>Hidden and Disabled</button>
57
+ <a id="show_and_enable_btn" href="#" onclick="setTimeoutDisplay('btn2', 'block', 500); setDisabled('btn2', false, 1000);">
58
+ show and enable btn
59
+ </a>
60
+ </div>
61
+ <div id="also_hidden" style="display:none;">
62
+ <div id="hidden_child">Nothing to see here</div>
63
+ </div>
64
+ </body>
65
+ </html>
File without changes
@@ -0,0 +1,12 @@
1
+ <!DOCTYPE HTML>
2
+ <html>
3
+ <head>
4
+ <title>window switching</title>
5
+ </head>
6
+
7
+ <body>
8
+ <p>
9
+ Click <a id="open" href="#" onclick='window.open("closeable.html")'>here</a> to open a new window.
10
+ </p>
11
+ </body>
12
+ </html>
@@ -0,0 +1,214 @@
1
+ require "watirspec_helper"
2
+
3
+ describe 'Watir#relaxed_locate?' do
4
+ not_compliant_on :not_relaxed_locate do
5
+ context 'when true' do
6
+ before :each do
7
+ browser.goto(WatirSpec.url_for("wait.html"))
8
+ end
9
+
10
+ context 'when acting on an element that is never present' do
11
+ it 'raises exception after timing out' do
12
+ begin
13
+ time_out = 2
14
+ Watir.default_timeout = time_out
15
+ element = browser.link(id: 'not_there')
16
+ start_time = ::Time.now
17
+ expect { element.click }.to raise_exception(Watir::Exception::UnknownObjectException)
18
+ expect(::Time.now - start_time).to be > time_out
19
+ ensure
20
+ Watir.default_timeout = 30
21
+ end
22
+ end
23
+ end
24
+
25
+ context 'when acting on an element that is already present' do
26
+ it 'does not wait' do
27
+ begin
28
+ Watir.default_timeout = 2
29
+ start_time = ::Time.now
30
+ expect { browser.link.click }.to_not raise_exception
31
+ expect(::Time.now - start_time).to be < 2
32
+ ensure
33
+ Watir.default_timeout = 30
34
+ end
35
+ end
36
+ end
37
+
38
+ context 'when acting on an element that eventually becomes present' do
39
+ it 'waits until present and then takes action' do
40
+ begin
41
+ Watir.default_timeout = 3
42
+ start_time = ::Time.now
43
+ browser.a(id: 'show_bar').click
44
+ expect { browser.div(id: 'bar').click }.to_not raise_exception
45
+ expect(::Time.now - start_time).to be < 3
46
+ ensure
47
+ Watir.default_timeout = 30
48
+ end
49
+ end
50
+ end
51
+
52
+ context 'when evaluating order of failure precedence' do
53
+ it 'fails first for parent not existing' do
54
+ begin
55
+ Watir.default_timeout = 0
56
+ selector = "{:id=>\"no_parent\", :tag_name=>\"div\"}"
57
+ element = browser.div(id: 'no_parent').div(id: 'no_child')
58
+ error = Watir::Exception::UnknownObjectException
59
+ message = "timed out after #{Watir.default_timeout} seconds, waiting for #{selector} to be located"
60
+ expect { element.click }.to raise_exception(error, message)
61
+ ensure
62
+ Watir.default_timeout = 30
63
+ end
64
+ end
65
+
66
+ it 'fails for child not existing if parent exists' do
67
+ begin
68
+ Watir.default_timeout = 0
69
+ selector = "{:id=>\"buttons\", :tag_name=>\"div\"} --> {:id=>\"no_child\", :tag_name=>\"div\"}"
70
+ element = browser.div(id: 'buttons').div(id: 'no_child')
71
+ error = Watir::Exception::UnknownObjectException
72
+ message = "timed out after #{Watir.default_timeout} seconds, waiting for #{selector} to be located"
73
+ expect { element.click }.to raise_exception(error, message)
74
+ ensure
75
+ Watir.default_timeout = 30
76
+ end
77
+ end
78
+
79
+ it 'fails for parent not present if child exists' do
80
+ begin
81
+ Watir.default_timeout = 0.5
82
+ selector = "{:id=>\"also_hidden\", :tag_name=>\"div\"}"
83
+ element = browser.div(id: 'also_hidden').div(id: 'hidden_child')
84
+ error = Watir::Exception::UnknownObjectException
85
+ message = "element located, but timed out after #{Watir.default_timeout} seconds, waiting for true condition on #{selector}"
86
+ expect { element.click }.to raise_exception(error, message)
87
+ ensure
88
+ Watir.default_timeout = 30
89
+ end
90
+ end
91
+
92
+ it 'fails for child not present if parent is present' do
93
+ begin
94
+ Watir.default_timeout = 0.5
95
+ selector = "{:id=>\"buttons\", :tag_name=>\"div\"} --> {:id=>\"btn2\", :tag_name=>\"button\"}"
96
+ element = browser.div(id: 'buttons').button(id: 'btn2')
97
+ error = Watir::Exception::UnknownObjectException
98
+ message = "element located, but timed out after #{Watir.default_timeout} seconds, waiting for true condition on #{selector}"
99
+ expect { element.click }.to raise_exception(error, message)
100
+ ensure
101
+ Watir.default_timeout = 30
102
+ end
103
+ end
104
+
105
+ it 'fails for element not enabled if present' do
106
+ browser.goto(WatirSpec.url_for("forms_with_input_elements.html"))
107
+ begin
108
+ Watir.default_timeout = 0.5
109
+ selector = "{:id=>\"new_user\", :tag_name=>\"form\"} --> {:id=>\"good_luck\", :tag_name=>\"input or textarea\", :type=>\"(any text type)\"}"
110
+ element = browser.form(id: 'new_user').text_field(id: 'good_luck')
111
+ error = Watir::Exception::ObjectDisabledException
112
+ message = "element present, but timed out after #{Watir.default_timeout} seconds, waiting for #{selector} to be enabled"
113
+ expect { element.set('foo') }.to raise_exception(error, message)
114
+ ensure
115
+ Watir.default_timeout = 30
116
+ end
117
+ end
118
+
119
+ it 'fails for element being readonly if enabled' do
120
+ browser.goto(WatirSpec.url_for("forms_with_input_elements.html"))
121
+ begin
122
+ Watir.default_timeout = 0.5
123
+ selector = "{:id=>\"new_user\", :tag_name=>\"form\"} --> {:id=>\"new_user_code\", :tag_name=>\"input or textarea\", :type=>\"(any text type)\"}"
124
+ element = browser.form(id: 'new_user').text_field(id: 'new_user_code')
125
+ error = Watir::Exception::ObjectReadOnlyException
126
+ message = "element present and enabled, but timed out after #{Watir.default_timeout} seconds, waiting for #{selector} to not be readonly"
127
+ expect { element.set('foo') }.to raise_exception(error, message)
128
+ ensure
129
+ Watir.default_timeout = 30
130
+ end
131
+ end
132
+ end
133
+
134
+ it 'gives warning when rescuing for flow control' do
135
+ begin
136
+ Watir.default_timeout = 1
137
+ element = browser.link(id: 'not_there')
138
+ message = "This code has slept for the duration of the default timeout "
139
+ message << "waiting for an Element to exist. If the test is still passing, "
140
+ message << "consider using Element#exists? instead of rescuing UnknownObjectException\n"
141
+ expect do
142
+ begin
143
+ element.click
144
+ rescue Watir::Exception::UnknownObjectException
145
+ end
146
+ end.to output(message).to_stderr
147
+ ensure
148
+ Watir.default_timeout = 30
149
+ end
150
+ end
151
+
152
+ it 'ensures all checks happen once even if time has expired' do
153
+ begin
154
+ Watir.default_timeout = -1
155
+ expect { browser.link.click }.to_not raise_exception
156
+ ensure
157
+ Watir.default_timeout = 30
158
+ end
159
+ end
160
+
161
+ it 'ensures that the same timeout is used for all of the calls' do
162
+ begin
163
+ Watir.default_timeout = 1.1
164
+ browser.a(id: 'add_foobar').click
165
+ # Element created after 1 second, and displays after 2 seconds
166
+ # Click will only raise this exception if the timer is not reset between #wait_for_exists and #wait_for_present
167
+ expect { browser.div(id: 'foobar').click }.to raise_exception Watir::Exception::UnknownObjectException
168
+ ensure
169
+ Watir.default_timeout = 30
170
+ end
171
+ end
172
+ end
173
+ end
174
+
175
+ not_compliant_on :relaxed_locate do
176
+ context 'when false' do
177
+ before :each do
178
+ browser.goto(WatirSpec.url_for("wait.html"))
179
+ end
180
+
181
+ context 'when acting on an element that is never present' do
182
+ it 'raises exception immediately' do
183
+ begin
184
+ time_out = 2
185
+ Watir.default_timeout = time_out
186
+ element = browser.link(id: 'not_there')
187
+ start_time = ::Time.now
188
+ expect { element.click }.to raise_exception(Watir::Exception::UnknownObjectException)
189
+ expect(::Time.now - start_time).to be < 1
190
+ ensure
191
+ Watir.default_timeout = 30
192
+ end
193
+ end
194
+ end
195
+
196
+ context 'when acting on an element that eventually becomes present' do
197
+ it 'raises exception immediately' do
198
+ start_time = ::Time.now
199
+ browser.a(id: 'show_bar').click
200
+ expect { browser.div(id: 'bar').click }.to raise_exception(Selenium::WebDriver::Error::ElementNotVisibleError)
201
+ expect(::Time.now - start_time).to be < 1
202
+ end
203
+ end
204
+
205
+ it 'receives a warning for using #when_present' do
206
+ message = /#when_present has been deprecated and is unlikely to be needed; replace this with #wait_until_present if a wait is still needed/
207
+ browser.a(id: 'show_bar').click
208
+ expect do
209
+ browser.div(id: 'bar').when_present.click
210
+ end.to output(message).to_stderr
211
+ end
212
+ end
213
+ end
214
+ end