watir 6.4.3 → 6.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGES.md +4 -0
- data/lib/watir/locators/element/selector_builder.rb +4 -1
- data/lib/watir/locators/element/selector_builder/xpath.rb +17 -3
- data/spec/element_locator_spec.rb +1 -1
- data/spec/locator_spec_helper.rb +1 -3
- data/spec/watirspec/elements/element_spec.rb +28 -2
- data/spec/watirspec/html/class_locator.html +1 -0
- data/watir.gemspec +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 6e19bc6a7d28d78bba208d88dd97a58bce85fc9d
|
|
4
|
+
data.tar.gz: 0031cc40646d67219270b7914369df5a7e084144
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: f71791589c4bc26c594d25ffb755fec75a8cbf41c2d93e0bf8c9671573a66e2fac01a21618159c169fa79a25387963a5a79c6940a329b177939b305ede9c3dbd
|
|
7
|
+
data.tar.gz: 7ca2f02eb0a3c950f2e8b8e16ce8e1acb9c3dd8766637d8bc5c3594b49634c0dce2af3d7ec216add6d36f81968df69eb3b35215bd5a43c216b2c04883d350c98
|
data/CHANGES.md
CHANGED
|
@@ -2,7 +2,7 @@ module Watir
|
|
|
2
2
|
module Locators
|
|
3
3
|
class Element
|
|
4
4
|
class SelectorBuilder
|
|
5
|
-
VALID_WHATS = [String, Regexp, TrueClass, FalseClass].freeze
|
|
5
|
+
VALID_WHATS = [Array, String, Regexp, TrueClass, FalseClass].freeze
|
|
6
6
|
WILDCARD_ATTRIBUTE = /^(aria|data)_(.+)$/
|
|
7
7
|
|
|
8
8
|
def initialize(query_scope, selector, valid_attributes)
|
|
@@ -35,6 +35,9 @@ module Watir
|
|
|
35
35
|
raise TypeError, "expected TrueClass or FalseClass, got #{what.inspect}:#{what.class}"
|
|
36
36
|
end
|
|
37
37
|
else
|
|
38
|
+
if what.is_a?(Array) && how != :class
|
|
39
|
+
raise TypeError, "Only :class locator can have a value of an Array"
|
|
40
|
+
end
|
|
38
41
|
unless VALID_WHATS.any? { |t| what.is_a? t }
|
|
39
42
|
raise TypeError, "expected one of #{VALID_WHATS.inspect}, got #{what.inspect}:#{what.class}"
|
|
40
43
|
end
|
|
@@ -26,7 +26,9 @@ module Watir
|
|
|
26
26
|
# @todo Get rid of building
|
|
27
27
|
def attribute_expression(building, selectors)
|
|
28
28
|
f = selectors.map do |key, val|
|
|
29
|
-
if val.is_a?(Array)
|
|
29
|
+
if val.is_a?(Array) && key == :class
|
|
30
|
+
"(" + val.map { |v| build_class_match(v) }.join(" and ") + ")"
|
|
31
|
+
elsif val.is_a?(Array)
|
|
30
32
|
"(" + val.map { |v| equal_pair(building, key, v) }.join(" or ") + ")"
|
|
31
33
|
elsif val == true
|
|
32
34
|
attribute_presence(key)
|
|
@@ -42,8 +44,10 @@ module Watir
|
|
|
42
44
|
# @todo Get rid of building
|
|
43
45
|
def equal_pair(building, key, value)
|
|
44
46
|
if key == :class
|
|
45
|
-
|
|
46
|
-
|
|
47
|
+
if value.strip.include?(' ')
|
|
48
|
+
warn 'Using the :class locator to locate multiple classes with a String value is deprecated; use an Array instead'
|
|
49
|
+
end
|
|
50
|
+
build_class_match(value)
|
|
47
51
|
elsif key == :label && @should_use_label_element
|
|
48
52
|
# we assume :label means a corresponding label element, not the attribute
|
|
49
53
|
text = "normalize-space()=#{XpathSupport.escape value}"
|
|
@@ -72,6 +76,16 @@ module Watir
|
|
|
72
76
|
|
|
73
77
|
private
|
|
74
78
|
|
|
79
|
+
def build_class_match(value)
|
|
80
|
+
if value.match(/^!/)
|
|
81
|
+
klass = XpathSupport.escape " #{value[1..-1]} "
|
|
82
|
+
"not(contains(concat(' ', @class, ' '), #{klass}))"
|
|
83
|
+
else
|
|
84
|
+
klass = XpathSupport.escape " #{value} "
|
|
85
|
+
"contains(concat(' ', @class, ' '), #{klass})"
|
|
86
|
+
end
|
|
87
|
+
end
|
|
88
|
+
|
|
75
89
|
def attribute_presence(attribute)
|
|
76
90
|
lhs_for(nil, attribute)
|
|
77
91
|
end
|
|
@@ -303,7 +303,7 @@ describe Watir::Locators::Element::Locator do
|
|
|
303
303
|
it "raises a TypeError if selector value is not a String, Regexp or Boolean" do
|
|
304
304
|
num_type = RUBY_VERSION[/^\d+\.(\d+)/, 1].to_i >= 4 ? 'Integer' : 'Fixnum'
|
|
305
305
|
expect { locate_one(tag_name: 123) }.to \
|
|
306
|
-
raise_error(TypeError, %[expected one of [String, Regexp, TrueClass, FalseClass], got 123:#{num_type}])
|
|
306
|
+
raise_error(TypeError, %[expected one of [Array, String, Regexp, TrueClass, FalseClass], got 123:#{num_type}])
|
|
307
307
|
end
|
|
308
308
|
|
|
309
309
|
it "raises a MissingWayOfFindingObjectException if the attribute is not valid" do
|
data/spec/locator_spec_helper.rb
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
require 'active_support/ordered_hash'
|
|
2
|
-
|
|
3
1
|
module LocatorSpecHelper
|
|
4
2
|
def browser
|
|
5
3
|
@browser ||= double(Watir::Browser, wd: driver)
|
|
@@ -48,7 +46,7 @@ module LocatorSpecHelper
|
|
|
48
46
|
when Hash
|
|
49
47
|
selector
|
|
50
48
|
when Array
|
|
51
|
-
|
|
49
|
+
Hash[*selector]
|
|
52
50
|
else
|
|
53
51
|
raise ArgumentError, "couldn't create hash for #{selector.inspect}"
|
|
54
52
|
end
|
|
@@ -237,16 +237,42 @@ describe "Element" do
|
|
|
237
237
|
it "matches when the element has several classes" do
|
|
238
238
|
e = browser.div(class: "b")
|
|
239
239
|
expect(e).to exist
|
|
240
|
-
expect(e.class_name).to eq "a b"
|
|
240
|
+
expect(e.class_name).to eq "a b c"
|
|
241
241
|
end
|
|
242
242
|
|
|
243
243
|
it "does not match only part of the class name" do
|
|
244
|
-
expect(browser.div(class: "
|
|
244
|
+
expect(browser.div(class: "bc")).to_not exist
|
|
245
245
|
end
|
|
246
246
|
|
|
247
247
|
it "matches part of the class name when given a regexp" do
|
|
248
248
|
expect(browser.div(class: /c/)).to exist
|
|
249
249
|
end
|
|
250
|
+
|
|
251
|
+
context "with multiple classes" do
|
|
252
|
+
it "matches when the element has a single class" do
|
|
253
|
+
e = browser.div(class: ["a"])
|
|
254
|
+
expect(e).to exist
|
|
255
|
+
expect(e.class_name).to eq "a"
|
|
256
|
+
end
|
|
257
|
+
|
|
258
|
+
it "matches a non-ordered subset" do
|
|
259
|
+
e = browser.div(class: ["c", "a"])
|
|
260
|
+
expect(e).to exist
|
|
261
|
+
expect(e.class_name).to eq "a b c"
|
|
262
|
+
end
|
|
263
|
+
|
|
264
|
+
it "matches one with a negation" do
|
|
265
|
+
e = browser.div(class: ["!a"])
|
|
266
|
+
expect(e).to exist
|
|
267
|
+
expect(e.class_name).to eq "abc"
|
|
268
|
+
end
|
|
269
|
+
|
|
270
|
+
it "matches multiple with a negation" do
|
|
271
|
+
e = browser.div(class: ["a", "!c", "b"])
|
|
272
|
+
expect(e).to exist
|
|
273
|
+
expect(e.class_name).to eq "a b"
|
|
274
|
+
end
|
|
275
|
+
end
|
|
250
276
|
end
|
|
251
277
|
|
|
252
278
|
context "attribute presence" do
|
data/watir.gemspec
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: watir
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 6.
|
|
4
|
+
version: 6.5.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Alex Rodionov
|
|
@@ -9,7 +9,7 @@ authors:
|
|
|
9
9
|
autorequire:
|
|
10
10
|
bindir: bin
|
|
11
11
|
cert_chain: []
|
|
12
|
-
date: 2017-07-
|
|
12
|
+
date: 2017-07-25 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
|
14
14
|
- !ruby/object:Gem::Dependency
|
|
15
15
|
name: selenium-webdriver
|
|
@@ -481,7 +481,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
481
481
|
version: '0'
|
|
482
482
|
requirements: []
|
|
483
483
|
rubyforge_project: watir
|
|
484
|
-
rubygems_version: 2.
|
|
484
|
+
rubygems_version: 2.6.11
|
|
485
485
|
signing_key:
|
|
486
486
|
specification_version: 4
|
|
487
487
|
summary: Watir powered by Selenium
|