watir 1.4.1 → 1.5.2

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.
Files changed (151) hide show
  1. data/bin/watir-console +1 -0
  2. data/changes.rb +119 -0
  3. data/license.rb +37 -0
  4. data/readme.rb +55 -120
  5. data/unittests/buttons_test.rb +107 -104
  6. data/unittests/buttons_xpath_test.rb +69 -0
  7. data/unittests/checkbox_test.rb +154 -141
  8. data/unittests/checkbox_xpath_test.rb +107 -0
  9. data/unittests/core_tests.rb +6 -2
  10. data/unittests/css_test.rb +50 -50
  11. data/unittests/defer_test.rb +47 -0
  12. data/unittests/dialog_test.rb +78 -0
  13. data/unittests/div2_xpath_test.rb +22 -0
  14. data/unittests/div_test.rb +159 -159
  15. data/unittests/div_xpath_test.rb +96 -0
  16. data/unittests/errorchecker_test.rb +22 -22
  17. data/unittests/filefield_test.rb +30 -23
  18. data/unittests/filefield_xpath_test.rb +35 -0
  19. data/unittests/form_test.rb +250 -229
  20. data/unittests/form_xpath_test.rb +253 -0
  21. data/unittests/frame_test.rb +123 -108
  22. data/unittests/google_form_test.rb +17 -0
  23. data/unittests/html/JavascriptClick.html +39 -0
  24. data/unittests/html/buttons1.html +3 -2
  25. data/unittests/html/checkboxes1.html +32 -14
  26. data/unittests/html/complex_table.html +1 -1
  27. data/unittests/html/depot_store.html +59 -0
  28. data/unittests/html/div.html +3 -21
  29. data/unittests/html/div_xml.html +21 -0
  30. data/unittests/html/fileupload.html +2 -2
  31. data/unittests/html/forms2.html +3 -3
  32. data/unittests/html/forms3.html +2 -2
  33. data/unittests/html/frame_links.html +2 -2
  34. data/unittests/html/google_india.html +119 -0
  35. data/unittests/html/iframeTest.html +2 -2
  36. data/unittests/html/images/map.GIF +0 -0
  37. data/unittests/html/images/map2.gif +0 -0
  38. data/unittests/html/images1.html +17 -2
  39. data/unittests/html/javascriptevents.html +3 -7
  40. data/unittests/html/links1.html +9 -8
  41. data/unittests/html/links_multi.html +14 -0
  42. data/unittests/html/list_matters.html +720 -0
  43. data/unittests/html/lists.html +18 -0
  44. data/unittests/html/map_test.html +31 -0
  45. data/unittests/html/modal_dialog.html +10 -0
  46. data/unittests/html/modal_dialog_launcher.html +12 -0
  47. data/unittests/html/new_browser.html +17 -0
  48. data/unittests/html/pass.html +3 -0
  49. data/unittests/html/popups1.html +1 -1
  50. data/unittests/html/pre.html +28 -0
  51. data/unittests/html/radioButtons1.html +6 -5
  52. data/unittests/html/selectboxes1.html +12 -11
  53. data/unittests/html/simple_table.html +1 -1
  54. data/unittests/html/simple_table_columns.html +1 -1
  55. data/unittests/html/table1.html +1 -1
  56. data/unittests/html/tableCell_using_xpath.html +19 -0
  57. data/unittests/html/textfields1.html +6 -4
  58. data/unittests/html/xpath_nbsp.html +12 -0
  59. data/unittests/ie_exists_test.rb +32 -0
  60. data/unittests/ie_mock.rb +78 -79
  61. data/unittests/ie_test.rb +39 -39
  62. data/unittests/images_test.rb +132 -155
  63. data/unittests/images_xpath_test.rb +91 -0
  64. data/unittests/links_multi_test.rb +36 -0
  65. data/unittests/links_test.rb +158 -152
  66. data/unittests/links_xpath_test.rb +40 -0
  67. data/unittests/lists_test.rb +29 -0
  68. data/unittests/map_test.rb +99 -0
  69. data/unittests/minmax_test.rb +23 -23
  70. data/unittests/navigate_test.rb +43 -51
  71. data/unittests/nbsp_xpath_test.rb +18 -0
  72. data/unittests/other/WindowLogonExample.rb +28 -0
  73. data/unittests/{WindowLogonExtra.rb → other/WindowLogonExtra.rb} +0 -0
  74. data/unittests/{all_tests_concurrent.rb → other/all_tests_concurrent.rb} +23 -23
  75. data/unittests/other/navigate_exception_test.rb +14 -0
  76. data/unittests/other/rexml_unit_test.rb +24 -0
  77. data/unittests/other/testcase_method_order_test.rb +36 -0
  78. data/unittests/other/testcase_verify_test.rb +25 -0
  79. data/unittests/other/wait_until_test.rb +99 -0
  80. data/unittests/pagecontainstext_test.rb +56 -37
  81. data/unittests/parent_child_test.rb +55 -0
  82. data/unittests/popups_test.rb +37 -37
  83. data/unittests/pre_test.rb +52 -0
  84. data/unittests/radios_test.rb +186 -155
  85. data/unittests/radios_xpath_test.rb +101 -0
  86. data/unittests/screen_capture_test.rb +41 -41
  87. data/unittests/selectbox_test.rb +223 -181
  88. data/unittests/selectbox_xpath_test.rb +113 -0
  89. data/unittests/setup.rb +29 -25
  90. data/unittests/speed_settings_test.rb +22 -0
  91. data/unittests/table_cell_using_xpath_test.rb +40 -0
  92. data/unittests/table_test.rb +315 -284
  93. data/unittests/table_xpath_test.rb +114 -0
  94. data/unittests/textarea_test.rb +81 -0
  95. data/unittests/textarea_xpath_test.rb +82 -0
  96. data/unittests/textfields_test.rb +205 -229
  97. data/unittests/textfields_xpath_test.rb +111 -0
  98. data/unittests/window_tests.rb +7 -0
  99. data/unittests/windows/attach_to_existing_window_test.rb +52 -0
  100. data/unittests/windows/attach_to_new_window_test.rb +82 -0
  101. data/unittests/windows/close_window_test.rb +22 -0
  102. data/unittests/windows/frame_links_test.rb +25 -0
  103. data/unittests/windows/ie-each_test.rb +48 -0
  104. data/unittests/windows/iedialog_test.rb +55 -0
  105. data/unittests/windows/js_events_test.rb +57 -0
  106. data/unittests/windows/jscriptExtraAlert.rb +6 -0
  107. data/unittests/windows/jscriptExtraConfirmCancel.rb +7 -0
  108. data/unittests/windows/jscriptExtraConfirmOk.rb +7 -0
  109. data/unittests/{jscriptPushButton.rb → windows/jscriptPushButton.rb} +1 -1
  110. data/unittests/windows/jscript_test.rb +64 -0
  111. data/unittests/windows/modal_dialog_test.rb +127 -0
  112. data/unittests/windows/new.rb +56 -0
  113. data/unittests/windows/open_close_test.rb +22 -0
  114. data/unittests/windows/send_keys_test.rb +34 -0
  115. data/unittests/xpath_tests.rb +10 -0
  116. data/watir.rb +4344 -3565
  117. data/watir/IEDialog/Release/IEDialog.dll +0 -0
  118. data/watir/WindowHelper.rb +13 -11
  119. data/watir/assertions.rb +36 -0
  120. data/watir/camel_case.rb +14 -5
  121. data/watir/close_all.rb +38 -0
  122. data/watir/contrib/enabled_popup.rb +21 -0
  123. data/watir/contrib/ie-new-process.rb +27 -0
  124. data/watir/contrib/page_checker.rb +29 -0
  125. data/watir/contrib/visible.rb +47 -0
  126. data/watir/cookiemanager.rb +4 -4
  127. data/watir/datahandler.rb +107 -0
  128. data/watir/dialog.rb +46 -0
  129. data/watir/elements.rb +65 -0
  130. data/watir/exceptions.rb +18 -36
  131. data/watir/ie-process.rb +40 -0
  132. data/watir/irb-history.rb +31 -0
  133. data/watir/process.rb +20 -0
  134. data/watir/testUnitAddons.rb +3 -42
  135. data/watir/testcase.rb +58 -0
  136. data/watir/utils.rb +20 -0
  137. data/watir/waiter.rb +88 -0
  138. data/watir/watir_simple.rb +4 -4
  139. data/watir/win32ole.rb +8 -0
  140. data/watir/win32ole/win32ole.so +0 -0
  141. data/watir/winClicker.rb +374 -400
  142. metadata +209 -128
  143. data/unittests/WindowLogonExample.rb +0 -30
  144. data/unittests/attachToExistingWindow_test.rb +0 -40
  145. data/unittests/js_events_test.rb +0 -77
  146. data/unittests/jscriptExtraAlert.rb +0 -6
  147. data/unittests/jscriptExtraConfirmCancel.rb +0 -7
  148. data/unittests/jscriptExtraConfirmOk.rb +0 -7
  149. data/unittests/jscript_test.rb +0 -57
  150. data/unittests/send_keys_test.rb +0 -29
  151. data/unittests/textAreafields_test.rb +0 -81
