watir 1.5.4 → 1.5.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (75) hide show
  1. data/bin/watir-console +1 -0
  2. data/changes.rb +16 -2
  3. data/readme.rb +2 -16
  4. data/unittests/buttons_test.rb +74 -101
  5. data/unittests/buttons_xpath_test.rb +3 -3
  6. data/unittests/checkbox_test.rb +3 -3
  7. data/unittests/checkbox_xpath_test.rb +3 -3
  8. data/unittests/core_tests.rb +1 -1
  9. data/unittests/css_test.rb +2 -7
  10. data/unittests/defer_test.rb +2 -2
  11. data/unittests/dialog_test.rb +2 -2
  12. data/unittests/div2_xpath_test.rb +1 -1
  13. data/unittests/div_test.rb +122 -121
  14. data/unittests/div_xpath_test.rb +3 -3
  15. data/unittests/errorchecker_test.rb +3 -8
  16. data/unittests/filefield_test.rb +4 -7
  17. data/unittests/filefield_xpath_test.rb +3 -5
  18. data/unittests/form_test.rb +7 -7
  19. data/unittests/form_xpath_test.rb +6 -6
  20. data/unittests/frame_test.rb +8 -9
  21. data/unittests/google_form_test.rb +1 -2
  22. data/unittests/html/div.html +7 -1
  23. data/unittests/html/lists.html +1 -1
  24. data/unittests/ie_mock.rb +4 -2
  25. data/unittests/ie_test.rb +2 -2
  26. data/unittests/images_test.rb +2 -2
  27. data/unittests/images_xpath_test.rb +2 -2
  28. data/unittests/links_multi_test.rb +23 -9
  29. data/unittests/links_test.rb +7 -7
  30. data/unittests/links_xpath_test.rb +2 -3
  31. data/unittests/lists_test.rb +6 -3
  32. data/unittests/map_test.rb +1 -2
  33. data/unittests/minmax_test.rb +4 -5
  34. data/unittests/navigate_test.rb +18 -23
  35. data/unittests/nbsp_xpath_test.rb +4 -5
  36. data/unittests/{screen_capture_test.rb → other/screen_capture_test.rb} +1 -1
  37. data/unittests/pagecontainstext_test.rb +3 -4
  38. data/unittests/parent_child_test.rb +1 -1
  39. data/unittests/pre_test.rb +2 -3
  40. data/unittests/radios_test.rb +13 -17
  41. data/unittests/radios_xpath_test.rb +3 -3
  42. data/unittests/selectbox_test.rb +6 -14
  43. data/unittests/selectbox_xpath_test.rb +3 -3
  44. data/unittests/setup.rb +30 -10
  45. data/unittests/speed_settings_test.rb +2 -3
  46. data/unittests/table_cell_using_xpath_test.rb +2 -7
  47. data/unittests/table_test.rb +144 -136
  48. data/unittests/table_xpath_test.rb +5 -9
  49. data/unittests/textarea_test.rb +3 -7
  50. data/unittests/textarea_xpath_test.rb +5 -9
  51. data/unittests/textfield_for_ch_char_test.rb +1 -1
  52. data/unittests/textfields_test.rb +3 -4
  53. data/unittests/textfields_xpath_test.rb +3 -3
  54. data/unittests/windows/attach_to_existing_window_test.rb +2 -2
  55. data/unittests/windows/attach_to_new_window_test.rb +2 -2
  56. data/unittests/windows/close_window_test.rb +2 -3
  57. data/unittests/windows/frame_links_test.rb +1 -1
  58. data/unittests/windows/iedialog_test.rb +3 -3
  59. data/unittests/windows/js_events_test.rb +2 -4
  60. data/unittests/windows/modal_dialog_test.rb +2 -2
  61. data/unittests/windows/send_keys_test.rb +2 -4
  62. data/watir.rb +4 -13
  63. data/watir/assertions.rb +9 -1
  64. data/watir/collections.rb +6 -11
  65. data/watir/container.rb +9 -99
  66. data/watir/cookiemanager.rb +4 -1
  67. data/watir/element.rb +8 -1
  68. data/watir/ie.rb +2 -2
  69. data/watir/input_elements.rb +2 -2
  70. data/watir/non_control_elements.rb +39 -2
  71. data/watir/page-container.rb +1 -1
  72. data/watir/table.rb +25 -23
  73. metadata +68 -54
  74. data/watir/bonus-elements.rb +0 -65
  75. data/watir/testUnitAddons.rb +0 -8
