watir 1.8.0 → 1.8.1.rc1
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGES +17 -0
- data/VERSION +1 -1
- data/lib/watir/collections.rb +17 -0
- data/lib/watir/container.rb +24 -0
- data/lib/watir/core.rb +1 -1
- data/lib/watir/element.rb +37 -11
- data/lib/watir/form.rb +37 -89
- data/lib/watir/frame.rb +25 -36
- data/lib/watir/ie-class.rb +7 -8
- data/lib/watir/locator.rb +59 -41
- data/lib/watir/non_control_elements.rb +3 -3
- data/unittests/click_no_wait_test.rb +1 -1
- data/unittests/form_test.rb +20 -1
- data/unittests/frame_test.rb +34 -11
- data/unittests/no_wait_test.rb +22 -0
- data/unittests/setup.rb +2 -2
- metadata +21 -15
data/CHANGES
CHANGED
@@ -1,3 +1,20 @@
|
|
1
|
+
== Version 1.8.1 - 2011/04/07
|
2
|
+
|
3
|
+
=== IE improvements
|
4
|
+
|
5
|
+
* Added #frames method (Ivan Kabluchkov).
|
6
|
+
* Added Frame#exists?, #src, #name and other Element methods (Ivan Kabluchkov).
|
7
|
+
* Added multiple locators support for #frame method (Ivan Kabluchkov).
|
8
|
+
* Added *_no_wait methods (Ivan Kabluchkov).
|
9
|
+
|
10
|
+
=== Firefox improvements
|
11
|
+
|
12
|
+
* Nothing
|
13
|
+
|
14
|
+
=== General improvements
|
15
|
+
|
16
|
+
* Using Watir::Util for better compatibility with ActiveSupport used by Rails 3. Closes http://jira.openqa.org/browse/WTR-474 (Jarmo Pertman)
|
17
|
+
|
1
18
|
== Version 1.8.0 - 2011/28/02
|
2
19
|
|
3
20
|
=== IE improvements
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.8.
|
1
|
+
1.8.1.rc1
|
data/lib/watir/collections.rb
CHANGED
@@ -355,6 +355,23 @@ module Watir
|
|
355
355
|
def element_class; Em; end
|
356
356
|
def element_tag; Em::TAG; end
|
357
357
|
end
|
358
|
+
|
359
|
+
class Frames < ElementCollections
|
360
|
+
def element_class; Frame; end
|
361
|
+
|
362
|
+
def length
|
363
|
+
@container.document.getElementsByTagName("FRAME").length +
|
364
|
+
@container.document.getElementsByTagName("IFRAME").length
|
365
|
+
end
|
366
|
+
end
|
367
|
+
|
368
|
+
class Forms < ElementCollections
|
369
|
+
def element_class; Form; end
|
370
|
+
def element_tag; 'FORM'; end
|
371
|
+
def length
|
372
|
+
@container.document.getElementsByTagName("FORM").length
|
373
|
+
end
|
374
|
+
end
|
358
375
|
|
359
376
|
class HTMLElements < ElementCollections
|
360
377
|
include CommonCollection
|
data/lib/watir/container.rb
CHANGED
@@ -103,6 +103,18 @@ module Watir
|
|
103
103
|
how, what = process_default :name, how, what
|
104
104
|
Frame.new(self, how, what)
|
105
105
|
end
|
106
|
+
|
107
|
+
# this is the main method for accessing the frames iterator. Returns a Frames collection
|
108
|
+
#
|
109
|
+
# Typical usage:
|
110
|
+
#
|
111
|
+
# browser.frames.each { |f| puts f.src } # iterate through all the frames on the page
|
112
|
+
# browser.frames[1].to_s # goto the first frame on the page
|
113
|
+
# browser.frames.length # show how many frames are on the page.
|
114
|
+
#
|
115
|
+
def frames
|
116
|
+
Frames.new(self)
|
117
|
+
end
|
106
118
|
|
107
119
|
# this method is used to access a form.
|
108
120
|
# available ways of accessing it are, :index, :name, :id, :method, :action, :xpath
|
@@ -118,6 +130,18 @@ module Watir
|
|
118
130
|
Form.new(self, how, what)
|
119
131
|
end
|
120
132
|
|
133
|
+
# this is the main method for accessing the forms iterator. Returns a Forms collection
|
134
|
+
#
|
135
|
+
# Typical usage:
|
136
|
+
#
|
137
|
+
# browser.forms.each { |f| puts f.src } # iterate through all the forms on the page
|
138
|
+
# browser.forms[1].to_s # goto the first form on the page
|
139
|
+
# browser.forms.length # show how many forms are on the page.
|
140
|
+
#
|
141
|
+
def forms
|
142
|
+
Forms.new(self)
|
143
|
+
end
|
144
|
+
|
121
145
|
# This method is used to get a table from the page.
|
122
146
|
# :index (1 based counting) and :id are supported.
|
123
147
|
# NOTE :name is not supported, as the table tag does not have a name attribute. It is not part of the DOM.
|
data/lib/watir/core.rb
CHANGED
data/lib/watir/element.rb
CHANGED
@@ -231,31 +231,45 @@ module Watir
|
|
231
231
|
@container.wait
|
232
232
|
end
|
233
233
|
|
234
|
-
def
|
235
|
-
|
236
|
-
|
237
|
-
|
234
|
+
def replace_method(method)
|
235
|
+
method == 'click' ? 'click!' : method
|
236
|
+
end
|
237
|
+
private :replace_method
|
238
|
+
|
239
|
+
def build_method(method_name, *args)
|
240
|
+
arguments = args.map do |argument|
|
241
|
+
if argument.is_a?(String)
|
242
|
+
argument = "'#{argument}'"
|
243
|
+
else
|
244
|
+
argument = argument.inspect
|
245
|
+
end
|
246
|
+
end
|
247
|
+
"#{replace_method(method_name)}(#{arguments.join(',')})"
|
248
|
+
end
|
249
|
+
private :build_method
|
250
|
+
|
251
|
+
def generate_ruby_code(element, method_name, *args)
|
238
252
|
element = "#{self.class}.new(#{@page_container.attach_command}, :unique_number, #{self.unique_number})"
|
239
|
-
|
253
|
+
method = build_method(method_name, *args)
|
240
254
|
ruby_code = "$:.unshift(#{$LOAD_PATH.grep(%r{watir(-.*?)?/lib}).map {|p| "'#{p}'" }.join(").unshift(")});" <<
|
241
|
-
"require '#{File.expand_path(File.dirname(__FILE__))}/core';#{element}
|
242
|
-
|
243
|
-
highlight(:clear)
|
255
|
+
"require '#{File.expand_path(File.dirname(__FILE__))}/core';#{element}.#{method};"
|
256
|
+
return ruby_code
|
244
257
|
end
|
258
|
+
private :generate_ruby_code
|
245
259
|
|
246
|
-
def
|
260
|
+
def spawned_no_wait_command(command)
|
247
261
|
command = "-e #{command.inspect}"
|
248
262
|
unless $DEBUG
|
249
263
|
"start rubyw #{command}"
|
250
264
|
else
|
251
|
-
puts "#
|
265
|
+
puts "#no_wait command:"
|
252
266
|
command = "ruby #{command}"
|
253
267
|
puts command
|
254
268
|
command
|
255
269
|
end
|
256
270
|
end
|
257
271
|
|
258
|
-
private :
|
272
|
+
private :spawned_no_wait_command
|
259
273
|
|
260
274
|
def click!
|
261
275
|
assert_exists
|
@@ -352,6 +366,18 @@ module Watir
|
|
352
366
|
return ole_object.getAttribute(attribute_name)
|
353
367
|
end
|
354
368
|
|
369
|
+
def method_missing(method_name, *args, &block)
|
370
|
+
if method_name.to_s =~ /(.*)_no_wait/ && self.respond_to?($1)
|
371
|
+
assert_exists
|
372
|
+
assert_enabled
|
373
|
+
highlight(:set)
|
374
|
+
ruby_code = generate_ruby_code(self, $1, *args)
|
375
|
+
system(spawned_no_wait_command(ruby_code))
|
376
|
+
highlight(:clear)
|
377
|
+
else
|
378
|
+
super
|
379
|
+
end
|
380
|
+
end
|
355
381
|
end
|
356
382
|
|
357
383
|
class ElementMapper # Still to be used
|
data/lib/watir/form.rb
CHANGED
@@ -1,37 +1,35 @@
|
|
1
1
|
module Watir
|
2
2
|
|
3
3
|
# Forms
|
4
|
-
|
5
|
-
|
4
|
+
|
5
|
+
class FormElement < Element
|
6
|
+
def_wrap_guard :action
|
7
|
+
|
6
8
|
def name
|
7
|
-
|
8
|
-
|
9
|
-
def action
|
10
|
-
@ole_object.action
|
11
|
-
end
|
12
|
-
def method
|
13
|
-
@ole_object.invoke('method')
|
9
|
+
assert_exists
|
10
|
+
@o.getAttributeNode('name').value
|
14
11
|
end
|
15
|
-
|
16
|
-
|
12
|
+
|
13
|
+
def form_method
|
14
|
+
assert_exists
|
15
|
+
@o.invoke('method')
|
17
16
|
end
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
17
|
+
|
18
|
+
def method(arg = nil)
|
19
|
+
if arg.nil?
|
20
|
+
form_method
|
21
|
+
else
|
22
|
+
super(arg)
|
23
|
+
end
|
25
24
|
end
|
26
25
|
end
|
27
26
|
|
28
27
|
# Form Factory object
|
29
|
-
class Form <
|
30
|
-
include FormAccess
|
28
|
+
class Form < FormElement
|
31
29
|
include Container
|
32
30
|
|
33
|
-
attr_accessor :form
|
34
|
-
|
31
|
+
attr_accessor :form
|
32
|
+
|
35
33
|
# * container - the containing object, normally an instance of IE
|
36
34
|
# * how - symbol - how we access the form (:name, :id, :index, :action, :method)
|
37
35
|
# * what - what we use to access the form
|
@@ -39,76 +37,41 @@ module Watir
|
|
39
37
|
set_container container
|
40
38
|
@how = how
|
41
39
|
@what = what
|
42
|
-
|
40
|
+
copy_test_config container
|
41
|
+
end
|
42
|
+
|
43
|
+
def locate
|
43
44
|
log "Get form how is #{@how} what is #{@what} "
|
44
|
-
|
45
|
+
|
45
46
|
# Get form using xpath.
|
46
47
|
if @how == :xpath
|
47
|
-
@
|
48
|
+
@o = @container.element_by_xpath(@what)
|
48
49
|
elsif @how == :css
|
49
|
-
@
|
50
|
+
@o = @container.element_by_css(@what)
|
50
51
|
else
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
next unless @ole_object == nil
|
55
|
-
|
56
|
-
wrapped = FormWrapper.new(thisForm)
|
57
|
-
@ole_object =
|
58
|
-
case @how
|
59
|
-
when :name, :id, :method, :action
|
60
|
-
@what.matches(wrapped.send(@how)) ? thisForm : nil
|
61
|
-
when :index
|
62
|
-
count == @what ? thisForm : nil
|
63
|
-
else
|
64
|
-
raise MissingWayOfFindingObjectException, "#{how} is an unknown way of finding a form (#{what})"
|
65
|
-
end
|
66
|
-
count += 1
|
67
|
-
end
|
52
|
+
locator = FormLocator.new(@container, 'FORM')
|
53
|
+
locator.set_specifier(@how, @what)
|
54
|
+
@o = locator.locate
|
68
55
|
end
|
69
|
-
super(@ole_object)
|
70
|
-
|
71
|
-
copy_test_config container
|
72
56
|
end
|
73
|
-
|
74
|
-
def exists?
|
75
|
-
@ole_object ? true : false
|
76
|
-
end
|
77
|
-
alias :exist? :exists?
|
78
|
-
|
79
|
-
def assert_exists
|
80
|
-
unless exists?
|
81
|
-
raise UnknownFormException,
|
82
|
-
"Unable to locate a form using #{@how} and #{@what}"
|
83
|
-
end
|
84
|
-
end
|
85
|
-
|
57
|
+
|
86
58
|
# Submit the data -- equivalent to pressing Enter or Return to submit a form.
|
87
59
|
def submit
|
88
60
|
assert_exists
|
89
|
-
@
|
61
|
+
@o.invoke('submit')
|
90
62
|
@container.wait
|
91
63
|
end
|
92
64
|
|
93
65
|
def ole_inner_elements
|
94
66
|
assert_exists
|
95
|
-
@
|
67
|
+
@o.elements
|
96
68
|
end
|
97
69
|
private :ole_inner_elements
|
98
|
-
|
99
|
-
def document
|
100
|
-
return @ole_object
|
101
|
-
end
|
102
|
-
|
103
|
-
def wait(no_sleep=false)
|
104
|
-
@container.wait(no_sleep)
|
105
|
-
end
|
106
|
-
|
70
|
+
|
107
71
|
# This method is responsible for setting and clearing the colored highlighting on the specified form.
|
108
72
|
# use :set to set the highlight
|
109
73
|
# :clear to clear the highlight
|
110
74
|
def highlight(set_or_clear, element, count)
|
111
|
-
|
112
75
|
if set_or_clear == :set
|
113
76
|
begin
|
114
77
|
original_color = element.style.backgroundColor
|
@@ -135,16 +98,17 @@ module Watir
|
|
135
98
|
# causes the object to flash. Normally used in IRB when creating scripts
|
136
99
|
# Default is 10
|
137
100
|
def flash number=10
|
101
|
+
assert_exists
|
138
102
|
@original_styles = {}
|
139
103
|
number.times do
|
140
104
|
count = 0
|
141
|
-
@
|
105
|
+
@o.elements.each do |element|
|
142
106
|
highlight(:set, element, count)
|
143
107
|
count += 1
|
144
108
|
end
|
145
109
|
sleep 0.05
|
146
110
|
count = 0
|
147
|
-
@
|
111
|
+
@o.elements.each do |element|
|
148
112
|
highlight(:clear, element, count)
|
149
113
|
count += 1
|
150
114
|
end
|
@@ -154,20 +118,4 @@ module Watir
|
|
154
118
|
|
155
119
|
end # class Form
|
156
120
|
|
157
|
-
end
|
158
|
-
|
159
|
-
module Watir
|
160
|
-
class Forms < ElementCollections
|
161
|
-
def element_class; Form; end
|
162
|
-
def element_tag; 'FORM'; end
|
163
|
-
def length
|
164
|
-
@container.document.getElementsByTagName("FORM").length
|
165
|
-
end
|
166
|
-
end
|
167
|
-
|
168
|
-
module Container
|
169
|
-
def forms
|
170
|
-
Forms.new(self)
|
171
|
-
end
|
172
|
-
end
|
173
121
|
end
|
data/lib/watir/frame.rb
CHANGED
@@ -1,55 +1,44 @@
|
|
1
1
|
module Watir
|
2
|
-
class Frame
|
3
|
-
include Container
|
2
|
+
class Frame < Element
|
4
3
|
include PageContainer
|
5
|
-
|
4
|
+
|
6
5
|
# Find the frame denoted by how and what in the container and return its ole_object
|
7
6
|
def locate
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
7
|
+
@o = nil
|
8
|
+
if @how == :xpath
|
9
|
+
@o = @container.element_by_xpath(@what)
|
10
|
+
elsif @how == :css
|
11
|
+
@o = @container.element_by_css(@what)
|
12
|
+
else
|
13
|
+
locator = FrameLocator.new(@container)
|
14
|
+
locator.set_specifier(@how, @what)
|
15
|
+
['FRAME', 'IFRAME'].each do |frame_tag|
|
16
|
+
locator.tag = frame_tag
|
17
|
+
located_frame, document = locator.locate
|
18
|
+
unless (located_frame.nil? && document.nil?)
|
19
|
+
@o = located_frame
|
20
|
+
@document = document.document
|
21
|
+
break
|
23
22
|
end
|
24
|
-
when :id
|
25
|
-
# We assume that pages contain frames or iframes, but not both.
|
26
|
-
this_frame_tag = @container.document.getElementsByTagName("FRAME").item(i)
|
27
|
-
return this_frame if this_frame_tag and what.matches(this_frame_tag.invoke("id"))
|
28
|
-
this_iframe_tag = @container.document.getElementsByTagName("IFRAME").item(i)
|
29
|
-
return this_frame if this_iframe_tag and what.matches(this_iframe_tag.invoke("id"))
|
30
|
-
when :src
|
31
|
-
this_frame_tag = @container.document.getElementsByTagName("FRAME").item(i)
|
32
|
-
return this_frame if this_frame_tag and what.matches(this_frame_tag.src)
|
33
|
-
this_iframe_tag = @container.document.getElementsByTagName("IFRAME").item(i)
|
34
|
-
return this_frame if this_iframe_tag and what.matches(this_iframe_tag.src)
|
35
|
-
else
|
36
|
-
raise ArgumentError, "Argument #{how} not supported"
|
37
23
|
end
|
38
24
|
end
|
39
|
-
|
40
|
-
raise UnknownFrameException, "Unable to locate a frame with #{how.to_s} #{what}"
|
41
25
|
end
|
42
|
-
|
26
|
+
|
27
|
+
def ole_inner_elements
|
28
|
+
document.body.all
|
29
|
+
end
|
30
|
+
private :ole_inner_elements
|
31
|
+
|
43
32
|
def initialize(container, how, what)
|
44
33
|
set_container container
|
45
34
|
@how = how
|
46
35
|
@what = what
|
47
|
-
@o = locate
|
48
36
|
copy_test_config container
|
49
37
|
end
|
50
38
|
|
51
39
|
def document
|
52
|
-
|
40
|
+
assert_exists
|
41
|
+
@document
|
53
42
|
end
|
54
43
|
|
55
44
|
def attach_command
|
data/lib/watir/ie-class.rb
CHANGED
@@ -554,15 +554,14 @@ module Watir
|
|
554
554
|
|
555
555
|
# Show all forms displays all the forms that are on a web page.
|
556
556
|
def show_forms
|
557
|
-
if
|
558
|
-
count =
|
557
|
+
if all_forms = self.forms
|
558
|
+
count = all_forms.length
|
559
559
|
puts "There are #{count} forms"
|
560
|
-
|
561
|
-
|
562
|
-
puts "
|
563
|
-
puts "
|
564
|
-
puts "
|
565
|
-
puts " action: #{wrapped.action}"
|
560
|
+
all_forms.each do |form|
|
561
|
+
puts "Form name: #{form.name}"
|
562
|
+
puts " id: #{form.id}"
|
563
|
+
puts " method: #{form.method}"
|
564
|
+
puts " action: #{form.action}"
|
566
565
|
end
|
567
566
|
else
|
568
567
|
puts "No forms"
|
data/lib/watir/locator.rb
CHANGED
@@ -14,13 +14,21 @@ module Watir
|
|
14
14
|
how = :class_name
|
15
15
|
when :caption
|
16
16
|
how = :value
|
17
|
+
when :method
|
18
|
+
how = :form_method
|
17
19
|
end
|
18
20
|
|
19
21
|
@specifiers[how] = what
|
20
22
|
end
|
21
23
|
end
|
22
24
|
|
23
|
-
|
25
|
+
def match_with_specifiers?(element)
|
26
|
+
@specifiers.each do |how, what|
|
27
|
+
next if how == :index
|
28
|
+
return false unless match? element, how, what
|
29
|
+
end
|
30
|
+
return true
|
31
|
+
end
|
24
32
|
end
|
25
33
|
|
26
34
|
class TaggedElementLocator < Locator
|
@@ -49,21 +57,9 @@ module Watir
|
|
49
57
|
def locate
|
50
58
|
count = 0
|
51
59
|
each_element(@tag) do |element|
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
next if how == :index
|
56
|
-
unless match? element, how, what
|
57
|
-
throw :next_element
|
58
|
-
end
|
59
|
-
end
|
60
|
-
count += 1
|
61
|
-
unless count == @specifiers[:index]
|
62
|
-
throw :next_element
|
63
|
-
end
|
64
|
-
return element.ole_object
|
65
|
-
end
|
66
|
-
|
60
|
+
next unless match_with_specifiers?(element)
|
61
|
+
count += 1
|
62
|
+
return element.ole_object if count == @specifiers[:index]
|
67
63
|
end # elements
|
68
64
|
nil
|
69
65
|
end
|
@@ -73,7 +69,7 @@ module Watir
|
|
73
69
|
method = element.method(how)
|
74
70
|
rescue NameError
|
75
71
|
raise MissingWayOfFindingObjectException,
|
76
|
-
|
72
|
+
"#{how} is an unknown way of finding a <#{@tag}> element (#{what})"
|
77
73
|
end
|
78
74
|
case method.arity
|
79
75
|
when 0
|
@@ -82,11 +78,49 @@ module Watir
|
|
82
78
|
method.call(what)
|
83
79
|
else
|
84
80
|
raise MissingWayOfFindingObjectException,
|
85
|
-
|
81
|
+
"#{how} is an unknown way of finding a <#{@tag}> element (#{what})"
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
end
|
86
|
+
|
87
|
+
class FrameLocator < TaggedElementLocator
|
88
|
+
attr_accessor :tag
|
89
|
+
|
90
|
+
def initialize(container)
|
91
|
+
@container = container
|
92
|
+
end
|
93
|
+
|
94
|
+
def each_element tag
|
95
|
+
frames = @container.document.frames
|
96
|
+
i = 0
|
97
|
+
@container.document.getElementsByTagName(tag).each do |frame|
|
98
|
+
element = Element.new(frame)
|
99
|
+
document = frames.item(i)
|
100
|
+
yield element, document
|
101
|
+
i += 1
|
86
102
|
end
|
87
103
|
end
|
88
104
|
|
105
|
+
def locate
|
106
|
+
count = 0
|
107
|
+
each_element(@tag) do |element, document|
|
108
|
+
next unless match_with_specifiers?(element)
|
109
|
+
count += 1
|
110
|
+
return element.ole_object, document if count == @specifiers[:index]
|
111
|
+
end # elements
|
112
|
+
nil
|
113
|
+
end
|
89
114
|
end
|
115
|
+
|
116
|
+
class FormLocator < TaggedElementLocator
|
117
|
+
def each_element(tag)
|
118
|
+
@container.document.forms.each do |form|
|
119
|
+
yield FormElement.new(form)
|
120
|
+
end
|
121
|
+
end
|
122
|
+
end
|
123
|
+
|
90
124
|
class InputElementLocator < Locator
|
91
125
|
|
92
126
|
attr_accessor :document, :element, :elements, :klass
|
@@ -126,19 +160,10 @@ module Watir
|
|
126
160
|
def element.locate; @o; end
|
127
161
|
end
|
128
162
|
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
unless match? element, how, what
|
134
|
-
throw :next_element
|
135
|
-
end
|
136
|
-
end
|
137
|
-
count += 1
|
138
|
-
throw :next_element unless count == @specifiers[:index]
|
139
|
-
return object
|
140
|
-
end
|
141
|
-
|
163
|
+
next unless @types.include?(element.type) && match_with_specifiers?(element)
|
164
|
+
|
165
|
+
count += 1
|
166
|
+
return object if count == @specifiers[:index]
|
142
167
|
end
|
143
168
|
nil
|
144
169
|
end
|
@@ -166,7 +191,7 @@ module Watir
|
|
166
191
|
|
167
192
|
the_id = @specifiers[:id]
|
168
193
|
if the_id && the_id.class == String &&
|
169
|
-
|
194
|
+
@specifiers[:index] == 1 && @specifiers.length == 2
|
170
195
|
@element = @document.getElementById(the_id) rescue nil
|
171
196
|
# Return if our fast match really HAS a matching :id
|
172
197
|
return true if @element && @element.invoke('id') == the_id
|
@@ -190,15 +215,8 @@ module Watir
|
|
190
215
|
def each
|
191
216
|
count = 0
|
192
217
|
each_element('*') do |element|
|
193
|
-
|
194
|
-
|
195
|
-
next if how == :index
|
196
|
-
unless match? element, how, what
|
197
|
-
throw :next_element
|
198
|
-
end
|
199
|
-
end
|
200
|
-
yield element
|
201
|
-
end
|
218
|
+
next unless match_with_specifiers?(element)
|
219
|
+
yield element
|
202
220
|
end
|
203
221
|
nil
|
204
222
|
end
|
@@ -8,8 +8,8 @@ module Watir
|
|
8
8
|
class NonControlElement < Element
|
9
9
|
|
10
10
|
def self.inherited subclass
|
11
|
-
class_name = subclass.to_s
|
12
|
-
method_name =
|
11
|
+
class_name = Watir::Util.demodulize(subclass.to_s)
|
12
|
+
method_name = Watir::Util.underscore(class_name)
|
13
13
|
Watir::Container.module_eval <<-RUBY
|
14
14
|
def #{method_name}(how, what=nil)
|
15
15
|
return #{class_name}.new(self, how, what)
|
@@ -145,4 +145,4 @@ module Watir
|
|
145
145
|
TAG = 'EM'
|
146
146
|
end
|
147
147
|
|
148
|
-
end
|
148
|
+
end
|
@@ -15,7 +15,7 @@ class ClickNoWait_Tests < Watir::TestCase
|
|
15
15
|
end
|
16
16
|
|
17
17
|
def test_spawned_click_no_wait_command
|
18
|
-
assert_equal("start rubyw -e \"some command\"", browser.link(:id => 'link1').send(:
|
18
|
+
assert_equal("start rubyw -e \"some command\"", browser.link(:id => 'link1').send(:__spawned_no_wait_command, "some command"))
|
19
19
|
end
|
20
20
|
|
21
21
|
end
|
data/unittests/form_test.rb
CHANGED
@@ -27,7 +27,12 @@ class TC_Forms2 < Test::Unit::TestCase # Note: there is no TC_Forms1
|
|
27
27
|
assert(browser.form(:action, "pass.html").exists?)
|
28
28
|
assert_false(browser.form(:action, "missing").exists?)
|
29
29
|
end
|
30
|
-
|
30
|
+
|
31
|
+
def test_multiple_attribute
|
32
|
+
assert_true(browser.form(:name => 'test2', :id => 'f2').exists?)
|
33
|
+
assert_true(browser.form(:name => 'test2', :method => 'get', :action => 'pass2.html'))
|
34
|
+
end
|
35
|
+
|
31
36
|
def test_button_in_form
|
32
37
|
assert(browser.form(:name, "test2").button(:caption, "Submit").exists?)
|
33
38
|
end
|
@@ -62,6 +67,19 @@ class TC_Forms2 < Test::Unit::TestCase # Note: there is no TC_Forms1
|
|
62
67
|
end
|
63
68
|
end
|
64
69
|
|
70
|
+
class TC_Forms_Collection < Test::Unit::TestCase
|
71
|
+
def setup
|
72
|
+
goto_page "forms2.html"
|
73
|
+
end
|
74
|
+
|
75
|
+
def test_forms_collection
|
76
|
+
forms = browser.forms
|
77
|
+
assert_equal(4, forms.length)
|
78
|
+
assert_equal('pass.html', forms.first.action)
|
79
|
+
assert_equal('test2', forms.last.name)
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
65
83
|
class TC_Form_Display < Test::Unit::TestCase
|
66
84
|
include CaptureIOHelper
|
67
85
|
def test_showforms
|
@@ -288,3 +306,4 @@ class TC_Hidden_Fields < Test::Unit::TestCase
|
|
288
306
|
assert_equal("hidden_1", browser.hiddens[2].id)
|
289
307
|
end
|
290
308
|
end
|
309
|
+
|
data/unittests/frame_test.rb
CHANGED
@@ -11,43 +11,44 @@ class TC_Frames < Test::Unit::TestCase
|
|
11
11
|
end
|
12
12
|
|
13
13
|
def test_frame_no_what
|
14
|
-
assert_raises(
|
14
|
+
assert_raises(UnknownObjectException) { browser.frame("missingFrame").button(:id, "b2").enabled? }
|
15
15
|
assert_raises(UnknownObjectException) { browser.frame("buttonFrame2").button(:id, "b2").enabled? }
|
16
16
|
assert(browser.frame("buttonFrame").button(:id, "b2").enabled?)
|
17
17
|
assert_false(browser.frame("buttonFrame").button(:caption, "Disabled Button").enabled?)
|
18
18
|
end
|
19
19
|
|
20
20
|
def test_frame_using_name
|
21
|
-
assert_raises(
|
21
|
+
assert_raises(UnknownObjectException) { browser.frame(:name, "missingFrame").button(:id, "b2").enabled? }
|
22
22
|
assert_raises(UnknownObjectException) { browser.frame(:name, "buttonFrame2").button(:id, "b2").enabled? }
|
23
23
|
assert(browser.frame(:name, "buttonFrame").button(:id, "b2").enabled?)
|
24
24
|
assert_false(browser.frame(:name, "buttonFrame").button(:caption, "Disabled Button").enabled?)
|
25
25
|
end
|
26
26
|
|
27
27
|
def test_frame_using_name_and_regexp
|
28
|
-
assert_raises(
|
28
|
+
assert_raises(UnknownObjectException) { browser.frame(:name, /missingFrame/).button(:id, "b2").enabled? }
|
29
29
|
assert(browser.frame(:name, /button/).button(:id, "b2").enabled?)
|
30
30
|
end
|
31
31
|
|
32
32
|
def test_frame_using_index
|
33
|
-
assert_raises(
|
33
|
+
assert_raises(UnknownObjectException) { browser.frame(:index, 8).button(:id, "b2").enabled? }
|
34
34
|
assert_raises(UnknownObjectException) { browser.frame(:index, 2).button(:id, "b2").enabled? }
|
35
35
|
assert(browser.frame(:index, 1 ).button(:id, "b2").enabled?)
|
36
36
|
assert_false(browser.frame(:index, 1).button(:caption, "Disabled Button").enabled?)
|
37
|
+
assert_equal('blankpage.html', browser.frame(:index, 2).src)
|
37
38
|
end
|
38
39
|
|
39
40
|
tag_method :test_frame_with_invalid_attribute, :fails_on_firefox
|
40
41
|
|
41
42
|
def test_frame_with_invalid_attribute
|
42
|
-
assert_raises(
|
43
|
+
assert_raises(MissingWayOfFindingObjectException) { browser.frame(:blah, 'no_such_thing').button(:id, "b2").enabled? }
|
43
44
|
end
|
44
45
|
|
45
46
|
def test_preset_frame
|
46
47
|
# with ruby's instance_eval, we are able to use the same frame for several actions
|
47
48
|
results = browser.frame("buttonFrame").instance_eval do
|
48
49
|
[
|
49
|
-
|
50
|
-
|
50
|
+
button(:id, "b2").enabled?,
|
51
|
+
button(:caption, "Disabled Button").enabled?
|
51
52
|
]
|
52
53
|
end
|
53
54
|
assert_equal([true, false], results)
|
@@ -63,11 +64,11 @@ class TC_Frames2 < Test::Unit::TestCase
|
|
63
64
|
end
|
64
65
|
|
65
66
|
def test_frame_with_no_name
|
66
|
-
assert_raises(
|
67
|
+
assert_raises(UnknownObjectException) { browser.frame(:name, "missingFrame").button(:id, "b2").enabled? }
|
67
68
|
end
|
68
69
|
|
69
70
|
def test_frame_by_id
|
70
|
-
assert_raises(
|
71
|
+
assert_raises(UnknownObjectException) { browser.frame(:id, "missingFrame").button(:id, "b2").enabled? }
|
71
72
|
assert(browser.frame(:id, 'first_frame').button(:id, "b2").enabled?)
|
72
73
|
end
|
73
74
|
|
@@ -85,8 +86,8 @@ class TC_NestedFrames < Test::Unit::TestCase
|
|
85
86
|
end
|
86
87
|
|
87
88
|
def test_frame
|
88
|
-
assert_raises(
|
89
|
-
assert_raises(
|
89
|
+
assert_raises(UnknownObjectException) { browser.frame("missingFrame").button(:id, "b2").enabled? }
|
90
|
+
assert_raises(UnknownObjectException) { browser.frame("nestedFrame").frame("subFrame").button(:id, "b2").enabled? }
|
90
91
|
assert(browser.frame("nestedFrame").frame("senderFrame").button(:name, "sendIt").enabled?)
|
91
92
|
browser.frame("nestedFrame").frame("senderFrame").text_field(:index, "1").set("Hello")
|
92
93
|
browser.frame("nestedFrame").frame("senderFrame").button(:name, "sendIt").click
|
@@ -171,3 +172,25 @@ class TC_Frames_click_no_wait < Test::Unit::TestCase
|
|
171
172
|
end
|
172
173
|
end
|
173
174
|
|
175
|
+
class TC_Frame_multiple_attributes < Test::Unit::TestCase
|
176
|
+
def setup
|
177
|
+
goto_page "frame_multi.html"
|
178
|
+
end
|
179
|
+
|
180
|
+
def test_get_frame_by_name_and_id
|
181
|
+
assert_equal('blankpage.html', browser.frame(:id => 'second_frame', :name => 'buttonFrame2').src)
|
182
|
+
end
|
183
|
+
end
|
184
|
+
|
185
|
+
class TC_frames_method_for_container < Test::Unit::TestCase
|
186
|
+
def setup
|
187
|
+
goto_page "frame_multi.html"
|
188
|
+
end
|
189
|
+
|
190
|
+
def test_frames_collection
|
191
|
+
frames = browser.frames
|
192
|
+
assert_equal(3, frames.length)
|
193
|
+
assert_equal('first_frame', frames[1].id)
|
194
|
+
assert_equal('pass.html', frames[3].src)
|
195
|
+
end
|
196
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
$LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..', '..') unless $SETUP_LOADED
|
2
|
+
require 'unittests/setup'
|
3
|
+
|
4
|
+
class TC_No_Wait_Commands < Test::Unit::TestCase
|
5
|
+
def test_fire_event_no_wait
|
6
|
+
goto_page "javascriptevents.html"
|
7
|
+
browser.link(:text, "Check the Status").fire_event_no_wait("onMouseOver")
|
8
|
+
assert_equal("It worked", browser.status)
|
9
|
+
end
|
10
|
+
|
11
|
+
def test_set_no_wait_text_field
|
12
|
+
goto_page "textfields1.html"
|
13
|
+
browser.text_field(:name, "text1").set_no_wait("watir IE Controller")
|
14
|
+
assert_equal("watir IE Controller", browser.text_field(:name, "text1").value)
|
15
|
+
end
|
16
|
+
|
17
|
+
def test_set_no_wait_text_select_list
|
18
|
+
goto_page "selectboxes1.html"
|
19
|
+
browser.select_list(:name,'sel1').set_no_wait(/Option 1/)
|
20
|
+
assert_equal('Option 1', browser.select_list(:name , 'sel1').selected_options.first)
|
21
|
+
end
|
22
|
+
end
|
data/unittests/setup.rb
CHANGED
@@ -71,9 +71,9 @@ $window_tests = Dir["unittests/windows/*_test.rb"] - ["unittests/windows/ie-each
|
|
71
71
|
|
72
72
|
# load development libs also in #click_no_wait processes
|
73
73
|
Watir::Element.class_eval do
|
74
|
-
alias_method :
|
74
|
+
alias_method :__spawned_no_wait_command, :spawned_no_wait_command
|
75
75
|
|
76
|
-
def
|
76
|
+
def spawned_no_wait_command(command)
|
77
77
|
# make it actually wait in tests for easier testing
|
78
78
|
#
|
79
79
|
# please note that this implementation of click_no_wait takes considerably more time than
|
metadata
CHANGED
@@ -1,13 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: watir
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
5
|
-
prerelease:
|
4
|
+
hash: 977940506
|
5
|
+
prerelease: true
|
6
6
|
segments:
|
7
7
|
- 1
|
8
8
|
- 8
|
9
|
-
-
|
10
|
-
|
9
|
+
- 1
|
10
|
+
- rc1
|
11
|
+
version: 1.8.1.rc1
|
11
12
|
platform: ruby
|
12
13
|
authors:
|
13
14
|
- Bret Pettichord
|
@@ -15,7 +16,7 @@ autorequire:
|
|
15
16
|
bindir: bin
|
16
17
|
cert_chain: []
|
17
18
|
|
18
|
-
date: 2011-
|
19
|
+
date: 2011-04-07 00:00:00 +03:00
|
19
20
|
default_executable:
|
20
21
|
dependencies:
|
21
22
|
- !ruby/object:Gem::Dependency
|
@@ -58,12 +59,13 @@ dependencies:
|
|
58
59
|
requirements:
|
59
60
|
- - "="
|
60
61
|
- !ruby/object:Gem::Version
|
61
|
-
hash:
|
62
|
+
hash: 977940506
|
62
63
|
segments:
|
63
64
|
- 1
|
64
65
|
- 8
|
65
|
-
-
|
66
|
-
|
66
|
+
- 1
|
67
|
+
- rc1
|
68
|
+
version: 1.8.1.rc1
|
67
69
|
type: :runtime
|
68
70
|
version_requirements: *id003
|
69
71
|
- !ruby/object:Gem::Dependency
|
@@ -74,12 +76,13 @@ dependencies:
|
|
74
76
|
requirements:
|
75
77
|
- - "="
|
76
78
|
- !ruby/object:Gem::Version
|
77
|
-
hash:
|
79
|
+
hash: 977940506
|
78
80
|
segments:
|
79
81
|
- 1
|
80
82
|
- 8
|
81
|
-
-
|
82
|
-
|
83
|
+
- 1
|
84
|
+
- rc1
|
85
|
+
version: 1.8.1.rc1
|
83
86
|
type: :runtime
|
84
87
|
version_requirements: *id004
|
85
88
|
- !ruby/object:Gem::Dependency
|
@@ -185,6 +188,7 @@ files:
|
|
185
188
|
- unittests/navigate_test.rb
|
186
189
|
- unittests/nbsp_xpath_test.rb
|
187
190
|
- unittests/non_core_tests.rb
|
191
|
+
- unittests/no_wait_test.rb
|
188
192
|
- unittests/pagecontainstext_test.rb
|
189
193
|
- unittests/parent_child_test.rb
|
190
194
|
- unittests/perf_test.rb
|
@@ -332,12 +336,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
332
336
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
333
337
|
none: false
|
334
338
|
requirements:
|
335
|
-
- - "
|
339
|
+
- - ">"
|
336
340
|
- !ruby/object:Gem::Version
|
337
|
-
hash:
|
341
|
+
hash: 25
|
338
342
|
segments:
|
339
|
-
-
|
340
|
-
|
343
|
+
- 1
|
344
|
+
- 3
|
345
|
+
- 1
|
346
|
+
version: 1.3.1
|
341
347
|
requirements:
|
342
348
|
- Microsoft Windows running Internet Explorer 5.5 or later.
|
343
349
|
rubyforge_project: Watir
|