@@ -1,49 +1,68 @@
1
1
  # feature tests for IE::contains_text
2
- # revision: $Revision: 1.3 $
2
+ # revision: $Revision: 1100 $
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_contains_text < Test::Unit::TestCase
8
- include Watir
9
-
10
- def setup
11
- $ie.goto($htmlRoot + "textsearch.html")
12
- end
13
-
14
- def test_text_found
15
- assert($ie.contains_text('slings and arrows of outrageous fortune'))
16
- end
17
-
18
- def test_text_not_found
19
- assert_false($ie.contains_text('So are they all, all honourable men'))
8
+ include Watir
9
+
10
+ def setup
11
+ $ie.goto($htmlRoot + "textsearch.html")
12
+ end
13
+
14
+ def test_text_found
15
+ assert($ie.contains_text('slings and arrows of outrageous fortune'))
16
+ end
17
+
18
+ def test_text_not_found
19
+ assert(!$ie.contains_text('So are they all, all honourable men'))
20
+ end
21
+
22
+ def test_regexp_found
23
+ assert($ie.contains_text(/bodkin.*fardels/))
24
+ end
25
+
26
+ def test_regexp_not_found
27
+ assert(!$ie.contains_text(/winding.*watch.*wit/))
28
+ end
29
+
30
+ def test_match_regexp_found
31
+ $~ = $ie.contains_text(/Messages ([0-9]+)/)
32
+ assert_equal('42', $1)
33
+ end
34
+
35
+ def test_bad_search_argument
36
+ assert_raises(ArgumentError) do
37
+ $ie.contains_text
20
38
  end
