watir 7.1.0 → 7.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (253) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/chrome.yml +29 -16
  3. data/.github/workflows/edge.yml +19 -11
  4. data/.github/workflows/firefox.yml +28 -16
  5. data/.github/workflows/ie.yml +13 -7
  6. data/.github/workflows/safari.yml +22 -11
  7. data/.github/workflows/unit.yml +31 -23
  8. data/.rubocop.yml +14 -7
  9. data/.rubocop_todo.yml +0 -26
  10. data/CHANGES.md +16 -1
  11. data/Gemfile +6 -1
  12. data/README.md +15 -11
  13. data/Rakefile +9 -7
  14. data/lib/watir/adjacent.rb +3 -1
  15. data/lib/watir/after_hooks.rb +5 -3
  16. data/lib/watir/alert.rb +2 -0
  17. data/lib/watir/aliases.rb +2 -0
  18. data/lib/watir/attribute_helper.rb +4 -2
  19. data/lib/watir/browser.rb +10 -14
  20. data/lib/watir/capabilities.rb +56 -33
  21. data/lib/watir/cell_container.rb +2 -0
  22. data/lib/watir/container.rb +2 -0
  23. data/lib/watir/cookies.rb +5 -5
  24. data/lib/watir/element_collection.rb +3 -1
  25. data/lib/watir/elements/button.rb +2 -0
  26. data/lib/watir/elements/cell.rb +2 -0
  27. data/lib/watir/elements/checkbox.rb +2 -0
  28. data/lib/watir/elements/date_field.rb +2 -0
  29. data/lib/watir/elements/date_time_field.rb +2 -0
  30. data/lib/watir/elements/dlist.rb +3 -1
  31. data/lib/watir/elements/element.rb +29 -105
  32. data/lib/watir/elements/file_field.rb +2 -0
  33. data/lib/watir/elements/font.rb +2 -0
  34. data/lib/watir/elements/form.rb +2 -0
  35. data/lib/watir/elements/hidden.rb +2 -0
  36. data/lib/watir/elements/iframe.rb +2 -0
  37. data/lib/watir/elements/image.rb +2 -0
  38. data/lib/watir/elements/input.rb +2 -0
  39. data/lib/watir/elements/link.rb +2 -0
  40. data/lib/watir/elements/list.rb +2 -0
  41. data/lib/watir/elements/option.rb +2 -0
  42. data/lib/watir/elements/radio.rb +2 -0
  43. data/lib/watir/elements/row.rb +2 -0
  44. data/lib/watir/elements/select.rb +2 -0
  45. data/lib/watir/elements/table.rb +3 -1
  46. data/lib/watir/elements/table_cell.rb +2 -0
  47. data/lib/watir/elements/table_row.rb +2 -0
  48. data/lib/watir/elements/table_section.rb +2 -0
  49. data/lib/watir/elements/text_area.rb +2 -0
  50. data/lib/watir/elements/text_field.rb +2 -0
  51. data/lib/watir/exception.rb +2 -0
  52. data/lib/watir/extensions/nokogiri.rb +2 -0
  53. data/lib/watir/generator/base/generator.rb +2 -0
  54. data/lib/watir/generator/base/idl_sorter.rb +3 -1
  55. data/lib/watir/generator/base/spec_extractor.rb +6 -4
  56. data/lib/watir/generator/base/util.rb +2 -0
  57. data/lib/watir/generator/base/visitor.rb +5 -5
  58. data/lib/watir/generator/base.rb +2 -1
  59. data/lib/watir/generator/html/generator.rb +2 -0
  60. data/lib/watir/generator/html/spec_extractor.rb +2 -0
  61. data/lib/watir/generator/html/visitor.rb +2 -0
  62. data/lib/watir/generator/html.rb +2 -0
  63. data/lib/watir/generator/svg/generator.rb +2 -0
  64. data/lib/watir/generator/svg/spec_extractor.rb +2 -0
  65. data/lib/watir/generator/svg/visitor.rb +2 -0
  66. data/lib/watir/generator/svg.rb +2 -0
  67. data/lib/watir/generator.rb +2 -0
  68. data/lib/watir/has_window.rb +3 -1
  69. data/lib/watir/http_client.rb +2 -0
  70. data/lib/watir/js_execution.rb +2 -0
  71. data/lib/watir/js_snippets.rb +2 -0
  72. data/lib/watir/locators/anchor/selector_builder.rb +2 -0
  73. data/lib/watir/locators/button/matcher.rb +2 -0
  74. data/lib/watir/locators/button/selector_builder/xpath.rb +15 -19
  75. data/lib/watir/locators/button/selector_builder.rb +2 -0
  76. data/lib/watir/locators/cell/selector_builder/xpath.rb +2 -0
  77. data/lib/watir/locators/cell/selector_builder.rb +2 -0
  78. data/lib/watir/locators/element/locator.rb +2 -0
  79. data/lib/watir/locators/element/matcher.rb +2 -0
  80. data/lib/watir/locators/element/selector_builder/regexp_disassembler.rb +2 -0
  81. data/lib/watir/locators/element/selector_builder/xpath.rb +16 -15
  82. data/lib/watir/locators/element/selector_builder/xpath_support.rb +4 -2
  83. data/lib/watir/locators/element/selector_builder.rb +16 -6
  84. data/lib/watir/locators/option/matcher.rb +2 -0
  85. data/lib/watir/locators/option/selector_builder/xpath.rb +2 -0
  86. data/lib/watir/locators/option/selector_builder.rb +2 -0
  87. data/lib/watir/locators/row/selector_builder/xpath.rb +2 -0
  88. data/lib/watir/locators/row/selector_builder.rb +2 -0
  89. data/lib/watir/locators/text_area/selector_builder/xpath.rb +2 -0
  90. data/lib/watir/locators/text_area/selector_builder.rb +2 -0
  91. data/lib/watir/locators/text_field/matcher.rb +2 -0
  92. data/lib/watir/locators/text_field/selector_builder/xpath.rb +2 -0
  93. data/lib/watir/locators/text_field/selector_builder.rb +2 -0
  94. data/lib/watir/locators.rb +2 -0
  95. data/lib/watir/logger.rb +2 -0
  96. data/lib/watir/navigation.rb +3 -1
  97. data/lib/watir/radio_set.rb +2 -0
  98. data/lib/watir/row_container.rb +2 -0
  99. data/lib/watir/screenshot.rb +2 -0
  100. data/lib/watir/scroll.rb +27 -2
  101. data/lib/watir/search_context.rb +96 -0
  102. data/lib/watir/shadow_root.rb +60 -0
  103. data/lib/watir/user_editable.rb +3 -1
  104. data/lib/watir/version.rb +3 -1
  105. data/lib/watir/wait/timer.rb +3 -1
  106. data/lib/watir/wait.rb +5 -5
  107. data/lib/watir/window.rb +7 -3
  108. data/lib/watir/window_collection.rb +4 -1
  109. data/lib/watir.rb +4 -0
  110. data/lib/watirspec/guards.rb +2 -0
  111. data/lib/watirspec/implementation.rb +14 -10
  112. data/lib/watirspec/rake_tasks.rb +4 -4
  113. data/lib/watirspec/remote_server.rb +5 -3
  114. data/lib/watirspec/runner.rb +3 -1
  115. data/lib/watirspec/server/app.rb +2 -0
  116. data/lib/watirspec/server.rb +2 -0
  117. data/lib/watirspec.rb +7 -4
  118. data/spec/locator_spec_helper.rb +2 -0
  119. data/spec/spec_helper.rb +2 -0
  120. data/spec/unit/capabilities_spec.rb +77 -58
  121. data/spec/unit/element_locator_spec.rb +2 -0
  122. data/spec/unit/match_elements/button_spec.rb +2 -0
  123. data/spec/unit/match_elements/element_spec.rb +10 -8
  124. data/spec/unit/match_elements/text_field_spec.rb +2 -0
  125. data/spec/unit/selector_builder/anchor_spec.rb +2 -0
  126. data/spec/unit/selector_builder/button_spec.rb +31 -28
  127. data/spec/unit/selector_builder/cell_spec.rb +3 -1
  128. data/spec/unit/selector_builder/element_spec.rb +61 -60
  129. data/spec/unit/selector_builder/row_spec.rb +21 -10
  130. data/spec/unit/selector_builder/text_field_spec.rb +29 -21
  131. data/spec/unit/selector_builder/textarea_spec.rb +2 -0
  132. data/spec/unit/unit_helper.rb +2 -0
  133. data/spec/unit/wait_spec.rb +2 -0
  134. data/spec/watirspec/adjacent_spec.rb +8 -6
  135. data/spec/watirspec/after_hooks_spec.rb +19 -21
  136. data/spec/watirspec/alert_spec.rb +2 -0
  137. data/spec/watirspec/attributes_spec.rb +2 -0
  138. data/spec/watirspec/browser_spec.rb +16 -12
  139. data/spec/watirspec/capabilities_spec.rb +569 -0
  140. data/spec/watirspec/cookies_spec.rb +4 -2
  141. data/spec/watirspec/drag_and_drop_spec.rb +2 -0
  142. data/spec/watirspec/element_hidden_spec.rb +2 -0
  143. data/spec/watirspec/elements/area_spec.rb +2 -0
  144. data/spec/watirspec/elements/areas_spec.rb +2 -0
  145. data/spec/watirspec/elements/button_spec.rb +2 -0
  146. data/spec/watirspec/elements/buttons_spec.rb +2 -0
  147. data/spec/watirspec/elements/checkbox_spec.rb +2 -0
  148. data/spec/watirspec/elements/checkboxes_spec.rb +2 -0
  149. data/spec/watirspec/elements/collections_spec.rb +5 -3
  150. data/spec/watirspec/elements/date_field_spec.rb +2 -0
  151. data/spec/watirspec/elements/date_fields_spec.rb +2 -0
  152. data/spec/watirspec/elements/date_time_field_spec.rb +2 -0
  153. data/spec/watirspec/elements/date_time_fields_spec.rb +2 -0
  154. data/spec/watirspec/elements/dd_spec.rb +2 -0
  155. data/spec/watirspec/elements/dds_spec.rb +2 -0
  156. data/spec/watirspec/elements/del_spec.rb +2 -0
  157. data/spec/watirspec/elements/dels_spec.rb +2 -0
  158. data/spec/watirspec/elements/div_spec.rb +2 -1
  159. data/spec/watirspec/elements/divs_spec.rb +2 -0
  160. data/spec/watirspec/elements/dl_spec.rb +6 -6
  161. data/spec/watirspec/elements/dls_spec.rb +2 -0
  162. data/spec/watirspec/elements/dt_spec.rb +2 -0
  163. data/spec/watirspec/elements/dts_spec.rb +2 -0
  164. data/spec/watirspec/elements/element_spec.rb +9 -1
  165. data/spec/watirspec/elements/elements_spec.rb +2 -0
  166. data/spec/watirspec/elements/em_spec.rb +2 -0
  167. data/spec/watirspec/elements/ems_spec.rb +2 -0
  168. data/spec/watirspec/elements/filefield_spec.rb +2 -0
  169. data/spec/watirspec/elements/filefields_spec.rb +2 -0
  170. data/spec/watirspec/elements/font_spec.rb +2 -0
  171. data/spec/watirspec/elements/form_spec.rb +2 -0
  172. data/spec/watirspec/elements/forms_spec.rb +2 -0
  173. data/spec/watirspec/elements/frame_spec.rb +2 -0
  174. data/spec/watirspec/elements/frames_spec.rb +2 -0
  175. data/spec/watirspec/elements/hidden_spec.rb +2 -0
  176. data/spec/watirspec/elements/hiddens_spec.rb +2 -0
  177. data/spec/watirspec/elements/hn_spec.rb +2 -0
  178. data/spec/watirspec/elements/hns_spec.rb +2 -0
  179. data/spec/watirspec/elements/iframe_spec.rb +3 -1
  180. data/spec/watirspec/elements/iframes_spec.rb +2 -0
  181. data/spec/watirspec/elements/image_spec.rb +2 -0
  182. data/spec/watirspec/elements/images_spec.rb +2 -0
  183. data/spec/watirspec/elements/input_spec.rb +2 -0
  184. data/spec/watirspec/elements/ins_spec.rb +2 -0
  185. data/spec/watirspec/elements/inses_spec.rb +2 -0
  186. data/spec/watirspec/elements/label_spec.rb +2 -0
  187. data/spec/watirspec/elements/labels_spec.rb +2 -0
  188. data/spec/watirspec/elements/li_spec.rb +2 -0
  189. data/spec/watirspec/elements/link_spec.rb +4 -4
  190. data/spec/watirspec/elements/links_spec.rb +2 -0
  191. data/spec/watirspec/elements/lis_spec.rb +2 -0
  192. data/spec/watirspec/elements/list_spec.rb +2 -0
  193. data/spec/watirspec/elements/map_spec.rb +2 -0
  194. data/spec/watirspec/elements/maps_spec.rb +2 -0
  195. data/spec/watirspec/elements/meta_spec.rb +2 -0
  196. data/spec/watirspec/elements/metas_spec.rb +2 -0
  197. data/spec/watirspec/elements/ol_spec.rb +2 -0
  198. data/spec/watirspec/elements/ols_spec.rb +2 -0
  199. data/spec/watirspec/elements/option_spec.rb +2 -0
  200. data/spec/watirspec/elements/p_spec.rb +2 -0
  201. data/spec/watirspec/elements/pre_spec.rb +2 -0
  202. data/spec/watirspec/elements/pres_spec.rb +2 -0
  203. data/spec/watirspec/elements/ps_spec.rb +2 -0
  204. data/spec/watirspec/elements/radio_spec.rb +2 -0
  205. data/spec/watirspec/elements/radios_spec.rb +2 -0
  206. data/spec/watirspec/elements/select_list_spec.rb +7 -1
  207. data/spec/watirspec/elements/select_lists_spec.rb +2 -0
  208. data/spec/watirspec/elements/span_spec.rb +2 -0
  209. data/spec/watirspec/elements/spans_spec.rb +2 -0
  210. data/spec/watirspec/elements/strong_spec.rb +2 -0
  211. data/spec/watirspec/elements/strongs_spec.rb +2 -0
  212. data/spec/watirspec/elements/table_nesting_spec.rb +2 -0
  213. data/spec/watirspec/elements/table_spec.rb +2 -0
  214. data/spec/watirspec/elements/tables_spec.rb +2 -0
  215. data/spec/watirspec/elements/tbody_spec.rb +2 -0
  216. data/spec/watirspec/elements/tbodys_spec.rb +2 -0
  217. data/spec/watirspec/elements/td_spec.rb +2 -0
  218. data/spec/watirspec/elements/tds_spec.rb +2 -0
  219. data/spec/watirspec/elements/text_field_spec.rb +2 -0
  220. data/spec/watirspec/elements/text_fields_spec.rb +2 -0
  221. data/spec/watirspec/elements/textarea_spec.rb +2 -0
  222. data/spec/watirspec/elements/textareas_spec.rb +2 -0
  223. data/spec/watirspec/elements/tfoot_spec.rb +2 -0
  224. data/spec/watirspec/elements/tfoots_spec.rb +2 -0
  225. data/spec/watirspec/elements/thead_spec.rb +2 -0
  226. data/spec/watirspec/elements/theads_spec.rb +2 -0
  227. data/spec/watirspec/elements/tr_spec.rb +2 -0
  228. data/spec/watirspec/elements/trs_spec.rb +2 -0
  229. data/spec/watirspec/elements/ul_spec.rb +2 -0
  230. data/spec/watirspec/elements/uls_spec.rb +2 -0
  231. data/spec/watirspec/html/child_frame.html +29 -0
  232. data/spec/watirspec/html/class_locator.html +2 -0
  233. data/spec/watirspec/html/scroll_nested.html +17 -0
  234. data/spec/watirspec/html/scroll_nested_offscreen.html +18 -0
  235. data/spec/watirspec/html/shadow_dom.html +28 -0
  236. data/spec/watirspec/radio_set_spec.rb +2 -0
  237. data/spec/watirspec/screenshot_spec.rb +4 -2
  238. data/spec/watirspec/scroll_spec.rb +75 -7
  239. data/spec/watirspec/shadow_root_spec.rb +103 -0
  240. data/spec/watirspec/special_chars_spec.rb +2 -0
  241. data/spec/watirspec/support/rspec_matchers.rb +35 -32
  242. data/spec/watirspec/user_editable_spec.rb +2 -0
  243. data/spec/watirspec/wait_spec.rb +2 -0
  244. data/spec/watirspec/window_switching_spec.rb +48 -38
  245. data/spec/watirspec_helper.rb +24 -18
  246. data/support/doctest_helper.rb +2 -0
  247. data/support/version_differ.rb +2 -0
  248. data/watir.gemspec +11 -8
  249. metadata +54 -215
  250. data/.github/actions/enable-safari/action.yml +0 -11
  251. data/.github/actions/install-chrome/action.yml +0 -12
  252. data/.github/actions/setup-linux/action.yml +0 -8
  253. data/lib/watir-webdriver.rb +0 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e8a3f59dcd9f56e63cf532cc2ba8c9605e8ffad78bd59d3f104e6677c9f5e20c
