watir 6.13.0 → 6.14.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (223) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +141 -0
  3. data/.travis.yml +6 -0
  4. data/CHANGES.md +12 -0
  5. data/Gemfile +4 -10
  6. data/README.md +64 -49
  7. data/Rakefile +28 -16
  8. data/lib/watir.rb +13 -15
  9. data/lib/watir/adjacent.rb +15 -13
  10. data/lib/watir/after_hooks.rb +8 -10
  11. data/lib/watir/alert.rb +7 -8
  12. data/lib/watir/aliases.rb +2 -2
  13. data/lib/watir/attribute_helper.rb +18 -20
  14. data/lib/watir/browser.rb +42 -75
  15. data/lib/watir/capabilities.rb +19 -10
  16. data/lib/watir/cell_container.rb +0 -2
  17. data/lib/watir/container.rb +4 -4
  18. data/lib/watir/cookies.rb +7 -8
  19. data/lib/watir/element_collection.rb +37 -22
  20. data/lib/watir/elements/area.rb +0 -2
  21. data/lib/watir/elements/button.rb +1 -3
  22. data/lib/watir/elements/cell.rb +0 -1
  23. data/lib/watir/elements/checkbox.rb +5 -7
  24. data/lib/watir/elements/date_field.rb +5 -9
  25. data/lib/watir/elements/date_time_field.rb +6 -10
  26. data/lib/watir/elements/dlist.rb +2 -4
  27. data/lib/watir/elements/element.rb +201 -99
  28. data/lib/watir/elements/file_field.rb +3 -4
  29. data/lib/watir/elements/font.rb +2 -4
  30. data/lib/watir/elements/form.rb +0 -2
  31. data/lib/watir/elements/hidden.rb +3 -4
  32. data/lib/watir/elements/html_elements.rb +24 -76
  33. data/lib/watir/elements/iframe.rb +57 -71
  34. data/lib/watir/elements/image.rb +3 -4
  35. data/lib/watir/elements/input.rb +0 -2
  36. data/lib/watir/elements/link.rb +2 -5
  37. data/lib/watir/elements/list.rb +4 -4
  38. data/lib/watir/elements/option.rb +3 -6
  39. data/lib/watir/elements/radio.rb +4 -6
  40. data/lib/watir/elements/row.rb +0 -1
  41. data/lib/watir/elements/select.rb +41 -43
  42. data/lib/watir/elements/svg_elements.rb +0 -116
  43. data/lib/watir/elements/table.rb +1 -2
  44. data/lib/watir/elements/table_cell.rb +2 -3
  45. data/lib/watir/elements/text_field.rb +4 -6
  46. data/lib/watir/exception.rb +0 -1
  47. data/lib/watir/extensions/nokogiri.rb +2 -4
  48. data/lib/watir/generator.rb +3 -3
  49. data/lib/watir/generator/base.rb +10 -10
  50. data/lib/watir/generator/base/generator.rb +26 -29
  51. data/lib/watir/generator/base/idl_sorter.rb +34 -32
  52. data/lib/watir/generator/base/spec_extractor.rb +132 -114
  53. data/lib/watir/generator/base/util.rb +1 -3
  54. data/lib/watir/generator/base/visitor.rb +140 -140
  55. data/lib/watir/generator/html.rb +4 -4
  56. data/lib/watir/generator/html/generator.rb +2 -4
  57. data/lib/watir/generator/html/spec_extractor.rb +33 -33
  58. data/lib/watir/generator/html/visitor.rb +14 -14
  59. data/lib/watir/generator/svg.rb +3 -3
  60. data/lib/watir/generator/svg/generator.rb +1 -3
  61. data/lib/watir/generator/svg/spec_extractor.rb +35 -35
  62. data/lib/watir/generator/svg/visitor.rb +14 -14
  63. data/lib/watir/has_window.rb +2 -4
  64. data/lib/watir/js_execution.rb +7 -9
  65. data/lib/watir/js_snippets.rb +3 -3
  66. data/lib/watir/js_snippets/attributeValues.js +11 -0
  67. data/lib/watir/legacy_wait.rb +7 -12
  68. data/lib/watir/locators.rb +9 -11
  69. data/lib/watir/locators/button/locator.rb +2 -3
  70. data/lib/watir/locators/button/selector_builder.rb +9 -9
  71. data/lib/watir/locators/button/selector_builder/xpath.rb +1 -1
  72. data/lib/watir/locators/button/validator.rb +2 -2
  73. data/lib/watir/locators/cell/locator.rb +0 -2
  74. data/lib/watir/locators/cell/selector_builder.rb +3 -5
  75. data/lib/watir/locators/element/locator.rb +85 -64
  76. data/lib/watir/locators/element/selector_builder.rb +40 -38
  77. data/lib/watir/locators/element/selector_builder/xpath.rb +20 -18
  78. data/lib/watir/locators/element/validator.rb +1 -1
  79. data/lib/watir/locators/row/locator.rb +0 -2
  80. data/lib/watir/locators/row/selector_builder.rb +6 -9
  81. data/lib/watir/locators/text_area/selector_builder.rb +1 -1
  82. data/lib/watir/locators/text_field/locator.rb +1 -3
  83. data/lib/watir/locators/text_field/selector_builder.rb +5 -5
  84. data/lib/watir/locators/text_field/selector_builder/xpath.rb +1 -1
  85. data/lib/watir/locators/text_field/validator.rb +3 -2
  86. data/lib/watir/logger.rb +11 -21
  87. data/lib/watir/navigation.rb +49 -0
  88. data/lib/watir/radio_set.rb +17 -18
  89. data/lib/watir/row_container.rb +3 -5
  90. data/lib/watir/screenshot.rb +2 -4
  91. data/lib/watir/user_editable.rb +13 -8
  92. data/lib/watir/version.rb +3 -0
  93. data/lib/watir/wait.rb +56 -55
  94. data/lib/watir/wait/timer.rb +1 -3
  95. data/lib/watir/window.rb +36 -45
  96. data/lib/watir/xpath_support.rb +1 -3
  97. data/lib/watirspec.rb +11 -11
  98. data/lib/watirspec/guards.rb +10 -7
  99. data/lib/watirspec/implementation.rb +3 -4
  100. data/lib/watirspec/rake_tasks.rb +30 -29
  101. data/lib/watirspec/remote_server.rb +3 -3
  102. data/lib/watirspec/runner.rb +1 -2
  103. data/lib/watirspec/server.rb +3 -0
  104. data/lib/watirspec/server/app.rb +14 -6
  105. data/spec/implementation_spec.rb +9 -9
  106. data/spec/locator_spec_helper.rb +3 -4
  107. data/spec/spec_helper.rb +3 -7
  108. data/spec/unit/container_spec.rb +9 -10
  109. data/spec/unit/element_locator_spec.rb +224 -219
  110. data/spec/unit/logger_spec.rb +4 -4
  111. data/spec/unit/unit_helper.rb +0 -2
  112. data/spec/unit/wait_spec.rb +26 -28
  113. data/spec/watirspec/adjacent_spec.rb +130 -130
  114. data/spec/watirspec/after_hooks_spec.rb +63 -63
  115. data/spec/watirspec/alert_spec.rb +6 -6
  116. data/spec/watirspec/attributes_spec.rb +6 -6
  117. data/spec/watirspec/browser_spec.rb +161 -162
  118. data/spec/watirspec/click_spec.rb +9 -9
  119. data/spec/watirspec/cookies_spec.rb +15 -14
  120. data/spec/watirspec/drag_and_drop_spec.rb +15 -16
  121. data/spec/watirspec/element_hidden_spec.rb +19 -21
  122. data/spec/watirspec/elements/area_spec.rb +18 -21
  123. data/spec/watirspec/elements/areas_spec.rb +13 -15
  124. data/spec/watirspec/elements/button_spec.rb +96 -99
  125. data/spec/watirspec/elements/buttons_spec.rb +17 -19
  126. data/spec/watirspec/elements/checkbox_spec.rb +102 -100
  127. data/spec/watirspec/elements/checkboxes_spec.rb +13 -15
  128. data/spec/watirspec/elements/collections_spec.rb +35 -37
  129. data/spec/watirspec/elements/date_field_spec.rb +46 -47
  130. data/spec/watirspec/elements/date_fields_spec.rb +13 -15
  131. data/spec/watirspec/elements/date_time_field_spec.rb +62 -57
  132. data/spec/watirspec/elements/date_time_fields_spec.rb +14 -15
  133. data/spec/watirspec/elements/dd_spec.rb +46 -48
  134. data/spec/watirspec/elements/dds_spec.rb +13 -15
  135. data/spec/watirspec/elements/del_spec.rb +27 -28
  136. data/spec/watirspec/elements/dels_spec.rb +13 -15
  137. data/spec/watirspec/elements/div_spec.rb +89 -91
  138. data/spec/watirspec/elements/divs_spec.rb +17 -19
  139. data/spec/watirspec/elements/dl_spec.rb +52 -54
  140. data/spec/watirspec/elements/dls_spec.rb +13 -15
  141. data/spec/watirspec/elements/dt_spec.rb +46 -48
  142. data/spec/watirspec/elements/dts_spec.rb +13 -15
  143. data/spec/watirspec/elements/element_spec.rb +240 -189
  144. data/spec/watirspec/elements/elements_spec.rb +16 -16
  145. data/spec/watirspec/elements/em_spec.rb +38 -40
  146. data/spec/watirspec/elements/ems_spec.rb +13 -15
  147. data/spec/watirspec/elements/filefield_spec.rb +45 -46
  148. data/spec/watirspec/elements/filefields_spec.rb +13 -15
  149. data/spec/watirspec/elements/font_spec.rb +11 -13
  150. data/spec/watirspec/elements/form_spec.rb +13 -15
  151. data/spec/watirspec/elements/forms_spec.rb +13 -15
  152. data/spec/watirspec/elements/frame_spec.rb +48 -50
  153. data/spec/watirspec/elements/frames_spec.rb +13 -15
  154. data/spec/watirspec/elements/hidden_spec.rb +23 -25
  155. data/spec/watirspec/elements/hiddens_spec.rb +13 -15
  156. data/spec/watirspec/elements/hn_spec.rb +22 -24
  157. data/spec/watirspec/elements/hns_spec.rb +13 -13
  158. data/spec/watirspec/elements/iframe_spec.rb +106 -74
  159. data/spec/watirspec/elements/iframes_spec.rb +16 -18
  160. data/spec/watirspec/elements/image_spec.rb +30 -32
  161. data/spec/watirspec/elements/images_spec.rb +13 -15
  162. data/spec/watirspec/elements/input_spec.rb +4 -5
  163. data/spec/watirspec/elements/ins_spec.rb +27 -29
  164. data/spec/watirspec/elements/inses_spec.rb +13 -15
  165. data/spec/watirspec/elements/label_spec.rb +17 -19
  166. data/spec/watirspec/elements/labels_spec.rb +13 -15
  167. data/spec/watirspec/elements/li_spec.rb +23 -25
  168. data/spec/watirspec/elements/link_spec.rb +45 -48
  169. data/spec/watirspec/elements/links_spec.rb +14 -16
  170. data/spec/watirspec/elements/lis_spec.rb +13 -15
  171. data/spec/watirspec/elements/list_spec.rb +14 -15
  172. data/spec/watirspec/elements/map_spec.rb +19 -20
  173. data/spec/watirspec/elements/maps_spec.rb +13 -15
  174. data/spec/watirspec/elements/meta_spec.rb +10 -10
  175. data/spec/watirspec/elements/metas_spec.rb +13 -15
  176. data/spec/watirspec/elements/ol_spec.rb +20 -21
  177. data/spec/watirspec/elements/ols_spec.rb +13 -15
  178. data/spec/watirspec/elements/option_spec.rb +63 -63
  179. data/spec/watirspec/elements/p_spec.rb +27 -26
  180. data/spec/watirspec/elements/pre_spec.rb +24 -25
  181. data/spec/watirspec/elements/pres_spec.rb +13 -15
  182. data/spec/watirspec/elements/ps_spec.rb +13 -15
  183. data/spec/watirspec/elements/radio_spec.rb +96 -97
  184. data/spec/watirspec/elements/radios_spec.rb +13 -15
  185. data/spec/watirspec/elements/select_list_spec.rb +244 -237
  186. data/spec/watirspec/elements/select_lists_spec.rb +15 -16
  187. data/spec/watirspec/elements/span_spec.rb +32 -31
  188. data/spec/watirspec/elements/spans_spec.rb +13 -15
  189. data/spec/watirspec/elements/strong_spec.rb +23 -24
  190. data/spec/watirspec/elements/strongs_spec.rb +13 -15
  191. data/spec/watirspec/elements/table_nesting_spec.rb +15 -14
  192. data/spec/watirspec/elements/table_spec.rb +61 -62
  193. data/spec/watirspec/elements/tables_spec.rb +15 -17
  194. data/spec/watirspec/elements/tbody_spec.rb +25 -26
  195. data/spec/watirspec/elements/tbodys_spec.rb +17 -19
  196. data/spec/watirspec/elements/td_spec.rb +20 -22
  197. data/spec/watirspec/elements/tds_spec.rb +9 -11
  198. data/spec/watirspec/elements/text_field_spec.rb +55 -56
  199. data/spec/watirspec/elements/text_fields_spec.rb +15 -16
  200. data/spec/watirspec/elements/textarea_spec.rb +2 -2
  201. data/spec/watirspec/elements/textareas_spec.rb +1 -1
  202. data/spec/watirspec/elements/tfoot_spec.rb +22 -23
  203. data/spec/watirspec/elements/tfoots_spec.rb +19 -19
  204. data/spec/watirspec/elements/thead_spec.rb +21 -23
  205. data/spec/watirspec/elements/theads_spec.rb +19 -19
  206. data/spec/watirspec/elements/tr_spec.rb +20 -22
  207. data/spec/watirspec/elements/trs_spec.rb +17 -19
  208. data/spec/watirspec/elements/ul_spec.rb +17 -19
  209. data/spec/watirspec/elements/uls_spec.rb +13 -14
  210. data/spec/watirspec/html/data_attributes.html +1 -0
  211. data/spec/watirspec/radio_set_spec.rb +100 -99
  212. data/spec/watirspec/relaxed_locate_spec.rb +19 -43
  213. data/spec/watirspec/screenshot_spec.rb +4 -4
  214. data/spec/watirspec/special_chars_spec.rb +2 -4
  215. data/spec/watirspec/support/rspec_matchers.rb +85 -22
  216. data/spec/watirspec/user_editable_spec.rb +84 -85
  217. data/spec/watirspec/wait_spec.rb +74 -95
  218. data/spec/watirspec/window_switching_spec.rb +131 -132
  219. data/spec/watirspec_helper.rb +12 -9
  220. data/support/travis.sh +4 -0
  221. data/support/version_differ.rb +12 -13
  222. data/watir.gemspec +29 -22
  223. metadata +76 -50