21
-
22
- def test_regexp_found
23
- assert($ie.contains_text(/bodkin.*fardels/))
39
+ assert_raises(ArgumentError) do
40
+ $ie.contains_text(nil)
24
41
  end
25
-
26
- def test_regexp_not_found
27
- assert_false($ie.contains_text(/winding.*watch.*wit/))
28
- end
29
-
30
- def test_match_regexp_found
31
- $~ = $ie.contains_text(/Messages ([0-9]+)/)
32
- assert_equal('42', $1)
42
+ assert_raises(ArgumentError) do
43
+ $ie.contains_text(42)
33
44
  end
45
+ end
46
+
47
+ end
34
48
 
35
- def test_bad_search_argument
36
- assert_raises(ArgumentError) do
37
- $ie.contains_text()
38
- end
39
- assert_raises(MissingWayOfFindingObjectException) do
40
- $ie.contains_text(nil)
41
- end
42
- assert_raises(MissingWayOfFindingObjectException) do
43
- $ie.contains_text(42)
44
- end
45
- end
46
-
49
+ class TC_contains_text_in_new_ie < Test::Unit::TestCase
50
+ def setup
51
+ @ie = Watir::IE.new
52
+ end
53
+ def test_nothing_raised
54
+ assert_nothing_raised {@ie.contains_text ''}
55
+ end
56
+ def teardown
57
+ @ie.close
58
+ end
47
59
  end
48
60
 
