watir 1.5.4 → 1.5.5
Sign up to get free protection for your applications and to get access to all the features.
- data/bin/watir-console +1 -0
- data/changes.rb +16 -2
- data/readme.rb +2 -16
- data/unittests/buttons_test.rb +74 -101
- data/unittests/buttons_xpath_test.rb +3 -3
- data/unittests/checkbox_test.rb +3 -3
- data/unittests/checkbox_xpath_test.rb +3 -3
- data/unittests/core_tests.rb +1 -1
- data/unittests/css_test.rb +2 -7
- data/unittests/defer_test.rb +2 -2
- data/unittests/dialog_test.rb +2 -2
- data/unittests/div2_xpath_test.rb +1 -1
- data/unittests/div_test.rb +122 -121
- data/unittests/div_xpath_test.rb +3 -3
- data/unittests/errorchecker_test.rb +3 -8
- data/unittests/filefield_test.rb +4 -7
- data/unittests/filefield_xpath_test.rb +3 -5
- data/unittests/form_test.rb +7 -7
- data/unittests/form_xpath_test.rb +6 -6
- data/unittests/frame_test.rb +8 -9
- data/unittests/google_form_test.rb +1 -2
- data/unittests/html/div.html +7 -1
- data/unittests/html/lists.html +1 -1
- data/unittests/ie_mock.rb +4 -2
- data/unittests/ie_test.rb +2 -2
- data/unittests/images_test.rb +2 -2
- data/unittests/images_xpath_test.rb +2 -2
- data/unittests/links_multi_test.rb +23 -9
- data/unittests/links_test.rb +7 -7
- data/unittests/links_xpath_test.rb +2 -3
- data/unittests/lists_test.rb +6 -3
- data/unittests/map_test.rb +1 -2
- data/unittests/minmax_test.rb +4 -5
- data/unittests/navigate_test.rb +18 -23
- data/unittests/nbsp_xpath_test.rb +4 -5
- data/unittests/{screen_capture_test.rb → other/screen_capture_test.rb} +1 -1
- data/unittests/pagecontainstext_test.rb +3 -4
- data/unittests/parent_child_test.rb +1 -1
- data/unittests/pre_test.rb +2 -3
- data/unittests/radios_test.rb +13 -17
- data/unittests/radios_xpath_test.rb +3 -3
- data/unittests/selectbox_test.rb +6 -14
- data/unittests/selectbox_xpath_test.rb +3 -3
- data/unittests/setup.rb +30 -10
- data/unittests/speed_settings_test.rb +2 -3
- data/unittests/table_cell_using_xpath_test.rb +2 -7
- data/unittests/table_test.rb +144 -136
- data/unittests/table_xpath_test.rb +5 -9
- data/unittests/textarea_test.rb +3 -7
- data/unittests/textarea_xpath_test.rb +5 -9
- data/unittests/textfield_for_ch_char_test.rb +1 -1
- data/unittests/textfields_test.rb +3 -4
- data/unittests/textfields_xpath_test.rb +3 -3
- data/unittests/windows/attach_to_existing_window_test.rb +2 -2
- data/unittests/windows/attach_to_new_window_test.rb +2 -2
- data/unittests/windows/close_window_test.rb +2 -3
- data/unittests/windows/frame_links_test.rb +1 -1
- data/unittests/windows/iedialog_test.rb +3 -3
- data/unittests/windows/js_events_test.rb +2 -4
- data/unittests/windows/modal_dialog_test.rb +2 -2
- data/unittests/windows/send_keys_test.rb +2 -4
- data/watir.rb +4 -13
- data/watir/assertions.rb +9 -1
- data/watir/collections.rb +6 -11
- data/watir/container.rb +9 -99
- data/watir/cookiemanager.rb +4 -1
- data/watir/element.rb +8 -1
- data/watir/ie.rb +2 -2
- data/watir/input_elements.rb +2 -2
- data/watir/non_control_elements.rb +39 -2
- data/watir/page-container.rb +1 -1
- data/watir/table.rb +25 -23
- metadata +68 -54
- data/watir/bonus-elements.rb +0 -65
- data/watir/testUnitAddons.rb +0 -8
data/bin/watir-console
CHANGED
data/changes.rb
CHANGED
@@ -1,4 +1,18 @@
|
|
1
1
|
=begin rdoc
|
2
|
+
== Version 1.5.4
|
3
|
+
New Features
|
4
|
+
* Add new speed, :zippy. This is like fast, but, in effect, it does a TextField#value= instead of a TextField#set. If you have specific text fields that you never want this to happen to, use ie.text_field(:how, what).requires_typing.set instead.
|
5
|
+
http://svn.openqa.org/fisheye/changelog/watir/?cs=1295
|
6
|
+
* Add support for Chinese input as supplied by Vincent Xu.
|
7
|
+
http://jira.openqa.org/browse/WTR-71.
|
8
|
+
|
9
|
+
Bug Fixes
|
10
|
+
* Add dependency on windows-pr 0.6.6, which seems to be necessary on Vista.
|
11
|
+
* Fix for bug in IE.close_others provided by Paul Taylor.
|
12
|
+
http://jira.openqa.org/browse/WTR-194
|
13
|
+
* Fix for error when using verify_equal with ci_reporter, provided by Marcog.
|
14
|
+
http://svn.openqa.org/fisheye/changelog/watir/?cs=1301
|
15
|
+
|
2
16
|
== Version 1.5.3
|
3
17
|
Bug fixes and minor cleanup.
|
4
18
|
|
@@ -10,7 +24,7 @@ Bug fixes and minor cleanup.
|
|
10
24
|
* Fix tests.
|
11
25
|
* Update documentation.
|
12
26
|
|
13
|
-
Major Changes in 1.5.
|
27
|
+
Major Changes in 1.5.2
|
14
28
|
Support for IE's Modal Dialogs.
|
15
29
|
showModalDialog()
|
16
30
|
Any method can be used to specify an element (:text, :class, etc.).
|
@@ -20,7 +34,7 @@ Major Changes in 1.5.1
|
|
20
34
|
One can now use multiple attributes to specify an element.
|
21
35
|
ie.span(:class =>'Label', :text => 'Add new').click
|
22
36
|
|
23
|
-
Other Changes in 1.5.
|
37
|
+
Other Changes in 1.5.2
|
24
38
|
* Migrated IE.new_process from watir/contrib and improved its reliability. We now recommend IE.new_process over IE.new as a way to avoid numerous errors detailed in http://jira.openqa.org/browse/WTR-150.
|
25
39
|
* Added IE.start_process. This works like IE.start, but uses the new_process mechanism to start IE.
|
26
40
|
* Added IE.new_window and IE.start_window. This are synonyms for IE.new and IE.start.
|
data/readme.rb
CHANGED
@@ -66,21 +66,6 @@ Typical Usage
|
|
66
66
|
|
67
67
|
* :id and :name are the quickest of these to process, and so should be used when possible to speed up scripts.
|
68
68
|
|
69
|
-
The objects that are currently supported include
|
70
|
-
Button
|
71
|
-
Radio
|
72
|
-
CheckBox
|
73
|
-
TextField (Including TextArea and Password)
|
74
|
-
Hidden
|
75
|
-
SelectList
|
76
|
-
Label
|
77
|
-
Span
|
78
|
-
Div
|
79
|
-
P
|
80
|
-
Link
|
81
|
-
Table
|
82
|
-
Image
|
83
|
-
|
84
69
|
These 2 web sites provide info on Internet Explorer and on the DOM as implemented by Internet Explorer
|
85
70
|
http://msdn.microsoft.com/library/default.asp?url=/workshop/browser/webbrowser/webbrowser.asp
|
86
71
|
http://msdn.microsoft.com/library/default.asp?url=/workshop/browser/overview/overview.asp
|
@@ -98,9 +83,9 @@ Javascript Pop Up Support
|
|
98
83
|
This is the prefered method for dealing wth pop ups, file requesters etc. Support for Winclickers will be removed.
|
99
84
|
|
100
85
|
Contacts:
|
101
|
-
Paul Rogers (paul.rogers@shaw.ca)
|
102
86
|
Bret Pettichord (bret@pettichord.com)
|
103
87
|
Charley Baker (charley.baker@gmail.com)
|
88
|
+
Paul Rogers (paul.rogers@shaw.ca)
|
104
89
|
The mailing list: http://groups.google.com/group/watir-general
|
105
90
|
|
106
91
|
Contributors:
|
@@ -141,6 +126,7 @@ Contributors:
|
|
141
126
|
Zeljko Filipin
|
142
127
|
Paul Taylor - Bug fix 194
|
143
128
|
Vincent Xu - Chinese input support
|
129
|
+
Tomislav Car - Filefield fix (210)
|
144
130
|
|
145
131
|
Acknowledgements:
|
146
132
|
Chris Morris
|
data/unittests/buttons_test.rb
CHANGED
@@ -1,133 +1,106 @@
|
|
1
1
|
# feature tests for Buttons
|
2
|
-
# revision: $Revision:
|
2
|
+
# revision: $Revision: 1348 $
|
3
3
|
|
4
4
|
$LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..') if $0 == __FILE__
|
5
5
|
require 'unittests/setup'
|
6
6
|
|
7
|
-
class
|
8
|
-
include Watir
|
9
|
-
|
7
|
+
class TC_Button < Test::Unit::TestCase
|
8
|
+
include Watir::Exception
|
10
9
|
def setup
|
11
|
-
|
12
|
-
end
|
13
|
-
|
14
|
-
def goto_frames_page
|
15
|
-
$ie.goto($htmlRoot + "frame_buttons.html")
|
10
|
+
goto_page "buttons1.html"
|
16
11
|
end
|
17
12
|
|
18
|
-
def
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
'id b5',
|
36
|
-
'value Disabled Button',
|
37
|
-
'disabled true']
|
38
|
-
b1 = ['name b1',
|
39
|
-
'type button',
|
40
|
-
'id b2',
|
41
|
-
'value Click Me',
|
42
|
-
'disabled false']
|
43
|
-
|
44
|
-
assert_equal(b4, $ie.button(:name, "b4").to_s)
|
45
|
-
assert_equal(b1, $ie.button(:caption, "Click Me").to_s)
|
46
|
-
assert_equal(b1, $ie.button(:index, 1).to_s)
|
47
|
-
assert_raises(UnknownObjectException , "UnknownObjectException was supposed to be thrown" ) { $ie.button(:name, "noName").to_s }
|
13
|
+
def test_to_s
|
14
|
+
b4 = [
|
15
|
+
'type: *button',
|
16
|
+
'id: *b5',
|
17
|
+
'name: *b4',
|
18
|
+
'value: *Disabled Button',
|
19
|
+
'disabled: *true']
|
20
|
+
b1 = [
|
21
|
+
'type: *button',
|
22
|
+
'id: *b2',
|
23
|
+
'name: *b1',
|
24
|
+
'value: *Click Me',
|
25
|
+
'disabled: *false']
|
26
|
+
assert_match(Regexp.new(b4.join("\n")), browser.button(:name, "b4").to_s)
|
27
|
+
assert_match(Regexp.new(b1.join("\n")), browser.button(:caption, "Click Me").to_s)
|
28
|
+
assert_match(Regexp.new(b1.join("\n")), browser.button(:index, 1).to_s)
|
29
|
+
assert_raises(UnknownObjectException) { browser.button(:name, "noName").to_s }
|
48
30
|
end
|
49
31
|
|
50
32
|
def test_properties
|
51
|
-
assert_raises(UnknownObjectException
|
52
|
-
assert_raises(UnknownObjectException
|
53
|
-
assert_raises(UnknownObjectException
|
54
|
-
assert_raises(UnknownObjectException
|
55
|
-
assert_raises(UnknownObjectException
|
33
|
+
assert_raises(UnknownObjectException) { browser.button(:name, "noName").id }
|
34
|
+
assert_raises(UnknownObjectException) { browser.button(:name, "noName").name }
|
35
|
+
assert_raises(UnknownObjectException) { browser.button(:name, "noName").disabled }
|
36
|
+
assert_raises(UnknownObjectException) { browser.button(:name, "noName").type }
|
37
|
+
assert_raises(UnknownObjectException) { browser.button(:name, "noName").value }
|
56
38
|
|
57
|
-
assert_equal("b1"
|
58
|
-
assert_equal("b2"
|
59
|
-
assert_equal("button"
|
60
|
-
assert_equal("Click Me"
|
61
|
-
assert_equal(false
|
62
|
-
assert_equal("italic_button"
|
63
|
-
assert_equal(""
|
39
|
+
assert_equal("b1", browser.button(:index, 1).name)
|
40
|
+
assert_equal("b2", browser.button(:index, 1).id)
|
41
|
+
assert_equal("button", browser.button(:index, 1).type)
|
42
|
+
assert_equal("Click Me", browser.button(:index, 1).value)
|
43
|
+
assert_equal(false, browser.button(:index, 1).disabled)
|
44
|
+
assert_equal("italic_button", browser.button(:name, "b1").class_name)
|
45
|
+
assert_equal("", browser.button(:name , "b4").class_name)
|
46
|
+
|
47
|
+
assert_equal("b1" , browser.button(:id, "b2").name )
|
48
|
+
assert_equal("b2" , browser.button(:id, "b2").id )
|
49
|
+
assert_equal("button" , browser.button(:id, "b2").type )
|
64
50
|
|
51
|
+
assert_equal("b4" , browser.button(:index, 2).name )
|
52
|
+
assert_equal("b5" , browser.button(:index, 2).id )
|
53
|
+
assert_equal("button" , browser.button(:index, 2).type )
|
54
|
+
assert_equal("Disabled Button" , browser.button(:index, 2).value )
|
55
|
+
assert_equal(true , browser.button(:index, 2).disabled )
|
65
56
|
|
66
|
-
assert_equal("
|
67
|
-
assert_equal("
|
68
|
-
assert_equal("button" , $ie.button(:id, "b2").type )
|
69
|
-
|
70
|
-
assert_equal("b4" , $ie.button(:index, 2).name )
|
71
|
-
assert_equal("b5" , $ie.button(:index, 2).id )
|
72
|
-
assert_equal("button" , $ie.button(:index, 2).type )
|
73
|
-
assert_equal("Disabled Button" , $ie.button(:index, 2).value )
|
74
|
-
assert_equal(true , $ie.button(:index, 2).disabled )
|
75
|
-
|
76
|
-
assert_equal( "" , $ie.button(:index, 2).title )
|
77
|
-
assert_equal( "this is button1" , $ie.button(:index, 1).title )
|
57
|
+
assert_equal( "" , browser.button(:index, 2).title )
|
58
|
+
assert_equal( "this is button1" , browser.button(:index, 1).title )
|
78
59
|
end
|
79
60
|
|
80
|
-
|
81
|
-
|
82
|
-
# since most of the time, a button will be accessed based on its caption, there is a default way of accessing it....
|
83
|
-
assert_raises(UnknownObjectException , "UnknownObjectException was supposed to be thrown" ) { $ie.button( "Missing Caption").click }
|
61
|
+
def test_default_how
|
62
|
+
assert_raises(UnknownObjectException) { browser.button( "Missing Caption").click }
|
84
63
|
|
85
|
-
|
86
|
-
assert(
|
64
|
+
browser.button("Click Me").click
|
65
|
+
assert(browser.text.include?("PASS") )
|
87
66
|
end
|
88
67
|
|
89
|
-
def
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
def test_button_click
|
95
|
-
assert_raises(UnknownObjectException , "UnknownObjectException was supposed to be thrown" ) { $ie.button(:caption, "Missing Caption").click }
|
96
|
-
assert_raises(UnknownObjectException , "UnknownObjectException was supposed to be thrown" ) { $ie.button(:id, "missingID").click }
|
97
|
-
|
98
|
-
assert_raises(ObjectDisabledException , "ObjectDisabledException was supposed to be thrown" ) { $ie.button(:caption, "Disabled Button").click }
|
68
|
+
def test_click
|
69
|
+
assert_raises(UnknownObjectException) { browser.button(:caption, "Missing Caption").click }
|
70
|
+
assert_raises(UnknownObjectException) { browser.button(:id, "missingID").click }
|
71
|
+
assert_raises(ObjectDisabledException) { browser.button(:caption, "Disabled Button").click }
|
99
72
|
|
100
|
-
|
101
|
-
assert(
|
73
|
+
browser.button(:caption, "Click Me").click
|
74
|
+
assert(browser.text.include?("PASS"))
|
102
75
|
end
|
103
76
|
|
104
|
-
def
|
105
|
-
assert(
|
106
|
-
assert(
|
107
|
-
assert(
|
108
|
-
assert(
|
109
|
-
assert(
|
77
|
+
def test_exists
|
78
|
+
assert(browser.button(:caption, "Click Me").exists?)
|
79
|
+
assert(browser.button(:caption, "Submit").exists?)
|
80
|
+
assert(browser.button(:name, "b1").exists?)
|
81
|
+
assert(browser.button(:id, "b2").exists?)
|
82
|
+
assert(browser.button(:caption, /sub/i).exists?)
|
110
83
|
|
111
|
-
assert(
|
112
|
-
assert(
|
113
|
-
assert(
|
114
|
-
assert(
|
84
|
+
assert(!browser.button(:caption, "missingcaption").exists?)
|
85
|
+
assert(!browser.button(:name, "missingname").exists?)
|
86
|
+
assert(!browser.button(:id, "missingid").exists?)
|
87
|
+
assert(!browser.button(:caption, /missing/i).exists?)
|
115
88
|
end
|
116
89
|
|
117
|
-
def
|
90
|
+
def test_enabled
|
118
91
|
assert($ie.button(:caption, "Click Me").enabled?)
|
119
|
-
assert(
|
120
|
-
assert(
|
121
|
-
assert(
|
92
|
+
assert(!browser.button(:caption, "Disabled Button").enabled?)
|
93
|
+
assert(!browser.button(:name, "b4").enabled?)
|
94
|
+
assert(!browser.button(:id, "b5").enabled?)
|
122
95
|
|
123
|
-
assert_raises(UnknownObjectException , "UnknownObjectException was supposed to be thrown" ) {
|
96
|
+
assert_raises(UnknownObjectException , "UnknownObjectException was supposed to be thrown" ) { browser.button(:name, "noName").enabled? }
|
124
97
|
end
|
125
98
|
|
126
|
-
def
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
assert_raises(
|
99
|
+
def test_in_frame
|
100
|
+
goto_page "frame_buttons.html"
|
101
|
+
assert(browser.frame("buttonFrame").button(:caption, "Click Me").enabled?)
|
102
|
+
# frame must be specified
|
103
|
+
assert_raises(UnknownObjectException) { browser.button(:caption, "Disabled Button").enabled?}
|
131
104
|
end
|
132
105
|
|
133
106
|
end
|
@@ -1,14 +1,14 @@
|
|
1
1
|
# feature tests for Buttons
|
2
|
-
# revision: $Revision:
|
2
|
+
# revision: $Revision: 1348 $
|
3
3
|
|
4
4
|
$LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..') if $0 == __FILE__
|
5
5
|
require 'unittests/setup'
|
6
6
|
|
7
7
|
class TC_Buttons_XPath < Test::Unit::TestCase
|
8
|
-
include Watir
|
8
|
+
include Watir::Exception
|
9
9
|
|
10
10
|
def setup
|
11
|
-
|
11
|
+
goto_page "buttons1.html"
|
12
12
|
end
|
13
13
|
|
14
14
|
def test_properties
|
data/unittests/checkbox_test.rb
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
# feature tests for Check Boxes
|
2
|
-
# revision: $Revision:
|
2
|
+
# revision: $Revision: 1348 $
|
3
3
|
|
4
4
|
$LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..') if $0 == __FILE__
|
5
5
|
require 'unittests/setup'
|
6
6
|
|
7
7
|
class TC_CheckBox < Test::Unit::TestCase
|
8
|
-
include Watir
|
8
|
+
include Watir::Exception
|
9
9
|
|
10
10
|
def setup
|
11
|
-
|
11
|
+
goto_page "checkboxes1.html"
|
12
12
|
end
|
13
13
|
|
14
14
|
def test_checkbox_properties
|
@@ -1,14 +1,14 @@
|
|
1
1
|
# feature tests for Check Boxes
|
2
|
-
# revision: $Revision:
|
2
|
+
# revision: $Revision: 1348 $
|
3
3
|
|
4
4
|
$LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..') if $0 == __FILE__
|
5
5
|
require 'unittests/setup'
|
6
6
|
|
7
7
|
class TC_CheckBox_XPath < Test::Unit::TestCase
|
8
|
-
include Watir
|
8
|
+
include Watir::Exception
|
9
9
|
|
10
10
|
def setup
|
11
|
-
|
11
|
+
goto_page "checkboxes1.html"
|
12
12
|
end
|
13
13
|
|
14
14
|
def test_checkbox_properties
|
data/unittests/core_tests.rb
CHANGED
data/unittests/css_test.rb
CHANGED
@@ -1,11 +1,10 @@
|
|
1
1
|
# feature tests for css
|
2
|
-
# revision: $Revision:
|
2
|
+
# revision: $Revision: 1348 $
|
3
3
|
|
4
4
|
$LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..') if $0 == __FILE__
|
5
5
|
require 'unittests/setup'
|
6
6
|
|
7
7
|
class TC_CSS < Test::Unit::TestCase
|
8
|
-
include Watir
|
9
8
|
|
10
9
|
def divTester( message )
|
11
10
|
|
@@ -40,12 +39,8 @@ class TC_CSS < Test::Unit::TestCase
|
|
40
39
|
return s
|
41
40
|
end
|
42
41
|
|
43
|
-
def gotoCSSPage
|
44
|
-
$ie.goto($htmlRoot + "cssTest.html")
|
45
|
-
end
|
46
|
-
|
47
42
|
def test_SuccessMessage
|
48
|
-
|
43
|
+
goto_page "cssTest.html"
|
49
44
|
$ie.button( :caption , "Success").click
|
50
45
|
|
51
46
|
#isMessageDisplayed( "Success" )
|
data/unittests/defer_test.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# tests of deferring when a Watir object is bound to a com object (lazy evaluation)
|
2
2
|
|
3
|
-
# revision: $Revision:
|
3
|
+
# revision: $Revision: 1348 $
|
4
4
|
|
5
5
|
$LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..') if $0 == __FILE__
|
6
6
|
require 'unittests/setup'
|
@@ -22,7 +22,7 @@ class TC_Defer < Test::Unit::TestCase
|
|
22
22
|
assert_equal('Div Text', div.text)
|
23
23
|
end
|
24
24
|
def test_binding_to_refreshed_page
|
25
|
-
|
25
|
+
goto_page "textfields1.html"
|
26
26
|
text_field = $ie.text_field(:name, 'text1')
|
27
27
|
button = $ie.button(:value, 'Clear Events Box')
|
28
28
|
div = $ie.div(:name, 'divvy')
|
data/unittests/dialog_test.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
# Feature tests for Dialog class
|
2
|
-
# revision: $Revision:
|
2
|
+
# revision: $Revision: 1348 $
|
3
3
|
|
4
4
|
$LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..') if $0 == __FILE__
|
5
5
|
require 'unittests/setup'
|
@@ -9,7 +9,7 @@ class TC_Dialog_Test < Test::Unit::TestCase
|
|
9
9
|
include Watir
|
10
10
|
|
11
11
|
def setup
|
12
|
-
|
12
|
+
goto_page 'JavascriptClick.html'
|
13
13
|
end
|
14
14
|
def teardown
|
15
15
|
begin
|
@@ -6,7 +6,7 @@ require 'unittests/setup'
|
|
6
6
|
|
7
7
|
class TC_Divs_XPath2 < Test::Unit::TestCase
|
8
8
|
def setup
|
9
|
-
|
9
|
+
goto_page "list_matters.html"
|
10
10
|
end
|
11
11
|
def test_div_with_text
|
12
12
|
# Note: this test fails, probably because of bad html to xml translation.
|
data/unittests/div_test.rb
CHANGED
@@ -1,179 +1,180 @@
|
|
1
1
|
# feature tests for Divs, Spans and P's
|
2
|
-
# revision: $Revision:
|
2
|
+
# revision: $Revision: 1354 $
|
3
3
|
|
4
4
|
$LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..') if $0 == __FILE__
|
5
5
|
require 'unittests/setup'
|
6
6
|
|
7
7
|
class TC_Divs < Test::Unit::TestCase
|
8
|
-
include Watir
|
8
|
+
include Watir::Exception
|
9
9
|
|
10
10
|
def setup
|
11
|
-
|
11
|
+
uses_page "div.html"
|
12
12
|
end
|
13
13
|
|
14
14
|
def test_divs
|
15
|
-
assert_raises(UnknownObjectException) {
|
16
|
-
assert_raises(UnknownObjectException) {
|
17
|
-
|
18
|
-
assert
|
19
|
-
|
20
|
-
assert
|
21
|
-
|
22
|
-
assert
|
15
|
+
assert_raises(UnknownObjectException) { browser.div(:id, "div77").click }
|
16
|
+
assert_raises(UnknownObjectException) { browser.div(:title, "div77").click }
|
17
|
+
|
18
|
+
assert browser.text_field(:name, "text1").verify_contains("0")
|
19
|
+
browser.div(:id, "div3").click
|
20
|
+
assert browser.text_field(:name, "text1").verify_contains("1")
|
21
|
+
browser.div(:id, "div4").click
|
22
|
+
assert browser.text_field(:name, "text1").verify_contains("0")
|
23
23
|
end
|
24
24
|
|
25
25
|
def test_div_properties
|
26
|
-
assert_raises(UnknownObjectException) {
|
27
|
-
assert_raises(UnknownObjectException) {
|
26
|
+
assert_raises(UnknownObjectException) { browser.div(:id, "div77").text }
|
27
|
+
assert_raises(UnknownObjectException) { browser.div(:title, "div77").text }
|
28
28
|
|
29
29
|
assert_equal("This div has an onClick that increments text1",
|
30
|
-
|
30
|
+
browser.div(:id , "div3").text.strip )
|
31
31
|
assert_equal("This text is in a div with an id of div1 and title of test1",
|
32
|
-
|
33
|
-
|
34
|
-
assert_raises(UnknownObjectException) {
|
35
|
-
assert_equal("blueText"
|
36
|
-
assert_equal(""
|
37
|
-
|
38
|
-
assert_raises(UnknownObjectException) {
|
39
|
-
assert_equal("div1" ,
|
40
|
-
assert_equal("" ,
|
41
|
-
assert_equal("blueText" ,
|
42
|
-
assert_equal("" ,
|
43
|
-
assert_equal(false ,
|
44
|
-
assert_equal("" ,
|
45
|
-
assert_equal("div2",
|
32
|
+
browser.div(:title , "Test1").text.strip )
|
33
|
+
|
34
|
+
assert_raises(UnknownObjectException) { browser.div(:id , "div77").class_name }
|
35
|
+
assert_equal("blueText", browser.div(:id, "div2").class_name)
|
36
|
+
assert_equal("", browser.div(:id, "div1").class_name)
|
37
|
+
|
38
|
+
assert_raises(UnknownObjectException) { browser.div(:index, 44).class_name }
|
39
|
+
assert_equal("div1" , browser.div(:index, 1).id)
|
40
|
+
assert_equal("" , browser.div(:index, 1).class_name)
|
41
|
+
assert_equal("blueText" , browser.div(:index, 2).class_name)
|
42
|
+
assert_equal("" , browser.div(:index, 2).value)
|
43
|
+
assert_equal(false , browser.div(:index, 2).disabled)
|
44
|
+
assert_equal("" , browser.div(:index, 2).name)
|
45
|
+
assert_equal("div2", browser.div(:index, 2).id)
|
46
46
|
end
|
47
47
|
|
48
48
|
def test_div_iterator
|
49
|
-
assert_equal(
|
50
|
-
assert_equal(
|
51
|
-
|
52
|
-
index =1
|
53
|
-
|
54
|
-
|
55
|
-
assert_equal(
|
56
|
-
assert_equal(
|
57
|
-
|
58
|
-
index +=1
|
49
|
+
assert_equal(8, browser.divs.length)
|
50
|
+
assert_equal("div1", browser.divs[1].id)
|
51
|
+
|
52
|
+
index = 1
|
53
|
+
browser.divs.each do |s|
|
54
|
+
assert_equal(browser.div(:index,index).name, s.name)
|
55
|
+
assert_equal(browser.div(:index,index).id, s.id)
|
56
|
+
assert_equal(browser.div(:index,index).class_name , s.class_name)
|
57
|
+
index += 1
|
59
58
|
end
|
60
|
-
assert_equal(index-1,
|
59
|
+
assert_equal(index - 1, browser.divs.length) # -1 as we add 1 at the end of the loop
|
61
60
|
end
|
62
61
|
|
63
62
|
def test_objects_in_div
|
64
|
-
assert
|
65
|
-
assert
|
66
|
-
assert
|
63
|
+
assert browser.div(:id, 'buttons1').button(:index,1).exists?
|
64
|
+
assert !browser.div(:id, 'buttons1').button(:index,3).exists?
|
65
|
+
assert browser.div(:id, 'buttons1').button(:name,'b1').exists?
|
67
66
|
|
68
|
-
assert
|
69
|
-
assert
|
70
|
-
assert
|
67
|
+
assert browser.div(:id, 'buttons2').button(:index,1).exists?
|
68
|
+
assert browser.div(:id, 'buttons2').button(:index,2).exists?
|
69
|
+
assert !browser.div(:id, 'buttons1').button(:index,3).exists?
|
71
70
|
|
72
|
-
|
71
|
+
browser.div(:id, 'buttons1').button(:index, 1).click
|
72
|
+
assert_equal('button1', browser.div(:id, 'text_fields1').text_field(:index,1).value)
|
73
73
|
|
74
|
-
assert_equal(
|
75
|
-
|
76
|
-
assert_equal(
|
77
|
-
|
78
|
-
|
74
|
+
assert_equal(3, browser.div(:id, 'text_fields1').text_fields.length )
|
75
|
+
browser.div(:id, 'text_fields1').text_field(:name, 'div_text1').set("drink me")
|
76
|
+
assert_equal("drink me", browser.div(:id, 'text_fields1').text_field(:name, 'div_text1').getContents)
|
77
|
+
end
|
78
|
+
|
79
|
+
def test_images_inside_a_div
|
80
|
+
assert_equal(3, browser.div(:id, 'hasImages').images.length)
|
81
|
+
assert_match(/triangle/, browser.div(:id, 'hasImages').images[1].src)
|
82
|
+
assert_match(/circle/, browser.div(:id, 'hasImages').image(:id , 'circle').src)
|
79
83
|
end
|
80
84
|
|
81
85
|
#---- Span Tests ---
|
82
86
|
def test_spans
|
83
|
-
assert_raises(UnknownObjectException) {
|
84
|
-
assert_raises(UnknownObjectException) {
|
85
|
-
|
86
|
-
assert($ie.text_field(:name, "text2").verify_contains("0") )
|
87
|
-
$ie.span(:id , "span3").click
|
88
|
-
assert($ie.text_field(:name, "text2").verify_contains("1") )
|
87
|
+
assert_raises(UnknownObjectException) {browser.span(:id , "span77").click }
|
88
|
+
assert_raises(UnknownObjectException) {browser.span(:title , "span77").click }
|
89
89
|
|
90
|
-
|
91
|
-
|
90
|
+
assert(browser.text_field(:name, "text2").verify_contains("0") )
|
91
|
+
browser.span(:id , "span3").click
|
92
|
+
assert(browser.text_field(:name, "text2").verify_contains("1") )
|
92
93
|
|
94
|
+
browser.span(:id , "span4").click
|
95
|
+
assert(browser.text_field(:name, "text2").verify_contains("0") )
|
93
96
|
end
|
94
97
|
|
95
98
|
def test_span_properties
|
96
|
-
assert_raises(UnknownObjectException) {
|
97
|
-
assert_raises(UnknownObjectException) {
|
98
|
-
|
99
|
-
assert_equal("This span has an onClick that increments text2" ,
|
100
|
-
assert_equal("This text is in a span with an id of span1 and title of test2" ,
|
101
|
-
|
102
|
-
assert_raises(UnknownObjectException) {
|
103
|
-
assert_equal("blueText" ,
|
104
|
-
assert_equal("" ,
|
105
|
-
|
106
|
-
assert_raises(UnknownObjectException) {
|
107
|
-
assert_equal("span1" ,
|
108
|
-
assert_equal("" ,
|
109
|
-
assert_equal("blueText" ,
|
110
|
-
assert_equal("" ,
|
111
|
-
assert_equal(false ,
|
112
|
-
assert_equal("" ,
|
113
|
-
assert_equal("span2",
|
99
|
+
assert_raises(UnknownObjectException) {browser.span(:id , "span77").text }
|
100
|
+
assert_raises(UnknownObjectException) {browser.span(:title , "span77").text }
|
101
|
+
|
102
|
+
assert_equal("This span has an onClick that increments text2" , browser.span(:id , "span3").text.strip )
|
103
|
+
assert_equal("This text is in a span with an id of span1 and title of test2" , browser.span(:title , "Test2").text.strip )
|
104
|
+
|
105
|
+
assert_raises(UnknownObjectException) {browser.span(:id , "span77").class_name }
|
106
|
+
assert_equal("blueText" , browser.span(:id , "span2").class_name )
|
107
|
+
assert_equal("" , browser.span(:id , "span1").class_name )
|
108
|
+
|
109
|
+
assert_raises(UnknownObjectException) {browser.span(:index , 44).class_name }
|
110
|
+
assert_equal("span1" , browser.span(:index , 1).id )
|
111
|
+
assert_equal("" , browser.span(:index , 1).class_name )
|
112
|
+
assert_equal("blueText" , browser.span(:index , 2).class_name )
|
113
|
+
assert_equal("" , browser.span(:index , 2).value)
|
114
|
+
assert_equal(false , browser.span(:index , 2).disabled)
|
115
|
+
assert_equal("" , browser.span(:index , 2).name)
|
116
|
+
assert_equal("span2", browser.span(:index , 2).id)
|
114
117
|
end
|
115
118
|
|
116
119
|
def test_span_iterator
|
117
|
-
assert_equal(7,
|
118
|
-
assert_equal("span1",
|
120
|
+
assert_equal(7, browser.spans.length)
|
121
|
+
assert_equal("span1", browser.spans[1].id)
|
119
122
|
|
120
123
|
index = 1
|
121
|
-
|
124
|
+
browser.spans.each do |s|
|
122
125
|
# puts "each - span = " + s.to_s
|
123
|
-
assert_equal(
|
124
|
-
assert_equal(
|
125
|
-
assert_equal(
|
126
|
+
assert_equal(browser.span(:index, index ).name , s.name )
|
127
|
+
assert_equal(browser.span(:index, index ).id , s.id )
|
128
|
+
assert_equal(browser.span(:index, index ).class_name , s.class_name )
|
126
129
|
index += 1
|
127
130
|
end
|
128
|
-
assert_equal(index - 1,
|
131
|
+
assert_equal(index - 1, browser.spans.length) # -1 as we add 1 at the end of the loop
|
129
132
|
end
|
130
133
|
|
131
134
|
def test_objects_in_span
|
132
|
-
assert(
|
133
|
-
assert(
|
134
|
-
assert(
|
135
|
-
|
136
|
-
assert($ie.span(:id, 'buttons2').button(:index,1).exists? )
|
137
|
-
assert($ie.span(:id, 'buttons2').button(:index,2).exists? )
|
138
|
-
assert(!$ie.span(:id, 'buttons1').button(:index,3).exists? )
|
139
|
-
|
140
|
-
$ie.span(:id, 'buttons1').button(:index,1).click
|
135
|
+
assert(browser.span(:id, 'buttons1').button(:index,1).exists? )
|
136
|
+
assert(!browser.span(:id, 'buttons1').button(:index,3).exists? )
|
137
|
+
assert(browser.span(:id, 'buttons1').button(:name,'b1').exists? )
|
141
138
|
|
142
|
-
|
139
|
+
assert(browser.span(:id, 'buttons2').button(:index,1).exists? )
|
140
|
+
assert(browser.span(:id, 'buttons2').button(:index,2).exists? )
|
141
|
+
assert(!browser.span(:id, 'buttons1').button(:index,3).exists? )
|
143
142
|
|
144
|
-
|
143
|
+
browser.span(:id, 'buttons1').button(:index,1).click
|
144
|
+
assert_equal( 'button1' , browser.span(:id , 'text_fields1').text_field(:index,1).value)
|
145
|
+
assert_equal( 3 , browser.span(:id , 'text_fields1').text_fields.length )
|
145
146
|
end
|
146
147
|
|
147
148
|
def test_p
|
148
|
-
assert(
|
149
|
-
assert(
|
150
|
-
assert(
|
151
|
-
|
152
|
-
assert(
|
153
|
-
assert(
|
154
|
-
assert(
|
155
|
-
|
156
|
-
assert_raises( UnknownObjectException) {
|
157
|
-
assert_raises( UnknownObjectException) {
|
158
|
-
assert_raises( UnknownObjectException) {
|
159
|
-
assert_raises( UnknownObjectException) {
|
160
|
-
assert_raises( UnknownObjectException) {
|
161
|
-
|
162
|
-
assert_equal(
|
163
|
-
assert_equal(
|
164
|
-
assert_equal(
|
149
|
+
assert(browser.p(:id, 'number1').exists?)
|
150
|
+
assert(browser.p(:index, 3).exists?)
|
151
|
+
assert(browser.p(:title, 'test_3').exists?)
|
152
|
+
|
153
|
+
assert(!browser.p(:id, 'missing').exists?)
|
154
|
+
assert(!browser.p(:index, 8).exists?)
|
155
|
+
assert(!browser.p(:title, 'test_55').exists?)
|
156
|
+
|
157
|
+
assert_raises( UnknownObjectException) {browser.p(:id , 'missing').class_name }
|
158
|
+
assert_raises( UnknownObjectException) {browser.p(:id , 'missing').text }
|
159
|
+
assert_raises( UnknownObjectException) {browser.p(:id , 'missing').title }
|
160
|
+
assert_raises( UnknownObjectException) {browser.p(:id , 'missing').to_s }
|
161
|
+
assert_raises( UnknownObjectException) {browser.p(:id , 'missing').disabled }
|
162
|
+
|
163
|
+
assert_equal('redText' , browser.p(:index,1).class_name)
|
164
|
+
assert_equal('P_tag_1' , browser.p(:index,1).title)
|
165
|
+
assert_equal('This text is in a p with an id of number2' , browser.p(:index,2).text)
|
165
166
|
end
|
166
167
|
|
167
168
|
def test_p_iterator
|
168
|
-
assert_equal(
|
169
|
-
assert_equal(
|
170
|
-
assert_equal(
|
171
|
-
|
172
|
-
count=1
|
173
|
-
|
174
|
-
assert_equal('number'+count.to_s
|
175
|
-
count+=1
|
169
|
+
assert_equal(3, browser.ps.length)
|
170
|
+
assert_equal('italicText', browser.ps[2].class_name)
|
171
|
+
assert_equal('number3', browser.ps[3].id)
|
172
|
+
|
173
|
+
count = 1
|
174
|
+
browser.ps.each do |p|
|
175
|
+
assert_equal('number'+count.to_s, p.id)
|
176
|
+
count += 1
|
176
177
|
end
|
177
|
-
assert_equal(
|
178
|
+
assert_equal(count - 1, browser.ps.length)
|
178
179
|
end
|
179
180
|
end
|