@@ -3,177 +3,178 @@ require_relative 'unit_helper'
3
3
  describe Watir::Locators::Element::Locator do
4
4
  include LocatorSpecHelper
5
5
 
6
- describe "finds a single element" do
7
- describe "by delegating to Selenium" do
6
+ describe 'finds a single element' do
7
+ describe 'by delegating to Selenium' do
8
8
  SELENIUM_SELECTORS.each do |loc|
9
9
  it "delegates to Selenium's #{loc} locator" do
10
- expect_one(loc, "bar").and_return(element(tag_name: "div"))
10
+ expect_one(loc, 'bar').and_return(element(tag_name: 'div'))
11
11
  match = %i[link link_text partial_link_text].include?(loc) ? :to : :to_not
12
12
  msg = /:#{loc} locator is deprecated\. Use :visible_text instead/
13
- expect { locate_one loc => "bar" }.send(match, output(msg).to_stdout_from_any_process)
13
+ expect { locate_one loc => 'bar' }.send(match, output(msg).to_stdout_from_any_process)
14
14
  end
15
15
  end
16
16
  end
17
17
 
18
- describe "with selectors not supported by Selenium" do
19
- it "handles selector with tag name and a single attribute" do
20
- expect_one :xpath, ".//div[@title='foo']"
18
+ describe 'with selectors not supported by Selenium' do
19
+ it 'handles selector with tag name and a single attribute' do
20
+ expect_one :xpath, ".//*[local-name()='div'][@title='foo']"
21
21
 