49
-
61
+ class TC_contains_text_in_frame < Test::Unit::TestCase
62
+ def setup
63
+ $ie.goto($htmlRoot + "frame_links.html")
64
+ end
65
+ def test_in_frame
66
+ assert $ie.frame('linkFrame').contains_text('The button is really a link')
67
+ end
68
+ end
@@ -0,0 +1,55 @@
1
+ # feature tests for relative navigation/specification
2
+
3
+ $LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..') if $0 == __FILE__
4
+ require 'unittests/setup'
5
+
6
+ # These tests are based on the rails depot application, which requires some
7
+ # modifications...
8
+
9
+ module Watir
10
+ class H3 < NonControlElement
11
+ TAG = 'h3'
12
+ end
13
+ module Container
14
+ def h3(how, what)
15
+ return H3.new(self, how, what)
16
+ end
17
+ end
18
+ end
19
+
20
+
21
+ class TC_Relative < Test::Unit::TestCase
22
+
23
+ def setup
24
+ $ie.goto($htmlRoot + "depot_store.html")
25
+ @headline = $ie.h3(:text, 'Pragmatic Version Control')
26
+ end
27
+
28
+ def test_parent
29
+ catalog_entry = @headline.parent
30
+ link = catalog_entry.link(:class, 'addtocart')
31
+ assert_equal 'http://localhost:3000/store/add_to_cart/12', link.href
32
+ assert_nothing_raised{link.click}
33
+ end
34
+
35
+ def test_parent_page_container
36
+ catalog_entry = @headline.parent
37
+ assert_not_nil catalog_entry.page_container
38
+ end
39
+
40
+ def test_before_and_after
41
+ link = $ie.link(:class => 'addtocart', :index => 2)
42
+ assert_equal 'http://localhost:3000/store/add_to_cart/12', link.href
43
+ assert(link.after?(@headline))
44
+ assert(@headline.before?(link))
45
+ assert !(link.before? @headline)
46
+ assert !(@headline.after? link)
47
+ assert !(link.after? link)
48
+ end
49
+
50
+ def test_find_after
51
+ link = $ie.link(:class => 'addtocart', :after? => @headline)
52
+ assert_equal 'http://localhost:3000/store/add_to_cart/12', link.href
53
+ end
54
+
55
+ end
@@ -1,44 +1,44 @@
1
- # feature tests for javascript PopUps
2
- # revision: $Revision: 1.13 $
1
+
2
+ # revision: $Revision: 958 $
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_PopUps < Test::Unit::TestCase
8
- include Watir
9
-
10
- def setup
11
- $ie.goto("file://#{$myDir}/html/popups1.html")
12
- end
13
-
14
- def startClicker( button , waitTime = 0.5)
15
- w = WinClicker.new
16
- longName = $ie.dir.gsub("/" , "\\" )
17
- shortName = w.getShortFileName(longName)
18
- c = "start rubyw #{shortName }\\watir\\clickJSDialog.rb #{button } #{ waitTime} "
19
- puts "Starting #{c}"
20
- w.winsystem(c )
21
- w=nil
22
- end
23
-
24
- def test_simple
25
- startClicker("OK")
26
- $ie.button("Alert").click
27
- end
28
-
29
- def test_confirm
30
- startClicker("OK")
31
- $ie.button("Confirm").click
32
- assert( $ie.text_field(:name , "confirmtext").verify_contains("OK") )
33
-
34
- startClicker("Cancel")
35
- $ie.button("Confirm").click
36
- assert( $ie.text_field(:name , "confirmtext").verify_contains("Cancel") )
37
- end
38
-
39
- def xtest_Prompt
40
- startClicker("OK")
41
- $ie.button("Prompt").click
42
- end
8
+ include Watir
9
+
10
+ def setup
11
+ $ie.goto("file://#{$myDir}/html/popups1.html")
12
+ end
13
+
14
+ def startClicker( button , waitTime = 0.5)
15
+ w = WinClicker.new
16
+ longName = $ie.dir.gsub("/" , "\\" )
17
+ shortName = w.getShortFileName(longName)
18
+ c = "start rubyw #{shortName }\\watir\\clickJSDialog.rb #{button } #{ waitTime} "
19
+ puts "Starting #{c}"
20
+ w.winsystem(c )
21
+ w=nil
22
+ end
23
+
24
+ def test_simple
25
+ startClicker("OK")
26
+ $ie.button("Alert").click
27
+ end
28
+
29
+ def test_confirm
30
+ startClicker("OK")
31
+ $ie.button("Confirm").click
32
+ assert( $ie.text_field(:name , "confirmtext").verify_contains("OK") )
33
+
34
+ startClicker("Cancel")
35
+ $ie.button("Confirm").click
36
+ assert( $ie.text_field(:name , "confirmtext").verify_contains("Cancel") )
37
+ end
38
+
39
+ def xtest_Prompt
40
+ startClicker("OK")
41
+ $ie.button("Prompt").click
42
+ end
43
43
  end
44
44
 
@@ -0,0 +1,52 @@
1
+ # feature tests for Pre
2
+ # revision: $Revision: 962 $
3
+
4
+ $LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..') if $0 == __FILE__
5
+ require 'unittests/setup'
6
+
7
+ class TC_Pre < Test::Unit::TestCase
8
+ include Watir
9
+
10
+ def setup
11
+ $ie.goto($htmlRoot + "pre.html")
12
+ end
13
+
14
+ def test_Pre_Count
15
+ assert( $ie.pres.length == 3 )
16
+ end
17
+
18
+ def test_Pre_Exists
19
+ assert(! $ie.pre( :id, 'missingPre' ).exists? )
20
+ assert(! $ie.pre( :index, 33 ).exists? )
21
+
22
+ assert( $ie.pre( :id, '1' ).exists? )
23
+ assert( $ie.pre( :id, /[3-9]/ ).exists? )
24
+
25
+ assert(! $ie.pre( :id, /missing_pre/ ).exists? )
26
+
27
+ assert( $ie.pre( :index, 1 ).exists? )
28
+ assert( $ie.pre( :index, 2 ).exists? )
29
+ assert( $ie.pre( :index, 3 ).exists? )
30
+
31
+ assert( $ie.pre( :name, '3' ).exists? )
32
+ assert(! $ie.pre( :name, "name_missing" ).exists? )
33
+ end
34
+
35
+ def test_simple_access
36
+ pre = $ie.pre( :index, 1 )
37
+ assert( pre.text.include?( "simple pre space" ) )
38
+ assert(! pre.text.include?( "A second block" ) )
39
+
40
+ assert( pre.html.include?( "id=1 name=\"1\"" ) )
41
+
42
+ pre = $ie.pre( :index, 2 )
43
+ assert( pre.text.include?( "A second block" ) )
44
+ assert(! pre.text.include?( "this is the last block" ) )
45
+
46
+ pre = $ie.pre( :index, 3 )
47
+ assert( pre.text.include?( "continue to work" ) )
48
+ assert(! pre.text.include?( "Pre Tag Test" ) )
49
+
50
+ end
51
+
52
+ end
@@ -1,164 +1,195 @@
1
1
  # feature tests for Radio Buttons
