watir-webdriver 0.7.0 → 0.8.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +3 -2
- data/.travis.yml +2 -3
- data/CHANGES.md +10 -1
- data/Gemfile +1 -1
- data/README.md +22 -17
- data/Rakefile +55 -52
- data/lib/watir-webdriver.rb +3 -2
- data/lib/watir-webdriver/alert.rb +0 -1
- data/lib/watir-webdriver/atoms/README +1 -1
- data/lib/watir-webdriver/browser.rb +4 -5
- data/lib/watir-webdriver/cell_container.rb +2 -2
- data/lib/watir-webdriver/container.rb +2 -3
- data/lib/watir-webdriver/cookies.rb +8 -8
- data/lib/watir-webdriver/element_collection.rb +3 -4
- data/lib/watir-webdriver/elements/area.rb +0 -1
- data/lib/watir-webdriver/elements/button.rb +0 -1
- data/lib/watir-webdriver/elements/checkbox.rb +2 -4
- data/lib/watir-webdriver/elements/element.rb +69 -45
- data/lib/watir-webdriver/elements/file_field.rb +2 -3
- data/lib/watir-webdriver/elements/font.rb +2 -2
- data/lib/watir-webdriver/elements/form.rb +0 -1
- data/lib/watir-webdriver/elements/hidden.rb +2 -3
- data/lib/watir-webdriver/elements/html_elements.rb +2282 -0
- data/lib/watir-webdriver/elements/iframe.rb +6 -7
- data/lib/watir-webdriver/elements/image.rb +0 -1
- data/lib/watir-webdriver/elements/input.rb +0 -1
- data/lib/watir-webdriver/elements/link.rb +0 -1
- data/lib/watir-webdriver/elements/option.rb +3 -4
- data/lib/watir-webdriver/elements/radio.rb +2 -3
- data/lib/watir-webdriver/elements/select.rb +0 -1
- data/lib/watir-webdriver/elements/svg_elements.rb +787 -0
- data/lib/watir-webdriver/elements/table.rb +0 -2
- data/lib/watir-webdriver/elements/table_section.rb +1 -1
- data/lib/watir-webdriver/elements/text_field.rb +2 -3
- data/lib/watir-webdriver/exception.rb +0 -2
- data/lib/watir-webdriver/extensions/nokogiri.rb +1 -1
- data/lib/watir-webdriver/generator.rb +3 -0
- data/lib/watir-webdriver/generator/base.rb +11 -0
- data/lib/watir-webdriver/{html → generator/base}/generator.rb +23 -33
- data/lib/watir-webdriver/{html → generator/base}/idl_sorter.rb +3 -5
- data/lib/watir-webdriver/{html → generator/base}/spec_extractor.rb +15 -41
- data/lib/watir-webdriver/generator/base/util.rb +21 -0
- data/lib/watir-webdriver/{html → generator/base}/visitor.rb +15 -15
- data/lib/watir-webdriver/{html.rb → generator/html.rb} +3 -11
- data/lib/watir-webdriver/generator/html/generator.rb +36 -0
- data/lib/watir-webdriver/generator/html/spec_extractor.rb +50 -0
- data/lib/watir-webdriver/generator/html/visitor.rb +21 -0
- data/lib/watir-webdriver/generator/svg.rb +7 -0
- data/lib/watir-webdriver/generator/svg/generator.rb +38 -0
- data/lib/watir-webdriver/generator/svg/spec_extractor.rb +46 -0
- data/lib/watir-webdriver/generator/svg/visitor.rb +21 -0
- data/lib/watir-webdriver/has_window.rb +3 -3
- data/lib/watir-webdriver/locators/button_locator.rb +7 -2
- data/lib/watir-webdriver/locators/child_cell_locator.rb +1 -1
- data/lib/watir-webdriver/locators/child_row_locator.rb +1 -1
- data/lib/watir-webdriver/locators/element_locator.rb +44 -9
- data/lib/watir-webdriver/locators/text_area_locator.rb +4 -0
- data/lib/watir-webdriver/locators/text_field_locator.rb +7 -2
- data/lib/watir-webdriver/screenshot.rb +0 -1
- data/lib/watir-webdriver/version.rb +1 -1
- data/lib/watir-webdriver/wait.rb +10 -11
- data/lib/watir-webdriver/window.rb +5 -5
- data/lib/watir-webdriver/xpath_support.rb +0 -1
- data/spec/always_locate_spec.rb +4 -4
- data/spec/browser_spec.rb +3 -3
- data/spec/click_spec.rb +11 -4
- data/spec/container_spec.rb +2 -2
- data/spec/element_locator_spec.rb +145 -84
- data/spec/element_spec.rb +29 -16
- data/spec/html/clicks.html +3 -0
- data/spec/html/removed_element.html +7 -0
- data/spec/implementation.rb +5 -5
- data/spec/input_spec.rb +1 -1
- data/spec/spec_helper.rb +1 -2
- data/spec/special_chars_spec.rb +2 -2
- data/support/doctest_helper.rb +4 -4
- data/support/version_differ.rb +2 -2
- data/watir-webdriver.gemspec +3 -3
- metadata +27 -17
- data/lib/watir-webdriver/elements/generated.rb +0 -3106
- data/lib/watir-webdriver/html/util.rb +0 -22
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9370b06f40fbc6975aeea6dea8986520f4bf5ecd
|
4
|
+
data.tar.gz: f4cb6ecae2be21dfb1c30170e8b1aaf4aac78127
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 398ffa48eb35503b7b92b771bf6f2a9ab6a8afc5dbfcf9033e7daaa1fcb7c69c8dcd6b4a9df55a5c3d73fb20f7a2cd7b23106e26eb4b0ac2bed8f4f34155a5c9
|
7
|
+
data.tar.gz: 4966d71ac3d300392e7f8525a3f25aa81a712e7aada635632b2531cd5e57cfb52b0900f96ef0f2a141935095a251713727453301b06708474368778d3923ce89
|
data/.gitignore
CHANGED
data/.travis.yml
CHANGED
data/CHANGES.md
CHANGED
@@ -1,4 +1,13 @@
|
|
1
|
-
### 0.
|
1
|
+
### 0.8.0 (2015-06-26)
|
2
|
+
|
3
|
+
* Ruby 1.8 is no longer supported. Ruby 1.9 still works, but not supported as well (#327)
|
4
|
+
* Ensure `Watir::Element` responds to `data_*` and `aria_*` methods (#333, thanks @daneandersen)
|
5
|
+
* Fixed the handling of child elements becoming stale (#321)
|
6
|
+
* Performance optimization for nested elements (#321)
|
7
|
+
* Support for SVG elements (see `lib/watir-webdriver/elements/svg_elements.rb`)
|
8
|
+
* Updated selenium-webdriver to 2.46.2
|
9
|
+
|
10
|
+
### 0.7.0 (2015-03-02)
|
2
11
|
|
3
12
|
* Allow finding all elements with prefer_css
|
4
13
|
* Add support for yard-doctest (#287)
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -2,24 +2,24 @@ watir-webdriver
|
|
2
2
|
===============
|
3
3
|
|
4
4
|
Watir implementation built on WebDriver's Ruby bindings.
|
5
|
-
See https://web.archive.org/web/20140518221755/http://rubyforge.org/pipermail/wtr-development/2009-October/001313.html
|
5
|
+
See [introduction mail](https://web.archive.org/web/20140518221755/http://rubyforge.org/pipermail/wtr-development/2009-October/001313.html).
|
6
6
|
|
7
|
-
[![Gem Version](https://badge.fury.io/rb/watir-webdriver.
|
8
|
-
[![Build Status](https://travis-ci.org/watir/watir-webdriver.
|
9
|
-
[![Code Climate](https://codeclimate.com/github/watir/watir-webdriver.
|
10
|
-
[![Dependency Status](https://gemnasium.com/watir/watir-webdriver.
|
11
|
-
[![Coverage Status](https://coveralls.io/repos/watir/watir-webdriver/badge.
|
7
|
+
[![Gem Version](https://badge.fury.io/rb/watir-webdriver.svg)](http://badge.fury.io/rb/watir-webdriver)
|
8
|
+
[![Build Status](https://travis-ci.org/watir/watir-webdriver.svg?branch=master)](https://travis-ci.org/watir/watir-webdriver)
|
9
|
+
[![Code Climate](https://codeclimate.com/github/watir/watir-webdriver.svg)](https://codeclimate.com/github/watir/watir-webdriver)
|
10
|
+
[![Dependency Status](https://gemnasium.com/watir/watir-webdriver.svg)](https://gemnasium.com/watir/watir-webdriver)
|
11
|
+
[![Coverage Status](https://coveralls.io/repos/watir/watir-webdriver/badge.svg?branch=master)](https://coveralls.io/r/watir/watir-webdriver)
|
12
12
|
|
13
13
|
Example
|
14
14
|
-------
|
15
|
-
```ruby
|
16
15
|
|
16
|
+
```ruby
|
17
17
|
require 'watir-webdriver'
|
18
18
|
|
19
19
|
browser = Watir::Browser.new :firefox
|
20
20
|
browser.goto "http://google.com"
|
21
|
-
browser.text_field(:
|
22
|
-
browser.button(:
|
21
|
+
browser.text_field(name: 'q').set("WebDriver rocks!")
|
22
|
+
browser.button(name: 'btnG').click
|
23
23
|
puts browser.url
|
24
24
|
browser.close
|
25
25
|
```
|
@@ -27,29 +27,34 @@ browser.close
|
|
27
27
|
Description
|
28
28
|
-----------
|
29
29
|
|
30
|
-
The file in lib/watir/elements/
|
30
|
+
The file in `lib/watir-webdriver/elements/html_generated.rb` is autogenerated from the HTML spec. This is done by extracting the IDL parts from the spec and processing them with the WebIDL gem (link below).
|
31
|
+
|
32
|
+
The same is true for `lib/watir-webdriver/elements/svg_elements.rb`.
|
31
33
|
|
32
34
|
Specs
|
33
35
|
-----
|
34
36
|
|
35
37
|
watir-webdriver uses [watirspec](http://github.com/watir/watirspec) for testing. After cloning, you should fetch the submodule:
|
36
38
|
|
37
|
-
|
39
|
+
```bash
|
40
|
+
git submodule init && git submodule update
|
41
|
+
```
|
38
42
|
|
39
|
-
Specs specific to watir-webdriver are found in spec/*_spec.rb
|
43
|
+
Specs specific to watir-webdriver are found in `spec/*_spec.rb`, with watirspec in `spec/watirspec/`.
|
40
44
|
|
41
45
|
Doctests
|
42
46
|
--------
|
43
47
|
|
44
48
|
watir-webdriver uses [yard-doctest](https://github.com/p0deje/yard-doctest) for testing documentation examples.
|
45
49
|
|
46
|
-
|
50
|
+
```bash
|
51
|
+
rake yard:doctest
|
52
|
+
```
|
47
53
|
|
48
54
|
API docs
|
49
55
|
--------
|
50
56
|
|
51
|
-
* http://rdoc.info/gems/watir-webdriver/ (
|
52
|
-
* http://watir.github.com/watir-webdriver/doc/ (includes all attribute methods, updated occasionally)
|
57
|
+
* http://rdoc.info/gems/watir-webdriver/ (updated on every release)
|
53
58
|
|
54
59
|
See also
|
55
60
|
--------
|
@@ -57,7 +62,7 @@ See also
|
|
57
62
|
* http://watirwebdriver.com
|
58
63
|
* http://github.com/jarib/webidl
|
59
64
|
* http://github.com/watir/watirspec
|
60
|
-
*
|
65
|
+
* https://github.com/seleniumhq/selenium
|
61
66
|
|
62
67
|
Dependencies
|
63
68
|
------------
|
@@ -71,7 +76,7 @@ Note on Patches/Pull Requests
|
|
71
76
|
* Make your feature addition or bug fix.
|
72
77
|
* Add tests for it. This is important so I don't break it in a
|
73
78
|
future version unintentionally.
|
74
|
-
* Commit, do not mess with
|
79
|
+
* Commit, do not mess with Rakefile, version, or history.
|
75
80
|
(if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
|
76
81
|
* Send me a pull request. Bonus points for topic branches.
|
77
82
|
|
data/Rakefile
CHANGED
@@ -20,71 +20,72 @@ namespace :spec do
|
|
20
20
|
end
|
21
21
|
end
|
22
22
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
23
|
+
{
|
24
|
+
html: 'https://www.whatwg.org/specs/web-apps/current-work/',
|
25
|
+
svg: 'http://www.w3.org/TR/SVG2/single-page.html'
|
26
|
+
}.each do |type, spec_uri|
|
27
|
+
namespace type do
|
28
|
+
spec_path = "support/#{type}.html"
|
29
|
+
|
30
|
+
task generator_lib: :lib do
|
31
|
+
require "watir-webdriver/generator"
|
32
|
+
end
|
28
33
|
|
29
|
-
|
30
|
-
|
31
|
-
|
34
|
+
desc "Download #{type.upcase} spec from #{spec_uri}"
|
35
|
+
task :download do
|
36
|
+
require "open-uri"
|
37
|
+
mv spec_path, "#{spec_path}.old" if File.exist?(spec_path)
|
38
|
+
downloaded_bytes = 0
|
32
39
|
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
40
|
+
File.open(spec_path, "w") do |io|
|
41
|
+
io << "<!-- downloaded from #{spec_uri} on #{Time.now} -->\n"
|
42
|
+
io << data = open(spec_uri).read
|
43
|
+
downloaded_bytes = data.bytesize
|
44
|
+
end
|
38
45
|
|
39
|
-
|
40
|
-
io << "<!-- downloaded from #{SPEC_URI} on #{Time.now} -->\n"
|
41
|
-
io << data = open(SPEC_URI).read
|
42
|
-
downloaded_bytes = data.bytesize
|
46
|
+
puts "#{spec_uri} => #{spec_path} (#{downloaded_bytes} bytes)"
|
43
47
|
end
|
44
48
|
|
45
|
-
|
46
|
-
|
49
|
+
desc "Print IDL parts from #{spec_uri}"
|
50
|
+
task print: :generator_lib do
|
51
|
+
extractor = Watir::Generator.const_get("#{type.upcase}::SpecExtractor").new(spec_path)
|
47
52
|
|
48
|
-
|
49
|
-
|
50
|
-
|
53
|
+
extractor.process.each do |tag_name, interface_definitions|
|
54
|
+
puts "#{tag_name.ljust(10)} => #{interface_definitions.map(&:name)}"
|
55
|
+
end
|
51
56
|
|
52
|
-
|
53
|
-
puts "#{tag_name.ljust(10)} => #{interface_definitions.map { |e| e.name }}"
|
54
|
-
end
|
55
|
-
|
56
|
-
extractor.print_hierarchy
|
57
|
+
extractor.print_hierarchy
|
57
58
|
|
58
|
-
|
59
|
-
|
60
|
-
|
59
|
+
if extractor.errors.any?
|
60
|
+
puts "\n\n<======================= ERRORS =======================>\n\n"
|
61
|
+
puts extractor.errors.join("\n" + "=" * 80 + "\n")
|
62
|
+
end
|
61
63
|
end
|
62
|
-
end
|
63
64
|
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
65
|
+
desc 'Re-generate the base Watir element classes from the spec'
|
66
|
+
task generate: :generator_lib do
|
67
|
+
old_file = "lib/watir-webdriver/elements/#{type}_elements.rb"
|
68
|
+
generator = Watir::Generator.const_get(type.upcase).new
|
68
69
|
|
69
|
-
|
70
|
-
|
70
|
+
File.open("#{old_file}.new", "w") do |file|
|
71
|
+
generator.generate(spec_path, file)
|
72
|
+
end
|
73
|
+
|
74
|
+
if File.exist?(old_file)
|
75
|
+
system "diff -Naut #{old_file} #{old_file}.new | less"
|
76
|
+
end
|
71
77
|
end
|
72
78
|
|
73
|
-
|
74
|
-
|
79
|
+
desc "Move #{type}.rb.new to #{type}.rb"
|
80
|
+
task :overwrite do
|
81
|
+
file = "lib/watir-webdriver/elements/#{type}_elements.rb"
|
82
|
+
mv "#{file}.new", file
|
75
83
|
end
|
76
|
-
end
|
77
84
|
|
78
|
-
|
79
|
-
|
80
|
-
file = "lib/watir-webdriver/elements/generated.rb"
|
81
|
-
mv "#{file}.new", file
|
85
|
+
desc "download spec -> generate -> #{type}.rb"
|
86
|
+
task update: [:download, :generate, :overwrite]
|
82
87
|
end
|
83
|
-
|
84
|
-
desc 'download spec -> generate -> generated.rb'
|
85
|
-
task :update => [:download, :generate, :overwrite]
|
86
|
-
end # html5
|
87
|
-
|
88
|
+
end
|
88
89
|
|
89
90
|
require 'yard'
|
90
91
|
YARD::Rake::YardocTask.new do |task|
|
@@ -102,19 +103,21 @@ namespace :changes do
|
|
102
103
|
end
|
103
104
|
|
104
105
|
desc 'Update CHANGES.md'
|
105
|
-
task :
|
106
|
+
task update: :differ do
|
106
107
|
VersionDiffer.new.update('CHANGES.md')
|
107
108
|
end
|
108
109
|
|
109
110
|
desc 'Generate CHANGES.md from scratch'
|
110
|
-
task :
|
111
|
+
task generate: :differ do
|
111
112
|
VersionDiffer.new.generate('CHANGES.md')
|
112
113
|
end
|
113
114
|
|
114
115
|
desc 'Print latest diff'
|
115
|
-
task :
|
116
|
+
task print: :differ do
|
116
117
|
VersionDiffer.new.print_latest(STDOUT)
|
117
118
|
end
|
118
119
|
end
|
119
120
|
|
120
121
|
load "spec/watirspec/watirspec.rake" if File.exist?("spec/watirspec/watirspec.rake")
|
122
|
+
|
123
|
+
task default: [:spec, 'yard:doctest']
|
data/lib/watir-webdriver.rb
CHANGED
@@ -1,4 +1,3 @@
|
|
1
|
-
# encoding: utf-8
|
2
1
|
require 'selenium-webdriver'
|
3
2
|
|
4
3
|
require 'watir-webdriver/version'
|
@@ -87,7 +86,9 @@ require 'watir-webdriver/cell_container'
|
|
87
86
|
require 'watir-webdriver/user_editable'
|
88
87
|
require 'watir-webdriver/element_collection'
|
89
88
|
require 'watir-webdriver/elements/element'
|
90
|
-
|
89
|
+
|
90
|
+
require 'watir-webdriver/elements/html_elements'
|
91
|
+
require 'watir-webdriver/elements/svg_elements'
|
91
92
|
|
92
93
|
require 'watir-webdriver/elements/area'
|
93
94
|
require 'watir-webdriver/elements/button'
|
@@ -1,4 +1,3 @@
|
|
1
|
-
# encoding: utf-8
|
2
1
|
module Watir
|
3
2
|
|
4
3
|
#
|
@@ -42,7 +41,7 @@ module Watir
|
|
42
41
|
|
43
42
|
def initialize(browser = :firefox, *args)
|
44
43
|
case browser
|
45
|
-
when Symbol, String
|
44
|
+
when ::Symbol, String
|
46
45
|
@driver = Selenium::WebDriver.for browser.to_sym, *args
|
47
46
|
when Selenium::WebDriver::Driver
|
48
47
|
@driver = browser
|
@@ -343,7 +342,7 @@ module Watir
|
|
343
342
|
#
|
344
343
|
# @example
|
345
344
|
# browser.without_checkers do
|
346
|
-
# browser.element(:
|
345
|
+
# browser.element(name: "new_user_button").click
|
347
346
|
# end
|
348
347
|
#
|
349
348
|
# @yieldparam [Watir::Browser]
|
@@ -387,7 +386,7 @@ module Watir
|
|
387
386
|
true
|
388
387
|
end
|
389
388
|
end
|
390
|
-
alias_method :
|
389
|
+
alias_method :ensure_not_stale, :assert_exists
|
391
390
|
|
392
391
|
def reset!
|
393
392
|
# no-op
|
@@ -415,7 +414,7 @@ module Watir
|
|
415
414
|
end
|
416
415
|
|
417
416
|
def wrap_element(element)
|
418
|
-
Watir.element_class_for(element.tag_name.downcase).new(self, :
|
417
|
+
Watir.element_class_for(element.tag_name.downcase).new(self, element: element)
|
419
418
|
end
|
420
419
|
|
421
420
|
end # Browser
|
@@ -8,7 +8,7 @@ module Watir
|
|
8
8
|
#
|
9
9
|
|
10
10
|
def cell(*args)
|
11
|
-
cell = TableCell.new(self, extract_selector(args).merge(:
|
11
|
+
cell = TableCell.new(self, extract_selector(args).merge(tag_name: /^(th|td)$/))
|
12
12
|
cell.locator_class = ChildCellLocator
|
13
13
|
|
14
14
|
cell
|
@@ -21,7 +21,7 @@ module Watir
|
|
21
21
|
#
|
22
22
|
|
23
23
|
def cells(*args)
|
24
|
-
cells = TableCellCollection.new(self, extract_selector(args).merge(:
|
24
|
+
cells = TableCellCollection.new(self, extract_selector(args).merge(tag_name: /^(th|td)$/))
|
25
25
|
cells.locator_class = ChildCellLocator
|
26
26
|
|
27
27
|
cells
|
@@ -1,4 +1,3 @@
|
|
1
|
-
# encoding: utf-8
|
2
1
|
module Watir
|
3
2
|
module Container
|
4
3
|
include XpathSupport
|
@@ -8,7 +7,7 @@ module Watir
|
|
8
7
|
# Returns element.
|
9
8
|
#
|
10
9
|
# @example
|
11
|
-
# browser.element(:
|
10
|
+
# browser.element(data_bind: 'func')
|
12
11
|
#
|
13
12
|
# @return [HTMLElement]
|
14
13
|
#
|
@@ -21,7 +20,7 @@ module Watir
|
|
21
20
|
# Returns element collection.
|
22
21
|
#
|
23
22
|
# @example
|
24
|
-
# browser.elements(:
|
23
|
+
# browser.elements(data_bind: 'func')
|
25
24
|
#
|
26
25
|
# @return [HTMLElementCollection]
|
27
26
|
#
|
@@ -19,7 +19,7 @@ module Watir
|
|
19
19
|
|
20
20
|
def to_a
|
21
21
|
@control.all_cookies.map do |e|
|
22
|
-
e.merge(:
|
22
|
+
e.merge(expires: e[:expires] ? to_time(e[:expires]) : nil)
|
23
23
|
end
|
24
24
|
end
|
25
25
|
|
@@ -42,7 +42,7 @@ module Watir
|
|
42
42
|
# Adds new cookie.
|
43
43
|
#
|
44
44
|
# @example
|
45
|
-
# browser.cookies.add 'my_session', 'BAh7B0kiD3Nlc3Npb25faWQGOgZFRkk', :
|
45
|
+
# browser.cookies.add 'my_session', 'BAh7B0kiD3Nlc3Npb25faWQGOgZFRkk', secure: true
|
46
46
|
#
|
47
47
|
# @param [String] name
|
48
48
|
# @param [String] value
|
@@ -55,12 +55,12 @@ module Watir
|
|
55
55
|
|
56
56
|
def add(name, value, opts = {})
|
57
57
|
cookie = {
|
58
|
-
:
|
59
|
-
:
|
60
|
-
:
|
61
|
-
:
|
62
|
-
:
|
63
|
-
:
|
58
|
+
name: name,
|
59
|
+
value: value,
|
60
|
+
secure: opts[:secure],
|
61
|
+
path: opts[:path],
|
62
|
+
expires: opts[:expires],
|
63
|
+
domain: opts[:domain]
|
64
64
|
}
|
65
65
|
|
66
66
|
@control.add_cookie cookie
|