watir-webdriver 0.6.7 → 0.6.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGES.md +9 -0
- data/README.md +1 -1
- data/lib/watir-webdriver/cookies.rb +1 -1
- data/lib/watir-webdriver/locators/element_locator.rb +25 -18
- data/lib/watir-webdriver/version.rb +1 -1
- data/spec/element_locator_spec.rb +32 -0
- 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: 3c27ed00d9c0f60b3ba74da91a1a0543975f6e40
|
4
|
+
data.tar.gz: 9613de99f0a45fdbf00bb61edbfd64ba494b8ef1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5cb22dd0fe4715b647e43c91d637ea32fcb35747bcca0e0187995eca1ab9fa6ce1ddf3c355c8ce0dbac264f0530bd7ab5f423e8b8bfda6c74102d53170d00430
|
7
|
+
data.tar.gz: 4b0d5ea3f95dc25cb36eec24fc1ee5db4787250aae66eecd65e41ce18644aeef62ac8dcab32eb13a7d6612a0763ff3cf68e19b648ce2cd1ef2072303fe12695e
|
data/CHANGES.md
CHANGED
@@ -1,3 +1,12 @@
|
|
1
|
+
### 0.6.8 (2014-02-20)
|
2
|
+
|
3
|
+
* `:css` selector can now be used with `:index` (fixes #241)
|
4
|
+
* `:css` selector can now be used on all container methods (fixes #124)
|
5
|
+
|
6
|
+
### 0.6.7 (2014-02-04)
|
7
|
+
|
8
|
+
* Revert wait/timeout bug introduced in 0.6.5 to fix #228.
|
9
|
+
|
1
10
|
### 0.6.6 (2014-01-29)
|
2
11
|
|
3
12
|
* Fix regression where locating `<button>foo</button>` using (value: /foo/) would fail.
|
data/README.md
CHANGED
@@ -5,7 +5,7 @@ Watir implementation built on WebDriver's Ruby bindings.
|
|
5
5
|
See http://rubyforge.org/pipermail/wtr-development/2009-October/001313.html.
|
6
6
|
|
7
7
|
[![Gem Version](https://badge.fury.io/rb/watir-webdriver.png)](http://badge.fury.io/rb/watir-webdriver)
|
8
|
-
[![Build Status](https://
|
8
|
+
[![Build Status](https://travis-ci.org/watir/watir-webdriver.png?branch=master)](https://travis-ci.org/watir/watir-webdriver)
|
9
9
|
[![Code Climate](https://codeclimate.com/github/watir/watir-webdriver.png)](https://codeclimate.com/github/watir/watir-webdriver)
|
10
10
|
[![Dependency Status](https://gemnasium.com/watir/watir-webdriver.png)](https://gemnasium.com/watir/watir-webdriver)
|
11
11
|
[![Coverage Status](https://coveralls.io/repos/watir/watir-webdriver/badge.png?branch=master)](https://coveralls.io/r/watir/watir-webdriver)
|
@@ -3,7 +3,7 @@ module Watir
|
|
3
3
|
class ElementLocator
|
4
4
|
include Watir::Exception
|
5
5
|
|
6
|
-
WD_FINDERS =
|
6
|
+
WD_FINDERS = [
|
7
7
|
:class,
|
8
8
|
:class_name,
|
9
9
|
:css,
|
@@ -34,7 +34,7 @@ module Watir
|
|
34
34
|
element = find_first_by_multiple
|
35
35
|
end
|
36
36
|
|
37
|
-
# This actually only applies when finding by xpath - browser.text_field(:xpath, "//input[@type='radio']")
|
37
|
+
# This actually only applies when finding by xpath/css - browser.text_field(:xpath, "//input[@type='radio']")
|
38
38
|
# We don't need to validate the element if we built the xpath ourselves.
|
39
39
|
# It is also used to alter behavior of methods locating more than one type of element
|
40
40
|
# (e.g. text_field locates both input and textarea)
|
@@ -78,11 +78,11 @@ module Watir
|
|
78
78
|
def find_first_by_multiple
|
79
79
|
selector = normalized_selector
|
80
80
|
|
81
|
-
idx
|
82
|
-
how, what =
|
81
|
+
idx = selector.delete(:index)
|
82
|
+
how, what = given_xpath_or_css(selector) || build_wd_selector(selector)
|
83
83
|
|
84
84
|
if how
|
85
|
-
# could build xpath for selector
|
85
|
+
# could build xpath/css for selector
|
86
86
|
if idx
|
87
87
|
@wd.find_elements(how, what)[idx]
|
88
88
|
else
|
@@ -105,7 +105,7 @@ module Watir
|
|
105
105
|
raise ArgumentError, "can't locate all elements by :index"
|
106
106
|
end
|
107
107
|
|
108
|
-
how, what =
|
108
|
+
how, what = given_xpath_or_css(selector) || build_wd_selector(selector)
|
109
109
|
if how
|
110
110
|
@wd.find_elements(how, what)
|
111
111
|
else
|
@@ -208,7 +208,7 @@ module Watir
|
|
208
208
|
|
209
209
|
def normalize_selector(how, what)
|
210
210
|
case how
|
211
|
-
when :tag_name, :text, :xpath, :index, :class, :label
|
211
|
+
when :tag_name, :text, :xpath, :index, :class, :label, :css
|
212
212
|
# include :class since the valid attribute is 'class_name'
|
213
213
|
# include :for since the valid attribute is 'html_for'
|
214
214
|
[how, what]
|
@@ -293,10 +293,6 @@ module Watir
|
|
293
293
|
xpath << "[" << attribute_expression(selectors) << "]"
|
294
294
|
end
|
295
295
|
|
296
|
-
if idx
|
297
|
-
xpath << "[#{idx + 1}]"
|
298
|
-
end
|
299
|
-
|
300
296
|
p :xpath => xpath, :selectors => selectors if $DEBUG
|
301
297
|
|
302
298
|
[:xpath, xpath]
|
@@ -404,18 +400,29 @@ module Watir
|
|
404
400
|
element
|
405
401
|
end
|
406
402
|
|
407
|
-
def
|
408
|
-
|
403
|
+
def given_xpath_or_css(selector)
|
404
|
+
xpath = selector.delete(:xpath)
|
405
|
+
css = selector.delete(:css)
|
406
|
+
return unless xpath || css
|
409
407
|
|
410
|
-
|
411
|
-
raise ArgumentError, ":xpath cannot be combined
|
408
|
+
if xpath && css
|
409
|
+
raise ArgumentError, ":xpath and :css cannot be combined (#{selector.inspect})"
|
412
410
|
end
|
413
411
|
|
414
|
-
|
412
|
+
how, what = if xpath
|
413
|
+
[:xpath, xpath]
|
414
|
+
elsif css
|
415
|
+
[:css, css]
|
416
|
+
end
|
417
|
+
|
418
|
+
if selector.any? && !can_be_combined_with_xpath_or_css?(selector)
|
419
|
+
raise ArgumentError, "#{how} cannot be combined with other selectors (#{selector.inspect})"
|
420
|
+
end
|
421
|
+
|
422
|
+
[how, what]
|
415
423
|
end
|
416
424
|
|
417
|
-
def
|
418
|
-
# ouch - is this worth it?
|
425
|
+
def can_be_combined_with_xpath_or_css?(selector)
|
419
426
|
keys = selector.keys
|
420
427
|
return true if keys == [:tag_name]
|
421
428
|
|
@@ -219,6 +219,38 @@ describe Watir::ElementLocator do
|
|
219
219
|
expect(locate_one(selector)).to eq elements[1]
|
220
220
|
end
|
221
221
|
|
222
|
+
it "handles :xpath and :index selectors" do
|
223
|
+
elements = [
|
224
|
+
element(:tag_name => "div", :attributes => { :class => "foo" }),
|
225
|
+
element(:tag_name => "div", :attributes => { :class => "foo" })
|
226
|
+
]
|
227
|
+
|
228
|
+
expect_all(:xpath, './/div[@class="foo"]').and_return(elements)
|
229
|
+
|
230
|
+
selector = {
|
231
|
+
:xpath => './/div[@class="foo"]',
|
232
|
+
:index => 1
|
233
|
+
}
|
234
|
+
|
235
|
+
expect(locate_one(selector)).to eq elements[1]
|
236
|
+
end
|
237
|
+
|
238
|
+
it "handles :css and :index selectors" do
|
239
|
+
elements = [
|
240
|
+
element(:tag_name => "div", :attributes => { :class => "foo" }),
|
241
|
+
element(:tag_name => "div", :attributes => { :class => "foo" })
|
242
|
+
]
|
243
|
+
|
244
|
+
expect_all(:css, 'div[class="foo"]').and_return(elements)
|
245
|
+
|
246
|
+
selector = {
|
247
|
+
:css => 'div[class="foo"]',
|
248
|
+
:index => 1
|
249
|
+
}
|
250
|
+
|
251
|
+
expect(locate_one(selector)).to eq elements[1]
|
252
|
+
end
|
253
|
+
|
222
254
|
it "handles mix of string and regexp attributes" do
|
223
255
|
elements = [
|
224
256
|
element(:tag_name => "div", :attributes => { :dir => "foo", :title => "bar" }),
|
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.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jari Bakken
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-02-
|
11
|
+
date: 2014-02-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: selenium-webdriver
|