@@ -1,14 +1,14 @@
1
1
  # feature tests for Divs, Spans and P's
2
- # revision: $Revision: 962 $
2
+ # revision: $Revision: 1348 $
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_Divs_XPath < Test::Unit::TestCase
8
- include Watir
8
+ include Watir::Exception
9
9
 
10
10
  def setup
11
- $ie.goto($htmlRoot + "div.html")
11
+ goto_page "div.html"
12
12
  end
13
13
 
14
14
  def test_divs
@@ -1,16 +1,11 @@
1
1
  # feature tests for Goto
2
- # revision: $Revision: 958 $
2
+ # revision: $Revision: 1348 $
3
3
 
4
4
  $LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..') if $0 == __FILE__
5
5
  require 'unittests/setup'
6
6
 
7
- class TC_error_checker< Test::Unit::TestCase
8
- include Watir
9
-
10
- def goto_page(page)
11
- $ie.goto($htmlRoot + page)
12
- end
13
-
7
+ class TC_error_checker < Test::Unit::TestCase
8
+
14
9
  def test_simple_checker
15
10
  button_checker = Proc.new{
16
11
  |ie| raise RuntimeError, "text 'buttons' was missing" if !ie.pageContainsText(/buttons/)
@@ -1,5 +1,5 @@
1
1
  # feature tests for file Fields
2
- # revision: $Revision: 1138 $
2
+ # revision: $Revision: 1349 $
3
3
 
4
4
  $LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..') if $0 == __FILE__
5
5
  require 'unittests/setup'
@@ -7,13 +7,11 @@ require 'unittests/setup'
7
7
  class TC_FileField < Test::Unit::TestCase
8
8
  include Watir
9
9
 
10
- def goto_page
11
- $ie.goto($htmlRoot + "fileupload.html")
10
+ def setup
11
+ goto_page "fileupload.html"
12
12
  end
13
13
 
14
14
  def test_file_field_Exists
15
- goto_page
16
-
17
15
  # test for existance of 4 file area
18
16
  assert($ie.file_field(:name,"file1").exists?)
19
17
  assert($ie.file_field(:id,"file2").exists?)
@@ -24,7 +22,7 @@ class TC_FileField < Test::Unit::TestCase
24
22
 
25
23
  # pop one open and put something in it.
26
24
  file = $htmlRoot + "fileupload.html"
27
- file.gsub! 'file://', ''
25
+ file.gsub! 'file:///', ''
28
26
  file.gsub! '/', '\\'
29
27
  $ie.file_field(:name,"file1").set(file)
30
28
  assert_equal file, $ie.file_field(:name,"file1").value
@@ -35,7 +33,6 @@ class TC_FileField < Test::Unit::TestCase
35
33
  end
36
34
 
37
35
  def test_iterator
38
- goto_page
39
36
  assert_equal(6, $ie.file_fields.length)
40
37
  end
41
38
 
@@ -1,5 +1,5 @@
1
1
  # feature tests for TextArea Fields
2
- # revision: $Revision: 963 $
2
+ # revision: $Revision: 1348 $
3
3
 
4
4
  $LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..') if $0 == __FILE__
5
5
  require 'unittests/setup'
@@ -7,12 +7,11 @@ require 'unittests/setup'
7
7
  class TC_FileField_XPath < Test::Unit::TestCase
8
8
  include Watir
9
9
 
10
- def goto_page
11
- $ie.goto($htmlRoot + "fileupload.html")
10
+ def setup
11
+ goto_page "fileupload.html"
12
12
  end
13
13
 
14
14
  def test_file_field_Exists
15
- goto_page
16
15
  #test for existance of 4 file area
17
16
  assert($ie.file_field(:xpath, "//input[@name='file1']/").exists?)
18
17
  assert($ie.file_field(:xpath, "//input[@id='file2']/").exists?)
@@ -28,7 +27,6 @@ class TC_FileField_XPath < Test::Unit::TestCase
28
27
  end
29
28
 
30
29
  def test_iterator
31
- goto_page
32
30
  assert_equal(6, $ie.file_fields.length)
33
31
  end
34
32
 
@@ -1,12 +1,12 @@
1
1
  # feature tests for Forms
2
- # revision: $Revision: 1294 $
2
+ # revision: $Revision: 1348 $
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_Forms2 < Test::Unit::TestCase # Note: there is no TC_Forms1
8
8
  def setup
9
- $ie.goto($htmlRoot + "forms2.html")
9
+ goto_page "forms2.html"
10
10
  end
11
11
 
12
12
  def test_Form_Exists
@@ -50,7 +50,7 @@ require 'unittests/iostring'
50
50
  class TC_Form_Display < Test::Unit::TestCase
51
51
  include MockStdoutTestCase
52
52
  def test_showforms
53
- $ie.goto($htmlRoot + "forms2.html")
53
+ goto_page "forms2.html"
54
54
  $stdout = @mockout
55
55
  $ie.showForms
56
56
  assert_equal(<<END_OF_MESSAGE, @mockout)
@@ -77,7 +77,7 @@ end
77
77
 
78
78
  class TC_Forms3 < Test::Unit::TestCase
79
79
  def setup
80
- $ie.goto($htmlRoot + "forms3.html")
80
+ goto_page "forms3.html"
81
81
  end
82
82
 
83
83
  # The following tests from bug 2261
@@ -181,7 +181,7 @@ end
181
181
  class TC_Forms3_Display < Test::Unit::TestCase
182
182
  include MockStdoutTestCase # BUG in test: output not verified!
183
183
  def test_show_stuff
184
- $ie.goto($htmlRoot + "forms3.html")
184
+ goto_page "forms3.html"
185
185
  $stdout = @mockout
186
186
  $ie.showAllObjects
187
187
  puts $ie.getText
@@ -191,7 +191,7 @@ end
191
191
 
192
192
  class TC_Forms4 < Test::Unit::TestCase
193
193
  def setup
194
- $ie.goto($htmlRoot + "forms4.html")
194
+ goto_page "forms4.html"
195
195
  end
196
196
 
197
197
  def test_find_text_field_ignoring_form
@@ -221,7 +221,7 @@ end
221
221
 
222
222
  class TC_Hidden_Fields < Test::Unit::TestCase
223
223
  def setup
224
- $ie.goto($htmlRoot + "forms3.html")
224
+ goto_page "forms3.html"
225
225
  end
226
226
 
227
227
  def test_hidden
@@ -1,12 +1,12 @@
1
1
  # feature tests for Forms
2
- # revision: $Revision: 1201 $
2
+ # revision: $Revision: 1348 $
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_Forms2_XPath < Test::Unit::TestCase
8
8
  def setup
9
- $ie.goto($htmlRoot + "forms2.html")
9
+ goto_page "forms2.html"
10
10
  end
11
11
 
12
12
  def test_Form_Exists
@@ -29,7 +29,7 @@ require 'unittests/iostring'
29
29
  class TC_Form_Display < Test::Unit::TestCase
30
30
  include MockStdoutTestCase
31
31
  def test_showforms
32
- $ie.goto($htmlRoot + "forms2.html")
32
+ goto_page "forms2.html"
33
33
  $stdout = @mockout
34
34
  $ie.show_forms
35
35
  assert_equal(<<END_OF_MESSAGE, @mockout)
@@ -56,7 +56,7 @@ end
56
56
 
57
57
  class TC_Forms3 < Test::Unit::TestCase
58
58
  def setup
59
- $ie.goto($htmlRoot + "forms3.html")
59
+ goto_page "forms3.html"
60
60
  end
61
61
 
62
62
  def test_Form_Exists
@@ -149,7 +149,7 @@ end
149
149
 
150
150
  class TC_Forms4 < Test::Unit::TestCase
151
151
  def setup
152
- $ie.goto($htmlRoot + "forms4.html")
152
+ goto_page "forms4.html"
153
153
  end
154
154
 
155
155
  def test_find_text_field_ignoring_form
@@ -174,7 +174,7 @@ end
174
174
 
175
175
  class TC_Hidden_Fields < Test::Unit::TestCase
176
176
  def setup
177
- $ie.goto($htmlRoot + "forms3.html")
177
+ goto_page "forms3.html"
178
178
  end
179
179
 
180
180
  def test_hidden
@@ -1,14 +1,14 @@
1
1
  # feature tests for Frames
2
- # revision: $Revision: 1204 $
2
+ # revision: $Revision: 1348 $
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_Frames < Test::Unit::TestCase
8
- include Watir
8
+ include Watir::Exception
9
9
 
10
10
  def setup
11
- $ie.goto($htmlRoot + "frame_buttons.html")
11
+ goto_page "frame_buttons.html"
12
12
  end
13
13
 
14
14
  def test_frame_no_what
@@ -54,10 +54,10 @@ class TC_Frames < Test::Unit::TestCase
54
54
  end
55
55
 
56
56
  class TC_Frames2 < Test::Unit::TestCase
57
- include Watir
57
+ include Watir::Exception
58
58
 
59
59
  def setup
60
- $ie.goto($htmlRoot + "frame_multi.html")
60
+ goto_page "frame_multi.html"
61
61
  end
62
62
 
63
63
  def test_frame_with_no_name
@@ -76,10 +76,10 @@ class TC_Frames2 < Test::Unit::TestCase
76
76
  end
77
77
 
78
78
  class TC_NestedFrames < Test::Unit::TestCase
79
- include Watir
79
+ include Watir::Exception
80
80
 
81
81
  def setup
82
- $ie.goto($htmlRoot + "nestedFrames.html")
82
+ goto_page "nestedFrames.html"
83
83
  end
84
84
 
85
85
  def test_frame
@@ -95,10 +95,9 @@ class TC_NestedFrames < Test::Unit::TestCase
95
95
  end
96
96
 
97
97
  class TC_IFrames < Test::Unit::TestCase
98
- include Watir
99
98
 
100
99
  def setup
101
- $ie.goto($htmlRoot + "iframeTest.html")
100
+ goto_page "iframeTest.html"
102
101
  end
103
102
 
104
103
  def test_Iframe
@@ -5,10 +5,9 @@ $LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..') if $0 == __FILE__
5
5
  require 'unittests/setup'
6
6
 
7
7
  class TC_GoogleForm < Test::Unit::TestCase
8
- include Watir
9
8
 
10
9
  def setup
11
- $ie.goto($htmlRoot + "google_india.html")
10
+ goto_page "google_india.html"
12
11
  end
13
12
 
14
13
  def test_it
@@ -8,7 +8,7 @@
8
8
 
9
9
  </head>
10
10
  <body>
11
- CVS Revision: "$Revision: 1086 $"
11
+ CVS Revision: "$Revision: 1352 $"
12
12
  <br>
13
13
  <br>
14
14
  <div id = div1 title = "Test1" >This text is in a div with an id of div1 and title of test1</div>
@@ -34,6 +34,12 @@ This input field gets its value from div3. Its name is text1<input type = text n
34
34
  Text1: <input type=textarea name=div_text1 >&nbsp;&nbsp;&nbsp;&nbsp; Text2: <input type=text name=div_text2 >&nbsp;&nbsp;&nbsp;&nbsp; Text3: <input type=text name=div_text3>
35
35
  </div>
36
36
 
37
+ <div id=hasImages>
38
+ <img src = images/triangle.jpg id=img1>
39
+ <img src = images/square.jpg id=img2>
40
+ <img src = images/circle.jpg id=circle>
41
+ </div>
42
+
37
43
 
38
44
 
39
45
 
@@ -10,7 +10,7 @@
10
10
 
11
11
  <h4>An Ordered List:</h4>
12
12
  <ol>
13
- <li id='ordered1' name='l1'>Phil</li>
13
+ <li id='ordered1' name='x1'>Phil</li>
14
14
  <li id='ordered2'>Bob</li>
15
15
  <li id='ordered3'>Joe</li>
16
16
  </ol>
@@ -35,11 +35,13 @@ class FakeDoc
35
35
  @links << value
36
36
  end
37
37
  end
38
-
38
+ def location
39
+ self
40
+ end
39
41
  def url
40
42
  return "file://fake"
41
43
  end
42
-
44
+ alias :href :url
43
45
  end
44
46
 
45
47
  class StubExplorer
@@ -1,5 +1,5 @@
1
1
  # Unit Test for Internet Explorer
2
- # revision: $Revision: 1141 $
2
+ # revision: $Revision: 1318 $
3
3
 
4
4
  $LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..') if $0 == __FILE__
5
5
  require 'watir/win32ole'
@@ -7,7 +7,7 @@ require 'unittests/ie_mock'
7
7
  require 'test/unit'
8
8
 
9
9
  class TC_ie < Test::Unit::TestCase
10
- include Watir
10
+ include Watir::Exception
11
11
 
12
12
  def setup
13
13
  @faked_ie = TestIE.new
@@ -1,5 +1,5 @@
1
1
  # feature tests for Images
2
- # revision: $Revision: 958 $
2
+ # revision: $Revision: 1348 $
3
3
 
4
4
  $LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..') if $0 == __FILE__
5
5
  require 'unittests/setup'
@@ -11,7 +11,7 @@ class TC_Images < Test::Unit::TestCase
11
11
  include Watir
12
12
 
13
13
  def setup
14
- $ie.goto($htmlRoot + "images1.html")
14
+ goto_page "images1.html"
15
15
  @saved_img_path = build_path("sample.img.dat");
16
16
  clean_saved_image
17
17
  end
@@ -1,5 +1,5 @@
1
1
  # feature tests for Images
2
- # revision: $Revision: 962 $
2
+ # revision: $Revision: 1348 $
3
3
 
4
4
  $LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..') if $0 == __FILE__
5
5
  require 'unittests/setup'
@@ -15,7 +15,7 @@ class TC_Images_XPath < Test::Unit::TestCase
15
15
  end
16
16
 
17
17
  def gotoImagePage
18
- $ie.goto($htmlRoot + "images1.html")
18
+ goto_page "images1.html"
19
19
  end
20
20
 
21
21
  def test_imageExists
@@ -5,32 +5,46 @@ $LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..') if $0 == __FILE__
5
5
  require 'unittests/setup'
6
6
 
7
7
  class TC_Links_Multi < Test::Unit::TestCase
8
- include Watir
9
8
 
10
9
  def setup
11
- $ie.goto $htmlRoot + 'links_multi.html'
10
+ browser.goto $htmlRoot + 'links_multi.html'
12
11
  end
13
12
 
14
13
  def test_existing
15
- assert_match(/not.html/, $ie.link(:class_name, 'Papa').href)
16
- assert_match(/mama.html/, $ie.link(:text, 'click').href)
14
+ assert_match(/not.html/, browser.link(:class_name, 'Papa').href)
15
+ assert_match(/mama.html/, browser.link(:text, 'click').href)
17
16
  end
18
17
 
19
18
  def test_class_alias
20
- assert_match(/not.html/, $ie.link(:class, 'Papa').href)
19
+ assert_match(/not.html/, browser.link(:class, 'Papa').href)
21
20
  end
22
21
 
23
22
  def test_hash_syntax
24
- assert_match(/not.html/, $ie.link(:class_name => 'Papa').href)
25
- assert_match(/mama.html/, $ie.link(:text => 'click').href)
23
+ assert_match(/not.html/, browser.link(:class_name => 'Papa').href)
24
+ assert_match(/mama.html/, browser.link(:text => 'click').href)
26
25
  end
27
26
 
28
27
  def test_class_and_text
29
- assert_match(/papa.html/, $ie.link(:class => 'Papa', :text => 'click').href)
28
+ assert_match(/papa.html/, browser.link(:class => 'Papa', :text => 'click').href)
30
29
  end
31
30
 
32
31
  def test_class_and_index
33
- assert_match(/papa.html/, $ie.link(:class => 'Papa', :index => 2).href)
32
+ assert_match(/papa.html/, browser.link(:class => 'Papa', :index => 2).href)
34
33
  end
34
+
35
+ include Watir::Exception
36
+ def test_not_found_single
37
+ exception = assert_raise(UnknownObjectException) do
38
+ browser.link(:id, 'Missing').href
39
+ end
40
+ assert_equal('Unable to locate element, using :id, "Missing"', exception.message)
41
+ end
42
+
43
+ def test_not_found_with_multi
44
+ exception = assert_raise(UnknownObjectException) do
45
+ browser.link(:class => 'Missing', :index => 2).href
46
+ end
47
+ assert_equal('Unable to locate element, using {:class=>"Missing", :index=>2}', exception.message)
48
+ end
35
49
 
36
50
  end
@@ -1,15 +1,15 @@
1
1
  # feature tests for Links
2
- # revision: $Revision: 1277 $
2
+ # revision: $Revision: 1348 $
3
3
 
4
4
  $LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..') if $0 == __FILE__
5
5
  require 'unittests/setup'
6
6
  require 'cgi'
7
7
 
8
8
  class TC_Links < Test::Unit::TestCase
9
- include Watir
9
+ include Watir::Exception
10
10
 
11
11
  def setup
12
- $ie.goto($htmlRoot + "links1.html")
12
+ goto_page "links1.html"
13
13
  end
14
14
 
15
15
  def test_bad_attribute
@@ -119,16 +119,16 @@ class TC_Links < Test::Unit::TestCase
119
119
  end
120
120
 
121
121
  def test_div_xml_bug
122
- $ie.goto($htmlRoot + "div_xml.html")
122
+ goto_page "div_xml.html"
123
123
  assert_nothing_raised {$ie.link(:text, 'Create').exists? }
124
124
  end
125
125
  end
126
126
 
127
127
  class TC_Frame_Links < Test::Unit::TestCase
128
- include Watir
128
+ include Watir::Exception
129
129
 
130
130
  def setup
131
- $ie.goto($htmlRoot + "frame_links.html")
131
+ goto_page "frame_links.html"
132
132
  end
133
133
 
134
134
  def test_links_in_frames
@@ -152,7 +152,7 @@ class TC_showlinks < Test::Unit::TestCase
152
152
  include MockStdoutTestCase
153
153
 
154
154
  def test_showLinks
155
- $ie.goto($htmlRoot + "links1.html")
155
+ goto_page "links1.html"
156
156
  $stdout = @mockout
157
157
  $ie.showLinks
158
158
  expected = [/^index name +id +href + text\/src$/,