22
- locate_one tag_name: "div",
23
- title: "foo"
22
+ locate_one tag_name: 'div',
23
+ title: 'foo'
24
24
  end
25
25
 
26
- it "handles selector with no tag name and and a single attribute" do
26
+ it 'handles selector with no tag name and and a single attribute' do
27
27
  expect_one :xpath, ".//*[@title='foo']"
28
28
 
29
- locate_one title: "foo"
29
+ locate_one title: 'foo'
30
30
  end
31
31
 
32
- it "handles single quotes in the attribute string" do
32
+ it 'handles single quotes in the attribute string' do
33
33
  expect_one :xpath, %{.//*[@title=concat('foo and ',"'",'bar',"'",'')]}
34
34
 
35
35
  locate_one title: "foo and 'bar'"
36
36
  end
37
37
 
38
- it "handles selector with tag name and multiple attributes" do
39
- expect_one :xpath, ".//div[@title='foo' and @dir='bar']"
38
+ it 'handles selector with tag name and multiple attributes' do
39
+ expect_one :xpath, ".//*[local-name()='div'][@title='foo' and @dir='bar']"
40
40
 
41
- locate_one [:tag_name, "div",
42
- :title , "foo",
43
- :dir , 'bar']
41
+ locate_one [:tag_name, 'div',
42
+ :title, 'foo',
43
+ :dir, 'bar']
44
44
  end
45
45
 
46
- it "handles selector with no tag name and multiple attributes" do
46
+ it 'handles selector with no tag name and multiple attributes' do
47
47
  expect_one :xpath, ".//*[@dir='foo' and @title='bar']"
48
48
 
49
- locate_one [:dir, "foo",
50
- :title, "bar"]
49
+ locate_one [:dir, 'foo',
50
+ :title, 'bar']
51
51
  end
52
52
 
53
- it "handles selector with attribute presence" do
54
- expect_one :xpath, ".//*[@data-view]"
53
+ it 'handles selector with attribute presence' do
54
+ expect_one :xpath, './/*[@data-view]'
55
55
 
56
56
  locate_one [:data_view, true]
57
57
  end
58
58
 
59
- it "handles selector with attribute absence" do
60
- expect_one :xpath, ".//*[not(@data-view)]"
59
+ it 'handles selector with attribute absence' do
60
+ expect_one :xpath, './/*[not(@data-view)]'
61
61
 
62
62
  locate_one [:data_view, false]
63
63
  end
64
64
 
65
- it "handles selector with class attribute presence" do
66
- expect_one :xpath, ".//*[@class]"
65
+ it 'handles selector with class attribute presence' do
66
+ expect_one :xpath, './/*[@class]'
67
67
 
68
68
  locate_one class: true
69
69
  end
70
70
 
71
- it "handles selector with multiple classes in array" do
72
- expect_one :xpath, ".//*[(contains(concat(' ', @class, ' '), ' a ') and contains(concat(' ', @class, ' '), ' b '))]"
71
+ it 'handles selector with multiple classes in array' do
72
+ xpath = ".//*[(contains(concat(' ', @class, ' '), ' a ') and contains(concat(' ', @class, ' '), ' b '))]"
73
+ expect_one :xpath, xpath
73
74
 
74
- locate_one class: ["a", "b"]
75
+ locate_one class: %w[a b]
75
76
  end
76
77
 
77
- it "handles selector with multiple classes in string" do
78
+ it 'handles selector with multiple classes in string' do
78
79
  expect_one :xpath, ".//*[contains(concat(' ', @class, ' '), ' a b ')]"
79
80
 
80
- expect { locate_one class: "a b" }.to have_deprecated_class_array
81
+ expect { locate_one class: 'a b' }.to have_deprecated_class_array
81
82
  end
82
83
 
83
- it "handles selector with tag_name and xpath" do
84
- elements = [
85
- element(tag_name: "div", attributes: { class: "foo" }),
86
- element(tag_name: "span", attributes: { class: "foo" }),
87
- element(tag_name: "div", attributes: { class: "foo" })
88
- ]
84
+ it 'handles selector with tag_name and xpath' do
85
+ elements = [
86
+ element(tag_name: 'div', attributes: {class: 'foo'}),
87
+ element(tag_name: 'span', attributes: {class: 'foo'}),
88
+ element(tag_name: 'div', attributes: {class: 'foo'})
89
+ ]
89
90
 
90
- expect_all(:xpath, './/*[@class="foo"]').and_return(elements)
91
+ expect_all(:xpath, './/*[@class="foo"]').and_return(elements)
91
92
 
92
- selector = {
93
- xpath: './/*[@class="foo"]',
94
- tag_name: 'span'
95
- }
93
+ selector = {
94
+ xpath: './/*[@class="foo"]',
95
+ tag_name: 'span'
96
+ }
96
97
 
97
- expect(locate_one(selector).tag_name).to eq 'span'
98
+ expect(locate_one(selector).tag_name).to eq 'span'
98
99
  end
99
100
 
100
- it "handles custom attributes" do
101
+ it 'handles custom attributes' do
101
102
  elements = [
102
- element(tag_name: "div", attributes: { custom_attribute: "foo" }),
103
- element(tag_name: "span", attributes: { custom_attribute: "foo" }),
104
- element(tag_name: "div", attributes: { custom_attribute: "foo" })
103
+ element(tag_name: 'div', attributes: {custom_attribute: 'foo'}),
104
+ element(tag_name: 'span', attributes: {custom_attribute: 'foo'}),
105
+ element(tag_name: 'div', attributes: {custom_attribute: 'foo'})
105
106
  ]
106
107
 
107
- expect_one(:xpath, ".//span[@custom-attribute='foo']").and_return(elements[1])
108
+ expect_one(:xpath, ".//*[local-name()='span'][@custom-attribute='foo']").and_return(elements[1])
108
109
 
109
110
  selector = {
110
- custom_attribute: 'foo',
111
- tag_name: 'span'
111
+ custom_attribute: 'foo',
112
+ tag_name: 'span'
112
113
  }
113
114
 
114
115
  expect(locate_one(selector).tag_name).to eq 'span'
115
116
  end
116
117
  end
117
118
 
118
- describe "with special cased selectors" do
119
- it "normalizes space for :text" do
120
- expect_one :xpath, ".//div[normalize-space()='foo']"
121
- locate_one tag_name: "div",
122
- text: "foo"
119
+ describe 'with special cased selectors' do
120
+ it 'normalizes space for :text' do
121
+ expect_one :xpath, ".//*[local-name()='div'][normalize-space()='foo']"
122
+ locate_one tag_name: 'div',
123
+ text: 'foo'
123
124
  end
124
125
 
125
126
  it "handles 'text' key when it's a string" do
126
- expect_one :xpath, ".//div[normalize-space()='foo']"
127
- locate_one tag_name: "div",
128
- "text" => "foo"
127
+ expect_one :xpath, ".//*[local-name()='div'][normalize-space()='foo']"
128
+ locate_one tag_name: 'div',
129
+ 'text' => 'foo'
129
130
  end
130
131
 
131
- it "translates :caption to :text" do
132
- expect_one :xpath, ".//div[normalize-space()='foo']"
132
+ it 'translates :caption to :text' do
133
+ expect_one :xpath, ".//*[local-name()='div'][normalize-space()='foo']"
133
134
 
134
- locate_one tag_name: "div",
135
- caption: "foo"
135
+ locate_one tag_name: 'div',
136
+ caption: 'foo'
136
137
  end
137
138
 
138
- it "handles data-* attributes" do
139
- expect_one :xpath, ".//div[@data-name='foo']"
139
+ it 'handles data-* attributes' do
140
+ expect_one :xpath, ".//*[local-name()='div'][@data-name='foo']"
140
141
 
141
- locate_one tag_name: "div",
142
- data_name: "foo"
142
+ locate_one tag_name: 'div',
143
+ data_name: 'foo'
143
144
  end
144
145
 
145
- it "handles aria-* attributes" do
146
- expect_one :xpath, ".//div[@aria-label='foo']"
146
+ it 'handles aria-* attributes' do
147
+ expect_one :xpath, ".//*[local-name()='div'][@aria-label='foo']"
147
148
 
148
- locate_one tag_name: "div",
149
- aria_label: "foo"
149
+ locate_one tag_name: 'div',
150
+ aria_label: 'foo'
150
151
  end
151
152
 
152
153
  it "doesn't modify attribute name when the attribute key is a string" do
153
- expect_one :xpath, ".//div[@_ngcontent-c24]"
154
+ expect_one :xpath, ".//*[local-name()='div'][@_ngcontent-c24]"
154
155
 
155
- locate_one tag_name: "div",
156
- "_ngcontent-c24" => true
156
+ locate_one tag_name: 'div',
157
+ '_ngcontent-c24' => true
157
158
  end
158
159
 
159
- it "normalizes space for the :href attribute" do
160
- expect_one :xpath, ".//a[normalize-space(@href)='foo']"
160
+ it 'normalizes space for the :href attribute' do
161
+ expect_one :xpath, ".//*[local-name()='a'][normalize-space(@href)='foo']"
161
162
 
162
163
  selector = {
163
- tag_name: "a",
164
- href: "foo"
164
+ tag_name: 'a',
165
+ href: 'foo'
165
166
  }
166
167
 
167
168
  locate_one selector, Watir::Anchor.attributes
168
169
  end
169
170
 
170
- it "wraps :type attribute with translate() for upper case values" do
171
+ it 'wraps :type attribute with translate() for upper case values' do
171
172
  translated_type = "translate(@type,'ABCDEFGHIJKLMNOPQRSTUVWXYZ','abcdefghijklmnopqrstuvwxyz')"
172
- expect_one :xpath, ".//input[#{translated_type}='file']"
173
+ expect_one :xpath, ".//*[local-name()='input'][#{translated_type}='file']"
173
174
 
174
175
  selector = [
175
- :tag_name, "input",
176
- :type , "file",
176
+ :tag_name, 'input',
177
+ :type, 'file'
177
178
  ]
178
179
 
179
180
  locate_one selector, Watir::Input.attributes
@@ -181,30 +182,33 @@ describe Watir::Locators::Element::Locator do
181
182
 
182
183
  it "uses the corresponding <label>'s @for attribute or parent::label when locating by label" do
183
184
  translated_type = "translate(@type,'ABCDEFGHIJKLMNOPQRSTUVWXYZ','abcdefghijklmnopqrstuvwxyz')"
184
- expect_one :xpath, ".//input[#{translated_type}='text' and (@id=//label[normalize-space()='foo']/@for or parent::label[normalize-space()='foo'])]"
185
+ xpath = ".//*[local-name()='input'][#{translated_type}='text' and " \
186
+ "(@id=//label[normalize-space()='foo']/@for or " \
187
+ "parent::label[normalize-space()='foo'])]"
188
+ expect_one :xpath, xpath
185
189
 
186
190
  selector = [
187
- :tag_name, "input",
188
- :type , "text",
189
- :label , "foo"
191
+ :tag_name, 'input',
192
+ :type, 'text',
193
+ :label, 'foo'
190
194
  ]
191
195
 
192
196
  locate_one selector, Watir::Input.attributes
193
197
  end
194
198
 
195
- it "uses label attribute if it is valid for element" do
196
- expect_one :xpath, ".//option[@label='foo']"
199
+ it 'uses label attribute if it is valid for element' do
200
+ expect_one :xpath, ".//*[local-name()='option'][@label='foo']"
197
201
 
198
- selector = { tag_name: "option", label: "foo" }
202
+ selector = {tag_name: 'option', label: 'foo'}
199
203
  locate_one selector, Watir::Option.attributes
200
204
  end
201
205
 
202
- it "translates ruby attribute names to content attribute names" do
203
- expect_one :xpath, ".//meta[@http-equiv='foo']"
206
+ it 'translates ruby attribute names to content attribute names' do
207
+ expect_one :xpath, ".//*[local-name()='meta'][@http-equiv='foo']"
204
208
 
205
209
  selector = {
206
- tag_name: "meta",
207
- http_equiv: "foo"
210
+ tag_name: 'meta',
211
+ http_equiv: 'foo'
208
212
  }
209
213
 
210
214
  locate_one selector, Watir::Meta.attributes
@@ -213,28 +217,28 @@ describe Watir::Locators::Element::Locator do
213
217
  end
214
218
  end
215
219
 
216
- describe "with regexp selectors" do
217
- it "handles selector with tag name and a single regexp attribute" do
220
+ describe 'with regexp selectors' do
221
+ it 'handles selector with tag name and a single regexp attribute' do
218
222
  elements = [
219
- element(tag_name: "div", attributes: { class: "foo" }),
220
- element(tag_name: "div", attributes: { class: "foob"})
223
+ element(tag_name: 'div', attributes: {class: 'foo'}),
224
+ element(tag_name: 'div', attributes: {class: 'foob'})
221
225
  ]
222
226
 
223
- expect_all(:xpath, "(.//div)[contains(@class, 'oob')]").and_return(elements)
227
+ expect_all(:xpath, "(.//*[local-name()='div'])[contains(@class, 'oob')]").and_return(elements)
224
228
 
225
- expect(locate_one(tag_name: "div", class: /oob/)).to eq elements[1]
229
+ expect(locate_one(tag_name: 'div', class: /oob/)).to eq elements[1]
226
230
  end
227
231
 
228
- it "handles :tag_name, :index and a single regexp attribute" do
232
+ it 'handles :tag_name, :index and a single regexp attribute' do
229
233
  elements = [
230
- element(tag_name: "div", attributes: { class: "foo" }),
231
- element(tag_name: "div", attributes: { class: "foo" })
234
+ element(tag_name: 'div', attributes: {class: 'foo'}),
235
+ element(tag_name: 'div', attributes: {class: 'foo'})
232
236
  ]
233
237
 
234
- expect_all(:xpath, "(.//div)[contains(@class, 'foo')]").and_return(elements)
238
+ expect_all(:xpath, "(.//*[local-name()='div'])[contains(@class, 'foo')]").and_return(elements)
235
239
 
236
240
  selector = {
237
- tag_name: "div",
241
+ tag_name: 'div',
238
242
  class: /foo/,
239
243
  index: 1
240
244
  }
@@ -242,10 +246,10 @@ describe Watir::Locators::Element::Locator do
242
246
  expect(locate_one(selector)).to eq elements[1]
243
247
  end
244
248
 
245
- it "handles :xpath and :index selectors" do
249
+ it 'handles :xpath and :index selectors' do
246
250
  elements = [
247
- element(tag_name: "div", attributes: { class: "foo" }),
248
- element(tag_name: "div", attributes: { class: "foo" })
251
+ element(tag_name: 'div', attributes: {class: 'foo'}),
252
+ element(tag_name: 'div', attributes: {class: 'foo'})
249
253
  ]
250
254
 
251
255
  expect_all(:xpath, './/div[@class="foo"]').and_return(elements)
@@ -258,10 +262,10 @@ describe Watir::Locators::Element::Locator do
258
262
  expect(locate_one(selector)).to eq elements[1]
259
263
  end
260
264
 
261
- it "handles :css and :index selectors" do
265
+ it 'handles :css and :index selectors' do
262
266
  elements = [
263
- element(tag_name: "div", attributes: { class: "foo" }),
264
- element(tag_name: "div", attributes: { class: "foo" })
267
+ element(tag_name: 'div', attributes: {class: 'foo'}),
268
+ element(tag_name: 'div', attributes: {class: 'foo'})
265
269
  ]
266
270
 
267
271
  expect_all(:css, 'div[class="foo"]').and_return(elements)
@@ -274,63 +278,63 @@ describe Watir::Locators::Element::Locator do
274
278
  expect(locate_one(selector)).to eq elements[1]
275
279
  end
276
280
 
277
- it "handles mix of string and regexp attributes" do
281
+ it 'handles mix of string and regexp attributes' do
278
282
  elements = [
279
- element(tag_name: "div", attributes: { dir: "foo", title: "bar" }),
280
- element(tag_name: "div", attributes: { dir: "foo", title: "baz" })
283
+ element(tag_name: 'div', attributes: {dir: 'foo', title: 'bar'}),
284
+ element(tag_name: 'div', attributes: {dir: 'foo', title: 'baz'})
281
285
  ]
282
286
 
283
- expect_all(:xpath, "(.//div[@dir='foo'])[contains(@title, 'baz')]").and_return(elements)
287
+ expect_all(:xpath, "(.//*[local-name()='div'][@dir='foo'])[contains(@title, 'baz')]").and_return(elements)
284
288
 
285
289
  selector = {
286
- tag_name: "div",
287
- dir: "foo",
290
+ tag_name: 'div',
291
+ dir: 'foo',
288
292
  title: /baz/
289
293
  }
290
294
 
291
295
  expect(locate_one(selector)).to eq elements[1]
292
296
  end
293
297
 
294
- it "handles data-* attributes with regexp" do
298
+ it 'handles data-* attributes with regexp' do
295
299
  elements = [
296
- element(tag_name: "div", attributes: { :'data-automation-id' => "foo" }),
297
- element(tag_name: "div", attributes: { :'data-automation-id' => "bar" })
300
+ element(tag_name: 'div', attributes: {'data-automation-id': 'foo'}),
301
+ element(tag_name: 'div', attributes: {'data-automation-id': 'bar'})
298
302
  ]
299
303
 
300
- expect_all(:xpath, "(.//div)[contains(@data-automation-id, 'bar')]").and_return(elements)
304
+ expect_all(:xpath, "(.//*[local-name()='div'])[contains(@data-automation-id, 'bar')]").and_return(elements)
301
305
 
302
306
  selector = {
303
- tag_name: "div",
307
+ tag_name: 'div',
304
308
  data_automation_id: /bar/
305
309
  }
306
310
 
307
311
  expect(locate_one(selector)).to eq elements[1]
308
312
  end
309
313
 
310
- it "handles :label => /regexp/ selector" do
314
+ it 'handles :label => /regexp/ selector' do
311
315
  label_elements = [
312
- element(tag_name: "label", text: "foo", attributes: { 'for' => "bar"}),
313
- element(tag_name: "label", text: "foob", attributes: { 'for' => "baz"})
316
+ element(tag_name: 'label', text: 'foo', attributes: {'for' => 'bar'}),
317
+ element(tag_name: 'label', text: 'foob', attributes: {'for' => 'baz'})
314
318
  ]
315
- div_elements = [element(tag_name: "div")]
319
+ div_elements = [element(tag_name: 'div')]
316
320
 
317
- expect_all(:tag_name, "label").ordered.and_return(label_elements)
318
- expect_one(:xpath, ".//div[@id='baz']").ordered.and_return(div_elements.first)
321
+ expect_all(:tag_name, 'label').ordered.and_return(label_elements)
322
+ expect_one(:xpath, ".//*[local-name()='div'][@id='baz']").ordered.and_return(div_elements.first)
319
323
 
320
324
  allow(browser).to receive(:ensure_context).and_return(nil)
321
325
  allow(browser).to receive(:execute_script).and_return('foo', 'foob')
322
326
 
323
- expect(locate_one(tag_name: "div", label: /oob/)).to eq div_elements.first
327
+ expect(locate_one(tag_name: 'div', label: /oob/)).to eq div_elements.first
324
328
  end
325
329
 
326
- it "returns nil when no label matching the regexp is found" do
327
- expect_all(:tag_name, "label").and_return([])
328
- expect(locate_one(tag_name: "div", label: /foo/)).to be_nil
330
+ it 'returns nil when no label matching the regexp is found' do
331
+ expect_all(:tag_name, 'label').and_return([])
332
+ expect(locate_one(tag_name: 'div', label: /foo/)).to be_nil
329
333
  end
330
334
 
331
- it "relocates an element that goes stale during filtering" do
332
- element1 = element(tag_name: "div", attributes: {class: "foo"})
333
- element2 = element(tag_name: "div", attributes: {class: "foob"})
335
+ it 'relocates an element that goes stale during filtering' do
336
+ element1 = element(tag_name: 'div', attributes: {class: 'foo'})
337
+ element2 = element(tag_name: 'div', attributes: {class: 'foob'})
334
338
 
335
339
  elements1 = [element1.clone, element2.clone]
336
340
  elements2 = [element1.clone, element2.clone]
@@ -343,18 +347,18 @@ describe Watir::Locators::Element::Locator do
343
347
  end
344
348
  end
345
349
 
346
- it "finds all if :index is given" do
350
+ it 'finds all if :index is given' do
347
351
  # or could we use XPath indeces reliably instead?
348
352
  elements = [
349
- element(tag_name: "div"),
350
- element(tag_name: "div")
353
+ element(tag_name: 'div'),
354
+ element(tag_name: 'div')
351
355
  ]
352
356
 
353
- expect_all(:xpath, ".//div[@dir='foo']").and_return(elements)
357
+ expect_all(:xpath, ".//*[local-name()='div'][@dir='foo']").and_return(elements)
354
358
 
355
359
  selector = {
356
- tag_name: "div",
357
- dir: "foo",
360
+ tag_name: 'div',
361
+ dir: 'foo',
358
362
  index: 1
359
363
  }
360
364
 
@@ -362,179 +366,180 @@ describe Watir::Locators::Element::Locator do
362
366
  end
363
367
 
364
368
  it "returns nil if found element didn't match the selector tag_name" do
365
- expect_all(:xpath, "//div").and_return([element(tag_name: "div")])
369
+ expect_all(:xpath, '//div').and_return([element(tag_name: 'div')])
366
370
 
367
371
  selector = {
368
- tag_name: "input",
369
- xpath: "//div"
372
+ tag_name: 'input',
373
+ xpath: '//div'
370
374
  }
371
375
 
372
376
  expect(locate_one(selector, Watir::Input.attributes)).to be_nil
373
377
  end
374
378
 
375
- describe "errors" do
376
- it "raises a TypeError if :index is not a Integer" do
377
- expect { locate_one(tag_name: "div", index: "bar") }.to \
378
- raise_error(TypeError, %[expected Integer, got "bar":String])
379
+ describe 'errors' do
380
+ it 'raises a TypeError if :index is not a Integer' do
381
+ expect { locate_one(tag_name: 'div', index: 'bar') }.to \
382
+ raise_error(TypeError, %(expected Integer, got "bar":String))
379
383
  end
380
384
 
381
- it "raises a TypeError if selector value is not a String, Regexp or Boolean" do
385
+ it 'raises a TypeError if selector value is not a String, Regexp or Boolean' do
382
386
  num_type = RUBY_VERSION[/^\d+\.(\d+)/, 1].to_i >= 4 ? 'Integer' : 'Fixnum'
383
- expect { locate_one(tag_name: 123) }.to \
384
- raise_error(TypeError, %[expected one of [Array, String, Regexp, TrueClass, FalseClass, Symbol], got 123:#{num_type}])
387
+ msg = %(expected one of [Array, String, Regexp, TrueClass, FalseClass, Symbol], got 123:#{num_type})
388
+ expect { locate_one(tag_name: 123) }
389
+ .to raise_error TypeError, msg
385
390
  end
386
391
  end
387
392
  end
388
393
 
389
- describe "finds several elements" do
390
- describe "by delegating to Selenium" do
394
+ describe 'finds several elements' do
395
+ describe 'by delegating to Selenium' do
391
396
  SELENIUM_SELECTORS.each do |loc|
392
397
  it "delegates to Selenium's #{loc} locator" do
393
- expect_all(loc, "bar").and_return([element(tag_name: "div")])
398
+ expect_all(loc, 'bar').and_return([element(tag_name: 'div')])
394
399
  match = %i[link link_text partial_link_text].include?(loc) ? :to : :to_not
395
400
  msg = /:#{loc} locator is deprecated\. Use :visible_text instead/
396
- expect { locate_all loc => "bar" }.send(match, output(msg).to_stdout_from_any_process)
401
+ expect { locate_all loc => 'bar' }.send(match, output(msg).to_stdout_from_any_process)
397
402
  end
398
403
  end
399
404
  end
400
405
 
401
- describe "with an empty selector" do
402
- it "finds all when an empty selctor is given" do
406
+ describe 'with an empty selector' do
407
+ it 'finds all when an empty selctor is given' do
403
408
  expect_all :xpath, './/*'
404
409
  locate_all({})
405
410
  end
406
411
  end
407
412
 
408
- describe "with selectors not supported by Selenium" do
409
- it "handles selector with tag name and a single attribute" do
410
- expect_all :xpath, ".//div[@dir='foo']"
411
- locate_all tag_name: "div",
412
- dir: "foo"
413
+ describe 'with selectors not supported by Selenium' do
414
+ it 'handles selector with tag name and a single attribute' do
415
+ expect_all :xpath, ".//*[local-name()='div'][@dir='foo']"
416
+ locate_all tag_name: 'div',
417
+ dir: 'foo'
413
418
  end
414
419
 
415
- it "handles selector with tag name and multiple attributes" do
416
- expect_all :xpath, ".//div[@dir='foo' and @title='bar']"
417
- locate_all [:tag_name, "div",
418
- :dir , "foo",
419
- :title , 'bar']
420
+ it 'handles selector with tag name and multiple attributes' do
421
+ expect_all :xpath, ".//*[local-name()='div'][@dir='foo' and @title='bar']"
422
+ locate_all [:tag_name, 'div',
423
+ :dir, 'foo',
424
+ :title, 'bar']
420
425
  end
421
426
 
422
- it "handles selector with class attribute presence" do
423
- expect_all :xpath, ".//*[@class]"
427
+ it 'handles selector with class attribute presence' do
428
+ expect_all :xpath, './/*[@class]'
424
429
 
425
430
  locate_all class: true
426
431
  end
427
432
 
428
- it "handles selector with multiple classes in array" do
429
- expect_all :xpath, ".//*[(contains(concat(' ', @class, ' '), ' a ') and contains(concat(' ', @class, ' '), ' b '))]"
433
+ it 'handles selector with multiple classes in array' do
434
+ xpath = ".//*[(contains(concat(' ', @class, ' '), ' a ') and contains(concat(' ', @class, ' '), ' b '))]"
435
+ expect_all :xpath, xpath
430
436
 
431
- locate_all class: ["a", "b"]
437
+ locate_all class: %w[a b]
432
438
  end
433
439
 
434
- it "handles selector with multiple classes in string" do
440
+ it 'handles selector with multiple classes in string' do
435
441
  expect_all :xpath, ".//*[contains(concat(' ', @class, ' '), ' a b ')]"
436
442
 
437
- expect { locate_all class: "a b" }.to have_deprecated_class_array
443
+ expect { locate_all class: 'a b' }.to have_deprecated_class_array
438
444
  end
439
445
  end
440
446
 
441
- describe "with regexp selectors" do
442
- it "handles selector with tag name and a single regexp attribute" do
447
+ describe 'with regexp selectors' do
448
+ it 'handles selector with tag name and a single regexp attribute' do
443
449
  elements = [
444
- element(tag_name: "div", attributes: { class: "foo" }),
445
- element(tag_name: "div", attributes: { class: "foob"}),
446
- element(tag_name: "div", attributes: { class: "doob"}),
447
- element(tag_name: "div", attributes: { class: "noob"})
450
+ element(tag_name: 'div', attributes: {class: 'foo'}),
451
+ element(tag_name: 'div', attributes: {class: 'foob'}),
452
+ element(tag_name: 'div', attributes: {class: 'doob'}),
453
+ element(tag_name: 'div', attributes: {class: 'noob'})
448
454
  ]
449
455
 
450
- expect_all(:xpath, "(.//div)[contains(@class, 'oob')]").and_return(elements)
451
- expect(locate_all(tag_name: "div", class: /oob/)).to eq elements.last(3)
456
+ expect_all(:xpath, "(.//*[local-name()='div'])[contains(@class, 'oob')]").and_return(elements)
457
+ expect(locate_all(tag_name: 'div', class: /oob/)).to eq elements.last(3)
452
458
  end
453
459
 
454
- it "handles mix of string and regexp attributes" do
460
+ it 'handles mix of string and regexp attributes' do
455
461
  elements = [
456
- element(tag_name: "div", attributes: { dir: "foo", title: "bar" }),
457
- element(tag_name: "div", attributes: { dir: "foo", title: "baz" }),
458
- element(tag_name: "div", attributes: { dir: "foo", title: "bazt"})
462
+ element(tag_name: 'div', attributes: {dir: 'foo', title: 'bar'}),
463
+ element(tag_name: 'div', attributes: {dir: 'foo', title: 'baz'}),
464
+ element(tag_name: 'div', attributes: {dir: 'foo', title: 'bazt'})
459
465
  ]
460
466
 
461
- expect_all(:xpath, "(.//div[@dir='foo'])[contains(@title, 'baz')]").and_return(elements)
467
+ expect_all(:xpath, "(.//*[local-name()='div'][@dir='foo'])[contains(@title, 'baz')]").and_return(elements)
462
468
 
463
469
  selector = {
464
- tag_name: "div",
465
- dir: "foo",
470
+ tag_name: 'div',
471
+ dir: 'foo',
466
472
  title: /baz/
467
473
  }
468
474
 
469
475
  expect(locate_all(selector)).to eq elements.last(2)
470
476
  end
471
477
 
472
- context "and xpath" do
473
- it "converts a leading run of regexp literals to a contains() expression" do
478
+ context 'and xpath' do
479
+ it 'converts a leading run of regexp literals to a contains() expression' do
474
480
  elements = [
475
- element(tag_name: "div", attributes: { class: "foo" }),
476
- element(tag_name: "div", attributes: { class: "foob" }),
477
- element(tag_name: "div", attributes: { class: "bar" })
481
+ element(tag_name: 'div', attributes: {class: 'foo'}),
482
+ element(tag_name: 'div', attributes: {class: 'foob'}),
483
+ element(tag_name: 'div', attributes: {class: 'bar'})
478
484
  ]
479
485
 
480
- expect_all(:xpath, "(.//div)[contains(@class, 'fo')]").and_return(elements.first(2))
486
+ expect_all(:xpath, "(.//*[local-name()='div'])[contains(@class, 'fo')]").and_return(elements.first(2))
481
487
 
482
- expect(locate_one(tag_name: "div", class: /fo.b$/)).to eq elements[1]
488
+ expect(locate_one(tag_name: 'div', class: /fo.b$/)).to eq elements[1]
483
489
  end
484
490
 
485
- it "converts a trailing run of regexp literals to a contains() expression" do
491
+ it 'converts a trailing run of regexp literals to a contains() expression' do
486
492
  elements = [
487
- element(tag_name: "div", attributes: { class: "foo" }),
488
- element(tag_name: "div", attributes: { class: "foob" })
493
+ element(tag_name: 'div', attributes: {class: 'foo'}),
494
+ element(tag_name: 'div', attributes: {class: 'foob'})
489
495
  ]
490
496
 
491
- expect_all(:xpath, "(.//div)[contains(@class, 'b')]").and_return(elements.last(1))
497
+ expect_all(:xpath, "(.//*[local-name()='div'])[contains(@class, 'b')]").and_return(elements.last(1))
492
498
 
493
- expect(locate_one(tag_name: "div", class: /^fo.b/)).to eq elements[1]
499
+ expect(locate_one(tag_name: 'div', class: /^fo.b/)).to eq elements[1]
494
500
  end
495
501
 
496
- it "converts a leading and a trailing run of regexp literals to a contains() expression" do
502
+ it 'converts a leading and a trailing run of regexp literals to a contains() expression' do
497
503
  elements = [
498
- element(tag_name: "div", attributes: { class: "foo" }),
499
- element(tag_name: "div", attributes: { class: "foob" })
504
+ element(tag_name: 'div', attributes: {class: 'foo'}),
505
+ element(tag_name: 'div', attributes: {class: 'foob'})
500
506
  ]
501
507
 
502
- expect_all(:xpath, "(.//div)[contains(@class, 'fo') and contains(@class, 'b')]").
503
- and_return(elements.last(1))
508
+ expect_all(:xpath, "(.//*[local-name()='div'])[contains(@class, 'fo') and contains(@class, 'b')]")
509
+ .and_return(elements.last(1))
504
510
 
505
- expect(locate_one(tag_name: "div", class: /fo.b/)).to eq elements[1]
511
+ expect(locate_one(tag_name: 'div', class: /fo.b/)).to eq elements[1]
506
512
  end
507
513
 
508
- it "does not try to convert case insensitive expressions" do
514
+ it 'does not try to convert case insensitive expressions' do
509
515
  elements = [
510
- element(tag_name: "div", attributes: { class: "foo" }),
511
- element(tag_name: "div", attributes: { class: "foob"})
516
+ element(tag_name: 'div', attributes: {class: 'foo'}),
517
+ element(tag_name: 'div', attributes: {class: 'foob'})
512
518
  ]
513
519
 
514
- expect_all(:xpath, ".//div").and_return(elements.last(1))
520
+ expect_all(:xpath, ".//*[local-name()='div']").and_return(elements.last(1))
515
521
 
516
- expect(locate_one(tag_name: "div", class: /FOOB/i)).to eq elements[1]
522
+ expect(locate_one(tag_name: 'div', class: /FOOB/i)).to eq elements[1]
517
523
  end
518
524
 
519
525
  it "does not try to convert expressions containing '|'" do
520
526
  elements = [
521
- element(tag_name: "div", attributes: { class: "foo" }),
522
- element(tag_name: "div", attributes: { class: "foob"})
527
+ element(tag_name: 'div', attributes: {class: 'foo'}),
528
+ element(tag_name: 'div', attributes: {class: 'foob'})
523
529
  ]
524
530
 
525
- expect_all(:xpath, ".//div").and_return(elements.last(1))
531
+ expect_all(:xpath, ".//*[local-name()='div']").and_return(elements.last(1))
526
532
 
527
- expect(locate_one(tag_name: "div", class: /x|b/)).to eq elements[1]
533
+ expect(locate_one(tag_name: 'div', class: /x|b/)).to eq elements[1]
528
534
  end
529
535
  end
530
536
  end
531
537
 
532
- describe "errors" do
533
- it "raises ArgumentError if :index is given" do
534
- expect { locate_all(tag_name: "div", index: 1) }.to \
535
- raise_error(ArgumentError, "can't locate all elements by :index")
538
+ describe 'errors' do
539
+ it 'raises ArgumentError if :index is given' do
540
+ expect { locate_all(tag_name: 'div', index: 1) }.to \
541
+ raise_error(ArgumentError, "can't locate all elements by :index")
536
542
  end
537
543
  end
538
544
  end
539
-
540
545
  end