firewatir 1.6.2 → 1.6.5

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 (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
@@ -0,0 +1,101 @@
1
+ module JsshSocket
2
+ # Evaluate javascript and return result. Raise an exception if an error occurred.
3
+ def js_eval(str)
4
+ str.gsub!("\n", "")
5
+ jssh_socket.send("#{str};\n", 0)
6
+ value = read_socket()
7
+ if md = /^(\w+)Error:(.*)$/.match(value)
8
+ errclassname="JS#{md[1]}Error"
9
+ unless JsshSocket.const_defined?(errclassname)
10
+ JsshSocket.const_set(errclassname, Class.new(StandardError))
11
+ end
12
+ raise JsshSocket.const_get(errclassname), md[2]
13
+ end
14
+ value
15
+ end
16
+
17
+ # evaluate the provides javascript method on the current object and return
18
+ # the result
19
+ def js_eval_method method_name
20
+ js_eval("#{element_object}.#{method_name}")
21
+ end
22
+
23
+ def jssh_socket
24
+ $jssh_socket || @container.jssh_socket
25
+ end
26
+
27
+ #
28
+ # Description:
29
+ # Reads the javascript execution result from the jssh socket.
30
+ #
31
+ # Input:
32
+ # - socket - It is the jssh socket, the only point of communication between the browser and firewatir scripts.
33
+ #
34
+ # Output:
35
+ # The javascript execution result as string.
36
+ #
37
+ def read_socket(socket = jssh_socket)
38
+ return_value = ""
39
+ data = ""
40
+ receive = true
41
+ #puts Thread.list
42
+ s = nil
43
+ while(s == nil) do
44
+ s = Kernel.select([socket] , nil , nil, 1)
45
+ end
46
+ #if(s != nil)
47
+ for stream in s[0]
48
+ data = stream.recv(1024)
49
+ #puts "data is : #{data}"
50
+ while(receive)
51
+ #while(data.length == 1024)
52
+ return_value += data
53
+ if(return_value.include?("\n> "))
54
+ receive = false
55
+ else
56
+ data = stream.recv(1024)
57
+ end
58
+ #puts "return_value is : #{return_value}"
59
+ #puts "data length is : #{data.length}"
60
+ end
61
+ end
62
+
63
+ # If received data is less than 1024 characters or for last data
64
+ # we read in the above loop
65
+ #return_value += data
66
+
67
+ # Get the command prompt inserted by JSSH
68
+ #s = Kernel.select([socket] , nil , nil, 0.3)
69
+
70
+ #if(s != nil)
71
+ # for stream in s[0]
72
+ # return_value += socket.recv(1024)
73
+ # end
74
+ #end
75
+
76
+ length = return_value.length
77
+ #puts "Return value before removing command prompt is : #{return_value}"
78
+
79
+ #Remove the command prompt. Every result returned by JSSH has "\n> " at the end.
80
+ if length <= 3
81
+ return_value = ""
82
+ elsif(return_value[0..2] == "\n> ")
83
+ return_value = return_value[3..length-1]
84
+ else
85
+ #return_value = return_value[0..length-3]
86
+ return_value = return_value[0..length-4]
87
+ end
88
+ #puts "Return value after removing command prompt is : #{return_value}"
89
+ #socket.flush
90
+
91
+ # make sure that command prompt doesn't get there.
92
+ if(return_value[return_value.length - 3..return_value.length - 1] == "\n> ")
93
+ return_value = return_value[0..return_value.length - 4]
94
+ end
95
+ if(return_value[0..2] == "\n> ")
96
+ return_value = return_value[3..return_value.length - 1]
97
+ end
98
+ #puts "return value is : #{return_value}"
99
+ return return_value
100
+ end
101
+ end
@@ -1,5 +1,5 @@
1
- module FireWatir
2
- class Firefox
3
- VERSION = '1.6.2'
4
- end
5
- end
1
+ module FireWatir
2
+ class Firefox
3
+ VERSION = '1.6.5'
4
+ end
5
+ end
@@ -1,42 +1,49 @@
1
- # feature tests for attaching to new Firefox windows
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_NewWindow < Test::Unit::TestCase
8
- tags :fails_on_ie
9
-
10
- def setup
11
- goto_page("new_browser.html")
12
- end
13
-
14
- def test_simply_attach_to_new_window_using_title
15
- browser.link(:text, 'New Window').click
16
- begin
17
- ff_new = browser.attach(:title, 'Pass Page')
18
- rescue Watir::Exception::NoMatchingWindowFoundException
19
- raise $!, "Attach failed, check your Firefox settings: http://wiki.openqa.org/display/WTR/FireWatir+Installation#FireWatirInstallation-ffsettings"
20
- end
21
- assert(ff_new.text.include?('PASS'))
22
- ff_new.close
23
- #browser.link(:text, 'New Window').click
24
- end
25
-
26
- def test_simply_attach_to_new_window_using_url
27
- browser.link(:text, 'New Window').click
28
- begin
29
- ff_new = browser.attach(:url, /pass\.html/)
30
- rescue Watir::Exception::NoMatchingWindowFoundException
31
- raise $!, "Attach failed, check your Firefox settings: http://wiki.openqa.org/display/WTR/FireWatir+Installation#FireWatirInstallation-ffsettings"
32
- end
33
- assert(ff_new.text.include?('PASS'))
34
- ff_new.close
35
- #browser.link(:text, 'New Window').click
36
- end
37
-
38
- def test_new_window_exists
39
- assert_raises(NoMatchingWindowFoundException , "NoMatchingWindowFoundException was supposed to be thrown" ) { browser.attach(:title, "missing_title") }
40
- assert_raises(NoMatchingWindowFoundException , "NoMatchingWindowFoundException was supposed to be thrown" ) { browser.attach(:url, "missing_url") }
41
- end
42
- end
1
+ # feature tests for attaching to new Firefox windows
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_NewWindow < Test::Unit::TestCase
8
+ tags :fails_on_ie
9
+
10
+ def setup
11
+ goto_page("new_browser.html")
12
+ end
13
+
14
+ def test_simply_attach_to_new_window_using_title
15
+ browser.link(:text, 'New Window').click
16
+ begin
17
+ ff_new = browser.attach(:title, 'Pass Page')
18
+ rescue Watir::Exception::NoMatchingWindowFoundException
19
+ raise $!, "Attach failed, check your Firefox settings: http://wiki.openqa.org/display/WTR/FireWatir+Installation#FireWatirInstallation-ffsettings"
20
+ end
21
+ assert(ff_new.text.include?('PASS'))
22
+ ff_new.close
23
+ #browser.link(:text, 'New Window').click
24
+ end
25
+
26
+ def test_simply_attach_to_new_window_using_url
27
+ browser.link(:text, 'New Window').click
28
+ begin
29
+ ff_new = browser.attach(:url, /pass\.html/)
30
+ rescue Watir::Exception::NoMatchingWindowFoundException
31
+ raise $!, "Attach failed, check your Firefox settings: http://wiki.openqa.org/display/WTR/FireWatir+Installation#FireWatirInstallation-ffsettings"
32
+ end
33
+ assert(ff_new.text.include?('PASS'))
34
+ ff_new.close
35
+ #browser.link(:text, 'New Window').click
36
+ end
37
+
38
+ def test_attach_to_new_window_with_same_title_as_parent
39
+ browser.link(:text, 'New Browser Window').click
40
+ ff_new = browser.attach(:title, 'New Browser Launcher')
41
+ assert(ff_new.text.include?('PASS'))
42
+ ff_new.close
43
+ end
44
+
45
+ def test_new_window_exists
46
+ assert_raises(NoMatchingWindowFoundException , "NoMatchingWindowFoundException was supposed to be thrown" ) { browser.attach(:title, "missing_title") }
47
+ assert_raises(NoMatchingWindowFoundException , "NoMatchingWindowFoundException was supposed to be thrown" ) { browser.attach(:url, "missing_url") }
48
+ end
49
+ end
@@ -1,198 +1,195 @@
1
- $LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..') unless $SETUP_LOADED
2
- require 'unittests/setup'
3
-
4
- class TC_Bugs< Test::Unit::TestCase
5
-
6
-
7
- def setup
8
- goto_page("frame_buttons.html")
9
- end
10
-
11
- tag_method :test_frame_objects_bug3, :fails_on_ie
12
- def test_frame_objects_bug3
13
- frame = browser.frame("buttonFrame")
14
- button = frame.button(:name, "b1")
15
- assert_equal("buttonFrame", frame.name)
16
- assert_equal("b2", button.id)
17
- text1 = frame.text_field(:id, "text_id")
18
- text1.set("NewValue")
19
- assert("NewValue",frame.text_field(:id, "text_id").value)
20
- end
21
-
22
- def test_link_object_bug9
23
- goto_page("links1.html")
24
- link = browser.link(:text, "nameDelet")
25
- assert_equal("test_link", link.name)
26
- end
27
-
28
-
29
- # element_by_xpath should return an element that's instance of the
30
- # appropriate class, not the generic Element class. So if it's a div,
31
- # it should return an instance of Div, if it's a checkbox, CheckBox,
32
- # and so on. TODO write tests for all classes
33
- tag_method :test_element_by_xpath_bug01, :fails_on_ie
34
- def test_element_by_xpath_bug01
35
- goto_page("div.html")
36
- element = browser.element_by_xpath("//div[@id='div1']")
37
- assert_not_nil(element) # helder
38
- # next assert always breaks, dunno why (error, not failure)
39
- #assert_instance_of(Div, element, "wrong constructor was used")
40
- # using this hack instead
41
- assert_class element, 'Div'
42
- end
43
-
44
- tag_method :test_elements_by_xpath_bug10, :fails_on_ie
45
- def test_elements_by_xpath_bug10
46
- goto_page("links1.html")
47
- elements = browser.elements_by_xpath("//a")
48
- assert_equal(11, elements.length)
49
- assert_equal("links2.html", elements[0].href)
50
- assert_equal("link_class_1", elements[1].className)
51
- assert_equal("link_id", elements[5].id)
52
- assert_equal("Link Using an ID", elements[5].text)
53
- end
54
-
55
- def test_button_by_value_bug8
56
- goto_page("buttons1.html")
57
- assert_equal("Sign In", browser.button(:value,"Sign In").value)
58
- end
59
-
60
- tag_method :test_html_bug7, :fails_on_ie
61
- def test_html_bug7
62
- goto_page("links1.html")
63
- html = browser.html
64
- assert_match(/.*<a id="linktos" *>*/,html)
65
- end
66
-
67
- def test_span_onclick_bug14
68
- goto_page("div.html")
69
- browser.span(:id, "span1").fireEvent("onclick")
70
- assert(browser.text.include?("PASS") )
71
- end
72
-
73
- tag_method :test_file_field_value_bug20, :fails_on_ie # hangs, actually
74
- def test_file_field_value_bug20
75
- actual_file_name = "c:\\Program Files\\TestFile.html"
76
- goto_page("fileupload.html")
77
- browser.file_field(:name, "file3").set(actual_file_name)
78
- set_file_name = browser.file_field(:name, "file3").value
79
- # make sure correct value for upload file is posted.
80
- assert(actual_file_name, set_file_name)
81
- end
82
-
83
- tag_method :test_attribute_value_bug22, :fails_on_ie
84
- def test_attribute_value_bug22
85
- goto_page("div.html")
86
- assert("Test1", browser.element_by_xpath("//div[@id='div1']").attribute_value("title"))
87
- end
88
-
89
- def test_url_value_bug23
90
- goto_page("buttons1.html")
91
- browser.button(:id, "b2").click
92
- assert($htmlRoot + "pass.html", browser.url)
93
- end
94
-
95
- def test_contains_text_bug28
96
- goto_page("buttons1.html")
97
- browser.button(:id, "b2").click
98
- assert_false(browser.contains_text("passed"))
99
- assert(browser.contains_text("PASS"))
100
- assert(browser.contains_text("PAS"))
101
- assert(browser.contains_text(/PAS/))
102
- assert(browser.contains_text(/pass/i))
103
- assert_false(browser.contains_text(/pass/))
104
- end
105
-
106
- tag_method :test_frame_bug_21, :fails_on_ie
107
- def test_frame_bug_21
108
- goto_page("frame_buttons.html")
109
- frame1 = browser.frame(:name, "buttonFrame")
110
- frame2 = browser.frame(:name, "buttonFrame2")
111
- assert_equal("buttons1.html", frame1.src)
112
- assert_equal("blankpage.html", frame2.src)
113
- end
114
-
115
- def test_quotes_bug_11
116
- goto_page("textfields1.html")
117
- browser.text_field(:name, "text1").set("value with quote (\")")
118
- assert_equal("value with quote (\")", browser.text_field(:name, "text1").value)
119
- browser.text_field(:name, "text1").set("value with backslash (\\)")
120
- assert_equal("value with backslash (\\)", browser.text_field(:name, "text1").value)
121
- end
122
-
123
- tag_method :test_close_bug_26, :fails_on_ie
124
- def test_close_bug_26
125
- if ! (RUBY_PLATFORM =~ /darwin/i)
126
- browser.close()
127
- browser = FireWatir::Firefox.new
128
- end
129
- end
130
-
131
- def test_class_bug_29
132
- goto_page("div.html")
133
- div = browser.div(:class, "blueText")
134
- assert_equal("div2", div.id)
135
- end
136
-
137
- def test_element_using_any_attribute
138
- goto_page("div.html")
139
- div = browser.div(:title, "Test1")
140
- assert_equal("div1", div.id)
141
- end
142
-
143
- tag_method :test_element_using_any_attribute2, :fails_on_ie
144
- def test_element_using_any_attribute2
145
- goto_page("div.html")
146
- div = browser.div(:attribute, "attribute")
147
- assert_equal("div1", div.id)
148
- end
149
-
150
- tag_method :test_file_field_bug_20, :fails_on_ie
151
- def test_file_field_bug_20
152
- goto_page("fileupload.html")
153
- # Enter dummy path.
154
- if(RUBY_PLATFORM =~ /.*mswin.*/)
155
- browser.file_field(:name, "file3").set("c:\\results.txt")
156
- else
157
- browser.file_field(:name, "file3").set("/user/lib/results.txt")
158
- end
159
- browser.button(:name, "upload").click()
160
- url = browser.url
161
- assert_match(/.*results.txt&upload=upload$/,url)
162
- end
163
-
164
- def test_button_bug2
165
- goto_page("buttons1.html")
166
- btn = browser.button(:id, "b7")
167
- assert_equal("b7", btn.id)
168
- end
169
-
170
- def test_getAllContents_bug25
171
- goto_page("select_tealeaf.html")
172
- browser.select_lists.each do |select|
173
- contents = select.getAllContents().to_s
174
- puts contents
175
- assert_equal("=<>>=<=", contents)
176
- break
177
- end
178
- end
179
-
180
- tag_method :test_fire_event_bug31, :fails_on_ie
181
- def test_fire_event_bug31
182
- goto_page("div.html")
183
- div = browser.div(:attribute, "attribute")
184
- div.fire_event("ondblclick")
185
- assert("PASS", browser.text)
186
- goto_page("div.html")
187
- div = browser.div(:id, "div1")
188
- div.fireEvent("ondblclick")
189
- assert("PASS", browser.text)
190
- end
191
-
192
- def test_contains_text_bug37
193
- goto_page("frame_buttons.html")
194
- frame = browser.frame(:name, "buttonFrame")
195
- assert(frame.contains_text("second button"))
196
- assert_false(frame.contains_text("second button second"))
197
- end
198
- end
1
+ $LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..') unless $SETUP_LOADED
2
+ require 'unittests/setup'
3
+
4
+ class TC_Bugs< Test::Unit::TestCase
5
+
6
+
7
+ def setup
8
+ goto_page("frame_buttons.html")
9
+ end
10
+
11
+ tag_method :test_frame_objects_bug3, :fails_on_ie
12
+ def test_frame_objects_bug3
13
+ frame = browser.frame("buttonFrame")
14
+ button = frame.button(:name, "b1")
15
+ assert_equal("buttonFrame", frame.name)
16
+ assert_equal("b2", button.id)
17
+ text1 = frame.text_field(:id, "text_id")
18
+ text1.set("NewValue")
19
+ assert("NewValue",frame.text_field(:id, "text_id").value)
20
+ end
21
+
22
+ def test_link_object_bug9
23
+ goto_page("links1.html")
24
+ link = browser.link(:text, "nameDelet")
25
+ assert_equal("test_link", link.name)
26
+ end
27
+
28
+
29
+ # element_by_xpath should return an element that's instance of the
30
+ # appropriate class, not the generic Element class. So if it's a div,
31
+ # it should return an instance of Div, if it's a checkbox, CheckBox,
32
+ # and so on. TODO write tests for all classes
33
+ tag_method :test_element_by_xpath_bug01, :fails_on_ie
34
+ def test_element_by_xpath_bug01
35
+ goto_page("div.html")
36
+ element = browser.element_by_xpath("//div[@id='div1']")
37
+ assert_not_nil(element) # helder
38
+ # next assert always breaks, dunno why (error, not failure)
39
+ #assert_instance_of(Div, element, "wrong constructor was used")
40
+ # using this hack instead
41
+ assert_class element, 'Div'
42
+ end
43
+
44
+ tag_method :test_elements_by_xpath_bug10, :fails_on_ie
45
+ def test_elements_by_xpath_bug10
46
+ goto_page("links1.html")
47
+ elements = browser.elements_by_xpath("//a")
48
+ assert_equal(11, elements.length)
49
+ assert_equal("links2.html", elements[0].href)
50
+ assert_equal("link_class_1", elements[1].className)
51
+ assert_equal("link_id", elements[5].id)
52
+ assert_equal("Link Using an ID", elements[5].text)
53
+ end
54
+
55
+ def test_button_by_value_bug8
56
+ goto_page("buttons1.html")
57
+ assert_equal("Sign In", browser.button(:value,"Sign In").value)
58
+ end
59
+
60
+ tag_method :test_html_bug7, :fails_on_ie
61
+ def test_html_bug7
62
+ goto_page("links1.html")
63
+ html = browser.html
64
+ assert_match(/.*<a id="linktos" *>*/,html)
65
+ end
66
+
67
+ def test_span_onclick_bug14
68
+ goto_page("div.html")
69
+ browser.span(:id, "span1").fireEvent("onclick")
70
+ assert(browser.text.include?("PASS") )
71
+ end
72
+
73
+ tag_method :test_file_field_value_bug20, :fails_on_ie # hangs, actually
74
+ def test_file_field_value_bug20
75
+ actual_file_name = "c:\\Program Files\\TestFile.html"
76
+ goto_page("fileupload.html")
77
+ browser.file_field(:name, "file3").set(actual_file_name)
78
+ set_file_name = browser.file_field(:name, "file3").value
79
+ # make sure correct value for upload file is posted.
80
+ assert(actual_file_name, set_file_name)
81
+ end
82
+
83
+ tag_method :test_attribute_value_bug22, :fails_on_ie
84
+ def test_attribute_value_bug22
85
+ goto_page("div.html")
86
+ assert("Test1", browser.element_by_xpath("//div[@id='div1']").attribute_value("title"))
87
+ end
88
+
89
+ def test_url_value_bug23
90
+ goto_page("buttons1.html")
91
+ browser.button(:id, "b2").click
92
+ assert($htmlRoot + "pass.html", browser.url)
93
+ end
94
+
95
+ def test_contains_text_bug28
96
+ goto_page("buttons1.html")
97
+ browser.button(:id, "b2").click
98
+ assert_false(browser.contains_text("passed"))
99
+ assert(browser.contains_text("PASS"))
100
+ assert(browser.contains_text("PAS"))
101
+ assert(browser.contains_text(/PAS/))
102
+ assert(browser.contains_text(/pass/i))
103
+ assert_false(browser.contains_text(/pass/))
104
+ end
105
+
106
+ tag_method :test_frame_bug_21, :fails_on_ie
107
+ def test_frame_bug_21
108
+ goto_page("frame_buttons.html")
109
+ frame1 = browser.frame(:name, "buttonFrame")
110
+ frame2 = browser.frame(:name, "buttonFrame2")
111
+ assert_equal("buttons1.html", frame1.src)
112
+ assert_equal("blankpage.html", frame2.src)
113
+ end
114
+
115
+ def test_quotes_bug_11
116
+ goto_page("textfields1.html")
117
+ browser.text_field(:name, "text1").set("value with quote (\")")
118
+ assert_equal("value with quote (\")", browser.text_field(:name, "text1").value)
119
+ browser.text_field(:name, "text1").set("value with backslash (\\)")
120
+ assert_equal("value with backslash (\\)", browser.text_field(:name, "text1").value)
121
+ end
122
+
123
+ tag_method :test_close_bug_26, :fails_on_ie
124
+ def test_close_bug_26
125
+ browser.close()
126
+ browser = FireWatir::Firefox.new
127
+ end
128
+
129
+ def test_class_bug_29
130
+ goto_page("div.html")
131
+ div = browser.div(:class, "blueText")
132
+ assert_equal("div2", div.id)
133
+ end
134
+
135
+ def test_element_using_any_attribute
136
+ goto_page("div.html")
137
+ div = browser.div(:title, "Test1")
138
+ assert_equal("div1", div.id)
139
+ end
140
+
141
+ tag_method :test_element_using_any_attribute2, :fails_on_ie
142
+ def test_element_using_any_attribute2
143
+ goto_page("div.html")
144
+ div = browser.div(:attribute, "attribute")
145
+ assert_equal("div1", div.id)
146
+ end
147
+
148
+ tag_method :test_file_field_bug_20, :fails_on_ie
149
+ def test_file_field_bug_20
150
+ goto_page("fileupload.html")
151
+ # Enter dummy path.
152
+ if(RUBY_PLATFORM =~ /.*mswin.*/)
153
+ browser.file_field(:name, "file3").set("c:\\results.txt")
154
+ else
155
+ browser.file_field(:name, "file3").set("/user/lib/results.txt")
156
+ end
157
+ browser.button(:name, "upload").click()
158
+ url = browser.url
159
+ assert_match(/.*results.txt&upload=upload$/,url)
160
+ end
161
+
162
+ def test_button_bug2
163
+ goto_page("buttons1.html")
164
+ btn = browser.button(:id, "b7")
165
+ assert_equal("b7", btn.id)
166
+ end
167
+
168
+ def test_getAllContents_bug25
169
+ goto_page("select_tealeaf.html")
170
+ browser.select_lists.each do |select|
171
+ contents = select.getAllContents().join
172
+ assert_equal("=<>>=<=", contents)
173
+ break
174
+ end
175
+ end
176
+
177
+ tag_method :test_fire_event_bug31, :fails_on_ie
178
+ def test_fire_event_bug31
179
+ goto_page("div.html")
180
+ div = browser.div(:attribute, "attribute")
181
+ div.fire_event("ondblclick")
182
+ assert("PASS", browser.text)
183
+ goto_page("div.html")
184
+ div = browser.div(:id, "div1")
185
+ div.fireEvent("ondblclick")
186
+ assert("PASS", browser.text)
187
+ end
188
+
189
+ def test_contains_text_bug37
190
+ goto_page("frame_buttons.html")
191
+ frame = browser.frame(:name, "buttonFrame")
192
+ assert(frame.contains_text("second button"))
193
+ assert_false(frame.contains_text("second button second"))
194
+ end
195
+ end