firewatir 1.6.2 → 1.6.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (85) hide show
  1. data/LICENSE +32 -0
  2. data/lib/firewatir.rb +40 -50
  3. data/lib/firewatir/container.rb +491 -534
  4. data/lib/firewatir/document.rb +239 -0
  5. data/lib/firewatir/element.rb +1365 -0
  6. data/lib/firewatir/element_collections.rb +314 -0
  7. data/lib/firewatir/elements/button.rb +15 -0
  8. data/lib/firewatir/elements/file_field.rb +29 -0
  9. data/lib/firewatir/elements/form.rb +40 -0
  10. data/lib/firewatir/elements/frame.rb +55 -0
  11. data/lib/firewatir/elements/hidden.rb +56 -0
  12. data/lib/firewatir/elements/image.rb +139 -0
  13. data/lib/firewatir/elements/input_element.rb +44 -0
  14. data/lib/firewatir/elements/link.rb +76 -0
  15. data/lib/firewatir/elements/non_control_element.rb +53 -0
  16. data/lib/firewatir/elements/non_control_elements.rb +108 -0
  17. data/lib/firewatir/elements/not_used.rb +278 -0
  18. data/lib/firewatir/elements/option.rb +131 -0
  19. data/lib/firewatir/elements/radio_check_common.rb +163 -0
  20. data/lib/firewatir/elements/select_list.rb +188 -0
  21. data/lib/firewatir/elements/table.rb +218 -0
  22. data/lib/firewatir/elements/table_cell.rb +54 -0
  23. data/lib/firewatir/elements/table_row.rb +100 -0
  24. data/lib/firewatir/elements/text_field.rb +218 -0
  25. data/lib/firewatir/exceptions.rb +10 -10
  26. data/lib/firewatir/firefox.rb +1040 -1127
  27. data/lib/firewatir/jssh_socket.rb +101 -0
  28. data/lib/firewatir/version.rb +5 -5
  29. data/unittests/attach_to_new_window_test.rb +49 -42
  30. data/unittests/bug_fixes_test.rb +195 -198
  31. data/unittests/buttons_xpath_test.rb +88 -88
  32. data/unittests/checkbox_test.rb +158 -155
  33. data/unittests/checkbox_xpath_test.rb +107 -107
  34. data/unittests/div_test.rb +275 -276
  35. data/unittests/filefield_test.rb +49 -45
  36. data/unittests/filefield_xpath_test.rb +35 -35
  37. data/unittests/form_test.rb +296 -308
  38. data/unittests/frame_test.rb +159 -152
  39. data/unittests/hidden_test.rb +85 -85
  40. data/unittests/hidden_xpath_test.rb +72 -72
  41. data/unittests/html/blankpage.html +11 -11
  42. data/unittests/html/buttons1.html +61 -61
  43. data/unittests/html/cssTest.html +42 -42
  44. data/unittests/html/div.html +72 -72
  45. data/unittests/html/fileupload.html +45 -45
  46. data/unittests/html/formTest1.html +38 -38
  47. data/unittests/html/forms2.html +45 -45
  48. data/unittests/html/frame_buttons.html +3 -3
  49. data/unittests/html/iframeTest.html +14 -14
  50. data/unittests/html/iframeTest1.html +13 -13
  51. data/unittests/html/iframeTest2.html +5 -5
  52. data/unittests/html/links1.html +42 -42
  53. data/unittests/html/nestedFrames.html +6 -6
  54. data/unittests/html/new_browser.html +1 -0
  55. data/unittests/html/new_browser_popup.html +8 -0
  56. data/unittests/html/pass.html +9 -9
  57. data/unittests/html/pre.html +27 -27
  58. data/unittests/html/redirect.html +10 -10
  59. data/unittests/html/redirect1.html +8 -8
  60. data/unittests/html/redirect2.html +8 -8
  61. data/unittests/html/redirect3.html +8 -8
  62. data/unittests/html/simple_table_columns.html +74 -74
  63. data/unittests/html/table1.html +165 -165
  64. data/unittests/html/textfields1.html +62 -62
  65. data/unittests/images_test.rb +198 -205
  66. data/unittests/images_xpath_test.rb +118 -119
  67. data/unittests/javascript_test.rb +75 -75
  68. data/unittests/links_test.rb +231 -232
  69. data/unittests/links_xpath_test.rb +79 -79
  70. data/unittests/mozilla_all_tests.rb +7 -7
  71. data/unittests/pre_test.rb +75 -76
  72. data/unittests/radios_xpath_test.rb +101 -101
  73. data/unittests/redirect_test.rb +41 -41
  74. data/unittests/selectbox_test.rb +142 -142
  75. data/unittests/selectbox_xpath_test.rb +129 -129
  76. data/unittests/setup.rb +29 -30
  77. data/unittests/table_test.rb +385 -373
  78. data/unittests/table_xpath_test.rb +185 -185
  79. data/unittests/textfields_test.rb +234 -233
  80. data/unittests/textfields_xpath_test.rb +113 -113
  81. metadata +33 -11
  82. data/lib/firewatir/MozillaBaseElement.rb +0 -1863
  83. data/lib/firewatir/htmlelements.rb +0 -1911
  84. data/unittests/iostring.rb +0 -30
  85. data/unittests/iostring_test.rb +0 -48