4
- data.tar.gz: 1f1cb55a4270ebdce957f4a8dc33e76403eef391ed59e3179f4f6772595d3f59
3
+ metadata.gz: 5e21571e92209dad62a8048886e0d383b0a2d8c720b2fa42cdb8d23c0f790a28
4
+ data.tar.gz: 2ebaf5e9faf6aa665986cb333b264e29a1b3400438f8eabecdc91ec42ce640b3
5
5
  SHA512:
6
- metadata.gz: 488c6b2f0a93a20390350da8b95025f9e33d2be9bb7bd84b130808906bca067860b3db6908c59961ef3914ccbb682d2d15d2418656749f8916a1416fa8c6cbb5
7
- data.tar.gz: 64bc4a7b36c294a75ceb86c3fea21809dbefc158cbca08ba72dc6bf7b3b64d76f04b5c02130a8cce15e78d5156659cb317ee397e27d93d06e537e804695e425b
6
+ metadata.gz: b631f01f18c1741b4949188ead10e9f42dd9e7f20853e6a11a4563c1cfeca71efd9cc4dc5d186ab9021f7b8134d73760519d34a765cd21498a4e454361d23ae9
7
+ data.tar.gz: 433d5075795f765aa516811c956573670f97efe667e2fbadb7a41be9acc96ad3a85df712b21ed23f73dcd8c7f0f70a15ad1db2c4a888f3a92ab2a1380c6f0e8b
@@ -1,6 +1,7 @@
1
1
  name: Chrome Tests
