watir-webdriver 0.4.1 → 0.5.0
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.
- data/.gitignore +2 -1
- data/.gitmodules +1 -1
- data/.travis.yml +2 -2
- data/LICENSE +1 -1
- data/README.md +4 -4
- data/Rakefile +7 -15
- data/lib/watir-webdriver.rb +13 -8
- data/lib/watir-webdriver/aliases.rb +6 -0
- data/lib/watir-webdriver/elements/element.rb +120 -10
- data/lib/watir-webdriver/elements/generated.rb +42 -12
- data/lib/watir-webdriver/elements/image.rb +8 -1
- data/lib/watir-webdriver/elements/option.rb +4 -0
- data/lib/watir-webdriver/elements/select.rb +2 -2
- data/lib/watir-webdriver/elements/text_area.rb +5 -0
- data/lib/watir-webdriver/elements/text_field.rb +3 -36
- data/lib/watir-webdriver/html/spec_extractor.rb +8 -1
- data/lib/watir-webdriver/locators/element_locator.rb +9 -3
- data/lib/watir-webdriver/locators/text_field_locator.rb +5 -0
- data/lib/watir-webdriver/user_editable.rb +37 -0
- data/lib/watir-webdriver/version.rb +1 -1
- data/lib/watir-webdriver/wait.rb +4 -0
- data/lib/yard/handlers/watir.rb +2 -4
- data/spec/click_spec.rb +36 -0
- data/spec/element_locator_spec.rb +23 -23
- data/spec/element_spec.rb +14 -1
- data/spec/html/clicks.html +16 -0
- data/spec/html/hover.html +12 -0
- data/spec/implementation.rb +82 -16
- data/spec/spec_helper.rb +5 -0
- data/spec/wait_spec.rb +12 -4
- data/support/html5.html +32579 -36525
- data/support/travis.sh +6 -7
- data/watir-webdriver.gemspec +11 -1
- metadata +27 -10
data/.gitignore
CHANGED
data/.gitmodules
CHANGED
data/.travis.yml
CHANGED
@@ -10,7 +10,7 @@ before_script:
|
|
10
10
|
env:
|
11
11
|
- WATIR_WEBDRIVER_BROWSER=firefox
|
12
12
|
- WATIR_WEBDRIVER_BROWSER=firefox ALWAYS_LOCATE=false
|
13
|
-
# - WATIR_WEBDRIVER_BROWSER=chrome
|
14
|
-
# - WATIR_WEBDRIVER_BROWSER=chrome ALWAYS_LOCATE=false
|
15
13
|
# - WATIR_WEBDRIVER_BROWSER=firefox NATIVE_EVENTS=true
|
14
|
+
- WATIR_WEBDRIVER_BROWSER=chrome
|
15
|
+
- WATIR_WEBDRIVER_BROWSER=chrome ALWAYS_LOCATE=false
|
16
16
|
# - WATIR_WEBDRIVER_BROWSER=chrome NATIVE_EVENTS=true
|
data/LICENSE
CHANGED
data/README.md
CHANGED
@@ -4,7 +4,7 @@ watir-webdriver
|
|
4
4
|
Watir implementation built on WebDriver's Ruby bindings.
|
5
5
|
See http://rubyforge.org/pipermail/wtr-development/2009-October/001313.html.
|
6
6
|
|
7
|
-
[](http://travis-ci.org/watir/watir-webdriver)
|
8
8
|
|
9
9
|
API docs
|
10
10
|
--------
|
@@ -33,7 +33,7 @@ The file in lib/watir/elements/generated.rb is autogenerated from the HTML5 spec
|
|
33
33
|
Specs
|
34
34
|
-----
|
35
35
|
|
36
|
-
watir-webdriver uses [watirspec](http://github.com/
|
36
|
+
watir-webdriver uses [watirspec](http://github.com/watir/watirspec) for testing. After cloning, you should fetch the submodule:
|
37
37
|
|
38
38
|
git submodule init && git submodule update
|
39
39
|
|
@@ -43,7 +43,7 @@ See also
|
|
43
43
|
--------
|
44
44
|
|
45
45
|
* http://github.com/jarib/webidl
|
46
|
-
* http://github.com/
|
46
|
+
* http://github.com/watir/watirspec
|
47
47
|
* http://selenium.googlecode.com
|
48
48
|
|
49
49
|
Dependencies
|
@@ -65,4 +65,4 @@ Note on Patches/Pull Requests
|
|
65
65
|
Copyright
|
66
66
|
---------
|
67
67
|
|
68
|
-
Copyright (c) 2009-
|
68
|
+
Copyright (c) 2009-2012 Jari Bakken. See LICENSE for details.
|
data/Rakefile
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
$LOAD_PATH.unshift File.expand_path("../lib", __FILE__)
|
2
|
+
|
1
3
|
require 'rubygems'
|
2
4
|
require 'bundler'
|
3
5
|
Bundler::GemHelper.install_tasks
|
@@ -19,10 +21,6 @@ end
|
|
19
21
|
|
20
22
|
task :default => :spec
|
21
23
|
|
22
|
-
task :lib do
|
23
|
-
$LOAD_PATH.unshift(File.expand_path("lib", File.dirname(__FILE__)))
|
24
|
-
end
|
25
|
-
|
26
24
|
namespace :html5 do
|
27
25
|
SPEC_URI = "http://www.whatwg.org/specs/web-apps/current-work/"
|
28
26
|
SPEC_PATH = "support/html5.html"
|
@@ -86,17 +84,11 @@ namespace :html5 do
|
|
86
84
|
task :update => [:download, :generate, :overwrite]
|
87
85
|
end # html5
|
88
86
|
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
task.options = %w[--debug] # this is pretty slow, so nice with some output
|
95
|
-
end
|
96
|
-
rescue LoadError
|
97
|
-
task :yard do
|
98
|
-
abort "YARD is not available. In order to run yardoc, you must: sudo gem install yard"
|
99
|
-
end
|
87
|
+
|
88
|
+
require 'yard'
|
89
|
+
require "yard/handlers/watir"
|
90
|
+
YARD::Rake::YardocTask.new do |task|
|
91
|
+
task.options = %w[--debug] # this is pretty slow, so nice with some output
|
100
92
|
end
|
101
93
|
|
102
94
|
load "spec/watirspec/watirspec.rake" if File.exist?("spec/watirspec/watirspec.rake")
|
data/lib/watir-webdriver.rb
CHANGED
@@ -57,26 +57,31 @@ end
|
|
57
57
|
require 'watir-webdriver/attribute_helper'
|
58
58
|
require 'watir-webdriver/row_container'
|
59
59
|
require 'watir-webdriver/cell_container'
|
60
|
+
require 'watir-webdriver/user_editable'
|
60
61
|
require 'watir-webdriver/element_collection'
|
61
62
|
require 'watir-webdriver/elements/element'
|
62
63
|
require 'watir-webdriver/elements/generated'
|
63
|
-
|
64
|
-
require 'watir-webdriver/elements/input'
|
64
|
+
|
65
65
|
require 'watir-webdriver/elements/button'
|
66
66
|
require 'watir-webdriver/elements/checkbox'
|
67
67
|
require 'watir-webdriver/elements/file_field'
|
68
|
+
require 'watir-webdriver/elements/font'
|
69
|
+
require 'watir-webdriver/elements/form'
|
70
|
+
require 'watir-webdriver/elements/frame'
|
71
|
+
require 'watir-webdriver/elements/hidden'
|
68
72
|
require 'watir-webdriver/elements/image'
|
73
|
+
require 'watir-webdriver/elements/input'
|
69
74
|
require 'watir-webdriver/elements/link'
|
70
|
-
require 'watir-webdriver/elements/
|
75
|
+
require 'watir-webdriver/elements/option'
|
71
76
|
require 'watir-webdriver/elements/radio'
|
72
|
-
require 'watir-webdriver/elements/text_field'
|
73
|
-
require 'watir-webdriver/elements/hidden'
|
74
77
|
require 'watir-webdriver/elements/select'
|
75
|
-
require 'watir-webdriver/elements/form'
|
76
|
-
require 'watir-webdriver/elements/option'
|
77
78
|
require 'watir-webdriver/elements/table'
|
78
|
-
require 'watir-webdriver/elements/table_row'
|
79
79
|
require 'watir-webdriver/elements/table_cell'
|
80
|
+
require 'watir-webdriver/elements/table_row'
|
80
81
|
require 'watir-webdriver/elements/table_section'
|
82
|
+
require 'watir-webdriver/elements/text_area'
|
83
|
+
require 'watir-webdriver/elements/text_field'
|
84
|
+
|
85
|
+
require 'watir-webdriver/aliases'
|
81
86
|
|
82
87
|
Watir.tag_to_class.freeze
|
@@ -70,35 +70,128 @@ module Watir
|
|
70
70
|
@element.tag_name.downcase
|
71
71
|
end
|
72
72
|
|
73
|
-
|
73
|
+
#
|
74
|
+
# Clicks the element, optionally while pressing the given mofifier keys.
|
75
|
+
# Note that support for holding a modifier key is currently experimental,
|
76
|
+
# and may not work at all.
|
77
|
+
#
|
78
|
+
# @example Click an element
|
79
|
+
#
|
80
|
+
# element.click
|
81
|
+
#
|
82
|
+
# @example Click an element with shift key pressed
|
83
|
+
#
|
84
|
+
# element.click(:shift)
|
85
|
+
#
|
86
|
+
# @example Click an element with several modifier keys pressed
|
87
|
+
#
|
88
|
+
# element.click(:shift, :control)
|
89
|
+
#
|
90
|
+
# @param [:shift, :alt, :control, :command, :meta] Modifier key(s) to press while clicking.
|
91
|
+
#
|
92
|
+
|
93
|
+
def click(*modifiers)
|
74
94
|
assert_exists
|
75
95
|
assert_enabled
|
76
|
-
|
96
|
+
|
97
|
+
if modifiers.any?
|
98
|
+
assert_has_input_devices_for "click(#{modifiers.join ', '})"
|
99
|
+
|
100
|
+
action = driver.action
|
101
|
+
modifiers.each { |mod| action.key_down mod }
|
102
|
+
action.click @element
|
103
|
+
modifiers.each { |mod| action.key_up mod }
|
104
|
+
|
105
|
+
action.perform
|
106
|
+
else
|
107
|
+
@element.click
|
108
|
+
end
|
109
|
+
|
77
110
|
run_checkers
|
78
111
|
end
|
79
112
|
|
113
|
+
#
|
114
|
+
# Double clicks the element.
|
115
|
+
#
|
116
|
+
# Note that browser support may vary.
|
117
|
+
#
|
118
|
+
|
119
|
+
|
80
120
|
def double_click
|
81
121
|
assert_exists
|
82
|
-
|
83
|
-
unless driver.kind_of? WebDriver::DriverExtensions::HasInputDevices
|
84
|
-
raise NotImplementedError, "Element#double_click is not supported by this driver"
|
85
|
-
end
|
122
|
+
assert_has_input_devices_for :double_click
|
86
123
|
|
87
124
|
driver.action.double_click(@element).perform
|
88
125
|
run_checkers
|
89
126
|
end
|
90
127
|
|
128
|
+
#
|
129
|
+
# Right clicks the element.
|
130
|
+
#
|
131
|
+
# Note that browser support may vary.
|
132
|
+
#
|
133
|
+
|
91
134
|
def right_click
|
92
135
|
assert_exists
|
93
|
-
|
94
|
-
unless driver.kind_of? WebDriver::DriverExtensions::HasInputDevices
|
95
|
-
raise NotImplementedError, "Element#context_click is not supported by this driver"
|
96
|
-
end
|
136
|
+
assert_has_input_devices_for :right_click
|
97
137
|
|
98
138
|
driver.action.context_click(@element).perform
|
99
139
|
run_checkers
|
100
140
|
end
|
101
141
|
|
142
|
+
#
|
143
|
+
# Moves the mouse to the middle of this element.
|
144
|
+
#
|
145
|
+
# Note that browser/platform support may vary.
|
146
|
+
#
|
147
|
+
|
148
|
+
def hover
|
149
|
+
assert_exists
|
150
|
+
assert_has_input_devices_for :hover
|
151
|
+
|
152
|
+
driver.action.move_to(@element).perform
|
153
|
+
end
|
154
|
+
|
155
|
+
#
|
156
|
+
# Drag and drop this element on to another element instance.
|
157
|
+
#
|
158
|
+
# Example:
|
159
|
+
#
|
160
|
+
# a = browser.div(:id => "draggable")
|
161
|
+
# b = browser.div(:id => "droppable")
|
162
|
+
#
|
163
|
+
# a.drag_and_drop_on b
|
164
|
+
#
|
165
|
+
|
166
|
+
def drag_and_drop_on(other)
|
167
|
+
assert_is_element other
|
168
|
+
assert_exists
|
169
|
+
assert_has_input_devices_for :drag_and_drop_on
|
170
|
+
|
171
|
+
driver.action.
|
172
|
+
drag_and_drop(@element, other.wd).
|
173
|
+
perform
|
174
|
+
end
|
175
|
+
|
176
|
+
#
|
177
|
+
# Drag and drop this element by the given offsets.
|
178
|
+
#
|
179
|
+
# Example:
|
180
|
+
#
|
181
|
+
# a = browser.div(:id => "draggable")
|
182
|
+
#
|
183
|
+
# a.drag_and_drop_by 100, -200
|
184
|
+
#
|
185
|
+
|
186
|
+
def drag_and_drop_by(right_by, down_by)
|
187
|
+
assert_exists
|
188
|
+
assert_has_input_devices_for :drag_and_drop_by
|
189
|
+
|
190
|
+
driver.action.
|
191
|
+
drag_and_drop_by(@element, right_by, down_by).
|
192
|
+
perform
|
193
|
+
end
|
194
|
+
|
102
195
|
def flash
|
103
196
|
original_color = style("backgroundColor")
|
104
197
|
|
@@ -144,6 +237,11 @@ module Watir
|
|
144
237
|
driver.execute_script "return arguments[0].focus()", @element
|
145
238
|
end
|
146
239
|
|
240
|
+
def focused?
|
241
|
+
assert_exists
|
242
|
+
@element == driver.switch_to.active_element
|
243
|
+
end
|
244
|
+
|
147
245
|
def fire_event(event_name)
|
148
246
|
assert_exists
|
149
247
|
event_name = event_name.to_s.sub(/^on/, '').downcase
|
@@ -309,6 +407,18 @@ module Watir
|
|
309
407
|
raise ObjectReadOnlyException if respond_to?(:readonly?) && readonly?
|
310
408
|
end
|
311
409
|
|
410
|
+
def assert_has_input_devices_for(name)
|
411
|
+
unless driver.kind_of? WebDriver::DriverExtensions::HasInputDevices
|
412
|
+
raise NotImplementedError, "#{self.class}##{name} is not supported by this driver"
|
413
|
+
end
|
414
|
+
end
|
415
|
+
|
416
|
+
def assert_is_element(obj)
|
417
|
+
unless obj.kind_of? Watir::Element
|
418
|
+
raise TypeError, "execpted Watir::Element, got #{obj.inspect}:#{obj.class}"
|
419
|
+
end
|
420
|
+
end
|
421
|
+
|
312
422
|
def method_missing(meth, *args, &blk)
|
313
423
|
method = meth.to_s
|
314
424
|
if method =~ /^data_(.+)$/
|
@@ -49,18 +49,6 @@ module Watir
|
|
49
49
|
|
50
50
|
|
51
51
|
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
52
|
|
65
53
|
|
66
54
|
|
@@ -538,6 +526,14 @@ module Watir
|
|
538
526
|
Span
|
539
527
|
end
|
540
528
|
end
|
529
|
+
class Time < HTMLElement
|
530
|
+
attributes(:string => [:datetime])
|
531
|
+
end
|
532
|
+
class TimeCollection < ElementCollection
|
533
|
+
def element_class
|
534
|
+
Time
|
535
|
+
end
|
536
|
+
end
|
541
537
|
class Data < HTMLElement
|
542
538
|
attributes(:string => [:value])
|
543
539
|
end
|
@@ -1422,6 +1418,23 @@ module Watir
|
|
1422
1418
|
|
1423
1419
|
Watir.tag_to_class[:form] = Form
|
1424
1420
|
#
|
1421
|
+
# @return [FrameSet]
|
1422
|
+
#
|
1423
|
+
|
1424
|
+
def frameset(*args)
|
1425
|
+
FrameSet.new(self, extract_selector(args).merge(:tag_name => "frameset"))
|
1426
|
+
end
|
1427
|
+
|
1428
|
+
#
|
1429
|
+
# @return [FrameSetCollection]
|
1430
|
+
#
|
1431
|
+
|
1432
|
+
def framesets(*args)
|
1433
|
+
FrameSetCollection.new(self, extract_selector(args).merge(:tag_name => "frameset"))
|
1434
|
+
end
|
1435
|
+
|
1436
|
+
Watir.tag_to_class[:frameset] = FrameSet
|
1437
|
+
#
|
1425
1438
|
# @return [Heading]
|
1426
1439
|
#
|
1427
1440
|
|
@@ -2459,6 +2472,23 @@ module Watir
|
|
2459
2472
|
|
2460
2473
|
Watir.tag_to_class[:thead] = TableSection
|
2461
2474
|
#
|
2475
|
+
# @return [Time]
|
2476
|
+
#
|
2477
|
+
|
2478
|
+
def time(*args)
|
2479
|
+
Time.new(self, extract_selector(args).merge(:tag_name => "time"))
|
2480
|
+
end
|
2481
|
+
|
2482
|
+
#
|
2483
|
+
# @return [TimeCollection]
|
2484
|
+
#
|
2485
|
+
|
2486
|
+
def times(*args)
|
2487
|
+
TimeCollection.new(self, extract_selector(args).merge(:tag_name => "time"))
|
2488
|
+
end
|
2489
|
+
|
2490
|
+
Watir.tag_to_class[:time] = Time
|
2491
|
+
#
|
2462
2492
|
# @return [Title]
|
2463
2493
|
#
|
2464
2494
|
|
@@ -2,7 +2,14 @@
|
|
2
2
|
module Watir
|
3
3
|
class Image < HTMLElement
|
4
4
|
|
5
|
-
|
5
|
+
def loaded?
|
6
|
+
return false unless complete?
|
7
|
+
|
8
|
+
driver.execute_script(
|
9
|
+
'return typeof arguments[0].naturalWidth != "undefined" && arguments[0].naturalWidth > 0',
|
10
|
+
@element
|
11
|
+
)
|
12
|
+
end
|
6
13
|
|
7
14
|
#
|
8
15
|
# returns the image's width in pixels
|
@@ -111,12 +111,12 @@ module Watir
|
|
111
111
|
|
112
112
|
|
113
113
|
#
|
114
|
-
# @return [Array<
|
114
|
+
# @return [Array<Watir::Option>] An array of Watir::Option elements that are currently selected.
|
115
115
|
#
|
116
116
|
|
117
117
|
def selected_options
|
118
118
|
assert_exists
|
119
|
-
options.
|
119
|
+
options.select { |e| e.selected? }
|
120
120
|
end
|
121
121
|
|
122
122
|
private
|