@@ -1,107 +1,107 @@
1
- # feature tests for Check Boxes
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_CheckBox_XPath < Test::Unit::TestCase
8
-
9
-
10
- def setup
11
- goto_page("checkboxes1.html")
12
- end
13
-
14
- def test_checkbox_properties
15
- assert_raises(UnknownObjectException) { browser.checkbox(:xpath , "//input[@name='noName']").id }
16
- assert_raises(UnknownObjectException) { browser.checkbox(:xpath , "//input[@name='noName']").name }
17
- assert_raises(UnknownObjectException) { browser.checkbox(:xpath , "//input[@name='noName']").disabled }
18
- assert_raises(UnknownObjectException) { browser.checkbox(:xpath , "//input[@name='noName']").type }
19
- assert_raises(UnknownObjectException) { browser.checkbox(:xpath , "//input[@name='noName']").value }
20
-
21
- assert_equal("1" , browser.checkbox(:xpath , "//input[@name='box4']").value )
22
- assert_equal("3" , browser.checkbox(:xpath , "//input[@name='box4' and @value='3']").value )
23
- assert_equal("checkbox" , browser.checkbox(:xpath , "//input[@name='box4' and @value='3']").type )
24
- assert_equal(false , browser.checkbox(:xpath , "//input[@name='box4' and @value='3']").disabled )
25
- assert_equal("" , browser.checkbox(:xpath , "//input[@name='box4' and @value='3']").id )
26
-
27
- assert_equal("box4-value5" , browser.checkbox(:xpath , "//input[@name='box4' and @value='5']").title)
28
- assert_equal("" , browser.checkbox(:xpath , "//input[@name='box4' and @value='4']").title)
29
- end
30
-
31
- def test_CheckBox_Exists
32
- assert(browser.checkbox(:xpath , "//input[@name='box4' and @value='1']").exists?)
33
- assert_false(browser.checkbox(:xpath , "//input[@name='box4' and @value='22']").exists?)
34
- end
35
-
36
- def test_checkbox_Enabled
37
- assert_raises(UnknownObjectException) { browser.checkbox(:xpath , "//input[@name='noName']").enabled? }
38
- assert_raises(UnknownObjectException) { browser.checkbox(:xpath , "//input[@id='noName']").enabled? }
39
- assert_raises(UnknownObjectException) { browser.checkbox(:xpath , "//input[@name='box4' and @value='6']").enabled? }
40
-
41
- assert(browser.checkbox(:xpath , "//input[@name='box1']").enabled?)
42
- assert_false(browser.checkbox(:xpath , "//input[@name='box2']").enabled?)
43
-
44
- assert(browser.checkbox(:xpath , "//input[@name='box4' and @value='4']").enabled?)
45
- assert_false(browser.checkbox(:xpath , "//input[@name='box4' and @value='5']").enabled?)
46
- end
47
-
48
- def test_checkbox_isSet
49
- assert_raises(UnknownObjectException ) { browser.checkbox(:xpath , "//input[@name='noName']").isSet? }
50
-
51
- assert_false(browser.checkbox(:xpath , "//input[@name='box1']").isSet?)
52
- assert_false(browser.checkbox(:xpath , "//input[@name='box2']").isSet?)
53
- assert(browser.checkbox(:xpath , "//input[@name='box3']").isSet?)
54
-
55
- assert_false(browser.checkbox(:xpath , "//input[@name='box4' and @value='2']").isSet?)
56
- assert(browser.checkbox(:xpath , "//input[@name='box4' and @value='1']").isSet?)
57
- end
58
-
59
- def test_checkbox_clear
60
- assert_raises(UnknownObjectException) { browser.checkbox(:xpath , "//input[@name='noName']").clear }
61
- browser.checkbox(:xpath , "//input[@name='box1']").clear
62
- assert_false(browser.checkbox(:xpath , "//input[@name='box1']").isSet?)
63
-
64
- assert_raises(ObjectDisabledException) { browser.checkbox(:xpath , "//input[@name='box2']").clear }
65
- assert_false(browser.checkbox(:xpath , "//input[@name='box2']").isSet?)
66
-
67
- browser.checkbox(:xpath , "//input[@name='box3']").clear
68
- assert_false(browser.checkbox(:xpath , "//input[@name='box3']").isSet?)
69
-
70
- browser.checkbox(:xpath , "//input[@name='box4' and @value='1']").clear
71
- assert_false(browser.checkbox(:xpath , "//input[@name='box4' and @value='1']").isSet?)
72
- end
73
-
74
- def test_checkbox_getState
75
- assert_raises(UnknownObjectException) { browser.checkbox(:xpath , "//input[@name='noName']").getState }
76
- assert_equal( false , browser.checkbox(:xpath , "//input[@name='box1']").getState )
77
- assert_equal( true , browser.checkbox(:xpath , "//input[@name='box3']").getState)
78
-
79
- # checkboxes that have the same name but different values
80
- assert_equal( false , browser.checkbox(:xpath , "//input[@name='box4' and @value='2']").getState )
81
- assert_equal( true , browser.checkbox(:xpath , "//input[@name='box4' and @value='1']").getState)
82
- end
83
-
84
- def test_checkbox_set
85
- assert_raises(UnknownObjectException) { browser.checkbox(:xpath , "//input[@name='noName']").set }
86
- browser.checkbox(:xpath , "//input[@name='box1']").set
87
- assert(browser.checkbox(:xpath , "//input[@name='box1']").isSet?)
88
-
89
- assert_raises(ObjectDisabledException) { browser.checkbox(:xpath , "//input[@name='box2']").set }
90
-
91
- browser.checkbox(:xpath , "//input[@name='box3']").set
92
- assert(browser.checkbox(:xpath , "//input[@name='box3']").isSet?)
93
-
94
- # checkboxes that have the same name but different values
95
- browser.checkbox(:xpath , "//input[@name='box4' and @value='3']").set
96
- assert(browser.checkbox(:xpath , "//input[@name='box4' and @value='3']").isSet?)
97
-
98
- # test set using the optinal true/false
99
- # assumes the checkbox is already checked
100
- browser.checkbox(:xpath , "//input[@name='box1']").set( false )
101
- assert_false(browser.checkbox(:xpath , "//input[@name='box1']").isSet?)
102
-
103
- browser.checkbox(:xpath , "//input[@name='box1']").set( true )
104
- assert(browser.checkbox(:xpath , "//input[@name='box1']").isSet?)
105
-
106
- end
107
- end
1
+ # feature tests for Check Boxes
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_CheckBox_XPath < Test::Unit::TestCase
8
+
9
+
10
+ def setup
11
+ goto_page("checkboxes1.html")
12
+ end
13
+
14
+ def test_checkbox_properties
15
+ assert_raises(UnknownObjectException) { browser.checkbox(:xpath , "//input[@name='noName']").id }
16
+ assert_raises(UnknownObjectException) { browser.checkbox(:xpath , "//input[@name='noName']").name }
17
+ assert_raises(UnknownObjectException) { browser.checkbox(:xpath , "//input[@name='noName']").disabled }
18
+ assert_raises(UnknownObjectException) { browser.checkbox(:xpath , "//input[@name='noName']").type }
19
+ assert_raises(UnknownObjectException) { browser.checkbox(:xpath , "//input[@name='noName']").value }
20
+
21
+ assert_equal("1" , browser.checkbox(:xpath , "//input[@name='box4']").value )
22
+ assert_equal("3" , browser.checkbox(:xpath , "//input[@name='box4' and @value='3']").value )
23
+ assert_equal("checkbox" , browser.checkbox(:xpath , "//input[@name='box4' and @value='3']").type )
24
+ assert_equal(false , browser.checkbox(:xpath , "//input[@name='box4' and @value='3']").disabled )
25
+ assert_equal("" , browser.checkbox(:xpath , "//input[@name='box4' and @value='3']").id )
26
+
27
+ assert_equal("box4-value5" , browser.checkbox(:xpath , "//input[@name='box4' and @value='5']").title)
28
+ assert_equal("" , browser.checkbox(:xpath , "//input[@name='box4' and @value='4']").title)
29
+ end
30
+
31
+ def test_CheckBox_Exists
32
+ assert(browser.checkbox(:xpath , "//input[@name='box4' and @value='1']").exists?)
33
+ assert_false(browser.checkbox(:xpath , "//input[@name='box4' and @value='22']").exists?)
34
+ end
35
+
36
+ def test_checkbox_Enabled
37
+ assert_raises(UnknownObjectException) { browser.checkbox(:xpath , "//input[@name='noName']").enabled? }
38
+ assert_raises(UnknownObjectException) { browser.checkbox(:xpath , "//input[@id='noName']").enabled? }
39
+ assert_raises(UnknownObjectException) { browser.checkbox(:xpath , "//input[@name='box4' and @value='6']").enabled? }
40
+
41
+ assert(browser.checkbox(:xpath , "//input[@name='box1']").enabled?)
42
+ assert_false(browser.checkbox(:xpath , "//input[@name='box2']").enabled?)
43
+
44
+ assert(browser.checkbox(:xpath , "//input[@name='box4' and @value='4']").enabled?)
45
+ assert_false(browser.checkbox(:xpath , "//input[@name='box4' and @value='5']").enabled?)
46
+ end
47
+
48
+ def test_checkbox_isSet
49
+ assert_raises(UnknownObjectException ) { browser.checkbox(:xpath , "//input[@name='noName']").isSet? }
50
+
51
+ assert_false(browser.checkbox(:xpath , "//input[@name='box1']").isSet?)
52
+ assert_false(browser.checkbox(:xpath , "//input[@name='box2']").isSet?)
53
+ assert(browser.checkbox(:xpath , "//input[@name='box3']").isSet?)
54
+
55
+ assert_false(browser.checkbox(:xpath , "//input[@name='box4' and @value='2']").isSet?)
56
+ assert(browser.checkbox(:xpath , "//input[@name='box4' and @value='1']").isSet?)
57
+ end
58
+
59
+ def test_checkbox_clear
60
+ assert_raises(UnknownObjectException) { browser.checkbox(:xpath , "//input[@name='noName']").clear }
61
+ browser.checkbox(:xpath , "//input[@name='box1']").clear
62
+ assert_false(browser.checkbox(:xpath , "//input[@name='box1']").isSet?)
63
+
64
+ assert_raises(ObjectDisabledException) { browser.checkbox(:xpath , "//input[@name='box2']").clear }
65
+ assert_false(browser.checkbox(:xpath , "//input[@name='box2']").isSet?)
66
+
67
+ browser.checkbox(:xpath , "//input[@name='box3']").clear
68
+ assert_false(browser.checkbox(:xpath , "//input[@name='box3']").isSet?)
69
+
70
+ browser.checkbox(:xpath , "//input[@name='box4' and @value='1']").clear
71
+ assert_false(browser.checkbox(:xpath , "//input[@name='box4' and @value='1']").isSet?)
72
+ end
73
+
74
+ def test_checkbox_getState
75
+ assert_raises(UnknownObjectException) { browser.checkbox(:xpath , "//input[@name='noName']").getState }
76
+ assert_equal( false , browser.checkbox(:xpath , "//input[@name='box1']").getState )
77
+ assert_equal( true , browser.checkbox(:xpath , "//input[@name='box3']").getState)
78
+
79
+ # checkboxes that have the same name but different values
80
+ assert_equal( false , browser.checkbox(:xpath , "//input[@name='box4' and @value='2']").getState )
81
+ assert_equal( true , browser.checkbox(:xpath , "//input[@name='box4' and @value='1']").getState)
82
+ end
83
+
84
+ def test_checkbox_set
85
+ assert_raises(UnknownObjectException) { browser.checkbox(:xpath , "//input[@name='noName']").set }
86
+ browser.checkbox(:xpath , "//input[@name='box1']").set
87
+ assert(browser.checkbox(:xpath , "//input[@name='box1']").isSet?)
88
+
89
+ assert_raises(ObjectDisabledException) { browser.checkbox(:xpath , "//input[@name='box2']").set }
90
+
91
+ browser.checkbox(:xpath , "//input[@name='box3']").set
92
+ assert(browser.checkbox(:xpath , "//input[@name='box3']").isSet?)
93
+
94
+ # checkboxes that have the same name but different values
95
+ browser.checkbox(:xpath , "//input[@name='box4' and @value='3']").set
96
+ assert(browser.checkbox(:xpath , "//input[@name='box4' and @value='3']").isSet?)
97
+
98
+ # test set using the optinal true/false
99
+ # assumes the checkbox is already checked
100
+ browser.checkbox(:xpath , "//input[@name='box1']").set( false )
101
+ assert_false(browser.checkbox(:xpath , "//input[@name='box1']").isSet?)
102
+
103
+ browser.checkbox(:xpath , "//input[@name='box1']").set( true )
104
+ assert(browser.checkbox(:xpath , "//input[@name='box1']").isSet?)
105
+
106
+ end
107
+ end
@@ -1,276 +1,275 @@
1
- # feature tests for Divs, Spans and P's
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_Divs < Test::Unit::TestCase
8
-
9
-
10
- def setup
11
- goto_page("div.html")
12
- end
13
-
14
- def test_divs
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
- end
24
-
25
- tag_method :test_show_all_objects, :fails_on_ie
26
- def test_show_all_objects
27
- assert_equal(36, browser.show_all_objects.length)
28
- assert_equal(3,browser.div(:id,"text_fields1").show_all_objects.length)
29
-
30
- assert_equal(8,browser.text_fields.length)
31
- assert_equal(3,browser.div(:id,"text_fields1").text_fields.length)
32
- end
33
-
34
- def test_div_properties
35
- assert_raises(UnknownObjectException) {browser.div(:id , "div77").text }
36
- assert_raises(UnknownObjectException) {browser.div(:title , "div77").text }
37
-
38
- assert_equal("This div has an onClick that increments text1", browser.div(:id , "div3").text.strip )
39
- assert_equal("This text is in a div with an id of div1 and title of test1",browser.div(:title , "Test1").text.strip )
40
-
41
- assert_raises(UnknownObjectException) {browser.div(:id , "div77").class_name }
42
- assert_equal("blueText" , browser.div(:id , "div2").class_name )
43
- assert_equal("" , browser.div(:id , "div1").class_name )
44
-
45
- assert_raises(UnknownObjectException) {browser.div(:index , 44).class_name }
46
- assert_equal("div1" , browser.div(:index , 1).id )
47
- assert_equal("" , browser.div(:index , 1).class_name )
48
- assert_equal("blueText" , browser.div(:index , 2).class_name )
49
- assert_equal("" , browser.div(:index , 2).value)
50
- assert_equal(false , browser.div(:index , 2).disabled)
51
- assert_equal("" , browser.div(:index , 2).name)
52
- assert_equal("div2", browser.div(:index , 2).id)
53
- #puts browser.div(:id,"text_fields1").to_s
54
- end
55
-
56
- def test_div_iterator
57
- assert_equal( 7 , browser.divs.length)
58
- assert_equal( "div1" , browser.divs[1].id )
59
-
60
- index =1
61
- browser.divs.each do |s|
62
- # puts "each - div= " + s.to_s
63
- assert_equal(browser.div(:index, index ).name , s.name )
64
- assert_equal(browser.div(:index, index ).id , s.id )
65
- assert_equal(browser.div(:index, index ).class_name , s.class_name )
66
- index +=1
67
- end
68
- assert_equal(index-1, browser.divs.length) # -1 as we add 1 at the end of the loop
69
- end
70
-
71
- def test_objects_in_div
72
- assert(browser.div(:id, 'buttons1').button(:index,1).exists? )
73
- assert_false(browser.div(:id, 'buttons1').button(:index,3).exists? )
74
- assert(browser.div(:id, 'buttons1').button(:name,'b1').exists? )
75
- browser.div(:id, 'buttons1').button(:name,'b1').click
76
-
77
- assert(browser.div(:id, 'buttons2').button(:index,1).exists? )
78
- assert(browser.div(:id, 'buttons2').button(:index,2).exists? )
79
- assert_false(browser.div(:id, 'buttons1').button(:index,3).exists? )
80
-
81
- browser.div(:id, 'buttons1').button(:index,1).click
82
-
83
- assert_equal( 'button1' , browser.div(:id , 'text_fields1').text_field(:index,1).value)
84
-
85
- #assert_equal( 3 , browser.div(:id , 'text_fields1').text_fields.length )
86
- browser.div(:id, 'text_fields1').text_field(:name, 'div_text1').set("drink me")
87
- assert_equal("drink me", browser.div(:id, 'text_fields1').text_field(:name, 'div_text1').value)
88
- end
89
-
90
- #---- Span Tests ---
91
- def test_spans
92
- assert_raises(UnknownObjectException) {browser.span(:id , "span77").click }
93
- assert_raises(UnknownObjectException) {browser.span(:title , "span77").click }
94
-
95
- assert(browser.text_field(:name, "text2").verify_contains("0") )
96
- browser.span(:id , "span3").click
97
- assert(browser.text_field(:name, "text2").verify_contains("1") )
98
-
99
- browser.span(:id , "span4").click
100
- assert(browser.text_field(:name, "text2").verify_contains("0") )
101
-
102
- #puts browser.span(:id,"text_fields1").to_s
103
- end
104
-
105
- def test_span_properties
106
- assert_raises(UnknownObjectException) {browser.span(:id , "span77").text }
107
- assert_raises(UnknownObjectException) {browser.span(:title , "span77").text }
108
-
109
- assert_equal("This span has an onClick that increments text2" , browser.span(:id , "span3").text.strip )
110
- assert_equal("This text is in a span with an id of span1 and title of test2" , browser.span(:title , "Test2").text.strip )
111
-
112
- assert_raises(UnknownObjectException) {browser.span(:id , "span77").class_name }
113
- assert_equal("blueText" , browser.span(:id , "span2").class_name )
114
- assert_equal("" , browser.span(:id , "span1").class_name )
115
-
116
- assert_raises(UnknownObjectException) {browser.span(:index , 44).class_name }
117
- assert_equal("span1" , browser.span(:index , 1).id )
118
- assert_equal("" , browser.span(:index , 1).class_name )
119
- assert_equal("blueText" , browser.span(:index , 2).class_name )
120
- assert_equal("" , browser.span(:index , 2).value)
121
- assert_equal(false , browser.span(:index , 2).disabled)
122
- assert_equal("" , browser.span(:index , 2).name)
123
- assert_equal("span2", browser.span(:index , 2).id)
124
- end
125
-
126
- def test_span_iterator
127
- assert_equal(7, browser.spans.length)
128
- assert_equal("span1", browser.spans[1].id)
129
-
130
- index = 1
131
- browser.spans.each do |s|
132
- # puts "each - span = " + s.to_s
133
- assert_equal(browser.span(:index, index ).name , s.name )
134
- assert_equal(browser.span(:index, index ).id , s.id )
135
- assert_equal(browser.span(:index, index ).class_name , s.class_name )
136
- index += 1
137
- end
138
- assert_equal(index - 1, browser.spans.length) # -1 as we add 1 at the end of the loop
139
- end
140
-
141
- def test_objects_in_span
142
- assert(browser.span(:id, 'buttons1').button(:index,1).exists? )
143
- assert_false(browser.span(:id, 'buttons1').button(:index,3).exists? )
144
- assert(browser.span(:id, 'buttons1').button(:name,'b1').exists? )
145
-
146
- assert(browser.span(:id, 'buttons2').button(:index,1).exists? )
147
- assert(browser.span(:id, 'buttons2').button(:index,2).exists? )
148
- assert_false(browser.span(:id, 'buttons1').button(:index,3).exists? )
149
-
150
- browser.span(:id, 'buttons1').button(:index,1).click
151
-
152
- assert_equal( 'button1' , browser.span(:id , 'text_fields1').text_field(:index,1).value)
153
- browser.span(:id , 'text_fields1').text_field(:index,1).set('text box inside span')
154
- assert_equal( 'text box inside span' , browser.span(:id , 'text_fields1').text_field(:index,1).value)
155
-
156
- #assert_equal( 3 , browser.span(:id , 'text_fields1').text_fields.length )
157
- end
158
-
159
- def test_p
160
- assert(browser.p(:id, 'number1').exists?)
161
- assert(browser.p(:index, 3).exists?)
162
- assert(browser.p(:title, 'test_3').exists?)
163
-
164
- assert_false(browser.p(:id, 'missing').exists?)
165
- assert_false(browser.p(:index, 8).exists?)
166
- assert_false(browser.p(:title, 'test_55').exists?)
167
-
168
- assert_raises( UnknownObjectException) {browser.p(:id , 'missing').class_name }
169
- assert_raises( UnknownObjectException) {browser.p(:id , 'missing').text }
170
- assert_raises( UnknownObjectException) {browser.p(:id , 'missing').title }
171
- assert_raises( UnknownObjectException) {browser.p(:id , 'missing').to_s }
172
- assert_raises( UnknownObjectException) {browser.p(:id , 'missing').disabled }
173
-
174
- assert_equal( 'redText' , browser.p(:index,1).class_name)
175
- assert_equal( 'P_tag_1' , browser.p(:index,1).title)
176
- assert_equal( 'This text is in a p with an id of number2' , browser.p(:index,2).text)
177
- end
178
-
179
- def test_p_iterator
180
- assert_equal( 3, browser.ps.length)
181
- assert_equal( 'italicText', browser.ps[2].class_name)
182
- assert_equal( 'number3', browser.ps[3].id)
183
-
184
- count=1
185
- browser.ps.each do |p|
186
- assert_equal('number'+count.to_s , p.id)
187
- count+=1
188
- end
189
- assert_equal( count-1 , browser.ps.length)
190
- end
191
- end
192
-
193
- class TC_Divs_Display < Test::Unit::TestCase
194
-
195
- include MockStdoutTestCase
196
-
197
- tag_method :test_showDivs, :fails_on_ie
198
- def test_showDivs
199
- goto_page("div.html")
200
- $stdout = @mockout
201
- browser.showDivs
202
- assert_equal(<<END_OF_MESSAGE, @mockout)
203
- There are 7 divs
204
- div: name:
205
- id: div1
206
- class:
207
- index: 1
208
- div: name:
209
- id: div2
210
- class: blueText
211
- index: 2
212
- div: name:
213
- id: div3
214
- class:
215
- index: 3
216
- div: name:
217
- id: div4
218
- class:
219
- index: 4
220
- div: name:
221
- id: buttons1
222
- class:
223
- index: 5
224
- div: name:
225
- id: buttons2
226
- class:
227
- index: 6
228
- div: name: divName
229
- id: text_fields1
230
- class: divClass
231
- index: 7
232
- END_OF_MESSAGE
233
- end
234
- end
235
-
236
- class TC_Spans_Display < Test::Unit::TestCase
237
- include MockStdoutTestCase
238
-
239
- tag_method :test_showSpans, :fails_on_ie
240
- def test_showSpans
241
- goto_page("div.html")
242
- $stdout = @mockout
243
- browser.showSpans
244
- assert_equal(<<END_OF_MESSAGE, @mockout)
245
- There are 7 spans
246
- span: name:
247
- id: span1
248
- class:
249
- index: 1
250
- span: name:
251
- id: span2
252
- class: blueText
253
- index: 2
254
- span: name:
255
- id: span3
256
- class:
257
- index: 3
258
- span: name:
259
- id: span4
260
- class:
261
- index: 4
262
- span: name:
263
- id: buttons1
264
- class:
265
- index: 5
266
- span: name:
267
- id: buttons2
268
- class:
269
- index: 6
270
- span: name: spanName
271
- id: text_fields1
272
- class: spanClass
273
- index: 7
274
- END_OF_MESSAGE
275
- end
276
- end
1
+ # feature tests for Divs, Spans and P's
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_Divs < Test::Unit::TestCase
8
+
9
+
10
+ def setup
11
+ goto_page("div.html")
12
+ end
13
+
14
+ def test_divs
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
+ end
24
+
25
+ tag_method :test_show_all_objects, :fails_on_ie
26
+ def test_show_all_objects
27
+ assert_equal(36, browser.show_all_objects.length)
28
+ assert_equal(3,browser.div(:id,"text_fields1").show_all_objects.length)
29
+
30
+ assert_equal(8,browser.text_fields.length)
31
+ assert_equal(3,browser.div(:id,"text_fields1").text_fields.length)
32
+ end
33
+
34
+ def test_div_properties
35
+ assert_raises(UnknownObjectException) {browser.div(:id , "div77").text }
36
+ assert_raises(UnknownObjectException) {browser.div(:title , "div77").text }
37
+
38
+ assert_equal("This div has an onClick that increments text1", browser.div(:id , "div3").text.strip )
39
+ assert_equal("This text is in a div with an id of div1 and title of test1",browser.div(:title , "Test1").text.strip )
40
+
41
+ assert_raises(UnknownObjectException) {browser.div(:id , "div77").class_name }
42
+ assert_equal("blueText" , browser.div(:id , "div2").class_name )
43
+ assert_equal("" , browser.div(:id , "div1").class_name )
44
+
45
+ assert_raises(UnknownObjectException) {browser.div(:index , 44).class_name }
46
+ assert_equal("div1" , browser.div(:index , 1).id )
47
+ assert_equal("" , browser.div(:index , 1).class_name )
48
+ assert_equal("blueText" , browser.div(:index , 2).class_name )
49
+ assert_equal("" , browser.div(:index , 2).value)
50
+ assert_equal(false , browser.div(:index , 2).disabled)
51
+ assert_equal("" , browser.div(:index , 2).name)
52
+ assert_equal("div2", browser.div(:index , 2).id)
53
+ #puts browser.div(:id,"text_fields1").to_s
54
+ end
55
+
56
+ def test_div_iterator
57
+ assert_equal( 7 , browser.divs.length)
58
+ assert_equal( "div1" , browser.divs[1].id )
59
+
60
+ index =1
61
+ browser.divs.each do |s|
62
+ # puts "each - div= " + s.to_s
63
+ assert_equal(browser.div(:index, index ).name , s.name )
64
+ assert_equal(browser.div(:index, index ).id , s.id )
65
+ assert_equal(browser.div(:index, index ).class_name , s.class_name )
66
+ index +=1
67
+ end
68
+ assert_equal(index-1, browser.divs.length) # -1 as we add 1 at the end of the loop
69
+ end
70
+
71
+ def test_objects_in_div
72
+ assert(browser.div(:id, 'buttons1').button(:index,1).exists? )
73
+ assert_false(browser.div(:id, 'buttons1').button(:index,3).exists? )
74
+ assert(browser.div(:id, 'buttons1').button(:name,'b1').exists? )
75
+ browser.div(:id, 'buttons1').button(:name,'b1').click
76
+
77
+ assert(browser.div(:id, 'buttons2').button(:index,1).exists? )
78
+ assert(browser.div(:id, 'buttons2').button(:index,2).exists? )
79
+ assert_false(browser.div(:id, 'buttons1').button(:index,3).exists? )
80
+
81
+ browser.div(:id, 'buttons1').button(:index,1).click
82
+
83
+ assert_equal( 'button1' , browser.div(:id , 'text_fields1').text_field(:index,1).value)
84
+
85
+ #assert_equal( 3 , browser.div(:id , 'text_fields1').text_fields.length )
86
+ browser.div(:id, 'text_fields1').text_field(:name, 'div_text1').set("drink me")
87
+ assert_equal("drink me", browser.div(:id, 'text_fields1').text_field(:name, 'div_text1').value)
88
+ end
89
+
90
+ #---- Span Tests ---
91
+ def test_spans
92
+ assert_raises(UnknownObjectException) {browser.span(:id , "span77").click }
93
+ assert_raises(UnknownObjectException) {browser.span(:title , "span77").click }
94
+
95
+ assert(browser.text_field(:name, "text2").verify_contains("0") )
96
+ browser.span(:id , "span3").click
97
+ assert(browser.text_field(:name, "text2").verify_contains("1") )
98
+
99
+ browser.span(:id , "span4").click
100
+ assert(browser.text_field(:name, "text2").verify_contains("0") )
101
+
102
+ #puts browser.span(:id,"text_fields1").to_s
103
+ end
104
+
105
+ def test_span_properties
106
+ assert_raises(UnknownObjectException) {browser.span(:id , "span77").text }
107
+ assert_raises(UnknownObjectException) {browser.span(:title , "span77").text }
108
+
109
+ assert_equal("This span has an onClick that increments text2" , browser.span(:id , "span3").text.strip )
110
+ assert_equal("This text is in a span with an id of span1 and title of test2" , browser.span(:title , "Test2").text.strip )
111
+
112
+ assert_raises(UnknownObjectException) {browser.span(:id , "span77").class_name }
113
+ assert_equal("blueText" , browser.span(:id , "span2").class_name )
114
+ assert_equal("" , browser.span(:id , "span1").class_name )
115
+
116
+ assert_raises(UnknownObjectException) {browser.span(:index , 44).class_name }
117
+ assert_equal("span1" , browser.span(:index , 1).id )
118
+ assert_equal("" , browser.span(:index , 1).class_name )
119
+ assert_equal("blueText" , browser.span(:index , 2).class_name )
120
+ assert_equal("" , browser.span(:index , 2).value)
121
+ assert_equal(false , browser.span(:index , 2).disabled)
122
+ assert_equal("" , browser.span(:index , 2).name)
123
+ assert_equal("span2", browser.span(:index , 2).id)
124
+ end
125
+
126
+ def test_span_iterator
127
+ assert_equal(7, browser.spans.length)
128
+ assert_equal("span1", browser.spans[1].id)
129
+
130
+ index = 1
131
+ browser.spans.each do |s|
132
+ # puts "each - span = " + s.to_s
133
+ assert_equal(browser.span(:index, index ).name , s.name )
134
+ assert_equal(browser.span(:index, index ).id , s.id )
135
+ assert_equal(browser.span(:index, index ).class_name , s.class_name )
136
+ index += 1
137
+ end
138
+ assert_equal(index - 1, browser.spans.length) # -1 as we add 1 at the end of the loop
139
+ end
140
+
141
+ def test_objects_in_span
142
+ assert(browser.span(:id, 'buttons1').button(:index,1).exists? )
143
+ assert_false(browser.span(:id, 'buttons1').button(:index,3).exists? )
144
+ assert(browser.span(:id, 'buttons1').button(:name,'b1').exists? )
145
+
146
+ assert(browser.span(:id, 'buttons2').button(:index,1).exists? )
147
+ assert(browser.span(:id, 'buttons2').button(:index,2).exists? )
148
+ assert_false(browser.span(:id, 'buttons1').button(:index,3).exists? )
149
+
150
+ browser.span(:id, 'buttons1').button(:index,1).click
151
+
152
+ assert_equal( 'button1' , browser.span(:id , 'text_fields1').text_field(:index,1).value)
153
+ browser.span(:id , 'text_fields1').text_field(:index,1).set('text box inside span')
154
+ assert_equal( 'text box inside span' , browser.span(:id , 'text_fields1').text_field(:index,1).value)
155
+
156
+ #assert_equal( 3 , browser.span(:id , 'text_fields1').text_fields.length )
157
+ end
158
+
159
+ def test_p
160
+ assert(browser.p(:id, 'number1').exists?)
161
+ assert(browser.p(:index, 3).exists?)
162
+ assert(browser.p(:title, 'test_3').exists?)
163
+
164
+ assert_false(browser.p(:id, 'missing').exists?)
165
+ assert_false(browser.p(:index, 8).exists?)
166
+ assert_false(browser.p(:title, 'test_55').exists?)
167
+
168
+ assert_raises( UnknownObjectException) {browser.p(:id , 'missing').class_name }
169
+ assert_raises( UnknownObjectException) {browser.p(:id , 'missing').text }
170
+ assert_raises( UnknownObjectException) {browser.p(:id , 'missing').title }
171
+ assert_raises( UnknownObjectException) {browser.p(:id , 'missing').to_s }
172
+ assert_raises( UnknownObjectException) {browser.p(:id , 'missing').disabled }
173
+
174
+ assert_equal( 'redText' , browser.p(:index,1).class_name)
175
+ assert_equal( 'P_tag_1' , browser.p(:index,1).title)
176
+ assert_equal( 'This text is in a p with an id of number2' , browser.p(:index,2).text)
177
+ end
178
+
179
+ def test_p_iterator
180
+ assert_equal( 3, browser.ps.length)
181
+ assert_equal( 'italicText', browser.ps[2].class_name)
182
+ assert_equal( 'number3', browser.ps[3].id)
183
+
184
+ count=1
185
+ browser.ps.each do |p|
186
+ assert_equal('number'+count.to_s , p.id)
187
+ count+=1
188
+ end
189
+ assert_equal( count-1 , browser.ps.length)
190
+ end
191
+ end
192
+
193
+ class TC_Divs_Display < Test::Unit::TestCase
194
+
195
+ include CaptureIOHelper
196
+
197
+ tag_method :test_showDivs, :fails_on_ie
198
+ def test_showDivs
199
+ goto_page("div.html")
200
+ actual = capture_stdout { browser.showDivs }
201
+
202
+ assert_equal(<<END_OF_MESSAGE, actual)
203
+ There are 7 divs
204
+ div: name:
205
+ id: div1
206
+ class:
207
+ index: 1
208
+ div: name:
209
+ id: div2
210
+ class: blueText
211
+ index: 2
212
+ div: name:
213
+ id: div3
214
+ class:
215
+ index: 3
216
+ div: name:
217
+ id: div4
218
+ class:
219
+ index: 4
220
+ div: name:
221
+ id: buttons1
222
+ class:
223
+ index: 5
224
+ div: name:
225
+ id: buttons2
226
+ class:
227
+ index: 6
228
+ div: name: divName
229
+ id: text_fields1
230
+ class: divClass
231
+ index: 7
232
+ END_OF_MESSAGE
233
+ end
234
+ end
235
+
236
+ class TC_Spans_Display < Test::Unit::TestCase
237
+ include CaptureIOHelper
238
+
239
+ tag_method :test_showSpans, :fails_on_ie
240
+ def test_showSpans
241
+ goto_page("div.html")
242
+ actual = capture_stdout { browser.showSpans }
243
+ assert_equal(<<END_OF_MESSAGE, actual)
244
+ There are 7 spans
245
+ span: name:
246
+ id: span1
247
+ class:
248
+ index: 1
249
+ span: name:
250
+ id: span2
251
+ class: blueText
252
+ index: 2
253
+ span: name:
254
+ id: span3
255
+ class:
256
+ index: 3
257
+ span: name:
258
+ id: span4
259
+ class:
260
+ index: 4
261
+ span: name:
262
+ id: buttons1
263
+ class:
264
+ index: 5
265
+ span: name:
266
+ id: buttons2
267
+ class:
268
+ index: 6
269
+ span: name: spanName
270
+ id: text_fields1
271
+ class: spanClass
272
+ index: 7
273
+ END_OF_MESSAGE
274
+ end
275
+ end