2
2
 
3
3
  on:
4
+ - workflow_dispatch
4
5
  - push
5
6
  - pull_request
6
7
 
@@ -12,23 +13,35 @@ jobs:
12
13
  fail-fast: false
13
14
  matrix:
14
15
  os: [ubuntu-latest, macos-latest, windows-latest]
15
- ruby: [ 2.6, 3.0 ]
16
+ ruby: [ 2.7, 3.1 ]
16
17
  steps:
17
- - uses: actions/checkout@v2
18
- - uses: ./.github/actions/setup-linux
19
- if: matrix.os == 'ubuntu-latest'
20
- - uses: ./.github/actions/install-chrome
21
- if: matrix.os == 'ubuntu-latest'
22
- - run: |
23
- echo "COVERAGE=true" >> $GITHUB_ENV
24
- if: |
25
- matrix.os == 'ubuntu-latest' ||
26
- matrix.os == 'macos-latest'
27
- - uses: ruby/setup-ruby@v1
18
+ - name: Checkout source tree
19
+ uses: actions/checkout@v2
20
+ - name: Setup Fluxbox
21
+ if: matrix.os == 'ubuntu-latest'
22
+ run: sudo apt-get -y install fluxbox
23
+ - name: Start XVFB
24
+ if: matrix.os == 'ubuntu-latest'
25
+ run: Xvfb :99 -screen 0 1920x1280x24 > /dev/null 2>&1 &
26
+ - name: Start Fluxbox
27
+ if: matrix.os == 'ubuntu-latest'
28
+ run: fluxbox -display :99 &
29
+ - name: Set Windows resolution
30
+ if: matrix.os == 'windows-latest'
31
+ run: Set-DisplayResolution -Width 1920 -Height 1080 -Force
32
+ - name: Set Mac resolution
33
+ if: ${{ matrix.os == 'macos-latest' }}
34
+ run: |
35
+ system_profiler SPDisplaysDataType | grep Resolution
36
+ "/Library/Application Support/VMware Tools/vmware-resolutionSet" 2560 1440
37
+ system_profiler SPDisplaysDataType | grep Resolution
38
+ - name: Install Ruby
39
+ uses: ruby/setup-ruby@v1
28
40
  with:
