firewatir 1.6.5 → 1.6.6.rc1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (112) hide show
  1. data/CHANGES +461 -0
  2. data/LICENSE +31 -31
  3. data/README.rdoc +112 -0
  4. data/VERSION +1 -0
  5. data/lib/firewatir.rb +41 -40
  6. data/lib/firewatir/container.rb +491 -491
  7. data/lib/firewatir/document.rb +239 -239
  8. data/lib/firewatir/element.rb +1364 -1364
  9. data/lib/firewatir/element_collections.rb +314 -314
  10. data/lib/firewatir/elements/button.rb +15 -15
  11. data/lib/firewatir/elements/file_field.rb +29 -29
  12. data/lib/firewatir/elements/form.rb +40 -40
  13. data/lib/firewatir/elements/frame.rb +55 -55
  14. data/lib/firewatir/elements/hidden.rb +56 -56
  15. data/lib/firewatir/elements/image.rb +139 -139
  16. data/lib/firewatir/elements/input_element.rb +44 -44
  17. data/lib/firewatir/elements/link.rb +76 -76
  18. data/lib/firewatir/elements/non_control_element.rb +53 -53
  19. data/lib/firewatir/elements/non_control_elements.rb +108 -108
  20. data/lib/firewatir/elements/not_used.rb +278 -278
  21. data/lib/firewatir/elements/option.rb +130 -130
  22. data/lib/firewatir/elements/radio_check_common.rb +163 -163
  23. data/lib/firewatir/elements/select_list.rb +188 -188
  24. data/lib/firewatir/elements/table.rb +218 -218
  25. data/lib/firewatir/elements/table_cell.rb +54 -54
  26. data/lib/firewatir/elements/table_row.rb +100 -100
  27. data/lib/firewatir/elements/text_field.rb +218 -218
  28. data/lib/firewatir/exceptions.rb +10 -10
  29. data/lib/firewatir/firefox.rb +984 -1040
  30. data/lib/firewatir/jssh_socket.rb +100 -100
  31. data/lib/firewatir/winClicker.rb +122 -122
  32. data/lib/firewatir/x11.rb +192 -192
  33. data/rakefile.rb +15 -0
  34. data/unittests/attach_to_new_window_test.rb +49 -49
  35. data/unittests/bug_fixes_test.rb +195 -195
  36. data/unittests/buttons_xpath_test.rb +88 -88
  37. data/unittests/checkbox_test.rb +158 -158
  38. data/unittests/checkbox_xpath_test.rb +107 -107
  39. data/unittests/div_test.rb +275 -275
  40. data/unittests/ff_test.rb +47 -0
  41. data/unittests/filefield_test.rb +49 -49
  42. data/unittests/filefield_xpath_test.rb +35 -35
  43. data/unittests/form_test.rb +296 -296
  44. data/unittests/frame_test.rb +159 -159
  45. data/unittests/hidden_test.rb +85 -85
  46. data/unittests/hidden_xpath_test.rb +72 -72
  47. data/unittests/html/JavascriptClick.html +42 -42
  48. data/unittests/html/blankpage.html +11 -11
  49. data/unittests/html/buttons1.html +61 -61
  50. data/unittests/html/checkboxes1.html +70 -70
  51. data/unittests/html/complex_table.html +36 -36
  52. data/unittests/html/cssTest.html +42 -42
  53. data/unittests/html/div.html +72 -72
  54. data/unittests/html/div_xml.html +20 -20
  55. data/unittests/html/fileupload.html +45 -45
  56. data/unittests/html/formTest1.html +38 -38
  57. data/unittests/html/forms2.html +45 -45
  58. data/unittests/html/forms3.html +132 -132
  59. data/unittests/html/forms4.html +27 -27
  60. data/unittests/html/frame_buttons.html +3 -3
  61. data/unittests/html/frame_links.html +3 -3
  62. data/unittests/html/frame_multi.html +4 -4
  63. data/unittests/html/iframeTest.html +14 -14
  64. data/unittests/html/iframeTest1.html +13 -13
  65. data/unittests/html/iframeTest2.html +5 -5
  66. data/unittests/html/images1.html +66 -66
  67. data/unittests/html/javascriptevents.html +35 -35
  68. data/unittests/html/link_pass.html +10 -10
  69. data/unittests/html/links1.html +42 -42
  70. data/unittests/html/links2.html +10 -10
  71. data/unittests/html/modal_dialog.html +8 -8
  72. data/unittests/html/modal_dialog_launcher.html +11 -11
  73. data/unittests/html/nestedFrames.html +6 -6
  74. data/unittests/html/new_browser.html +17 -17
  75. data/unittests/html/new_browser_popup.html +7 -7
  76. data/unittests/html/pass.html +9 -9
  77. data/unittests/html/popups1.html +60 -60
  78. data/unittests/html/pre.html +27 -27
  79. data/unittests/html/radioButtons1.html +70 -70
  80. data/unittests/html/redirect.html +10 -10
  81. data/unittests/html/redirect1.html +8 -8
  82. data/unittests/html/redirect2.html +8 -8
  83. data/unittests/html/redirect3.html +8 -8
  84. data/unittests/html/select_tealeaf.html +54 -54
  85. data/unittests/html/selectboxes1.html +55 -55
  86. data/unittests/html/simple_table.html +26 -26
  87. data/unittests/html/simple_table_buttons.html +104 -104
  88. data/unittests/html/simple_table_columns.html +74 -74
  89. data/unittests/html/table1.html +165 -165
  90. data/unittests/html/tableCell_using_xpath.html +19 -19
  91. data/unittests/html/textarea.html +30 -30
  92. data/unittests/html/textfields1.html +62 -62
  93. data/unittests/html/textsearch.html +44 -44
  94. data/unittests/images_test.rb +198 -198
  95. data/unittests/images_xpath_test.rb +118 -118
  96. data/unittests/javascript_test.rb +75 -75
  97. data/unittests/links_test.rb +231 -231
  98. data/unittests/links_xpath_test.rb +79 -79
  99. data/unittests/mozilla_all_tests.rb +7 -7
  100. data/unittests/pre_test.rb +75 -75
  101. data/unittests/radios_test.rb +166 -166
  102. data/unittests/radios_xpath_test.rb +101 -101
  103. data/unittests/redirect_test.rb +41 -41
  104. data/unittests/selectbox_test.rb +142 -142
  105. data/unittests/selectbox_xpath_test.rb +129 -129
  106. data/unittests/setup.rb +29 -29
  107. data/unittests/table_test.rb +385 -385
  108. data/unittests/table_xpath_test.rb +185 -185
  109. data/unittests/textfields_test.rb +234 -234
  110. data/unittests/textfields_xpath_test.rb +113 -113
  111. metadata +51 -19
  112. data/lib/firewatir/version.rb +0 -5
