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
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 935a787298648718688deca84d844924d69dc5b0
4
- data.tar.gz: d6e4f016435c83c21ab6045eac35365c2fb0b370
3
+ metadata.gz: fc26b04deabc014544f4768c6477d930ae316b9d
4
+ data.tar.gz: e3e954cff4868448b49735ab2e7e04018a601bc2
5
5
  SHA512:
6
- metadata.gz: 7e215494da9556e98fe9542a042ff80a64bedbef8071bc920a9653806b629e4876a0708f0b06cb318f69b8cdbc16855dc0704b630df0de83fac3b36225f406a5
7
- data.tar.gz: 4b77b7a781336fc2534b5a91051e1b66e590eabdc85162dd8ee6aebf4ba1cecb79d29a766d284d0bc849b42b82e025c51e627b543d59981a0756f5e0c31d8065
6
+ metadata.gz: 53b68b0ca306783b02910bc0152e8ccbc064262e7b9fe22792ee32b84c436f4232a782c4e5db387ce0b1168ebc0a322b5a5d15434c83b2b43063733784a06836
7
+ data.tar.gz: e2233b72dd59430fe9a49fcdf210188916719ee818724e65c9c25dc6588e9b47ddf57a97b796e54af68aca92df08203b861af946f2418c6b938395acbb467e5b
data/.travis.yml CHANGED
@@ -1,7 +1,7 @@
1
1
  sudo: false
2
2
  rvm:
3
- - 2.1
4
- - 2.2
3
+ - 2.1.9
4
+ - 2.2.5
5
5
  - 2.3.1
6
6
  addons:
7
7
  firefox: latest
@@ -24,6 +24,9 @@ before_script:
24
24
  script: bundle exec rake $RAKE_TASK
25
25
  env:
26
26
  - RAKE_TASK=spec:firefox
27
+ - RAKE_TASK=spec:firefox RELAXED_LOCATE=false
27
28
  - RAKE_TASK=spec:chrome
29
+ - RAKE_TASK=spec:chrome RELAXED_LOCATE=false
28
30
  - RAKE_TASK=spec:phantomjs
31
+ - RAKE_TASK=spec:phantomjs RELAXED_LOCATE=false
29
32
  - RAKE_TASK=yard:doctest