29
41
  ruby-version: ${{ matrix.ruby }}
30
- - run: bundle install
31
- - run: |
32
- bundle exec rake spec:chrome
42
+ - name: Install gems
43
+ run: bundle install
44
+ - name: Run tests
45
+ run: bundle exec rake spec:chrome
33
46
  env:
34
- DISPLAY: :99
47
+ DISPLAY: :99.0
@@ -1,6 +1,7 @@
1
1
  name: Edge Tests
2
2
 
3
3
  on:
4
+ - workflow_dispatch
4
5
  - push
5
6
  - pull_request
6
7
 
@@ -12,17 +13,24 @@ jobs:
12
13
  fail-fast: false
13
14
  matrix:
14
15
  os: [macos-latest, windows-latest]
15
- ruby: [ 2.6, 3.0 ]
16
+ ruby: [ 2.7, 3.1 ]
16
17
  steps:
17
- - uses: actions/checkout@v2
18
- - run: |
19
- echo "COVERAGE=true" >> $GITHUB_ENV
20
- if: matrix.os == 'macos-latest'
21
- - uses: ruby/setup-ruby@v1
18
+ - name: Checkout source tree
19
+ uses: actions/checkout@v2
20
+ - name: Set Windows resolution
21
+ if: matrix.os == 'windows-latest'
22
+ run: Set-DisplayResolution -Width 1920 -Height 1080 -Force
23
+ - name: Set Mac resolution
24
+ if: ${{ matrix.os == 'macos-latest' }}
25
+ run: |
26
+ system_profiler SPDisplaysDataType | grep Resolution
27
+ "/Library/Application Support/VMware Tools/vmware-resolutionSet" 2560 1440
28
+ system_profiler SPDisplaysDataType | grep Resolution
29
+ - name: Install Ruby
30
+ uses: ruby/setup-ruby@v1
22
31
  with:
23
32
  ruby-version: ${{ matrix.ruby }}
24
- - run: bundle install
25
- - run: |
26
- bundle exec rake spec:edge
27
- env:
28
- DISPLAY: :99
33
+ - name: Install gems
34
+ run: bundle install
35
+ - name: Run tests
36
+ run: bundle exec rake spec:chrome
@@ -1,6 +1,7 @@
1
1
  name: Firefox Tests
2
2
 
3
3
  on:
4
+ - workflow_dispatch
4
5
  - push
5
6
  - pull_request
6
7
 
@@ -12,24 +13,35 @@ jobs:
12
13
  fail-fast: false
13
14
  matrix:
14
15
  os: [ubuntu-latest, macos-latest, windows-latest]
