watir-webdriver 0.6.3 → 0.6.4
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 +5 -0
- data/lib/watir-webdriver/locators/element_locator.rb +12 -7
- data/lib/watir-webdriver/version.rb +1 -1
- data/spec/element_locator_spec.rb +2 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4db8bb80c796c2acc7a8e949ae60333ebd5048f6
|
4
|
+
data.tar.gz: 75fae8d53c1f376e2d4791d8d611c45362a88da1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e7e6f4875c630da9586dde5d5e96e4263734ec289e5139112e8f959b4a1a0b09efaf2d785088448e2f9557a416cd72fdb348a6dd7decde716b7775fa781581fd
|
7
|
+
data.tar.gz: 62877fce513d157a993b0b542a6e9c90a45cfac0edffca843c04090aa8dd83f1cfd1b47ecc53c99da8e50a8062c67bd540df692b897761dd984ce32d42556630
|
data/CHANGES.md
CHANGED
@@ -126,10 +126,16 @@ module Watir
|
|
126
126
|
end
|
127
127
|
|
128
128
|
def wd_find_by_regexp_selector(selector, method = :find)
|
129
|
+
parent = @wd
|
129
130
|
rx_selector = delete_regexps_from(selector)
|
130
131
|
|
131
132
|
if rx_selector.has_key?(:label) && should_use_label_element?
|
132
|
-
|
133
|
+
label = label_from_text(rx_selector.delete(:label)) || return
|
134
|
+
if (id = label.attribute(:for))
|
135
|
+
selector[:id] = id
|
136
|
+
else
|
137
|
+
parent = label
|
138
|
+
end
|
133
139
|
end
|
134
140
|
|
135
141
|
how, what = build_wd_selector(selector)
|
@@ -138,7 +144,7 @@ module Watir
|
|
138
144
|
raise Error, "internal error: unable to build WebDriver selector from #{selector.inspect}"
|
139
145
|
end
|
140
146
|
|
141
|
-
elements =
|
147
|
+
elements = parent.find_elements(how, what)
|
142
148
|
elements.__send__(method) { |el| matches_selector?(el, rx_selector) }
|
143
149
|
end
|
144
150
|
|
@@ -157,13 +163,11 @@ module Watir
|
|
157
163
|
end
|
158
164
|
end
|
159
165
|
|
160
|
-
def
|
166
|
+
def label_from_text(label_exp)
|
161
167
|
# TODO: this won't work correctly if @wd is a sub-element
|
162
|
-
|
168
|
+
@wd.find_elements(:tag_name, 'label').find do |el|
|
163
169
|
matches_selector?(el, :text => label_exp)
|
164
170
|
end
|
165
|
-
|
166
|
-
label.attribute(:for) if label
|
167
171
|
end
|
168
172
|
|
169
173
|
def fetch_value(element, how)
|
@@ -360,7 +364,8 @@ module Watir
|
|
360
364
|
"contains(concat(' ', @class, ' '), #{klass})"
|
361
365
|
elsif key == :label && should_use_label_element?
|
362
366
|
# we assume :label means a corresponding label element, not the attribute
|
363
|
-
"
|
367
|
+
text = "normalize-space()=#{XpathSupport.escape value}"
|
368
|
+
"(@id=//label[#{text}]/@for or parent::label[#{text}])"
|
364
369
|
else
|
365
370
|
"#{lhs_for(key)}=#{XpathSupport.escape value}"
|
366
371
|
end
|
@@ -133,9 +133,9 @@ describe Watir::ElementLocator do
|
|
133
133
|
locate_one selector, Watir::Input.attributes
|
134
134
|
end
|
135
135
|
|
136
|
-
it "uses the corresponding <label>'s @for attribute when locating by label" do
|
136
|
+
it "uses the corresponding <label>'s @for attribute or parent::label when locating by label" do
|
137
137
|
translated_type = "translate(@type,'ABCDEFGHIJKLMNOPQRSTUVWXYZ','abcdefghijklmnopqrstuvwxyz')"
|
138
|
-
expect_one :xpath, ".//input[#{translated_type}='text' and @id=//label[normalize-space()='foo']/@for]"
|
138
|
+
expect_one :xpath, ".//input[#{translated_type}='text' and (@id=//label[normalize-space()='foo']/@for or parent::label[normalize-space()='foo'])]"
|
139
139
|
|
140
140
|
selector = [
|
141
141
|
:tag_name, "input",
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: watir-webdriver
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.6.
|
4
|
+
version: 0.6.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jari Bakken
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-04-
|
11
|
+
date: 2013-04-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: selenium-webdriver
|