data/CHANGES.md CHANGED
@@ -1,7 +1,16 @@
1
+ ### 6.0.0 (2016-11-08)
2
+
3
+ * Add `#Watir#relaxed_locate` to enable automatic waiting for elements to be ready for a specified action
4
+ * Remove `when_present` method
5
+ * Update `wait_until` and `wait_while` to return `self` to allow chaining
6
+ * Support keywords for wait methods
7
+ * `Element#text_field` no longer locates textareas - use `Element#textarea` instead.
8
+ * Use `Process.clock_gettime` when available for waiting (#486)
9
+
1
10
  ### 6.0.0.beta5 (2016-09-25)
2
11
 
3
12
  * Elements in collections can now be relocated after going stale
4
- * Added visible locator to filter out matching elements that are hidden
13
+ * Added visible locator to filter out matching elements that are hidden
5
14
  * Element not found error messages now include selector information from parent elements
6
15
 
7
16
  ### 6.0.0.beta4 (2016-09-12)
data/Gemfile CHANGED
@@ -8,5 +8,9 @@ if ENV['LOCAL_WEBIDL']
8
8
  gem 'webidl', path: File.expand_path('../webidl')
9
9
  end
10
10
 
11
+ if ENV['LOCAL_SELENIUM']
12
+ gem 'selenium-webdriver', path: File.expand_path('../selenium/build/rb')
13
+ end
14
+
11
15
  # Specify your gem's dependencies in watir.gemspec
12
16
  gemspec
data/README.md CHANGED
@@ -1,16 +1,15 @@
1
- watir
2
- ===============
1
+ # watir
3
2
 
4
3
  Watir Powered By Selenium!
5
4
 
6
5
  [![Gem Version](https://badge.fury.io/rb/watir.svg)](http://badge.fury.io/rb/watir)
7
- [![Build Status](https://travis-ci.org/watir/watir.svg?branch=master)](https://travis-ci.org/watir/watir)
6
+ [![Travis Status](https://travis-ci.org/watir/watir.svg?branch=master)](https://travis-ci.org/watir/watir)
7
+ [![AppVeyor status](https://ci.appveyor.com/api/projects/status/9vbb7pp5p4uyoott/branch/master?svg=true)](https://ci.appveyor.com/project/p0deje/watir)
8
8
  [![Code Climate](https://codeclimate.com/github/watir/watir.svg)](https://codeclimate.com/github/watir/watir)
9
9
  [![Dependency Status](https://gemnasium.com/watir/watir.svg)](https://gemnasium.com/watir/watir)
10
10
  [![Coverage Status](https://coveralls.io/repos/watir/watir/badge.svg?branch=master)](https://coveralls.io/r/watir/watir)
11
11
 
12
- Example
13
- -------
12
+ ## Example
14
13
 
15
14
  ```ruby
16
15
  require 'watir'
@@ -25,8 +24,7 @@ puts browser.title
25
24
  browser.close
26
25
  ```
27
26
 
28
- Description
29
- -----------
27
+ ## Description
30
28
 
31
29
  The majority of element methods Watir provides with is autogenerated from specifications.
32
30
  This is done by extracting the IDL parts from the spec and processing them with the WebIDL gem (link below).
@@ -35,19 +33,39 @@ Currently supported specifications are:
35
33
  * [HTML](https://www.whatwg.org/specs/web-apps/current-work/) (`lib/watir/elements/html_generated.rb`)
36
34
  * [SVG](http://www.w3.org/TR/SVG2/single-page.html) (`lib/watir/elements/svg_generated.rb`)
37
35
 
38
- Specs
39
- -----
36
+ ## Specs
40
37
 
41
- Watir uses [watirspec](http://github.com/watir/watirspec) for testing. After cloning, you should fetch the submodule:
38
+ ### WatirSpec
39
+
40
+ Watir uses WatirSpec for testing - an executable specification of Watir API.
41
+
42
+ #### Using In Other Gems
43
+
44
+ When developing Watir extension, you might want to make sure it's fully compatible with
45
+ existing API. To achieve that, you can run WatirSpec against your own extension. Assuming
46
+ your gem depends on Watir, you should do next:
47
+
48
+ First, add WatirSpec Rake tasks to your gem:
49
+
50
+ ```ruby
51
+ # Rakefile
52
+ require 'watirspec/rake_tasks'
53
+ WatirSpec::RakeTasks.new
54
+ ```
55
+
56
+ Second, initialize WatirSpec for your gem:
42
57
 
43
58
  ```bash
44
- git submodule init && git submodule update
59
+ $ bundle exec rake watirspec:init
45
60
  ```
46
61
 
62
+ After initialized, just follow the instructions to customize Watir implementation in use.
63
+
64
+ ### Watir-specific Specs
65
+
47
66
  Specs specific to Watir are found in `spec/*_spec.rb`, with watirspec in `spec/watirspec/`.
48
67
 
49
- Doctests
50
- --------
68
+ ## Doctests
51
69
 
52
70
  Watir uses [yard-doctest](https://github.com/p0deje/yard-doctest) for testing documentation examples.
53
71
 
@@ -55,26 +73,23 @@ Watir uses [yard-doctest](https://github.com/p0deje/yard-doctest) for testing do
55
73
  rake yard:doctest
56
74
  ```
57
75
 
58
- API docs
59
- --------
76
+ ## API Documentation
60
77
 
61
78
  * http://rdoc.info/gems/watir/ (updated on every release)
62
79
 
63
- See also
64
- --------
80
+ ## See Also
65
81
 
66
82
  * http://watir.github.io
67
83
  * http://github.com/jarib/webidl
68
84
  * http://github.com/watir/watirspec
69
85
  * https://github.com/seleniumhq/selenium
70
86
 
71
- Dependencies
72
- ------------
87
+ ## Dependencies
73
88
 
74
89
  * selenium-webdriver
90
+ * rack (for watirspec)
75
91
 
76
- Note on Patches/Pull Requests
77
- -----------------------------
92
+ ## Note on Patches/Pull Requests
78
93
 
79
94
  * Fork the project.
80
95
  * Make your feature addition or bug fix.
@@ -84,8 +99,7 @@ Note on Patches/Pull Requests
84
99
  (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
85
100
  * Send me a pull request. Bonus points for topic branches.
86
101
 
87
- Copyright
88
- ---------
102
+ ## Copyright
89
103
 
90
104
  Copyright (c) 2009-2015 Jari Bakken
91
105
  Copyright (c) 2015-2016 Alex Rodionov, Titus Fortner
data/Rakefile CHANGED
@@ -5,14 +5,12 @@ Bundler::GemHelper.install_tasks
5
5
 
6
6
  require 'rspec/core/rake_task'
7
7
  RSpec::Core::RakeTask.new(:spec) do |spec|
8
- spec.ruby_opts = "-I lib:spec"
9
8
  spec.rspec_opts = %w[--color --require fuubar --format Fuubar]
10
9
  spec.pattern = 'spec/**/*_spec.rb'
11
10
  end
12
11
 
13
12
  namespace :spec do
14
13
  RSpec::Core::RakeTask.new(:html) do |spec|
15
- spec.ruby_opts = "-I lib:spec"
16
14
  spec.rspec_opts = "--format html --out #{ENV["SPEC_REPORT"] || "specs.html"}"
17
15
  spec.pattern = 'spec/**/*_spec.rb'
18
16
  end
@@ -116,8 +114,6 @@ namespace :changes do
116
114
  end
117
115
  end
118
116
 
119
- load "spec/watirspec/watirspec.rake" if File.exist?("spec/watirspec/watirspec.rake")
120
-
121
117
  task default: [:spec, 'yard:doctest']
122
118
 
123
119
  namespace :spec do
@@ -131,18 +127,18 @@ namespace :spec do
131
127
  :firefox,
132
128
  :ff_legacy,
133
129
  :phantomjs,
134
- (:safari if Selenium::WebDriver::Platform.os == :macosx),
135
- (:ie if Selenium::WebDriver::Platform.os == :windows),
136
- (:edge if Selenium::WebDriver::Platform.os == :windows)].compact
130
+ (:safari if Selenium::WebDriver::Platform.mac?),
131
+ (:ie if Selenium::WebDriver::Platform.windows?),
132
+ (:edge if Selenium::WebDriver::Platform.windows?)].compact
137
133
 
138
134
  desc 'Run specs remotely for all browsers'
139
135
  task remote_browsers: [:remote_chrome,
140
136
  :remote_firefox,
141
137
  :remote_ff_legacy,
142
138
  :remote_phantomjs,
143
- (:remote_safari if Selenium::WebDriver::Platform.os == :macosx),
144
- (:remote_ie if Selenium::WebDriver::Platform.os == :windows),
145
- (:remote_edge if Selenium::WebDriver::Platform.os == :windows)].compact
139
+ (:remote_safari if Selenium::WebDriver::Platform.mac?),
140
+ (:remote_ie if Selenium::WebDriver::Platform.windows?),
141
+ (:remote_edge if Selenium::WebDriver::Platform.windows?)].compact
146
142
 
147
143
  %w(firefox ff_legacy chrome safari phantomjs ie edge).each do |browser|
148
144
  desc "Run specs in #{browser}"
data/appveyor.yml ADDED
@@ -0,0 +1,13 @@
1
+ version: "#{build}"
2
+ build: off
3
+ clone_depth: 100
4
+ install:
5
+ - set PATH=C:\Ruby23\bin;%PATH%
6
+ - bundle install
7
+ - support/appveyor.cmd
8
+ test_script:
9
+ - bundle exec rake %RAKE_TASK%
10
+ environment:
11
+ matrix:
12
+ - RAKE_TASK: spec:chrome
13
+ - RAKE_TASK: spec:firefox
data/lib/watir.rb CHANGED
@@ -1,5 +1,6 @@
1
1
  require 'selenium-webdriver'
2
2
 
3
+ require 'watir/legacy_wait'
3
4
  require 'watir/wait'
4
5
  require 'watir/exception'
5
6
  require 'watir/xpath_support'
@@ -15,8 +16,22 @@ require 'watir/after_hooks'
15
16
 
16
17
  module Watir
17
18
 
19
+ @relaxed_locate = true
20
+
18
21
  class << self
19
22
 
23
+ attr_writer :relaxed_locate, :always_locate, :default_timeout, :prefer_css, :locator_namespace
24
+
25
+ #
26
+ # Whether or not Watir should wait for an element to be found or present
27
+ # before taking an action.
28
+ # Defaults to true.
29
+ #
30
+
31
+ def relaxed_locate?
32
+ @relaxed_locate
33
+ end
34
+
20
35
  #
21
36
  # Whether or not Watir should re-locate a stale Element on use.
22
37
  #
@@ -26,15 +41,11 @@ module Watir
26
41
  true
27
42
  end
28
43
 
29
- def always_locate=(_bool)
30
- always_locate_message
31
- end
32
-
33
44
  def always_locate_message
34
45
  warn <<-EOS
35
46
  Watir#always_locate is deprecated; elements are always cached and will always
36
47
  be re-located if they go stale before use.
37
- Use Element#stale? or Element#wait_until_stale if needed for flow control.
48
+ Use Element#stale? or Element#wait_until(&:stale?) if needed for flow control.
38
49
  EOS
39
50
  end
40
51
 
@@ -47,10 +58,6 @@ Use Element#stale? or Element#wait_until_stale if needed for flow control.
47
58
  false
48
59
  end
49
60
 
50
- def prefer_css=(_bool)
51
- prefer_css_message
52
- end
53
-
54
61
  def prefer_css_message
55
62
  warn <<-EOS
56
63
  Watir#prefer_css is deprecated; all elements that can not be passed directly
@@ -59,20 +66,12 @@ require the watir_css gem - https://github.com/watir/watir_css
59
66
  EOS
60
67
  end
61
68
 
62
- def default_timeout
63
- @default_timeout ||= 30
64
- end
65
-
66
69
  #
67
70
  # Default wait time for wait methods.
68
71
  #
69
72
 
70
- def default_timeout=(value)
71
- @default_timeout = value
72
- end
73
-
74
- def locator_namespace
75
- @locator_namespace ||= Watir::Locators
73
+ def default_timeout
74
+ @default_timeout ||= 30
76
75
  end
77
76
 
78
77
  #
@@ -80,8 +79,8 @@ require the watir_css gem - https://github.com/watir/watir_css
80
79
  # Defaults to Watir::Locators.
81
80
  #
82
81
 
83
- def locator_namespace=(mod)
84
- @locator_namespace = mod
82
+ def locator_namespace
83
+ @locator_namespace ||= Watir::Locators
85
84
  end
86
85
 
87
86
  #
data/lib/watir/alert.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  module Watir
2
2
  class Alert
3
-
4
3
  include EventuallyPresent
4
+ include Waitable
5
5
 
6
6
  def initialize(browser)
7
7
  @browser = browser
@@ -19,7 +19,7 @@ module Watir
19
19
  #
20
20
 
21
21
  def text
22
- assert_exists
22
+ wait_for_exists
23
23
  @alert.text
24
24
  end
25
25
 
@@ -33,7 +33,7 @@ module Watir
33
33
  #
34
34
 
35
35
  def ok
36
- assert_exists
36
+ wait_for_exists
37
37
  @alert.accept
38
38
  @browser.after_hooks.run
39
39
  end
@@ -48,7 +48,7 @@ module Watir
48
48
  #
49
49
 
50
50
  def close
51
- assert_exists
51
+ wait_for_exists
52
52
  @alert.dismiss
53
53
  @browser.after_hooks.run
54
54
  end
@@ -64,7 +64,7 @@ module Watir
64
64
  #
65
65
 
66
66
  def set(value)
67
- assert_exists
67
+ wait_for_exists
68
68
  @alert.send_keys(value)
69
69
  end
70
70
 
@@ -100,5 +100,21 @@ module Watir
100
100
  raise Exception::UnknownObjectException, 'unable to locate alert'
101
101
  end
102
102
 
103
+ def wait_for_exists
104
+ return assert_exists unless Watir.relaxed_locate?
105
+
106
+ begin
107
+ wait_until(&:exists?)
108
+ rescue Wait::TimeoutError
109
+ unless Watir.default_timeout == 0
110
+ message = "This code has slept for the duration of the default timeout "
111
+ message << "waiting for an Alert to exist. If the test is still passing, "
112
+ message << "consider using Alert#exists? instead of rescuing UnknownObjectException"
113
+ warn message
114
+ end
115
+ raise Exception::UnknownObjectException, 'unable to locate alert'
116
+ end
117
+ end
118
+
103
119
  end # Alert
104
120
  end # Watir
data/lib/watir/browser.rb CHANGED
@@ -60,6 +60,7 @@ module Watir
60
60
  rescue
61
61
  '#<%s:0x%x closed=%s>' % [self.class, hash*2, @closed.to_s]
62
62
  end
63
+ alias selector_string inspect
63
64
 
64
65
  #
65
66
  # Goes to the given URL.
@@ -152,9 +153,9 @@ module Watir
152
153
  # Returns browser name.
153
154
  #
154
155
  # @example
155
- # browser = Watir::Browser.new :phantomjs
156
+ # browser = Watir::Browser.new :chrome
156
157
  # browser.name
157
- # #=> :phantomjs
158
+ # #=> :chrome
158
159
  #
159
160
  # @return [Symbol]
160
161
  #
@@ -206,12 +207,15 @@ module Watir
206
207
  #
207
208
  # Waits until readyState of document is complete.
208
209
  #
210
+ # @example
211
+ # browser.wait
212
+ #
209
213
  # @param [Fixnum] timeout
210
214
  # @raise [Watir::Wait::TimeoutError] if timeout is exceeded
211
215
  #
212
216
 
213
217
  def wait(timeout = 5)
214
- wait_until(timeout, "waiting for document.readyState == 'complete'") do
218
+ wait_until(timeout: timeout, message: "waiting for document.readyState == 'complete'") do
215
219
  ready_state == "complete"
216
220
  end
217
221
  end
@@ -311,6 +315,8 @@ module Watir
311
315
  true
312
316
  end
313
317
  end
318
+ alias_method :wait_for_exists, :assert_exists
319
+ alias_method :wait_for_present, :assert_exists
314
320
 
315
321
  def browser
316
322
  self
@@ -25,7 +25,6 @@ module Watir
25
25
  #
26
26
 
27
27
  def set?
28
- assert_exists
29
28
  element_call { @element.selected? }
30
29
  end
31
30