15
- ruby: [ 2.6, 3.0 ]
16
+ ruby: [ 2.7, 3.1 ]
16
17
  steps:
17
- - uses: actions/checkout@v2
18
- - uses: ./.github/actions/setup-linux
19
- if: matrix.os == 'ubuntu-latest'
20
- - uses: browser-actions/setup-firefox@latest
21
- with:
22
- firefox-version: '93.0'
23
- - run: |
24
- echo "COVERAGE=true" >> $GITHUB_ENV
25
- if: |
26
- matrix.os == 'ubuntu-latest' ||
27
- matrix.os == 'macos-latest'
28
- - uses: ruby/setup-ruby@v1
18
+ - name: Checkout source tree
19
+ uses: actions/checkout@v2
20
+ - name: Setup Fluxbox
21
+ if: matrix.os == 'ubuntu-latest'
22
+ run: sudo apt-get -y install fluxbox
23
+ - name: Start XVFB
24
+ if: matrix.os == 'ubuntu-latest'
25
+ run: Xvfb :99 -screen 0 1920x1280x24 > /dev/null 2>&1 &
26
+ - name: Start Fluxbox
27
+ if: matrix.os == 'ubuntu-latest'
28
+ run: fluxbox -display :99 &
29
+ - name: Set Windows resolution
30
+ if: matrix.os == 'windows-latest'
31
+ run: Set-DisplayResolution -Width 1920 -Height 1080 -Force
32
+ - name: Set Mac resolution
33
+ if: ${{ matrix.os == 'macos-latest' }}
34
+ run: |
35
+ system_profiler SPDisplaysDataType | grep Resolution
36
+ "/Library/Application Support/VMware Tools/vmware-resolutionSet" 2560 1440
37
+ system_profiler SPDisplaysDataType | grep Resolution
38
+ - name: Install Ruby
39
+ uses: ruby/setup-ruby@v1
29
40
  with:
30
41
  ruby-version: ${{ matrix.ruby }}
31
- - run: bundle install
32
- - run: |
33
- bundle exec rake spec:firefox
42
+ - name: Install gems
43
+ run: bundle install
44
+ - name: Run tests
45
+ run: bundle exec rake spec:chrome
34
46
  env:
35
47
  DISPLAY: :99
@@ -1,6 +1,7 @@
1
1
  name: IE Tests
2
2
 
3
3
  on:
4
+ - workflow_dispatch
4
5
  - push
5
6
  - pull_request
6
7
 
@@ -11,14 +12,19 @@ jobs:
11
12
  strategy:
12
13
  fail-fast: false
13
14
  matrix:
14
- ruby: [ 2.6, 3.0 ]
15
+ ruby: [ 2.7, 3.1 ]
15
16
  steps:
16
- - uses: actions/checkout@v2
17
- - uses: ruby/setup-ruby@v1
17
+ - name: Checkout source tree
18
+ uses: actions/checkout@v2
19
+ - name: Set Windows resolution
20
+ run: Set-DisplayResolution -Width 1920 -Height 1080 -Force
21
+ - name: Install Ruby
22
+ uses: ruby/setup-ruby@v1
18
23
  with:
19
24
  ruby-version: ${{ matrix.ruby }}
20
- - run: bundle install
21
- - run: |
22
- bundle exec rake spec:ie
25
+ - name: Install gems
26
+ run: bundle install
27
+ - name: Run tests
28
+ run: bundle exec rake spec:ie
23
29
  env:
24
- DISPLAY: :99
30
+ GITHUB_TOKEN: ${{ github.token }}
@@ -1,6 +1,7 @@
1
1
  name: Safari Tests
2
2
 
3
3
  on:
4
+ - workflow_dispatch
4
5
  - push
5
6
  - pull_request
6
7
 
@@ -11,17 +12,27 @@ jobs:
11
12
  strategy:
12
13
  fail-fast: false
13
14
  matrix:
14
- ruby: [ 2.6, 3.0 ]
15
+ ruby: [ 2.7, 3.1 ]
15
16
  steps:
16
- - uses: actions/checkout@v2
17
- - uses: ./.github/actions/enable-safari
18
- - run: |
19
- echo "COVERAGE=true" >> $GITHUB_ENV
20
- - uses: ruby/setup-ruby@v1
17
+ - name: Checkout source tree
18
+ uses: actions/checkout@v2
19
+ - name: Set Mac resolution
20
+ run: |
21
+ system_profiler SPDisplaysDataType | grep Resolution
22
+ "/Library/Application Support/VMware Tools/vmware-resolutionSet" 2560 1440
23
+ system_profiler SPDisplaysDataType | grep Resolution
24
+ - name: Install Ruby
25
+ uses: ruby/setup-ruby@v1
21
26
  with:
22
27
  ruby-version: ${{ matrix.ruby }}
23
- - run: bundle install
24
- - run: |
25
- bundle exec rake spec:safari
26
- env:
27
- DISPLAY: :99
28
+ - name: Install gems
29
+ run: bundle install
30
+ - name: Configure safaridriver
31
+ run: |
32
+ defaults write com.apple.Safari IncludeDevelopMenu YES
33
+ defaults write com.apple.Safari AllowRemoteAutomation 1
34
+ sudo safaridriver --enable
35
+ safaridriver --version
36
+ safaridriver -p 0 &
37
+ - name: Run tests
38
+ run: bundle exec rake spec:safari
@@ -1,6 +1,7 @@
1
1
  name: Unit Tests
2
2
 
3
3
  on:
4
+ - workflow_dispatch
4
5
  - push
5
6
  - pull_request
6
7
 
@@ -9,16 +10,22 @@ jobs:
9
10
  name: Yard Doctest
10
11
  runs-on: ubuntu-latest
11
12
  steps:
