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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e372a1f6959d978774865329265a8384bcb5392f
4
- data.tar.gz: 62aa15e1de0949782b07234848810e9f1ada78d2
3
+ metadata.gz: 3c27ed00d9c0f60b3ba74da91a1a0543975f6e40
4
+ data.tar.gz: 9613de99f0a45fdbf00bb61edbfd64ba494b8ef1
5
5
  SHA512:
6
- metadata.gz: cf81b7db2c3f76b325aea31d4b200928ed210033c2017c0a777a8df8f5903841b35fb278ea1b0214bf955a1c1a8f28c25245d0801158388605f51c4577443e25
7
- data.tar.gz: 90b8cba253f40574f08781ad83ca52220c3091c412d9dac432216377be2f74725c837b1092780259c40ba3a8d62a9de817bcf25fd01e3cdfc66c217a18310d4a
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://secure.travis-ci.org/watir/watir-webdriver.png)](http://travis-ci.org/watir/watir-webdriver)
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)
@@ -45,7 +45,7 @@ module Watir
45
45
  :secure => opts[:secure],
46
46
  :path => opts[:path],
47
47
  :expires => opts[:expires],
48
- :domain => opts[:domain],
48
+ :domain => opts[:domain]
49
49
  }
50
50
 
51
51
  @control.add_cookie cookie
@@ -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 = selector.delete(:index)
82
- how, what = given_xpath(selector) || build_wd_selector(selector)
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 = given_xpath(selector) || build_wd_selector(selector)
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 given_xpath(selector)
408
- return unless xpath = selector.delete(:xpath)
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
- unless selector.empty? || can_be_combined_with_xpath?(selector)
411
- raise ArgumentError, ":xpath cannot be combined with other selectors (#{selector.inspect})"
408
+ if xpath && css
409
+ raise ArgumentError, ":xpath and :css cannot be combined (#{selector.inspect})"
412
410
  end
413
411
 
414
- [:xpath, xpath]
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 can_be_combined_with_xpath?(selector)
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
 
@@ -1,3 +1,3 @@
1
1
  module Watir
2
- VERSION = "0.6.7"
2
+ VERSION = "0.6.8"
3
3
  end
@@ -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.7
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-04 00:00:00.000000000 Z
11
+ date: 2014-02-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: selenium-webdriver