watir-webdriver 0.6.3 → 0.6.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9407ab3824340922a6ed7724f6f86dde94837cfa
4
- data.tar.gz: ac0da8d422e29382fa8349a0942b345925d279d0
3
+ metadata.gz: 4db8bb80c796c2acc7a8e949ae60333ebd5048f6
4
+ data.tar.gz: 75fae8d53c1f376e2d4791d8d611c45362a88da1
5
5
  SHA512:
6
- metadata.gz: 691b6c764ab1d227294fd4fcd3d6eb00afbf1d1c878b1cc444359fb27169646a846998c2964716b1e5d6ed047f43a5e6dbab224746a1a410723ff4e1196c080c
7
- data.tar.gz: 27656d8ffe2229a8a92735406772909b2d7b24ea18df726c0bf0bc5449d1d246bb3aa782fbd6b2b3350b6d9b22a6ff0680c6b023bc8d58ad25b5835eff175814
6
+ metadata.gz: e7e6f4875c630da9586dde5d5e96e4263734ec289e5139112e8f959b4a1a0b09efaf2d785088448e2f9557a416cd72fdb348a6dd7decde716b7775fa781581fd
7
+ data.tar.gz: 62877fce513d157a993b0b542a6e9c90a45cfac0edffca843c04090aa8dd83f1cfd1b47ecc53c99da8e50a8062c67bd540df692b897761dd984ce32d42556630
data/CHANGES.md CHANGED
@@ -1,3 +1,8 @@
1
+ 0.6.4
2
+ =====
3
+
4
+ * Add ability to find element by parent <label>
5
+
1
6
  0.6.3
2
7
  =====
3
8
 
@@ -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
- selector[:id] = id_from_label(rx_selector.delete(:label)) || return
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 = @wd.find_elements(how, what)
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 id_from_label(label_exp)
166
+ def label_from_text(label_exp)
161
167
  # TODO: this won't work correctly if @wd is a sub-element
162
- label = @wd.find_elements(:tag_name, 'label').find do |el|
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
- "@id=//label[normalize-space()=#{XpathSupport.escape value}]/@for"
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
@@ -1,3 +1,3 @@
1
1
  module Watir
2
- VERSION = "0.6.3"
2
+ VERSION = "0.6.4"
3
3
  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.3
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-10 00:00:00.000000000 Z
11
+ date: 2013-04-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: selenium-webdriver