12
- - uses: actions/checkout@v2
13
- - uses: ruby/setup-ruby@v1
13
+ - name: Checkout source tree
14
+ uses: actions/checkout@v2
15
+ - name: Setup Fluxbox
16
+ run: sudo apt-get -y install fluxbox
17
+ - name: Start XVFB
18
+ run: Xvfb :99 -screen 0 1920x1280x24 > /dev/null 2>&1 &
19
+ - name: Start Fluxbox
20
+ run: fluxbox -display :99 &
21
+ - name: Install Ruby
22
+ uses: ruby/setup-ruby@v1
14
23
  with:
15
- ruby-version: 2.6
16
- - run: bundle install
17
- - uses: ./.github/actions/install-chrome
18
- - uses: ./.github/actions/setup-linux
19
- - run: |
20
- bundle exec rake yard:doctest
21
-
24
+ ruby-version: 2.7
25
+ - name: Install gems
26
+ run: bundle install
27
+ - name: Run tests
28
+ run: bundle exec rake yard:doctest
22
29
 
23
30
  unit-test:
24
31
  name: Unit Tests
@@ -26,27 +33,28 @@ jobs:
26
33
  strategy:
27
34
  fail-fast: false
28
35
  matrix:
29
- ruby: ['2.6', '2.7', '3.0']
36
+ ruby: ['2.7', '3.0', '3.1']
30
37
  steps:
31
- - uses: actions/checkout@v2
32
- - uses: ruby/setup-ruby@v1
38
+ - name: Checkout source tree
39
+ uses: actions/checkout@v2
40
+ - name: Install Ruby
41
+ uses: ruby/setup-ruby@v1
33
42
  with:
34
43
  ruby-version: ${{ matrix.ruby }}
35
- - run: bundle install
36
- - uses: ./.github/actions/install-chrome
37
- - uses: ./.github/actions/setup-linux
38
- - run: |
39
- bundle exec rake spec:unit
40
- env:
41
- DISPLAY: :99
44
+ - name: Install gems
45
+ run: bundle install
46
+ - run: bundle exec rake spec:unit
42
47
 
43
48
  linter-test:
44
49
  name: Rubocop Tests
45
50
  runs-on: ubuntu-latest
46
51
  steps:
47
- - uses: actions/checkout@v2
48
- - uses: ruby/setup-ruby@v1
52
+ - name: Checkout source tree
53
+ uses: actions/checkout@v2
54
+ - name: Install Ruby
55
+ uses: ruby/setup-ruby@v1
49
56
  with:
50
- ruby-version: 2.6
51
- - run: bundle install
57
+ ruby-version: 2.7
58
+ - name: Install gems
59
+ run: bundle install
52
60
  - run: bundle exec rubocop
data/.rubocop.yml CHANGED
@@ -1,15 +1,16 @@
1
1
  inherit_from: .rubocop_todo.yml
2
2
 
3
+ require:
4
+ - rubocop-performance
5
+ - rubocop-rake
6
+
3
7
  AllCops:
4
- TargetRubyVersion: 2.6.8
8
+ TargetRubyVersion: 2.7
5
9
  NewCops: enable
6
10
  Exclude:
7
11
  - 'lib/watir/elements/html_elements.rb'
8
12
  - 'lib/watir/elements/svg_elements.rb'
9
13
 
10
- Layout/LineLength:
11
- Max: 120
12
-
13
14
  Layout/SpaceInsideHashLiteralBraces:
14
15
  EnforcedStyle: no_space
15
16
 
@@ -17,7 +18,6 @@ Lint/UnifiedInteger:
17
18
  Exclude:
18
19
  - 'lib/watir/locators/element/selector_builder.rb'
19
20
 
20
- # Default: 17
21
21
  Metrics/AbcSize:
22
22
  Max: 22
23
23
  Exclude:
@@ -33,6 +33,10 @@ Metrics/BlockLength:
33
33
  - 'watir.gemspec'
34
34
  - 'Rakefile'
35
35
 
36
+ Metrics/ModuleLength:
37
+ Exclude:
38
+ - 'spec/**/*'
39
+
36
40
  Metrics/ClassLength:
37
41
  Max: 93
38
42
  Exclude:
@@ -47,7 +51,6 @@ Metrics/ClassLength:
47
51
  - 'lib/watir/generator/base/spec_extractor.rb'
48
52
  - 'lib/watir/element_collection.rb'
49
53
 
50
- # Default: 7
51
54
  Metrics/CyclomaticComplexity:
52
55
  Max: 9
53
56
  Exclude:
@@ -61,16 +64,19 @@ Metrics/MethodLength:
61
64
  - 'lib/watir/locators/element/selector_builder/xpath.rb'
62
65
  - 'lib/watir/locators/element/selector_builder/regexp_disassembler.rb'
63
66
 
64
- # Default: 8
65
67
  Metrics/PerceivedComplexity:
66
68
  Max: 10
67
69
 
70
+ Performance/CollectionLiteralInLoop:
71
+ MinSize: 3
72
+
68
73
  Style/BlockDelimiters:
69
74
  EnforcedStyle: braces_for_chaining
70
75
 
71
76
  Style/CommentedKeyword:
72
77
  Enabled: false
73
78
 
79
+ # truthy is not true
74
80
  Style/DoubleNegation:
75
81
  Enabled: false
76
82
 
@@ -78,6 +84,7 @@ Style/GlobalVars:
78
84
  AllowedVariables:
79
85
  - $browser
80
86
 
87
+ # Need to add new keys into hash during iteration
81
88
  Style/HashEachMethods:
82
89
  Enabled: false
83
90
 
data/.rubocop_todo.yml CHANGED
@@ -6,31 +6,5 @@
6
6
  # Note that changes in the inspected code, or installation of new
7
7
  # versions of RuboCop, may require this file to be generated again.
8
8
 
9
- # Offense count: 116
10
9
  Style/Documentation:
11
10
  Enabled: false