@@ -1,79 +1,79 @@
1
- # feature tests for Links
2
- # revision: $Revision: 1.0 $
3
-
4
- $LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..') unless $SETUP_LOADED
5
- require 'unittests/setup'
6
-
7
- class TC_Links_XPath < Test::Unit::TestCase
8
-
9
- def setup()
10
- goto_page("links1.html")
11
- end
12
-
13
- def xtest_new_link_exists
14
- assert(exists?{browser.link(:xpath , "//a[contains(.,'test1')]")})
15
- assert(exists?{browser.link(:xpath, "//a[contains(., /TEST/i)]")})
16
- assert_false(exists?{browser.link(:xpath , "//a[contains(.,'missing')]")})
17
- assert_false(exists?{browser.link(:xpath, "//a[contains(., /miss/)]")})
18
- end
19
-
20
- tag_method :test_element_by_xpath_class, :fails_on_ie
21
- def test_element_by_xpath_class
22
- # TODO: If element is not present this should return null
23
- #element = browser.element_by_xpath("//a[contains(., /miss/)]")
24
- #assert(element.instance_of?(Link),"element class should be #{Link}; got #{element.class}")
25
- #element = browser.element_by_xpath("//a[contains(.,'missing')]")
26
- #assert(element.instance_of?(Link),"element class should be #{Link}; got #{element.class}")
27
- element = browser.element_by_xpath("//a[contains(., /TEST/i)]")
28
- assert_class(element, 'Link')
29
- element = browser.element_by_xpath("//a[contains(.,'test1')]")
30
- assert_class(element, 'Link')
31
- end
32
-
33
- def test_element_by_xpath_behavior
34
- # TODO implement this, acquiring objects through element_by_xpath and
35
- # then testing their properties to see if they behave normally, as if
36
- # they had been created with browser.link
37
- end
38
-
39
- def test_Link_Exists
40
- assert(browser.link(:xpath , "//a[contains(.,'test1')]").exists?)
41
- assert(browser.link(:xpath, "//a[contains(., /TEST/i)]").exists?)
42
- assert_false(browser.link(:xpath , "//a[contains(.,'missing')]").exists?)
43
-
44
- assert_false(browser.link(:xpath , "//a[@url='alsomissing.html']").exists?)
45
-
46
- assert(browser.link(:xpath , "//a[@id='link_id']").exists?)
47
- assert_false(browser.link(:xpath , "//a[@id='alsomissing']").exists?)
48
-
49
- assert(browser.link(:xpath , "//a[@name='link_name']").exists?)
50
- assert_false(browser.link(:xpath , "//a[@name='alsomissing']").exists?)
51
- assert(browser.link(:xpath , "//a[@title='link_title']").exists?)
52
-
53
- end
54
-
55
- def test_Link_click
56
- browser.link(:xpath , "//a[contains(.,'test1')]").click
57
- assert( browser.text.include?("Links2-Pass") )
58
- end
59
-
60
- def test_link_properties
61
-
62
- assert_match( /links2/ ,browser.link(:xpath , "//a[contains(.,'test1')]").href )
63
- assert_equal( "" , browser.link(:xpath , "//a[contains(.,'test1')]").value)
64
- assert_equal( "test1" , browser.link(:xpath , "//a[contains(.,'test1')]").text )
65
- assert_equal( "" , browser.link(:xpath , "//a[contains(.,'test1')]").name )
66
- assert_equal( "" , browser.link(:xpath , "//a[contains(.,'test1')]").id )
67
- assert_equal( false , browser.link(:xpath , "//a[contains(.,'test1')]").disabled )
68
- assert_equal( "" , browser.link(:xpath , "//a[contains(.,'test1')]").class_name)
69
- assert_equal( "link_class_1" , browser.link(:xpath , "//a[@class='link_class_1']").class_name)
70
-
71
- assert_equal( "link_id" , browser.link(:xpath , "//a[@id='link_id']").id )
72
- assert_equal( "link_name" , browser.link(:xpath , "//a[@name='link_name']").name )
73
-
74
- assert_equal( "" , browser.link(:xpath , "//a[@name='link_name']").title)
75
-
76
- assert_equal( "link_title" , browser.link(:xpath , "//a[@title='link_title']").title)
77
- end
78
- end
79
-
1
+ # feature tests for Links
2
+ # revision: $Revision: 1.0 $
3
+
4
+ $LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..') unless $SETUP_LOADED
5
+ require 'unittests/setup'
6
+
7
+ class TC_Links_XPath < Test::Unit::TestCase
8
+
9
+ def setup()
10
+ goto_page("links1.html")
11
+ end
12
+
13
+ def xtest_new_link_exists
14
+ assert(exists?{browser.link(:xpath , "//a[contains(.,'test1')]")})
15
+ assert(exists?{browser.link(:xpath, "//a[contains(., /TEST/i)]")})
16
+ assert_false(exists?{browser.link(:xpath , "//a[contains(.,'missing')]")})
17
+ assert_false(exists?{browser.link(:xpath, "//a[contains(., /miss/)]")})
18
+ end
19
+
20
+ tag_method :test_element_by_xpath_class, :fails_on_ie
21
+ def test_element_by_xpath_class
22
+ # TODO: If element is not present this should return null
23
+ #element = browser.element_by_xpath("//a[contains(., /miss/)]")
24
+ #assert(element.instance_of?(Link),"element class should be #{Link}; got #{element.class}")
25
+ #element = browser.element_by_xpath("//a[contains(.,'missing')]")
26
+ #assert(element.instance_of?(Link),"element class should be #{Link}; got #{element.class}")
27
+ element = browser.element_by_xpath("//a[contains(., /TEST/i)]")
28
+ assert_class(element, 'Link')
29
+ element = browser.element_by_xpath("//a[contains(.,'test1')]")
30
+ assert_class(element, 'Link')
31
+ end
32
+
33
+ def test_element_by_xpath_behavior
34
+ # TODO implement this, acquiring objects through element_by_xpath and
35
+ # then testing their properties to see if they behave normally, as if
36
+ # they had been created with browser.link
37
+ end
38
+
39
+ def test_Link_Exists
40
+ assert(browser.link(:xpath , "//a[contains(.,'test1')]").exists?)
41
+ assert(browser.link(:xpath, "//a[contains(., /TEST/i)]").exists?)
42
+ assert_false(browser.link(:xpath , "//a[contains(.,'missing')]").exists?)
43
+
44
+ assert_false(browser.link(:xpath , "//a[@url='alsomissing.html']").exists?)
45
+
46
+ assert(browser.link(:xpath , "//a[@id='link_id']").exists?)
47
+ assert_false(browser.link(:xpath , "//a[@id='alsomissing']").exists?)
48
+
49
+ assert(browser.link(:xpath , "//a[@name='link_name']").exists?)
50
+ assert_false(browser.link(:xpath , "//a[@name='alsomissing']").exists?)
51
+ assert(browser.link(:xpath , "//a[@title='link_title']").exists?)
52
+
53
+ end
54
+
55
+ def test_Link_click
56
+ browser.link(:xpath , "//a[contains(.,'test1')]").click
57
+ assert( browser.text.include?("Links2-Pass") )
58
+ end
59
+
60
+ def test_link_properties
61
+
62
+ assert_match( /links2/ ,browser.link(:xpath , "//a[contains(.,'test1')]").href )
63
+ assert_equal( "" , browser.link(:xpath , "//a[contains(.,'test1')]").value)
64
+ assert_equal( "test1" , browser.link(:xpath , "//a[contains(.,'test1')]").text )
65
+ assert_equal( "" , browser.link(:xpath , "//a[contains(.,'test1')]").name )
66
+ assert_equal( "" , browser.link(:xpath , "//a[contains(.,'test1')]").id )
67
+ assert_equal( false , browser.link(:xpath , "//a[contains(.,'test1')]").disabled )
68
+ assert_equal( "" , browser.link(:xpath , "//a[contains(.,'test1')]").class_name)
69
+ assert_equal( "link_class_1" , browser.link(:xpath , "//a[@class='link_class_1']").class_name)
70
+
71
+ assert_equal( "link_id" , browser.link(:xpath , "//a[@id='link_id']").id )
72
+ assert_equal( "link_name" , browser.link(:xpath , "//a[@name='link_name']").name )
73
+
74
+ assert_equal( "" , browser.link(:xpath , "//a[@name='link_name']").title)
75
+
76
+ assert_equal( "link_title" , browser.link(:xpath , "//a[@title='link_title']").title)
77
+ end
78
+ end
79
+
@@ -1,7 +1,7 @@
1
- TOPDIR = File.expand_path(File.join(File.dirname(__FILE__), '..'))
2
- $LOAD_PATH.unshift TOPDIR
3
- require 'unittests/setup'
4
-
5
- Dir.chdir TOPDIR do
6
- $all_tests.each {|x| require x }
7
- end
1
+ TOPDIR = File.expand_path(File.join(File.dirname(__FILE__), '..'))
2
+ $LOAD_PATH.unshift TOPDIR
3
+ require 'unittests/setup'
4
+
5
+ Dir.chdir TOPDIR do
6
+ $all_tests.each {|x| require x }
7
+ end
@@ -1,75 +1,75 @@
1
- # feature tests for Pre
2
- # revision: $Revision: 1.0 $
3
-
4
- $LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..') unless $SETUP_LOADED
5
- require 'unittests/setup'
6
-
7
- class TC_Pre < Test::Unit::TestCase
8
-
9
-
10
- def setup
11
- goto_page("pre.html")
12
- end
13
-
14
- def test_Pre_Count
15
- assert( browser.pres.length == 3 )
16
- end
17
-
18
- def test_Pre_Exists
19
- assert_false( browser.pre( :id, 'missingPre' ).exists? )
20
- assert_false( browser.pre( :index, 33 ).exists? )
21
-
22
- assert( browser.pre( :id, '1' ).exists? )
23
- assert( browser.pre( :id, /[3-9]/ ).exists? )
24
-
25
- assert_false( browser.pre( :id, /missing_pre/ ).exists? )
26
-
27
- assert( browser.pre( :index, 1 ).exists? )
28
- assert( browser.pre( :index, 2 ).exists? )
29
- assert( browser.pre( :index, 3 ).exists? )
30
-
31
- assert( browser.pre( :name, '3' ).exists? )
32
- assert_false( browser.pre( :name, "name_missing" ).exists? )
33
- end
34
-
35
- def test_simple_access
36
- pre = browser.pre( :index, 1 )
37
- assert( pre.text.include?( "simple pre space" ) )
38
- assert_false( pre.text.include?( "A second block" ) )
39
-
40
- pre = browser.pre( :index, 2 )
41
- assert( pre.text.include?( "A second block" ) )
42
- assert_false( pre.text.include?( "this is the last block" ) )
43
- end
44
-
45
- tag_method :test_embedded_spaces, :fails_on_firefox # http://jira.openqa.org/browse/WTR-267
46
- def test_embedded_spaces
47
- pre = browser.pre( :index, 3 )
48
- assert( pre.text.include?( "continue to work" ) )
49
- assert_false( pre.text.include?( "Pre Tag Test" ) )
50
- end
51
-
52
- end
53
-
54
-
55
- class TC_Pres_Display < Test::Unit::TestCase
56
- include CaptureIOHelper
57
-
58
- tag_method :test_showPres, :fails_on_ie
59
- def test_showPres
60
- goto_page("pre.html")
61
- actual = capture_stdout { browser.showPres }
62
- assert_equal(<<END_OF_MESSAGE, actual)
63
- There are 3 pres
64
- pre: id: 1
65
- name: 1
66
- index: 1
67
- pre: id: 2
68
- name: 2
69
- index: 2
70
- pre: id: 3
71
- name: 3
72
- index: 3
73
- END_OF_MESSAGE
74
- end
75
- end
1
+ # feature tests for Pre
2
+ # revision: $Revision: 1.0 $
3
+
4
+ $LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..') unless $SETUP_LOADED
5
+ require 'unittests/setup'
6
+
7
+ class TC_Pre < Test::Unit::TestCase
8
+
9
+
10
+ def setup
11
+ goto_page("pre.html")
12
+ end
13
+
14
+ def test_Pre_Count
15
+ assert( browser.pres.length == 3 )
16
+ end
17
+
18
+ def test_Pre_Exists
19
+ assert_false( browser.pre( :id, 'missingPre' ).exists? )
20
+ assert_false( browser.pre( :index, 33 ).exists? )
21
+
22
+ assert( browser.pre( :id, '1' ).exists? )
23
+ assert( browser.pre( :id, /[3-9]/ ).exists? )
24
+
25
+ assert_false( browser.pre( :id, /missing_pre/ ).exists? )
26
+
27
+ assert( browser.pre( :index, 1 ).exists? )
28
+ assert( browser.pre( :index, 2 ).exists? )
29
+ assert( browser.pre( :index, 3 ).exists? )
30
+
31
+ assert( browser.pre( :name, '3' ).exists? )
32
+ assert_false( browser.pre( :name, "name_missing" ).exists? )
33
+ end
34
+
35
+ def test_simple_access
36
+ pre = browser.pre( :index, 1 )
37
+ assert( pre.text.include?( "simple pre space" ) )
38
+ assert_false( pre.text.include?( "A second block" ) )
39
+
40
+ pre = browser.pre( :index, 2 )
41
+ assert( pre.text.include?( "A second block" ) )
42
+ assert_false( pre.text.include?( "this is the last block" ) )
43
+ end
44
+
45
+ tag_method :test_embedded_spaces, :fails_on_firefox # http://jira.openqa.org/browse/WTR-267
46
+ def test_embedded_spaces
47
+ pre = browser.pre( :index, 3 )
48
+ assert( pre.text.include?( "continue to work" ) )
49
+ assert_false( pre.text.include?( "Pre Tag Test" ) )
50
+ end
51
+
52
+ end
53
+
54
+
55
+ class TC_Pres_Display < Test::Unit::TestCase
56
+ include CaptureIOHelper
57
+
58
+ tag_method :test_showPres, :fails_on_ie
59
+ def test_showPres
60
+ goto_page("pre.html")
61
+ actual = capture_stdout { browser.showPres }
62
+ assert_equal(<<END_OF_MESSAGE, actual)
63
+ There are 3 pres
64
+ pre: id: 1
65
+ name: 1
66
+ index: 1
67
+ pre: id: 2
68
+ name: 2
69
+ index: 2
70
+ pre: id: 3
71
+ name: 3
72
+ index: 3
73
+ END_OF_MESSAGE
74
+ end
75
+ end
@@ -1,166 +1,166 @@
1
- # feature tests for Radio Buttons
2
- # revision: $Revision: 1.0 $
3
-
4
- $LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..') unless $SETUP_LOADED
5
- require 'unittests/setup'
6
-
7
- class TC_Radios < Test::Unit::TestCase
8
-
9
-
10
- def setup()
11
- goto_page("radioButtons1.html")
12
- end
13
-
14
- def test_Radio_Exists
15
- assert(browser.radio(:name, "box1").exists?)
16
- assert(browser.radio(:id, "box5").exists?)
17
-
18
- assert_false(browser.radio(:name, "missingname").exists?)
19
- assert_false(browser.radio(:id, "missingid").exists?)
20
- end
21
-
22
- def test_radio_class
23
- assert_raises(UnknownObjectException) { browser.radio(:name, "noName").class_name }
24
- assert_equal("radio_style" , browser.radio(:name, "box1").class_name)
25
- assert_equal("" , browser.radio(:id, "box5").class_name)
26
- end
27
-
28
- def test_Radio_Enabled
29
- assert_raises(UnknownObjectException) { browser.radio(:name, "noName").enabled? }
30
- assert_raises(UnknownObjectException) { browser.radio(:id, "noName").enabled? }
31
- assert_raises(UnknownObjectException) { browser.radio(:name, "box4" , 6).enabled? }
32
-
33
- assert_false(browser.radio(:name, "box2").enabled?)
34
- assert(browser.radio(:id, "box5").enabled?)
35
- assert(browser.radio(:name, "box1").enabled?)
36
- end
37
-
38
- def test_little
39
- assert_false(browser.button(:value , "foo").enabled?)
40
- end
41
-
42
- def test_onClick
43
-
44
- assert_false(browser.radio(:name, "box5").isSet?)
45
- assert_false(browser.button(:value , "foo").enabled?)
46
-
47
- # first click the button is enabled and the radio is set
48
- browser.radio(:name, "box5" , 1).click
49
- assert(browser.radio(:name, "box5",1).isSet?)
50
- #assert(browser.button(:value , "foo").enabled?)
51
-
52
- # second click the button is disabled and the radio is still set
53
- browser.radio(:name, "box5", 1).click
54
- assert(browser.radio(:name, "box5",1).isSet?)
55
- assert_false(browser.button(:value , "foo").enabled?)
56
-
57
- # third click the button is enabled and the radio is still set
58
- browser.radio(:name, "box5", 1).click
59
- assert(browser.radio(:name, "box5",1 ).isSet?)
60
- assert(browser.button(:value , "foo").enabled?)
61
-
62
- # click the radio with a value of 2 , button is disabled and the radio is still set
63
- browser.radio(:name, "box5", 2).click
64
- assert_false(browser.radio(:name, "box5" ,1).isSet?)
65
- assert(browser.radio(:name, "box5" ,2).isSet?)
66
- assert_false(browser.button(:value , "foo").enabled?)
67
- end
68
-
69
- def test_Radio_isSet
70
- assert_raises(UnknownObjectException) { browser.radio(:name, "noName").isSet? }
71
-
72
- assert_false(browser.radio(:name, "box1").isSet?)
73
- assert( browser.radio(:name, "box3").isSet?)
74
- assert_false(browser.radio(:name, "box2").isSet?)
75
- assert( browser.radio(:name, "box4" , 1 ).isSet?)
76
- assert_false(browser.radio(:name, "box4" , 2 ).isSet?)
77
- end
78
-
79
- def test_radio_clear
80
- assert_raises(UnknownObjectException) { browser.radio(:name, "noName").clear }
81
-
82
- browser.radio(:name, "box1").clear
83
- assert_false(browser.radio(:name, "box1").isSet?)
84
-
85
- assert_raises(ObjectDisabledException, "ObjectDisabledException was supposed to be thrown" ) { browser.radio(:name, "box2").clear }
86
- assert_false(browser.radio(:name, "box2").isSet?)
87
-
88
- browser.radio(:name, "box3").clear
89
- assert_false(browser.radio(:name, "box3").isSet?)
90
-
91
- browser.radio(:name, "box4" , 1).clear
92
- assert_false(browser.radio(:name, "box4" , 1).isSet?)
93
- end
94
-
95
- def test_radio_getState
96
- assert_raises(UnknownObjectException) { browser.radio(:name, "noName").getState }
97
-
98
- assert_equal( false , browser.radio(:name, "box1").getState )
99
- assert_equal( true , browser.radio(:name, "box3").getState)
100
-
101
- # radioes that have the same name but different values
102
- assert_equal( false , browser.radio(:name, "box4" , 2).getState )
103
- assert_equal( true , browser.radio(:name, "box4" , 1).getState)
104
- end
105
-
106
- def test_radio_set
107
- assert_raises(UnknownObjectException) { browser.radio(:name, "noName").set }
108
- browser.radio(:name, "box1").set
109
- assert(browser.radio(:name, "box1").isSet?)
110
-
111
- assert_raises(ObjectDisabledException, "ObjectDisabledException was supposed to be thrown" ) { browser.radio(:name, "box2").set }
112
-
113
- browser.radio(:name, "box3").set
114
- assert(browser.radio(:name, "box3").isSet?)
115
-
116
- # radioes that have the same name but different values
117
- browser.radio(:name, "box4" , 3).set
118
- assert(browser.radio(:name, "box4" , 3).isSet?)
119
- end
120
-
121
- def test_radio_properties
122
-
123
- assert_raises(UnknownObjectException , "UnknownObjectException was supposed to be thrown" ) { browser.radio(:index, 199).value}
124
- assert_raises(UnknownObjectException , "UnknownObjectException was supposed to be thrown" ) { browser.radio(:index, 199).name }
125
- assert_raises(UnknownObjectException , "UnknownObjectException was supposed to be thrown" ) { browser.radio(:index, 199).id }
126
- assert_raises(UnknownObjectException , "UnknownObjectException was supposed to be thrown" ) { browser.radio(:index, 199).disabled }
127
- assert_raises(UnknownObjectException , "UnknownObjectException was supposed to be thrown" ) { browser.radio(:index, 199).type }
128
-
129
- assert_equal("on" , browser.radio(:index, 1).value)
130
- assert_equal("box1" , browser.radio(:index, 1).name )
131
- assert_equal("" , browser.radio(:index, 1).id )
132
- assert_equal("radio", browser.radio(:index, 1).type )
133
-
134
- assert_equal( false, browser.radio(:index, 1).disabled )
135
- assert_equal( true, browser.radio(:index, 3).disabled )
136
-
137
- assert_equal("box5" , browser.radio(:index, 2).id )
138
- assert_equal("" , browser.radio(:index, 2).name )
139
-
140
- assert_equal("box4-value5", browser.radio(:name , "box4" , 5 ).title )
141
- assert_equal("", browser.radio(:name , "box4" , 4 ).title )
142
-
143
-
144
- end
145
-
146
- def test_radio_iterators
147
-
148
- assert_equal(11, browser.radios.length)
149
- assert_equal("box5" , browser.radios[2].id )
150
- assert_equal(true , browser.radios[3].disabled )
151
- assert_equal(false , browser.radios[1].disabled )
152
- index = 1
153
- browser.radios.each do |r|
154
- assert_equal( browser.radio(:index, index).name , r.name )
155
- assert_equal( browser.radio(:index, index).id , r.id )
156
- assert_equal( browser.radio(:index, index).value, r.value)
157
- assert_equal( browser.radio(:index, index).disabled , r.disabled )
158
- assert_equal( browser.radio(:index, index).isSet? , r.isSet? )
159
- index+=1
160
- end
161
- assert_equal(index -1, browser.radios.length)
162
- end
163
-
164
-
165
- end
166
-
1
+ # feature tests for Radio Buttons
2
+ # revision: $Revision: 1.0 $
3
+
4
+ $LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..') unless $SETUP_LOADED
5
+ require 'unittests/setup'
6
+
7
+ class TC_Radios < Test::Unit::TestCase
8
+
9
+
10
+ def setup()
11
+ goto_page("radioButtons1.html")
12
+ end
13
+
14
+ def test_Radio_Exists
15
+ assert(browser.radio(:name, "box1").exists?)
16
+ assert(browser.radio(:id, "box5").exists?)
17
+
18
+ assert_false(browser.radio(:name, "missingname").exists?)
19
+ assert_false(browser.radio(:id, "missingid").exists?)
20
+ end
21
+
22
+ def test_radio_class
23
+ assert_raises(UnknownObjectException) { browser.radio(:name, "noName").class_name }
24
+ assert_equal("radio_style" , browser.radio(:name, "box1").class_name)
25
+ assert_equal("" , browser.radio(:id, "box5").class_name)
26
+ end
27
+
28
+ def test_Radio_Enabled
29
+ assert_raises(UnknownObjectException) { browser.radio(:name, "noName").enabled? }
30
+ assert_raises(UnknownObjectException) { browser.radio(:id, "noName").enabled? }
31
+ assert_raises(UnknownObjectException) { browser.radio(:name, "box4" , 6).enabled? }
32
+
33
+ assert_false(browser.radio(:name, "box2").enabled?)
34
+ assert(browser.radio(:id, "box5").enabled?)
35
+ assert(browser.radio(:name, "box1").enabled?)
36
+ end
37
+
38
+ def test_little
39
+ assert_false(browser.button(:value , "foo").enabled?)
40
+ end
41
+
42
+ def test_onClick
43
+
44
+ assert_false(browser.radio(:name, "box5").isSet?)
45
+ assert_false(browser.button(:value , "foo").enabled?)
46
+
47
+ # first click the button is enabled and the radio is set
48
+ browser.radio(:name, "box5" , 1).click
49
+ assert(browser.radio(:name, "box5",1).isSet?)
50
+ #assert(browser.button(:value , "foo").enabled?)
51
+
52
+ # second click the button is disabled and the radio is still set
53
+ browser.radio(:name, "box5", 1).click
54
+ assert(browser.radio(:name, "box5",1).isSet?)
55
+ assert_false(browser.button(:value , "foo").enabled?)
56
+
57
+ # third click the button is enabled and the radio is still set
58
+ browser.radio(:name, "box5", 1).click
59
+ assert(browser.radio(:name, "box5",1 ).isSet?)
60
+ assert(browser.button(:value , "foo").enabled?)
61
+
62
+ # click the radio with a value of 2 , button is disabled and the radio is still set
63
+ browser.radio(:name, "box5", 2).click
64
+ assert_false(browser.radio(:name, "box5" ,1).isSet?)
65
+ assert(browser.radio(:name, "box5" ,2).isSet?)
66
+ assert_false(browser.button(:value , "foo").enabled?)
67
+ end
68
+
69
+ def test_Radio_isSet
70
+ assert_raises(UnknownObjectException) { browser.radio(:name, "noName").isSet? }
71
+
72
+ assert_false(browser.radio(:name, "box1").isSet?)
73
+ assert( browser.radio(:name, "box3").isSet?)
74
+ assert_false(browser.radio(:name, "box2").isSet?)
75
+ assert( browser.radio(:name, "box4" , 1 ).isSet?)
76
+ assert_false(browser.radio(:name, "box4" , 2 ).isSet?)
77
+ end
78
+
79
+ def test_radio_clear
80
+ assert_raises(UnknownObjectException) { browser.radio(:name, "noName").clear }
81
+
82
+ browser.radio(:name, "box1").clear
83
+ assert_false(browser.radio(:name, "box1").isSet?)
84
+
85
+ assert_raises(ObjectDisabledException, "ObjectDisabledException was supposed to be thrown" ) { browser.radio(:name, "box2").clear }
86
+ assert_false(browser.radio(:name, "box2").isSet?)
87
+
88
+ browser.radio(:name, "box3").clear
89
+ assert_false(browser.radio(:name, "box3").isSet?)
90
+
91
+ browser.radio(:name, "box4" , 1).clear
92
+ assert_false(browser.radio(:name, "box4" , 1).isSet?)
93
+ end
94
+
95
+ def test_radio_getState
96
+ assert_raises(UnknownObjectException) { browser.radio(:name, "noName").getState }
97
+
98
+ assert_equal( false , browser.radio(:name, "box1").getState )
99
+ assert_equal( true , browser.radio(:name, "box3").getState)
100
+
101
+ # radioes that have the same name but different values
102
+ assert_equal( false , browser.radio(:name, "box4" , 2).getState )
103
+ assert_equal( true , browser.radio(:name, "box4" , 1).getState)
104
+ end
105
+
106
+ def test_radio_set
107
+ assert_raises(UnknownObjectException) { browser.radio(:name, "noName").set }
108
+ browser.radio(:name, "box1").set
109
+ assert(browser.radio(:name, "box1").isSet?)
110
+
111
+ assert_raises(ObjectDisabledException, "ObjectDisabledException was supposed to be thrown" ) { browser.radio(:name, "box2").set }
112
+
113
+ browser.radio(:name, "box3").set
114
+ assert(browser.radio(:name, "box3").isSet?)
115
+
116
+ # radioes that have the same name but different values
117
+ browser.radio(:name, "box4" , 3).set
118
+ assert(browser.radio(:name, "box4" , 3).isSet?)
119
+ end
120
+
121
+ def test_radio_properties
122
+
123
+ assert_raises(UnknownObjectException , "UnknownObjectException was supposed to be thrown" ) { browser.radio(:index, 199).value}
124
+ assert_raises(UnknownObjectException , "UnknownObjectException was supposed to be thrown" ) { browser.radio(:index, 199).name }
125
+ assert_raises(UnknownObjectException , "UnknownObjectException was supposed to be thrown" ) { browser.radio(:index, 199).id }
126
+ assert_raises(UnknownObjectException , "UnknownObjectException was supposed to be thrown" ) { browser.radio(:index, 199).disabled }
127
+ assert_raises(UnknownObjectException , "UnknownObjectException was supposed to be thrown" ) { browser.radio(:index, 199).type }
128
+
129
+ assert_equal("on" , browser.radio(:index, 1).value)
130
+ assert_equal("box1" , browser.radio(:index, 1).name )
131
+ assert_equal("" , browser.radio(:index, 1).id )
132
+ assert_equal("radio", browser.radio(:index, 1).type )
133
+
134
+ assert_equal( false, browser.radio(:index, 1).disabled )
135
+ assert_equal( true, browser.radio(:index, 3).disabled )
136
+
137
+ assert_equal("box5" , browser.radio(:index, 2).id )
138
+ assert_equal("" , browser.radio(:index, 2).name )
139
+
140
+ assert_equal("box4-value5", browser.radio(:name , "box4" , 5 ).title )
141
+ assert_equal("", browser.radio(:name , "box4" , 4 ).title )
142
+
143
+
144
+ end
145
+
146
+ def test_radio_iterators
147
+
148
+ assert_equal(11, browser.radios.length)
149
+ assert_equal("box5" , browser.radios[2].id )
150
+ assert_equal(true , browser.radios[3].disabled )
151
+ assert_equal(false , browser.radios[1].disabled )
152
+ index = 1
153
+ browser.radios.each do |r|
154
+ assert_equal( browser.radio(:index, index).name , r.name )
155
+ assert_equal( browser.radio(:index, index).id , r.id )
156
+ assert_equal( browser.radio(:index, index).value, r.value)
157
+ assert_equal( browser.radio(:index, index).disabled , r.disabled )
158
+ assert_equal( browser.radio(:index, index).isSet? , r.isSet? )
159
+ index+=1
160
+ end
161
+ assert_equal(index -1, browser.radios.length)
162
+ end
163
+
164
+
165
+ end
166
+