2
- # revision: $Revision: 1.25 $
2
+ # revision: $Revision: 1164 $
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_Radios < Test::Unit::TestCase
8
- include Watir
9
-
10
- def setup()
11
- $ie.goto($htmlRoot + "radioButtons1.html")
12
- end
13
-
14
- def test_Radio_Exists
15
- assert($ie.radio(:name, "box1").exists?)
16
- assert($ie.radio(:id, "box5").exists?)
17
-
18
- assert_false($ie.radio(:name, "missingname").exists?)
19
- assert_false($ie.radio(:id, "missingid").exists?)
20
- end
21
-
22
- def test_Radio_Enabled
23
- assert_raises(UnknownObjectException , "UnknownObjectException was supposed to be thrown" ) { $ie.radio(:name, "noName").enabled? }
24
- assert_raises(UnknownObjectException , "UnknownObjectException was supposed to be thrown" ) { $ie.radio(:id, "noName").enabled? }
25
- assert_raises(UnknownObjectException , "UnknownObjectException was supposed to be thrown" ) { $ie.radio(:name, "box4" , 6).enabled? }
26
-
27
- assert_false($ie.radio(:name, "box2").enabled?)
28
- assert($ie.radio(:id, "box5").enabled?)
29
- assert($ie.radio(:name, "box1").enabled?)
30
- end
31
-
32
- def test_little
33
- assert_false($ie.button(:value , "foo").enabled?)
34
- end
35
-
36
- def test_onClick
37
-
38
- assert_false($ie.radio(:name, "box5").isSet?)
39
- assert_false($ie.button(:value , "foo").enabled?)
40
-
41
- # first click the button is enabled and the radio is set
42
- $ie.radio(:name, "box5" , 1).set
43
- assert($ie.radio(:name, "box5",1).isSet?)
44
- assert($ie.button(:value , "foo").enabled?)
45
-
46
- # second click the button is disabled and the radio is still set
47
- $ie.radio(:name, "box5", 1).set
48
- assert($ie.radio(:name, "box5",1).isSet?)
49
- assert_false($ie.button(:value , "foo").enabled?)
50
-
51
- # third click the button is enabled and the radio is still set
52
- $ie.radio(:name, "box5", 1).set
53
- assert($ie.radio(:name, "box5",1 ).isSet?)
54
- assert($ie.button(:value , "foo").enabled?)
55
-
56
- # click the radio with a value of 2 , button is disabled and the radio is still set
57
- $ie.radio(:name, "box5", 2).set
58
- assert_false($ie.radio(:name, "box5" ,1).isSet?)
59
- assert($ie.radio(:name, "box5" ,2).isSet?)
60
- assert_false($ie.button(:value , "foo").enabled?)
61
-
62
-
63
-
64
-
65
- end
66
-
67
- def test_Radio_isSet
68
- assert_raises(UnknownObjectException , "UnknownObjectException was supposed to be thrown" ) { $ie.radio(:name, "noName").isSet? }
69
-
70
- assert_false($ie.radio(:name, "box1").isSet?)
71
- assert( $ie.radio(:name, "box3").isSet?)
72
- assert_false($ie.radio(:name, "box2").isSet?)
73
- assert( $ie.radio(:name, "box4" , 1 ).isSet?)
74
- assert_false($ie.radio(:name, "box4" , 2 ).isSet?)
75
- end
76
-
77
- def test_radio_clear
78
- assert_raises(UnknownObjectException , "UnknownObjectException was supposed to be thrown" ) { $ie.radio(:name, "noName").clear }
79
-
80
- $ie.radio(:name, "box1").clear
81
- assert_false($ie.radio(:name, "box1").isSet?)
82
-
83
- assert_raises(ObjectDisabledException, "ObjectDisabledException was supposed to be thrown" ) { $ie.radio(:name, "box2").clear }
84
- assert_false($ie.radio(:name, "box2").isSet?)
85
-
86
- $ie.radio(:name, "box3").clear
87
- assert_false($ie.radio(:name, "box3").isSet?)
88
-
89
- $ie.radio(:name, "box4" , 1).clear
90
- assert_false($ie.radio(:name, "box4" , 1).isSet?)
91
- end
92
-
93
- def test_radio_getState
94
- assert_raises(UnknownObjectException , "UnknownObjectException was supposed to be thrown" ) { $ie.radio(:name, "noName").getState }
95
-
96
- assert_equal( false , $ie.radio(:name, "box1").getState )
97
- assert_equal( true , $ie.radio(:name, "box3").getState)
98
-
99
- # radioes that have the same name but different values
100
- assert_equal( false , $ie.radio(:name, "box4" , 2).getState )
101
- assert_equal( true , $ie.radio(:name, "box4" , 1).getState)
102
- end
103
-
104
- def test_radio_set
105
- assert_raises(UnknownObjectException , "UnknownObjectException was supposed to be thrown" ) { $ie.radio(:name, "noName").set }
106
- $ie.radio(:name, "box1").set
107
- assert($ie.radio(:name, "box1").isSet?)
108
-
109
- assert_raises(ObjectDisabledException, "ObjectDisabledException was supposed to be thrown" ) { $ie.radio(:name, "box2").set }
110
-
111
- $ie.radio(:name, "box3").set
112
- assert($ie.radio(:name, "box3").isSet?)
113
-
114
- # radioes that have the same name but different values
115
- $ie.radio(:name, "box4" , 3).set
116
- assert($ie.radio(:name, "box4" , 3).isSet?)
117
- end
118
-
119
- def test_radio_properties
120
-
121
- assert_raises(UnknownObjectException , "UnknownObjectException was supposed to be thrown" ) { $ie.radio(:index, 199).value}
122
- assert_raises(UnknownObjectException , "UnknownObjectException was supposed to be thrown" ) { $ie.radio(:index, 199).name }
123
- assert_raises(UnknownObjectException , "UnknownObjectException was supposed to be thrown" ) { $ie.radio(:index, 199).id }
124
- assert_raises(UnknownObjectException , "UnknownObjectException was supposed to be thrown" ) { $ie.radio(:index, 199).disabled }
125
- assert_raises(UnknownObjectException , "UnknownObjectException was supposed to be thrown" ) { $ie.radio(:index, 199).type }
126
-
127
- assert_equal("on" , $ie.radio(:index, 1).value)
128
- assert_equal("box1" , $ie.radio(:index, 1).name )
129
- assert_equal("" , $ie.radio(:index, 1).id )
130
- assert_equal("radio", $ie.radio(:index, 1).type )
131
-
132
- assert_equal( false, $ie.radio(:index, 1).disabled )
133
- assert_equal( true, $ie.radio(:index, 3).disabled )
134
-
135
- assert_equal("box5" , $ie.radio(:index, 2).id )
136
- assert_equal("" , $ie.radio(:index, 2).name )
137
-
138
- assert_equal("box4-value5", $ie.radio(:name , "box4" , 5 ).title )
139
- assert_equal("", $ie.radio(:name , "box4" , 4 ).title )
140
-
141
-
8
+ include Watir
9
+
10
+ def setup
11
+ $ie.goto($htmlRoot + "radioButtons1.html")
12
+ end
13
+
14
+ def test_Radio_Exists
15
+ assert($ie.radio(:name, "box1").exists?)
16
+ assert($ie.radio(:id, "box5").exists?)
17
+
18
+ assert(!$ie.radio(:name, "missingname").exists?)
19
+ assert(!$ie.radio(:id, "missingid").exists?)
20
+ end
21
+
22
+ def test_radio_class
23
+ assert_raises(UnknownObjectException , "UnknownObjectException was supposed to be thrown" ) { $ie.radio(:name, "noName").class_name }
24
+ assert_equal("radio_style" , $ie.radio(:name, "box1").class_name)
25
+ assert_equal("" , $ie.radio(:id, "box5").class_name)
26
+
27
+
28
+
29
+ end
30
+
31
+ def test_Radio_Enabled
32
+ assert_raises(UnknownObjectException , "UnknownObjectException was supposed to be thrown" ) { $ie.radio(:name, "noName").enabled? }
33
+ assert_raises(UnknownObjectException , "UnknownObjectException was supposed to be thrown" ) { $ie.radio(:id, "noName").enabled? }
34
+ assert_raises(UnknownObjectException , "UnknownObjectException was supposed to be thrown" ) { $ie.radio(:name, "box4" , 6).enabled? }
35
+
36
+ assert(!$ie.radio(:name, "box2").enabled?)
37
+ assert($ie.radio(:id, "box5").enabled?)
38
+ assert($ie.radio(:name, "box1").enabled?)
39
+ end
40
+
41
+ def test_little
42
+ assert(!$ie.button(:value , "foo").enabled?)
43
+ end
44
+
45
+ def test_onClick
46
+
47
+ assert(!$ie.radio(:name, "box5").isSet?)
48
+ assert(!$ie.button(:value , "foo").enabled?)
49
+
50
+ # first click the button is enabled and the radio is set
51
+ $ie.radio(:name, "box5" , 1).set
52
+ assert($ie.radio(:name, "box5",1).isSet?)
53
+ assert($ie.radio(:name, "box5",1).checked?)
54
+ assert($ie.button(:value , "foo").enabled?)
55
+
56
+ # second click the button is disabled and the radio is still set
57
+ $ie.radio(:name, "box5", 1).set
58
+ assert($ie.radio(:name, "box5",1).isSet?)
59
+ assert($ie.radio(:name, "box5",1).checked?)
60
+ assert(!$ie.button(:value , "foo").enabled?)
61
+
62
+ # third click the button is enabled and the radio is still set
63
+ $ie.radio(:name, "box5", 1).set
64
+ assert($ie.radio(:name, "box5",1 ).isSet?)
65
+ assert($ie.radio(:name, "box5",1 ).checked?)
66
+ assert($ie.button(:value , "foo").enabled?)
67
+
68
+ # click the radio with a value of 2 , button is disabled and the radio is still set
69
+ $ie.radio(:name, "box5", 2).set
70
+ assert(!$ie.radio(:name, "box5" ,1).isSet?)
71
+ assert(!$ie.radio(:name, "box5" ,1).checked?)
72
+ assert($ie.radio(:name, "box5" ,2).isSet?)
73
+ assert($ie.radio(:name, "box5" ,2).checked?)
74
+ assert(!$ie.button(:value , "foo").enabled?)
75
+ end
76
+
77
+ def test_Radio_isSet
78
+ assert_raises(UnknownObjectException , "UnknownObjectException was supposed to be thrown" ) { $ie.radio(:name, "noName").isSet? }
79
+
80
+ assert(!$ie.radio(:name, "box1").isSet?)
81
+ assert( $ie.radio(:name, "box3").isSet?)
82
+ assert(!$ie.radio(:name, "box2").isSet?)
83
+ assert( $ie.radio(:name, "box4" , 1 ).isSet?)
84
+ assert(!$ie.radio(:name, "box4" , 2 ).isSet?)
85
+
86
+ assert(!$ie.radio(:name, "box1").checked?)
87
+ assert( $ie.radio(:name, "box3").checked?)
88
+ assert(!$ie.radio(:name, "box2").checked?)
89
+ assert( $ie.radio(:name, "box4" , 1 ).checked?)
90
+ assert(!$ie.radio(:name, "box4" , 2 ).checked?)
91
+ end
92
+
93
+ def test_radio_clear
94
+ assert_raises(UnknownObjectException , "UnknownObjectException was supposed to be thrown" ) { $ie.radio(:name, "noName").clear }
95
+
96
+ $ie.radio(:name, "box1").clear
97
+ assert(!$ie.radio(:name, "box1").isSet?)
98
+
99
+ assert_raises(ObjectDisabledException, "ObjectDisabledException was supposed to be thrown" ) { $ie.radio(:name, "box2").clear }
100
+ assert(!$ie.radio(:name, "box2").isSet?)
101
+
102
+ $ie.radio(:name, "box3").clear
103
+ assert(!$ie.radio(:name, "box3").isSet?)
104
+
105
+ $ie.radio(:name, "box4" , 1).clear
106
+ assert(!$ie.radio(:name, "box4" , 1).isSet?)
107
+ end
108
+
109
+ def test_radio_getState
110
+ assert_raises(UnknownObjectException , "UnknownObjectException was supposed to be thrown" ) { $ie.radio(:name, "noName").getState }
111
+
112
+ assert_equal( false , $ie.radio(:name, "box1").getState )
113
+ assert_equal( true , $ie.radio(:name, "box3").getState)
114
+
115
+ # radioes that have the same name but different values
116
+ assert_equal( false , $ie.radio(:name, "box4" , 2).getState )
117
+ assert_equal( true , $ie.radio(:name, "box4" , 1).getState)
118
+ end
119
+
120
+ def test_radio_set
121
+ assert_raises(UnknownObjectException , "UnknownObjectException was supposed to be thrown" ) { $ie.radio(:name, "noName").set }
122
+ $ie.radio(:name, "box1").set
123
+ assert($ie.radio(:name, "box1").isSet?)
124
+
125
+ assert_raises(ObjectDisabledException, "ObjectDisabledException was supposed to be thrown" ) { $ie.radio(:name, "box2").set }
126
+
127
+ $ie.radio(:name, "box3").set
128
+ assert($ie.radio(:name, "box3").isSet?)
129
+
130
+ # radioes that have the same name but different values
131
+ $ie.radio(:name, "box4" , 3).set
132
+ assert($ie.radio(:name, "box4" , 3).isSet?)
133
+ end
134
+
135
+ def test_radio_properties
136
+
137
+ assert_raises(UnknownObjectException , "UnknownObjectException was supposed to be thrown" ) { $ie.radio(:index, 199).value}
138
+ assert_raises(UnknownObjectException , "UnknownObjectException was supposed to be thrown" ) { $ie.radio(:index, 199).name }
139
+ assert_raises(UnknownObjectException , "UnknownObjectException was supposed to be thrown" ) { $ie.radio(:index, 199).id }
140
+ assert_raises(UnknownObjectException , "UnknownObjectException was supposed to be thrown" ) { $ie.radio(:index, 199).disabled }
141
+ assert_raises(UnknownObjectException , "UnknownObjectException was supposed to be thrown" ) { $ie.radio(:index, 199).type }
142
+
143
+ assert_equal("on" , $ie.radio(:index, 1).value)
144
+ assert_equal("box1" , $ie.radio(:index, 1).name )
145
+ assert_equal("" , $ie.radio(:index, 1).id )
146
+ assert_equal("radio", $ie.radio(:index, 1).type )
147
+
148
+ assert_equal( false, $ie.radio(:index, 1).disabled )
149
+ assert_equal( true, $ie.radio(:index, 3).disabled )
150
+
151
+ assert_equal("box5" , $ie.radio(:index, 2).id )
152
+ assert_equal("" , $ie.radio(:index, 2).name )
153
+
154
+ assert_equal("box4-value5", $ie.radio(:name , "box4" , 5 ).title )
155
+ assert_equal("", $ie.radio(:name , "box4" , 4 ).title )
156
+
157
+
158
+ end
159
+
160
+ def test_radio_iterators
161
+
162
+ assert_equal(13, $ie.radios.length)
163
+ assert_equal("box5" , $ie.radios[2].id )
164
+ assert_equal(true , $ie.radios[3].disabled )
165
+ assert_equal(false , $ie.radios[1].disabled )
166
+
167
+ index = 1
168
+ $ie.radios.each do |r|
169
+ assert_equal( $ie.radio(:index, index).name , r.name )
170
+ assert_equal( $ie.radio(:index, index).id , r.id )
171
+ assert_equal( $ie.radio(:index, index).value, r.value)
172
+ assert_equal( $ie.radio(:index, index).disabled , r.disabled )
173
+ index+=1
142
174
  end
