watir 1.4.1 → 1.5.2
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 +119 -0
- data/license.rb +37 -0
- data/readme.rb +55 -120
- data/unittests/buttons_test.rb +107 -104
- data/unittests/buttons_xpath_test.rb +69 -0
- data/unittests/checkbox_test.rb +154 -141
- data/unittests/checkbox_xpath_test.rb +107 -0
- data/unittests/core_tests.rb +6 -2
- data/unittests/css_test.rb +50 -50
- data/unittests/defer_test.rb +47 -0
- data/unittests/dialog_test.rb +78 -0
- data/unittests/div2_xpath_test.rb +22 -0
- data/unittests/div_test.rb +159 -159
- data/unittests/div_xpath_test.rb +96 -0
- data/unittests/errorchecker_test.rb +22 -22
- data/unittests/filefield_test.rb +30 -23
- data/unittests/filefield_xpath_test.rb +35 -0
- data/unittests/form_test.rb +250 -229
- data/unittests/form_xpath_test.rb +253 -0
- data/unittests/frame_test.rb +123 -108
- data/unittests/google_form_test.rb +17 -0
- data/unittests/html/JavascriptClick.html +39 -0
- data/unittests/html/buttons1.html +3 -2
- data/unittests/html/checkboxes1.html +32 -14
- data/unittests/html/complex_table.html +1 -1
- data/unittests/html/depot_store.html +59 -0
- data/unittests/html/div.html +3 -21
- data/unittests/html/div_xml.html +21 -0
- data/unittests/html/fileupload.html +2 -2
- data/unittests/html/forms2.html +3 -3
- data/unittests/html/forms3.html +2 -2
- data/unittests/html/frame_links.html +2 -2
- data/unittests/html/google_india.html +119 -0
- data/unittests/html/iframeTest.html +2 -2
- data/unittests/html/images/map.GIF +0 -0
- data/unittests/html/images/map2.gif +0 -0
- data/unittests/html/images1.html +17 -2
- data/unittests/html/javascriptevents.html +3 -7
- data/unittests/html/links1.html +9 -8
- data/unittests/html/links_multi.html +14 -0
- data/unittests/html/list_matters.html +720 -0
- data/unittests/html/lists.html +18 -0
- data/unittests/html/map_test.html +31 -0
- data/unittests/html/modal_dialog.html +10 -0
- data/unittests/html/modal_dialog_launcher.html +12 -0
- data/unittests/html/new_browser.html +17 -0
- data/unittests/html/pass.html +3 -0
- data/unittests/html/popups1.html +1 -1
- data/unittests/html/pre.html +28 -0
- data/unittests/html/radioButtons1.html +6 -5
- data/unittests/html/selectboxes1.html +12 -11
- data/unittests/html/simple_table.html +1 -1
- data/unittests/html/simple_table_columns.html +1 -1
- data/unittests/html/table1.html +1 -1
- data/unittests/html/tableCell_using_xpath.html +19 -0
- data/unittests/html/textfields1.html +6 -4
- data/unittests/html/xpath_nbsp.html +12 -0
- data/unittests/ie_exists_test.rb +32 -0
- data/unittests/ie_mock.rb +78 -79
- data/unittests/ie_test.rb +39 -39
- data/unittests/images_test.rb +132 -155
- data/unittests/images_xpath_test.rb +91 -0
- data/unittests/links_multi_test.rb +36 -0
- data/unittests/links_test.rb +158 -152
- data/unittests/links_xpath_test.rb +40 -0
- data/unittests/lists_test.rb +29 -0
- data/unittests/map_test.rb +99 -0
- data/unittests/minmax_test.rb +23 -23
- data/unittests/navigate_test.rb +43 -51
- data/unittests/nbsp_xpath_test.rb +18 -0
- data/unittests/other/WindowLogonExample.rb +28 -0
- data/unittests/{WindowLogonExtra.rb → other/WindowLogonExtra.rb} +0 -0
- data/unittests/{all_tests_concurrent.rb → other/all_tests_concurrent.rb} +23 -23
- data/unittests/other/navigate_exception_test.rb +14 -0
- data/unittests/other/rexml_unit_test.rb +24 -0
- data/unittests/other/testcase_method_order_test.rb +36 -0
- data/unittests/other/testcase_verify_test.rb +25 -0
- data/unittests/other/wait_until_test.rb +99 -0
- data/unittests/pagecontainstext_test.rb +56 -37
- data/unittests/parent_child_test.rb +55 -0
- data/unittests/popups_test.rb +37 -37
- data/unittests/pre_test.rb +52 -0
- data/unittests/radios_test.rb +186 -155
- data/unittests/radios_xpath_test.rb +101 -0
- data/unittests/screen_capture_test.rb +41 -41
- data/unittests/selectbox_test.rb +223 -181
- data/unittests/selectbox_xpath_test.rb +113 -0
- data/unittests/setup.rb +29 -25
- data/unittests/speed_settings_test.rb +22 -0
- data/unittests/table_cell_using_xpath_test.rb +40 -0
- data/unittests/table_test.rb +315 -284
- data/unittests/table_xpath_test.rb +114 -0
- data/unittests/textarea_test.rb +81 -0
- data/unittests/textarea_xpath_test.rb +82 -0
- data/unittests/textfields_test.rb +205 -229
- data/unittests/textfields_xpath_test.rb +111 -0
- data/unittests/window_tests.rb +7 -0
- data/unittests/windows/attach_to_existing_window_test.rb +52 -0
- data/unittests/windows/attach_to_new_window_test.rb +82 -0
- data/unittests/windows/close_window_test.rb +22 -0
- data/unittests/windows/frame_links_test.rb +25 -0
- data/unittests/windows/ie-each_test.rb +48 -0
- data/unittests/windows/iedialog_test.rb +55 -0
- data/unittests/windows/js_events_test.rb +57 -0
- data/unittests/windows/jscriptExtraAlert.rb +6 -0
- data/unittests/windows/jscriptExtraConfirmCancel.rb +7 -0
- data/unittests/windows/jscriptExtraConfirmOk.rb +7 -0
- data/unittests/{jscriptPushButton.rb → windows/jscriptPushButton.rb} +1 -1
- data/unittests/windows/jscript_test.rb +64 -0
- data/unittests/windows/modal_dialog_test.rb +127 -0
- data/unittests/windows/new.rb +56 -0
- data/unittests/windows/open_close_test.rb +22 -0
- data/unittests/windows/send_keys_test.rb +34 -0
- data/unittests/xpath_tests.rb +10 -0
- data/watir.rb +4344 -3565
- data/watir/IEDialog/Release/IEDialog.dll +0 -0
- data/watir/WindowHelper.rb +13 -11
- data/watir/assertions.rb +36 -0
- data/watir/camel_case.rb +14 -5
- data/watir/close_all.rb +38 -0
- data/watir/contrib/enabled_popup.rb +21 -0
- data/watir/contrib/ie-new-process.rb +27 -0
- data/watir/contrib/page_checker.rb +29 -0
- data/watir/contrib/visible.rb +47 -0
- data/watir/cookiemanager.rb +4 -4
- data/watir/datahandler.rb +107 -0
- data/watir/dialog.rb +46 -0
- data/watir/elements.rb +65 -0
- data/watir/exceptions.rb +18 -36
- data/watir/ie-process.rb +40 -0
- data/watir/irb-history.rb +31 -0
- data/watir/process.rb +20 -0
- data/watir/testUnitAddons.rb +3 -42
- data/watir/testcase.rb +58 -0
- data/watir/utils.rb +20 -0
- data/watir/waiter.rb +88 -0
- data/watir/watir_simple.rb +4 -4
- data/watir/win32ole.rb +8 -0
- data/watir/win32ole/win32ole.so +0 -0
- data/watir/winClicker.rb +374 -400
- metadata +209 -128
- data/unittests/WindowLogonExample.rb +0 -30
- data/unittests/attachToExistingWindow_test.rb +0 -40
- data/unittests/js_events_test.rb +0 -77
- data/unittests/jscriptExtraAlert.rb +0 -6
- data/unittests/jscriptExtraConfirmCancel.rb +0 -7
- data/unittests/jscriptExtraConfirmOk.rb +0 -7
- data/unittests/jscript_test.rb +0 -57
- data/unittests/send_keys_test.rb +0 -29
- data/unittests/textAreafields_test.rb +0 -81
data/unittests/ie_test.rb
CHANGED
@@ -1,50 +1,50 @@
|
|
1
1
|
# Unit Test for Internet Explorer
|
2
|
-
# revision: $Revision:
|
2
|
+
# revision: $Revision: 1141 $
|
3
3
|
|
4
4
|
$LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..') if $0 == __FILE__
|
5
|
-
require 'win32ole'
|
5
|
+
require 'watir/win32ole'
|
6
6
|
require 'unittests/ie_mock'
|
7
7
|
require 'test/unit'
|
8
8
|
|
9
9
|
class TC_ie < Test::Unit::TestCase
|
10
|
-
|
10
|
+
include Watir
|
11
|
+
|
12
|
+
def setup
|
13
|
+
@faked_ie = TestIE.new
|
14
|
+
end
|
15
|
+
|
16
|
+
def test_waitForIE
|
17
|
+
wait_time = 1
|
18
|
+
# @faked_ie.logger.level = Logger::DEBUG
|
11
19
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
assert_nil(@faked_ie.getLink(:index, 1))
|
30
|
-
assert_nil(@faked_ie.getLink(:index, 1))
|
31
|
-
end
|
32
|
-
|
33
|
-
def test_getLink_ByBadHow
|
34
|
-
@faked_ie.addLink "foo"
|
35
|
-
assert_raise(MissingWayOfFindingObjectException) do
|
36
|
-
@faked_ie.getLink(:no_such_mechanism, "verifying error handling")
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
40
|
-
# is this correct?
|
41
|
-
def test_getLink_ByUrlReturnsNilOnNoLinks
|
42
|
-
assert_nil(@faked_ie.getLink(:url, "whatever"))
|
43
|
-
end
|
44
|
-
|
45
|
-
# is this correct?
|
46
|
-
def test_getLink_ByTextReturnsNilOnNoLinks
|
47
|
-
assert_nil(@faked_ie.getLink(:text, "whatever"))
|
20
|
+
@faked_ie.setTimeToWait wait_time
|
21
|
+
begin_time = Time.now
|
22
|
+
@faked_ie.wait
|
23
|
+
elapsed_time = Time.now - begin_time
|
24
|
+
assert_in_delta(wait_time, elapsed_time, 0.5)
|
25
|
+
end
|
26
|
+
|
27
|
+
# is this correct?
|
28
|
+
def test_getLink_ByIndexReturnsNilOnNoLinks
|
29
|
+
assert_nil(@faked_ie.locate_tagged_element('A', :index, 1))
|
30
|
+
assert_nil(@faked_ie.locate_tagged_element('A', :index, 1))
|
31
|
+
end
|
32
|
+
|
33
|
+
def test_getLink_ByBadHow
|
34
|
+
@faked_ie.addLink "foo"
|
35
|
+
assert_raise(MissingWayOfFindingObjectException) do
|
36
|
+
@faked_ie.locate_tagged_element('A', :no_such_mechanism, "verifying error handling")
|
48
37
|
end
|
38
|
+
end
|
39
|
+
|
40
|
+
# is this correct?
|
41
|
+
def test_getLink_ByUrlReturnsNilOnNoLinks
|
42
|
+
assert_nil(@faked_ie.locate_tagged_element('A', :url, "whatever"))
|
43
|
+
end
|
44
|
+
|
45
|
+
# is this correct?
|
46
|
+
def test_getLink_ByTextReturnsNilOnNoLinks
|
47
|
+
assert_nil(@faked_ie.locate_tagged_element('A', :text, "whatever"))
|
48
|
+
end
|
49
49
|
end
|
50
50
|
|
data/unittests/images_test.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
# feature tests for Images
|
2
|
-
# revision: $Revision:
|
2
|
+
# revision: $Revision: 958 $
|
3
3
|
|
4
4
|
$LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..') if $0 == __FILE__
|
5
5
|
require 'unittests/setup'
|
@@ -8,172 +8,149 @@ require 'webrick'
|
|
8
8
|
require 'watir/cookiemanager'
|
9
9
|
|
10
10
|
class TC_Images < Test::Unit::TestCase
|
11
|
-
|
11
|
+
include Watir
|
12
|
+
|
13
|
+
def setup
|
14
|
+
$ie.goto($htmlRoot + "images1.html")
|
15
|
+
@saved_img_path = build_path("sample.img.dat");
|
16
|
+
clean_saved_image
|
17
|
+
end
|
18
|
+
|
19
|
+
def teardown
|
20
|
+
clean_saved_image
|
21
|
+
end
|
22
|
+
|
23
|
+
def test_imageExists
|
24
|
+
assert( ! $ie.image(:name , "missing_name").exists? )
|
25
|
+
assert( $ie.image(:name , "circle").exists? )
|
26
|
+
assert( $ie.image(:name , /circ/ ).exists? )
|
12
27
|
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
end
|
28
|
+
assert( ! $ie.image(:id , "missing_id").exists? )
|
29
|
+
assert( $ie.image(:id , "square").exists? )
|
30
|
+
assert( $ie.image(:id , /squ/ ).exists? )
|
17
31
|
|
18
|
-
|
19
|
-
$ie.goto($htmlRoot + "images1.html")
|
20
|
-
end
|
21
|
-
|
22
|
-
def test_imageExists
|
23
|
-
assert_false( $ie.image(:name , "missing_name").exists? )
|
24
|
-
assert( $ie.image(:name , "circle").exists? )
|
25
|
-
assert( $ie.image(:name , /circ/ ).exists? )
|
26
|
-
|
27
|
-
assert_false( $ie.image(:id , "missing_id").exists? )
|
28
|
-
assert( $ie.image(:id , "square").exists? )
|
29
|
-
assert( $ie.image(:id , /squ/ ).exists? )
|
30
|
-
|
31
|
-
assert_false( $ie.image(:src, "missingsrc.gif").exists? )
|
32
|
-
|
33
|
-
# BP -- This fails for me but not for Paul. It doesn't make sense to me that it should pass.
|
34
|
-
# assert( $ie.image(:src , "file:///#{$myDir}/html/images/triangle.jpg").exists? )
|
35
|
-
assert( $ie.image(:src , /triangle/ ).exists? )
|
36
|
-
|
37
|
-
assert( $ie.image(:alt , "circle" ).exists? )
|
38
|
-
assert( $ie.image(:alt , /cir/ ).exists? )
|
39
|
-
|
40
|
-
assert_false( $ie.image(:alt , "triangle" ).exists? )
|
41
|
-
assert_false( $ie.image(:alt , /tri/ ).exists? )
|
42
|
-
end
|
32
|
+
assert( ! $ie.image(:src, "missingsrc.gif").exists? )
|
43
33
|
|
44
|
-
|
45
|
-
|
46
|
-
assert_raises(UnknownObjectException ) { $ie.image(:id, "no_image_with_this").click }
|
47
|
-
assert_raises(UnknownObjectException ) { $ie.image(:src, "no_image_with_this").click}
|
48
|
-
assert_raises(UnknownObjectException ) { $ie.image(:alt, "no_image_with_this").click}
|
49
|
-
|
50
|
-
# test for bug 1882
|
51
|
-
$ie.text_field(:name , "text1").clear
|
52
|
-
$ie.button(:value , /Pos/ ).click
|
53
|
-
assert_equal('clicked' , $ie.text_field(:name , "text1" ).value )
|
54
|
-
|
55
|
-
# # test for disabled button
|
56
|
-
# assert_false( $ie.image(:name , 'disabler_test').disabled )
|
57
|
-
# $ie.button(:name , 'disable_img').click
|
58
|
-
#
|
59
|
-
# assert( $ie.image(:name , 'disabler_test').disabled )
|
60
|
-
# $ie.button(:name , 'disable_img').click
|
61
|
-
|
62
|
-
$ie.image(:src, /button/).click
|
63
|
-
assert($ie.contains_text("PASS") )
|
64
|
-
|
65
|
-
end
|
34
|
+
assert( $ie.image(:src, "file:///#{$myDir}/html/images/triangle.jpg").exists? )
|
35
|
+
assert( $ie.image(:src , /triangle/ ).exists? )
|
66
36
|
|
67
|
-
|
68
|
-
|
69
|
-
def test_imageHasLoaded
|
70
|
-
assert_raises(UnknownObjectException ) { $ie.image(:name, "no_image_with_this").hasLoaded? }
|
71
|
-
assert_raises(UnknownObjectException ) { $ie.image(:id, "no_image_with_this").hasLoaded? }
|
72
|
-
assert_raises(UnknownObjectException ) { $ie.image(:src, "no_image_with_this").hasLoaded? }
|
73
|
-
assert_raises(UnknownObjectException ) { $ie.image(:alt, "no_image_with_this").hasLoaded? }
|
74
|
-
|
75
|
-
assert_false( $ie.image(:name, "themissingimage").hasLoaded? )
|
76
|
-
assert( $ie.image(:name, "circle").hasLoaded? )
|
77
|
-
|
78
|
-
assert( $ie.image(:alt, "circle").hasLoaded? )
|
79
|
-
assert( $ie.image(:alt, /cir/ ).hasLoaded? )
|
80
|
-
end
|
37
|
+
assert( $ie.image(:alt , "circle" ).exists? )
|
38
|
+
assert( $ie.image(:alt , /cir/ ).exists? )
|
81
39
|
|
82
|
-
|
83
|
-
|
84
|
-
assert_raises(UnknownObjectException ) { $ie.image(:id, "no_image_with_this").hasLoaded? }
|
85
|
-
assert_raises(UnknownObjectException ) { $ie.image(:src, "no_image_with_this").hasLoaded? }
|
86
|
-
assert_raises(UnknownObjectException ) { $ie.image(:index, 82).hasLoaded? }
|
87
|
-
|
88
|
-
assert_raises(UnknownObjectException ) { $ie.image(:index, 82).name }
|
89
|
-
assert_raises(UnknownObjectException ) { $ie.image(:index, 82).id }
|
90
|
-
assert_raises(UnknownObjectException ) { $ie.image(:index, 82).src }
|
91
|
-
assert_raises(UnknownObjectException ) { $ie.image(:index, 82).value }
|
92
|
-
assert_raises(UnknownObjectException ) { $ie.image(:index, 82).height }
|
93
|
-
assert_raises(UnknownObjectException ) { $ie.image(:index, 82).width }
|
94
|
-
assert_raises(UnknownObjectException ) { $ie.image(:index, 82).fileCreatedDate }
|
95
|
-
assert_raises(UnknownObjectException ) { $ie.image(:index, 82).fileSize }
|
96
|
-
assert_raises(UnknownObjectException ) { $ie.image(:index, 82).alt}
|
97
|
-
|
98
|
-
|
99
|
-
assert_equal( "image" , $ie.image(:index, 2).type )
|
100
|
-
assert_equal( "" , $ie.image(:index, 2).name )
|
101
|
-
assert_equal( "square" , $ie.image(:index, 2).id )
|
102
|
-
assert_match( /square\.jpg/i ,$ie.image(:index, 2).src )
|
103
|
-
assert_equal( "" , $ie.image(:index, 2).value )
|
104
|
-
assert_equal( "88" , $ie.image(:index, 2).height )
|
105
|
-
assert_equal( "88" , $ie.image(:index, 2).width )
|
106
|
-
|
107
|
-
|
108
|
-
# this line fails, as the date is when it is installed on the local oc, not the date the file was really created
|
109
|
-
#assert_equal( "03/10/2005" , $ie.image(:index, 2).fileCreatedDate )
|
110
|
-
assert_equal( "788", $ie.image(:index, 2).fileSize )
|
111
|
-
|
112
|
-
# alt text
|
113
|
-
assert_equal('circle' , $ie.image(:index, 6).alt)
|
114
|
-
assert_equal( "" , $ie.image(:index, 2).alt)
|
115
|
-
|
116
|
-
|
117
|
-
# to string tests -- output should be verified!
|
118
|
-
puts $ie.image(:name , "circle").to_s
|
119
|
-
puts $ie.image(:index , 2).to_s
|
120
|
-
end
|
40
|
+
assert( ! $ie.image(:alt , "triangle" ).exists? )
|
41
|
+
assert( ! $ie.image(:alt , /tri/ ).exists? )
|
121
42
|
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
assert_equal( $ie.image(:index, index).name , i.name )
|
132
|
-
assert_equal( $ie.image(:index, index).src , i.src )
|
133
|
-
assert_equal( $ie.image(:index, index).height , i.height )
|
134
|
-
assert_equal( $ie.image(:index, index).width , i.width )
|
135
|
-
|
136
|
-
index+=1
|
137
|
-
end
|
138
|
-
assert_equal( index-1 , $ie.images.length )
|
139
|
-
end
|
43
|
+
assert( $ie.image(:title, 'square_image').exists? )
|
44
|
+
assert( ! $ie.image(:title, 'pentagram').exists? )
|
45
|
+
end
|
46
|
+
|
47
|
+
def test_image_click
|
48
|
+
assert_raises(UnknownObjectException ) { $ie.image(:name, "no_image_with_this").click }
|
49
|
+
assert_raises(UnknownObjectException ) { $ie.image(:id, "no_image_with_this").click }
|
50
|
+
assert_raises(UnknownObjectException ) { $ie.image(:src, "no_image_with_this").click}
|
51
|
+
assert_raises(UnknownObjectException ) { $ie.image(:alt, "no_image_with_this").click}
|
140
52
|
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
end
|
146
|
-
safe_file_block(2) do
|
147
|
-
assert(File.compare(@saved_img_path, $ie.images[2].src.gsub(/^file:\/\/\//, '')))
|
148
|
-
end
|
149
|
-
end
|
53
|
+
# test for bug 1882
|
54
|
+
$ie.text_field(:name , "text1").clear
|
55
|
+
$ie.button(:value , /Pos/ ).click
|
56
|
+
assert_equal('clicked' , $ie.text_field(:name , "text1" ).value )
|
150
57
|
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
assert_equal(6 , $ie.images.length)
|
155
|
-
end
|
58
|
+
# test for disabled button
|
59
|
+
assert( ! $ie.image(:name , 'disabler_test').disabled )
|
60
|
+
$ie.button(:name , 'disable_img').click
|
156
61
|
|
157
|
-
|
158
|
-
|
159
|
-
begin
|
160
|
-
imgstosave.each {|imgidx| $ie.images[imgidx].save(build_windows_path("sample.img.dat"))}
|
161
|
-
yield
|
162
|
-
ensure
|
163
|
-
clean_saved_image
|
164
|
-
end
|
165
|
-
end
|
62
|
+
assert( $ie.image(:name , 'disabler_test').disabled )
|
63
|
+
$ie.button(:name , 'disable_img').click
|
166
64
|
|
167
|
-
|
168
|
-
|
169
|
-
|
65
|
+
$ie.image(:src, /button/).click
|
66
|
+
assert($ie.text.include?("PASS") )
|
67
|
+
end
|
68
|
+
|
69
|
+
def test_imageHasLoaded
|
70
|
+
assert_raises(UnknownObjectException ) { $ie.image(:name, "no_image_with_this").hasLoaded? }
|
71
|
+
assert_raises(UnknownObjectException ) { $ie.image(:id, "no_image_with_this").hasLoaded? }
|
72
|
+
assert_raises(UnknownObjectException ) { $ie.image(:src, "no_image_with_this").hasLoaded? }
|
73
|
+
assert_raises(UnknownObjectException ) { $ie.image(:alt, "no_image_with_this").hasLoaded? }
|
170
74
|
|
171
|
-
|
172
|
-
|
173
|
-
end
|
75
|
+
assert( ! $ie.image(:name, "themissingimage").hasLoaded? )
|
76
|
+
assert( $ie.image(:name, "circle").hasLoaded? )
|
174
77
|
|
175
|
-
|
176
|
-
|
78
|
+
assert( $ie.image(:alt, "circle").hasLoaded? )
|
79
|
+
assert( $ie.image(:alt, /cir/ ).hasLoaded? )
|
80
|
+
end
|
81
|
+
|
82
|
+
def test_image_properties
|
83
|
+
assert_raises(UnknownObjectException ) { $ie.image(:name, "no_image_with_this").hasLoaded? }
|
84
|
+
assert_raises(UnknownObjectException ) { $ie.image(:id, "no_image_with_this").hasLoaded? }
|
85
|
+
assert_raises(UnknownObjectException ) { $ie.image(:src, "no_image_with_this").hasLoaded? }
|
86
|
+
assert_raises(UnknownObjectException ) { $ie.image(:index, 82).hasLoaded? }
|
87
|
+
|
88
|
+
assert_raises(UnknownObjectException ) { $ie.image(:index, 82).name }
|
89
|
+
assert_raises(UnknownObjectException ) { $ie.image(:index, 82).id }
|
90
|
+
assert_raises(UnknownObjectException ) { $ie.image(:index, 82).src }
|
91
|
+
assert_raises(UnknownObjectException ) { $ie.image(:index, 82).value }
|
92
|
+
assert_raises(UnknownObjectException ) { $ie.image(:index, 82).height }
|
93
|
+
assert_raises(UnknownObjectException ) { $ie.image(:index, 82).width }
|
94
|
+
assert_raises(UnknownObjectException ) { $ie.image(:index, 82).fileCreatedDate }
|
95
|
+
assert_raises(UnknownObjectException ) { $ie.image(:index, 82).fileSize }
|
96
|
+
assert_raises(UnknownObjectException ) { $ie.image(:index, 82).alt}
|
97
|
+
assert_raises(UnknownObjectException ) { $ie.image(:index, 82).title}
|
98
|
+
|
99
|
+
assert_equal( "" , $ie.image(:index, 2).name )
|
100
|
+
assert_equal( "square" , $ie.image(:index, 2).id )
|
101
|
+
assert_match( /square\.jpg/i ,$ie.image(:index, 2).src )
|
102
|
+
assert_equal( "" , $ie.image(:index, 2).value )
|
103
|
+
assert_equal( "88" , $ie.image(:index, 2).height )
|
104
|
+
assert_equal( "88" , $ie.image(:index, 2).width )
|
105
|
+
|
106
|
+
# this line fails, as the date is when it is installed on the local oc, not the date the file was really created
|
107
|
+
#assert_equal( "03/10/2005" , $ie.image(:index, 2).fileCreatedDate )
|
108
|
+
assert_equal( "788", $ie.image(:index, 2).fileSize )
|
109
|
+
|
110
|
+
# tool tips: alt text + title
|
111
|
+
assert_equal('circle' , $ie.image(:index, 6).alt)
|
112
|
+
assert_equal( "" , $ie.image(:index, 2).alt)
|
113
|
+
assert_equal('square_image', $ie.image(:id, 'square').title)
|
114
|
+
|
115
|
+
# TODO: to string tests -- output should be verified!
|
116
|
+
$ie.image(:name , "circle").to_s
|
117
|
+
$ie.image(:index , 2).to_s
|
118
|
+
end
|
119
|
+
|
120
|
+
def test_image_iterator
|
121
|
+
assert_equal(6 , $ie.images.length)
|
122
|
+
assert_equal("" , $ie.images[2].name )
|
123
|
+
assert_equal("square", $ie.images[2].id )
|
124
|
+
assert_match(/square/, $ie.images[2].src )
|
125
|
+
|
126
|
+
index = 1
|
127
|
+
$ie.images.each do |i|
|
128
|
+
assert_equal( $ie.image(:index, index).id , i.id )
|
129
|
+
assert_equal( $ie.image(:index, index).name , i.name )
|
130
|
+
assert_equal( $ie.image(:index, index).src , i.src )
|
131
|
+
assert_equal( $ie.image(:index, index).height , i.height )
|
132
|
+
assert_equal( $ie.image(:index, index).width , i.width )
|
133
|
+
|
134
|
+
index+=1
|
177
135
|
end
|
136
|
+
assert_equal( index-1 , $ie.images.length )
|
137
|
+
end
|
138
|
+
|
139
|
+
def test_save_local_image
|
140
|
+
$ie.images[1].save(build_windows_path("sample.img.dat"))
|
141
|
+
assert(File.compare(@saved_img_path, $ie.images[1].src.gsub(/^file:\/\/\//, '')))
|
142
|
+
end
|
143
|
+
|
144
|
+
def clean_saved_image
|
145
|
+
File.delete(@saved_img_path) if (File.exists?(@saved_img_path))
|
146
|
+
end
|
147
|
+
|
148
|
+
def build_windows_path(part)
|
149
|
+
build_path(part).gsub(/\//, "\\")
|
150
|
+
end
|
151
|
+
|
152
|
+
def build_path(part)
|
153
|
+
"#{$myDir}/#{part}"
|
154
|
+
end
|
178
155
|
end
|
179
156
|
|
@@ -0,0 +1,91 @@
|
|
1
|
+
# feature tests for Images
|
2
|
+
# revision: $Revision: 962 $
|
3
|
+
|
4
|
+
$LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..') if $0 == __FILE__
|
5
|
+
require 'unittests/setup'
|
6
|
+
require 'ftools'
|
7
|
+
require 'webrick'
|
8
|
+
require 'watir/cookiemanager'
|
9
|
+
|
10
|
+
class TC_Images_XPath < Test::Unit::TestCase
|
11
|
+
include Watir
|
12
|
+
|
13
|
+
def setup
|
14
|
+
gotoImagePage
|
15
|
+
end
|
16
|
+
|
17
|
+
def gotoImagePage
|
18
|
+
$ie.goto($htmlRoot + "images1.html")
|
19
|
+
end
|
20
|
+
|
21
|
+
def test_imageExists
|
22
|
+
assert(! $ie.image(:xpath , "//img[@name='missing_name']/").exists? )
|
23
|
+
assert( $ie.image(:xpath , "//img[@name='circle']/").exists? )
|
24
|
+
# assert( $ie.image(:name , /circ/ ).exists? )
|
25
|
+
|
26
|
+
assert(! $ie.image(:xpath , "//img[@id='missing_id']/").exists? )
|
27
|
+
assert( $ie.image(:xpath , "//img[@id='square']/").exists? )
|
28
|
+
# assert( $ie.image(:id , /squ/ ).exists? )
|
29
|
+
|
30
|
+
assert(! $ie.image(:xpath , "//img[@src='missingsrc.gif']/").exists? )
|
31
|
+
|
32
|
+
# BP -- This fails for me but not for Paul. It doesn't make sense to me that it should pass.
|
33
|
+
# assert( $ie.image(:src , "file:///#{$myDir}/html/images/triangle.jpg").exists? )
|
34
|
+
# assert( $ie.image(:src , /triangle/ ).exists? )
|
35
|
+
|
36
|
+
assert( $ie.image(:alt , "circle" ).exists? )
|
37
|
+
# assert( $ie.image(:alt , /cir/ ).exists? )
|
38
|
+
|
39
|
+
assert(! $ie.image(:alt , "triangle" ).exists? )
|
40
|
+
# assert(! $ie.image(:alt , /tri/ ).exists? )
|
41
|
+
end
|
42
|
+
|
43
|
+
def test_image_click
|
44
|
+
assert_raises(UnknownObjectException ) { $ie.image(:xpath , "//img[@name='no_image_with_this']/").click }
|
45
|
+
assert_raises(UnknownObjectException ) { $ie.image(:xpath , "//img[@id='no_image_with_this']/").click }
|
46
|
+
assert_raises(UnknownObjectException ) { $ie.image(:xpath , "//img[@src='no_image_with_this']/").click}
|
47
|
+
assert_raises(UnknownObjectException ) { $ie.image(:xpath , "//img[@alt='no_image_with_this']/").click}
|
48
|
+
|
49
|
+
# test for bug 1882
|
50
|
+
$ie.text_field(:name , "text1").clear
|
51
|
+
$ie.button(:value , /Pos/ ).click
|
52
|
+
assert_equal('clicked' , $ie.text_field(:name , "text1" ).value )
|
53
|
+
|
54
|
+
# test for disabled button
|
55
|
+
# assert(! $ie.image(:name , 'disabler_test').disabled )
|
56
|
+
# $ie.button(:name , 'disable_img').click
|
57
|
+
|
58
|
+
# assert( $ie.image(:name , 'disabler_test').disabled )
|
59
|
+
# $ie.button(:name , 'disable_img').click
|
60
|
+
|
61
|
+
# $ie.image(:src, /button/).click
|
62
|
+
# assert($ie.text.include?("PASS") )
|
63
|
+
|
64
|
+
end
|
65
|
+
|
66
|
+
|
67
|
+
|
68
|
+
def test_imageHasLoaded
|
69
|
+
assert_raises(UnknownObjectException ) { $ie.image(:xpath , "//img[@name='no_image_with_this']/").hasLoaded? }
|
70
|
+
assert_raises(UnknownObjectException ) { $ie.image(:xpath , "//img[@id='no_image_with_this']/").hasLoaded? }
|
71
|
+
assert_raises(UnknownObjectException ) { $ie.image(:xpath , "//img[@src='no_image_with_this']/").hasLoaded? }
|
72
|
+
assert_raises(UnknownObjectException ) { $ie.image(:xpath , "//img[@alt='no_image_with_this']/").hasLoaded? }
|
73
|
+
|
74
|
+
assert(! $ie.image(:xpath , "//img[@name='themissingimage']/").hasLoaded? )
|
75
|
+
assert( $ie.image(:xpath , "//img[@name='circle']/").hasLoaded? )
|
76
|
+
|
77
|
+
assert( $ie.image(:xpath , "//img[@alt='circle']/").hasLoaded? )
|
78
|
+
# assert( $ie.image(:alt, /cir/ ).hasLoaded? )
|
79
|
+
end
|
80
|
+
|
81
|
+
def test_image_properties
|
82
|
+
assert_raises(UnknownObjectException ) { $ie.image(:xpath , "//img[@name='no_image_with_this']/").hasLoaded? }
|
83
|
+
assert_raises(UnknownObjectException ) { $ie.image(:xpath , "//img[@id='no_image_with_this']/").hasLoaded? }
|
84
|
+
assert_raises(UnknownObjectException ) { $ie.image(:xpath , "//img[@src='no_image_with_this']/").hasLoaded? }
|
85
|
+
|
86
|
+
# to string tests -- output should be verified!
|
87
|
+
puts $ie.image(:xpath , "//img[@name='circle']/").to_s
|
88
|
+
end
|
89
|
+
|
90
|
+
end
|
91
|
+
|