12
-
13
- # Offense count: 11
14
- # Configuration parameters: EnforcedStyle.
15
- # SupportedStyles: annotated, template, unannotated
16
- Style/FormatStringToken:
17
- Exclude:
18
- - 'lib/watir/browser.rb'
19
- - 'lib/watir/window.rb'
20
-
21
- # Offense count: 229
22
- # Cop supports --auto-correct.
23
- # Configuration parameters: EnforcedStyle.
24
- # SupportedStyles: always, always_true, never
25
- Style/FrozenStringLiteralComment:
26
- Enabled: false
27
-
28
- # Remove for Watir 7
29
- Naming/FileName:
30
- Exclude:
31
- - 'lib/watir-webdriver.rb'
32
-
33
- # Fix in Watir 7
34
- Metrics/ParameterLists:
35
- Exclude:
36
- - 'lib/watir/wait.rb'
data/CHANGES.md CHANGED
@@ -1,10 +1,25 @@
1
+ ### 7.2.0 (2022-12-22)
2
+
3
+ * Implement Shadow DOM support (#953)
4
+ * Implement existing `Scroll#by` with Selenium Actions Class instead of JavaScript
5
+ * Implement `Scroll#from` to set origin points
6
+ * Implement `Scroll#to(:viewport)` for elements using Selenium Actions Class
7
+ * Fix bug for regex matching on single quotes (#957)
8
+ * Fix bug for unexpected whitespace in classes (#956)
9
+ * Fix bug for inferring Edge browser name from Capabilities parameter
10
+ * Allow starting `Browser` with `Watir::Capabilities`
11
+ * Allow starting `Browser` with just a `Hash` for generating a `Watir::Capabilities`
12
+ * Have `Capabilities` use `:options` to generate Selenium `Options` instance
13
+ * Deprecate allowing `:capabilities` argument in `Browser` constructor
14
+ * Require Ruby 2.7 and Selenium 4.2
15
+
1
16
  ### 7.1.0 (2021-11-15)
2
17
 
3
18
  * Add automatic scroll to `Element#click` with method parameters to ensure element is in viewport
4
19
  * Provide `:scroll_to` parameter for element methods implemented with `Actions` class (thanks osadasami #948, #949)
5
20
  * Allow `:scroll_to` parameter to accept `nil` argument to avoid automatic scrolling
6
21
  * Implement `Element#in_viewport?`
7
- * Fix but where `Scroll#to` for `Browser` with `:center` argument did not scroll to center of page
22
+ * Fix bug where `Scroll#to` for `Browser` with `:center` argument did not scroll to center of page
8
23
  * Change `Element#obscured?` to only scroll when element out of viewport and then scroll to bottom instead of top
9
24
 
10
25
  ### 7.0.0 (2021-10-18)
data/Gemfile CHANGED
@@ -1,8 +1,13 @@
1
+ # frozen_string_literal: true
2
+
1
3
  source 'https://rubygems.org'
2
4
 
3
5
  gem 'webidl', path: File.expand_path('../webidl') if ENV['LOCAL_WEBIDL']
4
6
 
5
- gem 'selenium-webdriver', path: File.expand_path('../selenium/build/rb') if ENV['LOCAL_SELENIUM']
7
+ if ENV['LOCAL_SELENIUM']
8
+ ENV['RUBYOPT'] = '-I../selenium/bazel-bin/rb'
9
+ gem 'selenium-webdriver', path: File.expand_path('../selenium/rb')
10
+ end
6
11
 
7
12
  gem 'ffi' if Gem.win_platform? # For selenium-webdriver on Windows
8
13
 
data/README.md CHANGED
@@ -3,16 +3,19 @@
3
3
  Watir Powered By Selenium!
4
4
 
5
5
  [![Gem Version](https://badge.fury.io/rb/watir.svg)](http://badge.fury.io/rb/watir)
6
- [![All Tests](https://github.com/watir/watir/actions/workflows/tests.yml/badge.svg)](https://github.com/watir/watir/actions/workflows/tests.yml)
7
- [![Code Climate](https://codeclimate.com/github/watir/watir.svg)](https://codeclimate.com/github/watir/watir)
8
- [![Coverage Status](https://coveralls.io/repos/github/watir/watir/badge.svg?branch=main)](https://coveralls.io/github/watir/watir?branch=main)
6
+ [![Chrome Tests](https://github.com/watir/watir/actions/workflows/chrome.yml/badge.svg)](https://github.com/watir/watir/actions/workflows/chrome.yml)
7
+ [![Edge Tests](https://github.com/watir/watir/actions/workflows/edge.yml/badge.svg)](https://github.com/watir/watir/actions/workflows/edge.yml)
8
+ [![Firefox Tests](https://github.com/watir/watir/actions/workflows/firefox.yml/badge.svg)](https://github.com/watir/watir/actions/workflows/firefox.yml)
9
+ [![IE Tests](https://github.com/watir/watir/actions/workflows/ie.yml/badge.svg)](https://github.com/watir/watir/actions/workflows/ie.yml)
10
+ [![Safari Tests](https://github.com/watir/watir/actions/workflows/safari.yml/badge.svg)](https://github.com/watir/watir/actions/workflows/safari.yml)
11
+ [![Unit Tests](https://github.com/watir/watir/actions/workflows/unit.yml/badge.svg)](https://github.com/watir/watir/actions/workflows/unit.yml)
9
12
 
10
13
  ## Using Watir
11
14
 
12
15
  This README is for people interested in writing code for Watir or gems in the Watir ecosystem
13
16
  that leverage private-api Watir code.
14
17
 
15
- For our users, everything you'll need is on the [Watir website](http://watir.com):
18
+ For our users, everything you'll need is on the [Watir website](http://watir.com):
16
19
  examples, news, guides, additional resources, support information and more.
17
20
 
18
21
  ## Procedure for Patches/Pull Requests
@@ -30,7 +33,7 @@ examples, news, guides, additional resources, support information and more.
30
33
 
31
34
  ## Developing Extensions
32
35
 
33
- When developing a gem intended to be used with Watir, you can run your code with WatirSpec
36
+ When developing a gem intended to be used with Watir, you can run your code with WatirSpec
34
37
  to make sure that requiring your code does not break something else in Watir.
35
38
 
36
39
  First, add WatirSpec Rake tasks to your gem:
@@ -52,7 +55,7 @@ This command will walk you through how to customize your code.
52
55
  ## Automatic Element Generation
53
56
 
54
57
  The majority of element methods Watir provides is autogenerated from specifications.
55
- This is done by extracting the IDL parts from the spec and processing them with the
58
+ This is done by extracting the IDL parts from the spec and processing them with the
56
59
  [WebIDL gem](https://github.com/jarib/webidl).
57
60
 
58
61
  Generated elements are currently based on the following specifications:
@@ -61,6 +64,7 @@ Generated elements are currently based on the following specifications:
61
64
  * [SVG](https://www.w3.org/TR/2018/CR-SVG2-20180807/) (`lib/watir/elements/svg_elements.rb`)
62
65
 
63
66
  To run:
67
+
64
68
  ```bash
65
69
  $ bundle exec rake html:update
66
70
  $ bundle exec rake svg:update
@@ -70,7 +74,7 @@ $ bundle exec rake svg:update
70
74
 
71
75
  #### Github Actions
72
76
 
73
- Watir specs are run with [Github Actions](https://github.com/watir/watir/workflows).
77
+ Watir specs are run with [Github Actions](https://github.com/watir/watir/tree/main/.github/workflows).
74
78
 
75
79
  Watir code is tested on Linux with latest versions of supported browsers and all active Ruby versions.
76
80
 
@@ -92,14 +96,14 @@ to ensure all paths in their code have tests associated with them.
92
96
 
93
97
  #### Rubocop
94
98
 
95
- Watir is using [Rubocop](https://github.com/rubocop-hq/rubocop) to ensure a consistent style across the
96
- code base. It is run with our minimum supported Ruby version (2.3)
97
- We have some [established exceptions](https://github.com/watir/watir/blob/main/.rubocop.yml)
99
+ Watir is using [Rubocop](https://github.com/rubocop/rubocop) to ensure a consistent style across the
100
+ code base. It is run with our minimum supported Ruby version (2.3)
101
+ We have some established exceptions at `.rubocop.yml`
98
102
  that might need to be tweaked for new code submissions. This can be addressed in the PR as necessary.
99
103
 
100
104
  #### Statistics
101
105
 
102
- Element specs are run with
106
+ Element specs are run with
103
107
  [Selenium Statistics gem](https://github.com/titusfortner/selenium_statistics)
104
108
  to verify that changes to the code do not dramatically decrease the performance based
105
109
  on wire calls.
data/Rakefile CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  $LOAD_PATH.unshift File.expand_path('lib', __dir__)
2
4
 
3
5
  require 'bundler'
@@ -16,13 +18,6 @@ RuboCop::RakeTask.new(:rubocop) do |t|
16
18
  t.options = ['--display-cop-names']
17
19
  end
18
20
 
19
- namespace :spec do
20
- RSpec::Core::RakeTask.new(:html) do |spec|
21
- spec.rspec_opts = "--format html --out #{ENV['SPEC_REPORT'] || 'specs.html'}"
22
- spec.pattern = 'spec/**/*_spec.rb'
23
- end
24
- end
25
-
26
21
  {
27
22
  html: 'https://www.w3.org/TR/html52/single-page.html',
28
23
  svg: 'https://www.w3.org/TR/2018/CR-SVG2-20180807/single-page.html'
@@ -30,6 +25,7 @@ end
30
25
  namespace type do
31
26
  spec_path = "support/#{type}.html"
32
27
 
28
+ desc 'require generator'
33
29
  task generator_lib: :lib do
34
30
  require 'watir/generator'
35
31
  end
@@ -99,6 +95,7 @@ YARD::Doctest::RakeTask.new do |task|
99
95
  end
100
96
 
101
97
  namespace :changes do
98
+ desc 'Show how versions differ'
102
99
  task :differ do
103
100
  require './support/version_differ'
104
101
  end
@@ -122,6 +119,11 @@ end
122
119
  task default: [:spec, 'yard:doctest']
123
120
 
124
121
  namespace :spec do
122
+ RSpec::Core::RakeTask.new(:html) do |spec|
123
+ spec.rspec_opts = "--format html --out #{ENV['SPEC_REPORT'] || 'specs.html'}"
124
+ spec.pattern = 'spec/**/*_spec.rb'
125
+ end
126
+
125
127
  require 'selenium-webdriver'
126
128
 
127
129
  desc 'Run specs in all browsers'
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Watir
2
4
  module Adjacent
3
5
  #
@@ -112,7 +114,7 @@ module Watir
112
114
 
113
115
  def xpath_adjacent(opt = {})
114
116
  plural = opt.delete(:plural)
115
- opt[:index] ||= 0 unless plural || opt.values.any? { |e| e.is_a? Regexp }
117
+ opt[:index] ||= 0 unless plural || opt.values.any?(Regexp)
116
118
  if !plural
117
119
  el = Watir.element_class_for(opt[:tag_name] || '').new(self, opt)
118
120
  el.is_a?(Input) ? el.to_subtype : el
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Watir
2
4
  #
3
5
  # After hooks are blocks that run after certain browser events.
@@ -33,7 +35,7 @@ module Watir
33
35
  #
34
36
 
35
37
  def add(after_hook = nil, &block)
36
- if block_given?
38
+ if block
37
39
  @after_hooks << block
38
40
  elsif after_hook.respond_to? :call
39
41
  @after_hooks << after_hook
@@ -99,8 +101,8 @@ module Watir
99
101
  # @yieldparam [#call] after_hook Object responding to call
100
102
  #
101
103
 
102
- def each(&blk)
103
- @after_hooks.each { |after_hook| blk.call(after_hook) }
104
+ def each(&block)
105
+ @after_hooks.each(&block)
104
106
  end
105
107
 
106
108
  #
data/lib/watir/alert.rb CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Watir
2
4
  class Alert
3
5
  include Waitable