143
-
144
- def test_radio_iterators
145
-
146
- assert_equal(11, $ie.radios.length)
147
- assert_equal("box5" , $ie.radios[2].id )
148
- assert_equal(true , $ie.radios[3].disabled )
149
- assert_equal(false , $ie.radios[1].disabled )
150
-
151
- index = 1
152
- $ie.radios.each do |r|
153
- assert_equal( $ie.radio(:index, index).name , r.name )
154
- assert_equal( $ie.radio(:index, index).id , r.id )
155
- assert_equal( $ie.radio(:index, index).value, r.value)
156
- assert_equal( $ie.radio(:index, index).disabled , r.disabled )
157
- index+=1
158
- end
159
- assert_equal(index -1, $ie.radios.length)
160
- end
161
-
162
-
175
+ assert_equal(index -1, $ie.radios.length)
176
+ end
177
+
178
+ # test radio buttons that have a string as a value
179
+ def test_value_string
180
+ assert($ie.radio(:name, 'box6', 'Tea').exists?)
181
+ assert($ie.radio(:name, 'box6', 'Milk').exists?)
182
+ $ie.radio(:name, "box6" , 'Milk').set
183
+ assert($ie.radio(:name, "box6" , 'Milk').isSet?)
184
+ assert(!$ie.radio(:name, "box6" , 'Tea').isSet?)
185
+
186
+ $ie.radio(:name, "box6" , 'Tea').set
187
+ assert(!$ie.radio(:name, "box6" , 'Milk').isSet?)
188
+ assert($ie.radio(:name, "box6" , 'Tea').isSet?)
189
+ $ie.radio(:name, "box6", 'Tea').clear
190
+ assert(!$ie.radio(:name, "box6" , 'Tea').isSet?)
191
+ end
192
+
193
+
163
194
  end
164
195