watir 1.5.6 → 1.6.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (133) hide show
  1. data/{changes.rb → CHANGES} +12 -3
  2. data/bin/watir-console +7 -1
  3. data/lib/changes.rb +3 -0
  4. data/{license.rb → lib/license.rb} +2 -1
  5. data/{readme.rb → lib/readme.rb} +4 -6
  6. data/{watir → lib/watir}/AutoItX3.dll +0 -0
  7. data/{watir → lib/watir}/IEDialog/Release/IEDialog.dll +0 -0
  8. data/{watir → lib/watir}/WindowHelper.rb +1 -1
  9. data/{watir → lib/watir}/camel_case.rb +0 -0
  10. data/{watir → lib/watir}/clickJSDialog.rb +0 -0
  11. data/{watir → lib/watir}/close_all.rb +1 -1
  12. data/{watir → lib/watir}/collections.rb +1 -1
  13. data/{watir → lib/watir}/container.rb +17 -8
  14. data/{watir → lib/watir}/contrib/enabled_popup.rb +0 -0
  15. data/{watir → lib/watir}/contrib/ie-new-process.rb +0 -0
  16. data/{watir → lib/watir}/contrib/page_checker.rb +0 -0
  17. data/{watir → lib/watir}/contrib/visible.rb +2 -2
  18. data/{watir → lib/watir}/cookiemanager.rb +0 -0
  19. data/{watir → lib/watir}/datahandler.rb +0 -0
  20. data/{watir → lib/watir}/dialog.rb +1 -1
  21. data/{watir → lib/watir}/element.rb +3 -7
  22. data/{watir → lib/watir}/element_collections.rb +0 -0
  23. data/{watir → lib/watir}/form.rb +31 -11
  24. data/{watir → lib/watir}/frame.rb +0 -0
  25. data/{watir/ie.rb → lib/watir/ie-class.rb} +22 -22
  26. data/{watir → lib/watir}/ie-process.rb +0 -0
  27. data/{watir.rb → lib/watir/ie.rb} +11 -27
  28. data/{watir → lib/watir}/image.rb +0 -0
  29. data/{watir → lib/watir}/input_elements.rb +33 -44
  30. data/{watir → lib/watir}/irb-history.rb +0 -0
  31. data/{watir → lib/watir}/link.rb +0 -0
  32. data/{watir → lib/watir}/locator.rb +56 -43
  33. data/{watir → lib/watir}/logger.rb +0 -0
  34. data/{watir → lib/watir}/modal_dialog.rb +0 -0
  35. data/{watir → lib/watir}/non_control_elements.rb +0 -0
  36. data/{watir → lib/watir}/page-container.rb +2 -2
  37. data/{watir → lib/watir}/popup.rb +0 -0
  38. data/{watir → lib/watir}/process.rb +0 -0
  39. data/{watir → lib/watir}/screen_capture.rb +0 -0
  40. data/{watir → lib/watir}/setFileDialog.rb +0 -0
  41. data/{watir → lib/watir}/table.rb +7 -2
  42. data/{watir → lib/watir}/utils.rb +0 -0
  43. data/lib/watir/version.rb +5 -0
  44. data/{watir → lib/watir}/watir_simple.rb +3 -3
  45. data/{watir → lib/watir}/win32.rb +0 -0
  46. data/lib/watir/win32ole.rb +6 -0
  47. data/lib/watir/win32ole/win32ole.so +0 -0
  48. data/{watir → lib/watir}/winClicker.rb +0 -0
  49. data/unittests/buttons_xpath_test.rb +32 -32
  50. data/unittests/checkbox_test.rb +113 -99
  51. data/unittests/checkbox_xpath_test.rb +57 -57
  52. data/unittests/core_tests.rb +10 -7
  53. data/unittests/css_test.rb +12 -32
  54. data/unittests/defer_test.rb +22 -22
  55. data/unittests/dialog_test.rb +13 -13
  56. data/unittests/div2_xpath_test.rb +3 -3
  57. data/unittests/div_test.rb +23 -19
  58. data/unittests/div_xpath_test.rb +50 -50
  59. data/unittests/errorchecker_test.rb +7 -9
  60. data/unittests/filefield_test.rb +12 -11
  61. data/unittests/filefield_xpath_test.rb +10 -10
  62. data/unittests/form_test.rb +144 -151
  63. data/unittests/form_xpath_test.rb +99 -99
  64. data/unittests/frame_test.rb +46 -44
  65. data/unittests/google_form_test.rb +2 -2
  66. data/unittests/html/checkboxes1.html +19 -16
  67. data/unittests/html/forms3.html +2 -2
  68. data/unittests/html/wallofcheckboxes.html +1003 -0
  69. data/unittests/ie_exists_test.rb +5 -3
  70. data/unittests/ie_test.rb +2 -2
  71. data/unittests/images_test.rb +83 -82
  72. data/unittests/images_xpath_test.rb +40 -40
  73. data/unittests/iostring_test.rb +1 -1
  74. data/unittests/links_multi_test.rb +7 -8
  75. data/unittests/links_test.rb +73 -71
  76. data/unittests/links_xpath_test.rb +15 -15
  77. data/unittests/lists_test.rb +10 -10
  78. data/unittests/map_test.rb +65 -65
  79. data/unittests/minmax_test.rb +10 -9
  80. data/unittests/navigate_test.rb +19 -23
  81. data/unittests/nbsp_xpath_test.rb +2 -2
  82. data/unittests/non_core_tests.rb +5 -2
  83. data/unittests/other/WindowLogonExample.rb +2 -2
  84. data/unittests/other/WindowLogonExtra.rb +1 -1
  85. data/unittests/other/navigate_exception_test.rb +14 -3
  86. data/unittests/other/screen_capture_test.rb +3 -2
  87. data/unittests/other/testcase_method_order_test.rb +1 -1
  88. data/unittests/pagecontainstext_test.rb +17 -14
  89. data/unittests/parent_child_test.rb +11 -7
  90. data/unittests/perf_test.rb +20 -0
  91. data/unittests/popups_test.rb +13 -14
  92. data/unittests/pre_test.rb +30 -28
  93. data/unittests/radios_test.rb +128 -107
  94. data/unittests/radios_xpath_test.rb +47 -47
  95. data/unittests/security_setting_test.rb +24 -0
  96. data/unittests/selectbox_test.rb +65 -157
  97. data/unittests/selectbox_xpath_test.rb +51 -51
  98. data/unittests/setup.rb +52 -48
  99. data/unittests/speed_settings_test.rb +31 -20
  100. data/unittests/table_cell_using_xpath_test.rb +12 -12
  101. data/unittests/table_test.rb +30 -16
  102. data/unittests/table_xpath_test.rb +25 -25
  103. data/unittests/test_tests.rb +9 -0
  104. data/unittests/textarea_test.rb +33 -33
  105. data/unittests/textarea_xpath_test.rb +37 -37
  106. data/unittests/textfield_for_ch_char_test.rb +9 -9
  107. data/unittests/textfields_test.rb +103 -98
  108. data/unittests/textfields_xpath_test.rb +50 -50
  109. data/unittests/windows/attach_to_existing_window_test.rb +2 -2
  110. data/unittests/windows/attach_to_new_window_test.rb +10 -10
  111. data/unittests/windows/close_window_test.rb +2 -2
  112. data/unittests/windows/frame_links_test.rb +6 -6
  113. data/unittests/windows/ie-each_test.rb +1 -1
  114. data/unittests/windows/iedialog_test.rb +4 -5
  115. data/unittests/windows/js_events_test.rb +14 -14
  116. data/unittests/windows/jscriptExtraAlert.rb +2 -1
  117. data/unittests/windows/jscriptExtraConfirmCancel.rb +1 -1
  118. data/unittests/windows/jscriptExtraConfirmOk.rb +1 -1
  119. data/unittests/windows/jscriptPushButton.rb +2 -1
  120. data/unittests/windows/jscript_test.rb +7 -7
  121. data/unittests/windows/modal_dialog_test.rb +28 -29
  122. data/unittests/windows/{new.rb → new_test.rb} +1 -1
  123. data/unittests/windows/open_close_test.rb +4 -7
  124. data/unittests/windows/send_keys_test.rb +11 -11
  125. data/unittests/xpath_tests.rb +4 -3
  126. metadata +82 -58
  127. data/unittests/buttons_test.rb +0 -107
  128. data/watir/assertions.rb +0 -44
  129. data/watir/exceptions.rb +0 -42
  130. data/watir/testcase.rb +0 -58
  131. data/watir/waiter.rb +0 -88
  132. data/watir/win32ole.rb +0 -8
  133. data/watir/win32ole/win32ole.so +0 -0
@@ -1,10 +1,11 @@
1
1
  # test IE#exists?
2
2
  # revision: $Revision: 962 $
3
3
 
4
- $LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..') if $0 == __FILE__
4
+ $LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..') unless $SETUP_LOADED
5
5
  require 'unittests/setup'
6
6
 
7
7
  class TC_IE_Exists < Test::Unit::TestCase
8
+ tags :fails_on_firefox, :new
8
9
  def setup
9
10
  @ie = Watir::IE.new
10
11
  end
@@ -17,16 +18,17 @@ class TC_IE_Exists < Test::Unit::TestCase
17
18
  end
18
19
 
19
20
  class TC_IENotExists < Test::Unit::TestCase
21
+ tags :fails_on_firefox, :new
20
22
  def setup
21
23
  @ie = Watir::IE.new
22
24
  end
23
25
  def test_we_closed_it
24
26
  @ie.close
25
- assert(!@ie.exists?)
27
+ assert_false(@ie.exists?)
26
28
  end
27
29
  def test_some_one_else_closed_it
28
30
  @ie.ie.quit
29
31
  sleep 0.3 # give it some time to close
30
- assert(!@ie.exists?)
32
+ assert_false(@ie.exists?)
31
33
  end
32
34
  end
@@ -1,7 +1,7 @@
1
1
  # Unit Test for Internet Explorer
2
- # revision: $Revision: 1318 $
2
+ # revision: $Revision: 1417 $
3
3
 
4
- $LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..') if $0 == __FILE__
4
+ $LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..') unless $SETUP_LOADED
5
5
  require 'watir/win32ole'
6
6
  require 'unittests/ie_mock'
7
7
  require 'test/unit'
@@ -1,13 +1,14 @@
1
1
  # feature tests for Images
2
- # revision: $Revision: 1348 $
2
+ # revision: $Revision: 1431 $
3
3
 
4
- $LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..') if $0 == __FILE__
4
+ $LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..') unless $SETUP_LOADED
5
5
  require 'unittests/setup'
6
6
  require 'ftools'
7
7
  require 'webrick'
8
8
  require 'watir/cookiemanager'
9
9
 
10
10
  class TC_Images < Test::Unit::TestCase
11
+ tags :must_be_visible, :creates_windows
11
12
  include Watir
12
13
 
13
14
  def setup
@@ -21,124 +22,124 @@ class TC_Images < Test::Unit::TestCase
21
22
  end
22
23
 
23
24
  def test_imageExists
24
- assert( ! $ie.image(:name , "missing_name").exists? )
25
- assert( $ie.image(:name , "circle").exists? )
26
- assert( $ie.image(:name , /circ/ ).exists? )
25
+ assert( ! browser.image(:name , "missing_name").exists? )
26
+ assert( browser.image(:name , "circle").exists? )
27
+ assert( browser.image(:name , /circ/ ).exists? )
27
28
 
28
- assert( ! $ie.image(:id , "missing_id").exists? )
29
- assert( $ie.image(:id , "square").exists? )
30
- assert( $ie.image(:id , /squ/ ).exists? )
29
+ assert( ! browser.image(:id , "missing_id").exists? )
30
+ assert( browser.image(:id , "square").exists? )
31
+ assert( browser.image(:id , /squ/ ).exists? )
31
32
 
32
- assert( ! $ie.image(:src, "missingsrc.gif").exists? )
33
+ assert( ! browser.image(:src, "missingsrc.gif").exists? )
33
34
 
34
- assert( $ie.image(:src, "file:///#{$myDir}/html/images/triangle.jpg").exists? )
35
- assert( $ie.image(:src , /triangle/ ).exists? )
35
+ assert( browser.image(:src, "file:///#{$myDir}/html/images/triangle.jpg").exists? )
36
+ assert( browser.image(:src , /triangle/ ).exists? )
36
37
 
37
- assert( $ie.image(:alt , "circle" ).exists? )
38
- assert( $ie.image(:alt , /cir/ ).exists? )
38
+ assert( browser.image(:alt , "circle" ).exists? )
39
+ assert( browser.image(:alt , /cir/ ).exists? )
39
40
 
40
- assert( ! $ie.image(:alt , "triangle" ).exists? )
41
- assert( ! $ie.image(:alt , /tri/ ).exists? )
41
+ assert( ! browser.image(:alt , "triangle" ).exists? )
42
+ assert( ! browser.image(:alt , /tri/ ).exists? )
42
43
 
43
- assert( $ie.image(:title, 'square_image').exists? )
44
- assert( ! $ie.image(:title, 'pentagram').exists? )
44
+ assert( browser.image(:title, 'square_image').exists? )
45
+ assert( ! browser.image(:title, 'pentagram').exists? )
45
46
  end
46
47
 
47
48
  def test_image_click
48
- assert_raises(UnknownObjectException ) { $ie.image(:name, "no_image_with_this").click }
49
- assert_raises(UnknownObjectException ) { $ie.image(:id, "no_image_with_this").click }
50
- assert_raises(UnknownObjectException ) { $ie.image(:src, "no_image_with_this").click}
51
- assert_raises(UnknownObjectException ) { $ie.image(:alt, "no_image_with_this").click}
49
+ assert_raises(UnknownObjectException) { browser.image(:name, "no_image_with_this").click }
50
+ assert_raises(UnknownObjectException) { browser.image(:id, "no_image_with_this").click }
51
+ assert_raises(UnknownObjectException) { browser.image(:src, "no_image_with_this").click}
52
+ assert_raises(UnknownObjectException) { browser.image(:alt, "no_image_with_this").click}
52
53
 
53
54
  # test for bug 1882
54
- $ie.text_field(:name , "text1").clear
55
- $ie.button(:value , /Pos/ ).click
56
- assert_equal('clicked' , $ie.text_field(:name , "text1" ).value )
55
+ browser.text_field(:name , "text1").clear
56
+ browser.button(:value , /Pos/ ).click
57
+ assert_equal('clicked' , browser.text_field(:name , "text1" ).value )
57
58
 
58
59
  # test for disabled button
59
- assert( ! $ie.image(:name , 'disabler_test').disabled )
60
- $ie.button(:name , 'disable_img').click
60
+ assert( ! browser.image(:name , 'disabler_test').disabled )
61
+ browser.button(:name , 'disable_img').click
61
62
 
62
- assert( $ie.image(:name , 'disabler_test').disabled )
63
- $ie.button(:name , 'disable_img').click
63
+ assert( browser.image(:name , 'disabler_test').disabled )
64
+ browser.button(:name , 'disable_img').click
64
65
 
65
- $ie.image(:src, /button/).click
66
- assert($ie.text.include?("PASS") )
66
+ browser.image(:src, /button/).click
67
+ assert(browser.text.include?("PASS") )
67
68
  end
68
69
 
69
70
  def test_imageHasLoaded
70
- assert_raises(UnknownObjectException ) { $ie.image(:name, "no_image_with_this").hasLoaded? }
71
- assert_raises(UnknownObjectException ) { $ie.image(:id, "no_image_with_this").hasLoaded? }
72
- assert_raises(UnknownObjectException ) { $ie.image(:src, "no_image_with_this").hasLoaded? }
73
- assert_raises(UnknownObjectException ) { $ie.image(:alt, "no_image_with_this").hasLoaded? }
71
+ assert_raises(UnknownObjectException) { browser.image(:name, "no_image_with_this").hasLoaded? }
72
+ assert_raises(UnknownObjectException) { browser.image(:id, "no_image_with_this").hasLoaded? }
73
+ assert_raises(UnknownObjectException) { browser.image(:src, "no_image_with_this").hasLoaded? }
74
+ assert_raises(UnknownObjectException) { browser.image(:alt, "no_image_with_this").hasLoaded? }
74
75
 
75
- assert( ! $ie.image(:name, "themissingimage").hasLoaded? )
76
- assert( $ie.image(:name, "circle").hasLoaded? )
76
+ assert( ! browser.image(:name, "themissingimage").hasLoaded? )
77
+ assert( browser.image(:name, "circle").hasLoaded? )
77
78
 
78
- assert( $ie.image(:alt, "circle").hasLoaded? )
79
- assert( $ie.image(:alt, /cir/ ).hasLoaded? )
79
+ assert( browser.image(:alt, "circle").hasLoaded? )
80
+ assert( browser.image(:alt, /cir/ ).hasLoaded? )
80
81
  end
81
82
 
82
83
  def test_image_properties
83
- assert_raises(UnknownObjectException ) { $ie.image(:name, "no_image_with_this").hasLoaded? }
84
- assert_raises(UnknownObjectException ) { $ie.image(:id, "no_image_with_this").hasLoaded? }
85
- assert_raises(UnknownObjectException ) { $ie.image(:src, "no_image_with_this").hasLoaded? }
86
- assert_raises(UnknownObjectException ) { $ie.image(:index, 82).hasLoaded? }
87
-
88
- assert_raises(UnknownObjectException ) { $ie.image(:index, 82).name }
89
- assert_raises(UnknownObjectException ) { $ie.image(:index, 82).id }
90
- assert_raises(UnknownObjectException ) { $ie.image(:index, 82).src }
91
- assert_raises(UnknownObjectException ) { $ie.image(:index, 82).value }
92
- assert_raises(UnknownObjectException ) { $ie.image(:index, 82).height }
93
- assert_raises(UnknownObjectException ) { $ie.image(:index, 82).width }
94
- assert_raises(UnknownObjectException ) { $ie.image(:index, 82).fileCreatedDate }
95
- assert_raises(UnknownObjectException ) { $ie.image(:index, 82).fileSize }
96
- assert_raises(UnknownObjectException ) { $ie.image(:index, 82).alt}
97
- assert_raises(UnknownObjectException ) { $ie.image(:index, 82).title}
98
-
99
- assert_equal( "" , $ie.image(:index, 2).name )
100
- assert_equal( "square" , $ie.image(:index, 2).id )
101
- assert_match( /square\.jpg/i ,$ie.image(:index, 2).src )
102
- assert_equal( "" , $ie.image(:index, 2).value )
103
- assert_equal( "88" , $ie.image(:index, 2).height )
104
- assert_equal( "88" , $ie.image(:index, 2).width )
84
+ assert_raises(UnknownObjectException) { browser.image(:name, "no_image_with_this").hasLoaded? }
85
+ assert_raises(UnknownObjectException) { browser.image(:id, "no_image_with_this").hasLoaded? }
86
+ assert_raises(UnknownObjectException) { browser.image(:src, "no_image_with_this").hasLoaded? }
87
+ assert_raises(UnknownObjectException) { browser.image(:index, 82).hasLoaded? }
88
+
89
+ assert_raises(UnknownObjectException) { browser.image(:index, 82).name }
90
+ assert_raises(UnknownObjectException) { browser.image(:index, 82).id }
91
+ assert_raises(UnknownObjectException) { browser.image(:index, 82).src }
92
+ assert_raises(UnknownObjectException) { browser.image(:index, 82).value }
93
+ assert_raises(UnknownObjectException) { browser.image(:index, 82).height }
94
+ assert_raises(UnknownObjectException) { browser.image(:index, 82).width }
95
+ assert_raises(UnknownObjectException) { browser.image(:index, 82).fileCreatedDate }
96
+ assert_raises(UnknownObjectException) { browser.image(:index, 82).fileSize }
97
+ assert_raises(UnknownObjectException) { browser.image(:index, 82).alt}
98
+ assert_raises(UnknownObjectException) { browser.image(:index, 82).title}
99
+
100
+ assert_equal( "" , browser.image(:index, 2).name )
101
+ assert_equal( "square" , browser.image(:index, 2).id )
102
+ assert_match( /square\.jpg/i ,browser.image(:index, 2).src )
103
+ assert_equal( "" , browser.image(:index, 2).value )
104
+ assert_equal( "88" , browser.image(:index, 2).height )
105
+ assert_equal( "88" , browser.image(:index, 2).width )
105
106
 
106
107
  # this line fails, as the date is when it is installed on the local oc, not the date the file was really created
107
- #assert_equal( "03/10/2005" , $ie.image(:index, 2).fileCreatedDate )
108
- assert_equal( "788", $ie.image(:index, 2).fileSize )
108
+ #assert_equal( "03/10/2005" , browser.image(:index, 2).fileCreatedDate )
109
+ assert_equal( "788", browser.image(:index, 2).fileSize )
109
110
 
110
111
  # tool tips: alt text + title
111
- assert_equal('circle' , $ie.image(:index, 6).alt)
112
- assert_equal( "" , $ie.image(:index, 2).alt)
113
- assert_equal('square_image', $ie.image(:id, 'square').title)
112
+ assert_equal('circle' , browser.image(:index, 6).alt)
113
+ assert_equal( "" , browser.image(:index, 2).alt)
114
+ assert_equal('square_image', browser.image(:id, 'square').title)
114
115
 
115
116
  # TODO: to string tests -- output should be verified!
116
- $ie.image(:name , "circle").to_s
117
- $ie.image(:index , 2).to_s
117
+ browser.image(:name , "circle").to_s
118
+ browser.image(:index , 2).to_s
118
119
  end
119
120
 
120
121
  def test_image_iterator
121
- assert_equal(6 , $ie.images.length)
122
- assert_equal("" , $ie.images[2].name )
123
- assert_equal("square", $ie.images[2].id )
124
- assert_match(/square/, $ie.images[2].src )
122
+ assert_equal(6 , browser.images.length)
123
+ assert_equal("" , browser.images[2].name )
124
+ assert_equal("square", browser.images[2].id )
125
+ assert_match(/square/, browser.images[2].src )
125
126
 
126
127
  index = 1
127
- $ie.images.each do |i|
128
- assert_equal( $ie.image(:index, index).id , i.id )
129
- assert_equal( $ie.image(:index, index).name , i.name )
130
- assert_equal( $ie.image(:index, index).src , i.src )
131
- assert_equal( $ie.image(:index, index).height , i.height )
132
- assert_equal( $ie.image(:index, index).width , i.width )
128
+ browser.images.each do |i|
129
+ assert_equal( browser.image(:index, index).id , i.id )
130
+ assert_equal( browser.image(:index, index).name , i.name )
131
+ assert_equal( browser.image(:index, index).src , i.src )
132
+ assert_equal( browser.image(:index, index).height , i.height )
133
+ assert_equal( browser.image(:index, index).width , i.width )
133
134
 
134
- index+=1
135
+ index += 1
135
136
  end
136
- assert_equal( index-1 , $ie.images.length )
137
+ assert_equal(index - 1 , browser.images.length)
137
138
  end
138
139
 
139
140
  def test_save_local_image
140
- $ie.images[1].save(build_windows_path("sample.img.dat"))
141
- assert(File.compare(@saved_img_path, $ie.images[1].src.gsub(/^file:\/\/\//, '')))
141
+ browser.images[1].save(build_windows_path("sample.img.dat"))
142
+ assert(File.compare(@saved_img_path, browser.images[1].src.gsub(/^file:\/\/\//, '')))
142
143
  end
143
144
 
144
145
  def clean_saved_image
@@ -150,7 +151,7 @@ class TC_Images < Test::Unit::TestCase
150
151
  end
151
152
 
152
153
  def build_path(part)
153
- "#{$myDir}/#{part}"
154
+ "#{$myDir}/#{part}"
154
155
  end
155
156
  end
156
157
 
@@ -1,7 +1,7 @@
1
1
  # feature tests for Images
2
- # revision: $Revision: 1348 $
2
+ # revision: $Revision: 1505 $
3
3
 
4
- $LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..') if $0 == __FILE__
4
+ $LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..') unless $SETUP_LOADED
5
5
  require 'unittests/setup'
6
6
  require 'ftools'
7
7
  require 'webrick'
@@ -19,72 +19,72 @@ class TC_Images_XPath < Test::Unit::TestCase
19
19
  end
20
20
 
21
21
  def test_imageExists
22
- assert(! $ie.image(:xpath , "//img[@name='missing_name']/").exists? )
23
- assert( $ie.image(:xpath , "//img[@name='circle']/").exists? )
24
- # assert( $ie.image(:name , /circ/ ).exists? )
22
+ assert_false( browser.image(:xpath , "//img[@name='missing_name']/").exists? )
23
+ assert( browser.image(:xpath , "//img[@name='circle']/").exists? )
24
+ # assert( browser.image(:name , /circ/ ).exists? )
25
25
 
26
- assert(! $ie.image(:xpath , "//img[@id='missing_id']/").exists? )
27
- assert( $ie.image(:xpath , "//img[@id='square']/").exists? )
28
- # assert( $ie.image(:id , /squ/ ).exists? )
26
+ assert_false( browser.image(:xpath , "//img[@id='missing_id']/").exists? )
27
+ assert( browser.image(:xpath , "//img[@id='square']/").exists? )
28
+ # assert( browser.image(:id , /squ/ ).exists? )
29
29
 
30
- assert(! $ie.image(:xpath , "//img[@src='missingsrc.gif']/").exists? )
30
+ assert_false( browser.image(:xpath , "//img[@src='missingsrc.gif']/").exists? )
31
31
 
32
32
  # BP -- This fails for me but not for Paul. It doesn't make sense to me that it should pass.
33
- # assert( $ie.image(:src , "file:///#{$myDir}/html/images/triangle.jpg").exists? )
34
- # assert( $ie.image(:src , /triangle/ ).exists? )
33
+ # assert( browser.image(:src , "file:///#{$myDir}/html/images/triangle.jpg").exists? )
34
+ # assert( browser.image(:src , /triangle/ ).exists? )
35
35
 
36
- assert( $ie.image(:alt , "circle" ).exists? )
37
- # assert( $ie.image(:alt , /cir/ ).exists? )
36
+ assert( browser.image(:alt , "circle" ).exists? )
37
+ # assert( browser.image(:alt , /cir/ ).exists? )
38
38
 
39
- assert(! $ie.image(:alt , "triangle" ).exists? )
40
- # assert(! $ie.image(:alt , /tri/ ).exists? )
39
+ assert_false( browser.image(:alt , "triangle" ).exists? )
40
+ # assert_false( browser.image(:alt , /tri/ ).exists? )
41
41
  end
42
42
 
43
43
  def test_image_click
44
- assert_raises(UnknownObjectException ) { $ie.image(:xpath , "//img[@name='no_image_with_this']/").click }
45
- assert_raises(UnknownObjectException ) { $ie.image(:xpath , "//img[@id='no_image_with_this']/").click }
46
- assert_raises(UnknownObjectException ) { $ie.image(:xpath , "//img[@src='no_image_with_this']/").click}
47
- assert_raises(UnknownObjectException ) { $ie.image(:xpath , "//img[@alt='no_image_with_this']/").click}
44
+ assert_raises(UnknownObjectException ) { browser.image(:xpath , "//img[@name='no_image_with_this']/").click }
45
+ assert_raises(UnknownObjectException ) { browser.image(:xpath , "//img[@id='no_image_with_this']/").click }
46
+ assert_raises(UnknownObjectException ) { browser.image(:xpath , "//img[@src='no_image_with_this']/").click}
47
+ assert_raises(UnknownObjectException ) { browser.image(:xpath , "//img[@alt='no_image_with_this']/").click}
48
48
 
49
49
  # test for bug 1882
50
- $ie.text_field(:name , "text1").clear
51
- $ie.button(:value , /Pos/ ).click
52
- assert_equal('clicked' , $ie.text_field(:name , "text1" ).value )
50
+ browser.text_field(:name , "text1").clear
51
+ browser.button(:value , /Pos/ ).click
52
+ assert_equal('clicked' , browser.text_field(:name , "text1" ).value )
53
53
 
54
54
  # test for disabled button
55
- # assert(! $ie.image(:name , 'disabler_test').disabled )
56
- # $ie.button(:name , 'disable_img').click
55
+ # assert_false( browser.image(:name , 'disabler_test').disabled )
56
+ # browser.button(:name , 'disable_img').click
57
57
 
58
- # assert( $ie.image(:name , 'disabler_test').disabled )
59
- # $ie.button(:name , 'disable_img').click
58
+ # assert( browser.image(:name , 'disabler_test').disabled )
59
+ # browser.button(:name , 'disable_img').click
60
60
 
61
- # $ie.image(:src, /button/).click
62
- # assert($ie.text.include?("PASS") )
61
+ # browser.image(:src, /button/).click
62
+ # assert(browser.text.include?("PASS") )
63
63
 
64
64
  end
65
65
 
66
66
 
67
67
 
68
68
  def test_imageHasLoaded
69
- assert_raises(UnknownObjectException ) { $ie.image(:xpath , "//img[@name='no_image_with_this']/").hasLoaded? }
70
- assert_raises(UnknownObjectException ) { $ie.image(:xpath , "//img[@id='no_image_with_this']/").hasLoaded? }
71
- assert_raises(UnknownObjectException ) { $ie.image(:xpath , "//img[@src='no_image_with_this']/").hasLoaded? }
72
- assert_raises(UnknownObjectException ) { $ie.image(:xpath , "//img[@alt='no_image_with_this']/").hasLoaded? }
69
+ assert_raises(UnknownObjectException ) { browser.image(:xpath , "//img[@name='no_image_with_this']/").hasLoaded? }
70
+ assert_raises(UnknownObjectException ) { browser.image(:xpath , "//img[@id='no_image_with_this']/").hasLoaded? }
71
+ assert_raises(UnknownObjectException ) { browser.image(:xpath , "//img[@src='no_image_with_this']/").hasLoaded? }
72
+ assert_raises(UnknownObjectException ) { browser.image(:xpath , "//img[@alt='no_image_with_this']/").hasLoaded? }
73
73
 
74
- assert(! $ie.image(:xpath , "//img[@name='themissingimage']/").hasLoaded? )
75
- assert( $ie.image(:xpath , "//img[@name='circle']/").hasLoaded? )
74
+ assert_false( browser.image(:xpath , "//img[@name='themissingimage']/").hasLoaded? )
75
+ assert( browser.image(:xpath , "//img[@name='circle']/").hasLoaded? )
76
76
 
77
- assert( $ie.image(:xpath , "//img[@alt='circle']/").hasLoaded? )
78
- # assert( $ie.image(:alt, /cir/ ).hasLoaded? )
77
+ assert( browser.image(:xpath , "//img[@alt='circle']/").hasLoaded? )
78
+ # assert( browser.image(:alt, /cir/ ).hasLoaded? )
79
79
  end
80
80
 
81
81
  def test_image_properties
82
- assert_raises(UnknownObjectException ) { $ie.image(:xpath , "//img[@name='no_image_with_this']/").hasLoaded? }
83
- assert_raises(UnknownObjectException ) { $ie.image(:xpath , "//img[@id='no_image_with_this']/").hasLoaded? }
84
- assert_raises(UnknownObjectException ) { $ie.image(:xpath , "//img[@src='no_image_with_this']/").hasLoaded? }
82
+ assert_raises(UnknownObjectException ) { browser.image(:xpath , "//img[@name='no_image_with_this']/").hasLoaded? }
83
+ assert_raises(UnknownObjectException ) { browser.image(:xpath , "//img[@id='no_image_with_this']/").hasLoaded? }
84
+ assert_raises(UnknownObjectException ) { browser.image(:xpath , "//img[@src='no_image_with_this']/").hasLoaded? }
85
85
 
86
86
  # to string tests -- output should be verified!
87
- puts $ie.image(:xpath , "//img[@name='circle']/").to_s
87
+ puts browser.image(:xpath , "//img[@name='circle']/").to_s
88
88
  end
89
89
 
90
90
  end
@@ -1,6 +1,6 @@
1
1
  # unit tests for IOString in iostring.rb
2
2
 
3
- $LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..') if $0 == __FILE__
3
+ $LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..') unless $SETUP_LOADED
4
4
  require 'unittests/iostring'
5
5
  require 'test/unit'
6
6
 
@@ -1,26 +1,26 @@
1
1
  # feature tests for Links with multiple attributes
2
2
  # revision: $Revision: 1009 $
3
3
 
4
- $LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..') if $0 == __FILE__
4
+ $LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..') unless $SETUP_LOADED
5
5
  require 'unittests/setup'
6
6
 
7
7
  class TC_Links_Multi < Test::Unit::TestCase
8
8
 
9
9
  def setup
10
- browser.goto $htmlRoot + 'links_multi.html'
10
+ goto_page 'links_multi.html'
11
11
  end
12
12
 
13
13
  def test_existing
14
- assert_match(/not.html/, browser.link(:class_name, 'Papa').href)
14
+ assert_match(/not.html/, browser.link(:class, 'Papa').href)
15
15
  assert_match(/mama.html/, browser.link(:text, 'click').href)
16
16
  end
17
-
17
+
18
18
  def test_class_alias
19
- assert_match(/not.html/, browser.link(:class, 'Papa').href)
19
+ assert_match(/not.html/, browser.link(:class_name, 'Papa').href)
20
20
  end
21
-
21
+
22
22
  def test_hash_syntax
23
- assert_match(/not.html/, browser.link(:class_name => 'Papa').href)
23
+ assert_match(/not.html/, browser.link(:class => 'Papa').href)
24
24
  assert_match(/mama.html/, browser.link(:text => 'click').href)
25
25
  end
26
26
 
@@ -32,7 +32,6 @@ class TC_Links_Multi < Test::Unit::TestCase
32
32
  assert_match(/papa.html/, browser.link(:class => 'Papa', :index => 2).href)
33
33
  end
34
34
 
35
- include Watir::Exception
36
35
  def test_not_found_single
37
36
  exception = assert_raise(UnknownObjectException) do
38
37
  browser.link(:id, 'Missing').href
@@ -1,7 +1,7 @@
1
1
  # feature tests for Links
2
- # revision: $Revision: 1348 $
2
+ # revision: $Revision: 1536 $
3
3
 
4
- $LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..') if $0 == __FILE__
4
+ $LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..') unless $SETUP_LOADED
5
5
  require 'unittests/setup'
6
6
  require 'cgi'
7
7
 
@@ -12,115 +12,116 @@ class TC_Links < Test::Unit::TestCase
12
12
  goto_page "links1.html"
13
13
  end
14
14
 
15
+ tag_method :test_bad_attribute, :fails_on_firefox
15
16
  def test_bad_attribute
16
- assert_raises(MissingWayOfFindingObjectException) { $ie.link(:bad_attribute, 199).click }
17
+ assert_raises(MissingWayOfFindingObjectException) { browser.link(:bad_attribute, 199).click }
17
18
  begin
18
- $ie.link(:bad_attribute, 199).click
19
+ browser.link(:bad_attribute, 199).click
19
20
  rescue MissingWayOfFindingObjectException => e
20
21
  assert_equal "bad_attribute is an unknown way of finding a <A> element (199)", e.to_s
21
22
  end
22
23
  end
23
24
 
24
25
  def xtest_missing_links_dont_exist
25
- assert(!exists?{$ie.link(:text, "missing")})
26
- assert(!exists?{$ie.link(:text, /miss/)})
26
+ assert_false(exists?{browser.link(:text, "missing")})
27
+ assert_false(exists?{browser.link(:text, /miss/)})
27
28
  end
28
29
 
29
30
  def test_link_Exists
30
- assert($ie.link(:text, "test1").exists?)
31
- assert($ie.link(:text, /TEST/i).exists?)
32
- assert(!$ie.link(:text, "missing").exists?)
33
- assert(!$ie.link(:text, /miss/).exists?)
31
+ assert(browser.link(:text, "test1").exists?)
32
+ assert(browser.link(:text, /TEST/i).exists?)
33
+ assert_false(browser.link(:text, "missing").exists?)
34
+ assert_false(browser.link(:text, /miss/).exists?)
34
35
 
35
36
  # this assert we have to build up the path
36
37
  # this is what it looks like if you do a to_s on the link file:///C:/watir_bonus/unitTests/html/links1.HTML
37
38
  # but what we get back from $htmlRoot is a mixed case, so its almost impossible for use to test this correctly
38
- # assert($ie.link(:url,'file:///C:/watir_bonus/unitTests/html/links1.HTML' ).exists?)
39
+ # assert(browser.link(:url,'file:///C:/watir_bonus/unitTests/html/links1.HTML' ).exists?)
39
40
 
40
- assert($ie.link(:url, /link_pass.html/).exists?)
41
- assert(!$ie.link(:url, "alsomissing.html").exists?)
41
+ assert(browser.link(:url, /link_pass.html/).exists?)
42
+ assert_false(browser.link(:url, "alsomissing.html").exists?)
42
43
 
43
- assert($ie.link(:id, "link_id").exists?)
44
- assert(!$ie.link(:id, "alsomissing").exists?)
44
+ assert(browser.link(:id, "link_id").exists?)
45
+ assert_false(browser.link(:id, "alsomissing").exists?)
45
46
 
46
- assert($ie.link(:id, /_id/).exists?)
47
- assert(!$ie.link(:id, /alsomissing/).exists?)
47
+ assert(browser.link(:id, /_id/).exists?)
48
+ assert_false(browser.link(:id, /alsomissing/).exists?)
48
49
 
49
- assert($ie.link(:name, "link_name").exists?)
50
- assert(!$ie.link(:name, "alsomissing").exists?)
50
+ assert(browser.link(:name, "link_name").exists?)
51
+ assert_false(browser.link(:name, "alsomissing").exists?)
51
52
 
52
- assert($ie.link(:name, /_n/).exists?)
53
- assert(!$ie.link(:name, /missing/).exists?)
53
+ assert(browser.link(:name, /_n/).exists?)
54
+ assert_false(browser.link(:name, /missing/).exists?)
54
55
 
55
- assert($ie.link(:title, /ti/).exists?)
56
- assert($ie.link(:title, "link_title").exists?)
56
+ assert(browser.link(:title, /ti/).exists?)
57
+ assert(browser.link(:title, "link_title").exists?)
57
58
 
58
- assert(!$ie.link(:title, /missing/).exists?)
59
+ assert_false(browser.link(:title, /missing/).exists?)
59
60
 
60
- assert($ie.link(:url, /_pass/).exists?)
61
- assert(!$ie.link(:url, /dont_exist/).exists?)
61
+ assert(browser.link(:url, /_pass/).exists?)
62
+ assert_false(browser.link(:url, /dont_exist/).exists?)
62
63
  end
63
64
 
64
65
  def test_link_click
65
- $ie.link(:text, "test1").click
66
- assert( $ie.text.include?("Links2-Pass") )
66
+ browser.link(:text, "test1").click
67
+ assert( browser.text.include?("Links2-Pass") )
67
68
  end
68
69
  def test_link2_click
69
- $ie.link(:url, /link_pass.html/).click
70
- assert( $ie.text.include?("Links3-Pass") )
70
+ browser.link(:url, /link_pass.html/).click
71
+ assert( browser.text.include?("Links3-Pass") )
71
72
  end
72
73
  def test_link3_click
73
- $ie.link(:index, 1).click
74
- assert( $ie.text.include?("Links2-Pass") )
74
+ browser.link(:index, 1).click
75
+ assert( browser.text.include?("Links2-Pass") )
75
76
  end
76
77
  def test_link4_click
77
- assert_raises(UnknownObjectException , "UnknownObjectException was supposed to be thrown" ) { $ie.link(:index, 199).click }
78
+ assert_raises(UnknownObjectException, "UnknownObjectException was supposed to be thrown" ) { browser.link(:index, 199).click }
78
79
  end
79
80
 
80
81
  def test_link_properties
81
- assert_raises(UnknownObjectException , "UnknownObjectException was supposed to be thrown" ) { $ie.link(:index, 199).href }
82
- assert_raises(UnknownObjectException , "UnknownObjectException was supposed to be thrown" ) { $ie.link(:index, 199).value}
83
- assert_raises(UnknownObjectException , "UnknownObjectException was supposed to be thrown" ) { $ie.link(:index, 199).innerText }
84
- assert_raises(UnknownObjectException , "UnknownObjectException was supposed to be thrown" ) { $ie.link(:index, 199).name }
85
- assert_raises(UnknownObjectException , "UnknownObjectException was supposed to be thrown" ) { $ie.link(:index, 199).id }
86
- assert_raises(UnknownObjectException , "UnknownObjectException was supposed to be thrown" ) { $ie.link(:index, 199).disabled }
87
- assert_raises(UnknownObjectException , "UnknownObjectException was supposed to be thrown" ) { $ie.link(:index, 199).type }
88
- assert_raises(UnknownObjectException , "UnknownObjectException was supposed to be thrown" ) { $ie.link(:index, 199).class_name }
89
-
90
- assert_match( /links2/ ,$ie.link(:index, 1).href )
91
- assert_equal( "" , $ie.link(:index, 1).value)
92
- assert_equal( "test1" , $ie.link(:index, 1).innerText )
93
- assert_equal( "" , $ie.link(:index, 1).name )
94
- assert_equal( "" , $ie.link(:index, 1).id )
95
- assert_equal( false , $ie.link(:index, 1).disabled )
96
- assert_equal( "" , $ie.link(:index, 1).class_name)
97
- assert_equal( "link_class_1" , $ie.link(:index, 2).class_name)
98
-
99
- assert_equal( "link_id" , $ie.link(:index, 6).id )
100
- assert_equal( "link_name" , $ie.link(:index, 7).name )
101
-
102
- assert_equal( "" , $ie.link(:index, 7).title)
103
-
104
- assert_equal( "link_title" , $ie.link(:index, 8).title)
82
+ assert_raises(UnknownObjectException) { browser.link(:index, 199).href }
83
+ assert_raises(UnknownObjectException) { browser.link(:index, 199).value}
84
+ assert_raises(UnknownObjectException) { browser.link(:index, 199).innerText }
85
+ assert_raises(UnknownObjectException) { browser.link(:index, 199).name }
86
+ assert_raises(UnknownObjectException) { browser.link(:index, 199).id }
87
+ assert_raises(UnknownObjectException) { browser.link(:index, 199).disabled }
88
+ assert_raises(UnknownObjectException) { browser.link(:index, 199).type }
89
+ assert_raises(UnknownObjectException) { browser.link(:index, 199).class_name }
90
+
91
+ assert_match(/links2/ ,browser.link(:index, 1).href )
92
+ assert_equal("" , browser.link(:index, 1).value)
93
+ assert_equal("test1" , browser.link(:index, 1).innerText )
94
+ assert_equal("" , browser.link(:index, 1).name )
95
+ assert_equal("" , browser.link(:index, 1).id )
96
+ assert_equal(false , browser.link(:index, 1).disabled )
97
+ assert_equal("" , browser.link(:index, 1).class_name)
98
+ assert_equal("link_class_1" , browser.link(:index, 2).class_name)
99
+
100
+ assert_equal("link_id" , browser.link(:index, 6).id )
101
+ assert_equal("link_name" , browser.link(:index, 7).name )
102
+
103
+ assert_equal("" , browser.link(:index, 7).title)
104
+
105
+ assert_equal("link_title" , browser.link(:index, 8).title)
105
106
  end
106
107
 
107
108
  def test_link_iterator
108
- assert_equal(9, $ie.links.length )
109
- assert_equal("Link Using a name" , $ie.links[7].innerText)
109
+ assert_equal(9, browser.links.length )
110
+ assert_equal("Link Using a name" , browser.links[7].innerText)
110
111
 
111
112
  index = 1
112
- $ie.links.each do |link|
113
- assert_equal( $ie.link(:index, index).href , link.href )
114
- assert_equal( $ie.link(:index, index).id , link.id )
115
- assert_equal( $ie.link(:index, index).name , link.name )
116
- assert_equal( $ie.link(:index, index).innerText , link.innerText )
113
+ browser.links.each do |link|
114
+ assert_equal(browser.link(:index, index).href , link.href )
115
+ assert_equal(browser.link(:index, index).id , link.id )
116
+ assert_equal(browser.link(:index, index).name , link.name )
117
+ assert_equal(browser.link(:index, index).innerText , link.innerText )
117
118
  index+=1
118
119
  end
119
120
  end
120
121
 
121
122
  def test_div_xml_bug
122
123
  goto_page "div_xml.html"
123
- assert_nothing_raised {$ie.link(:text, 'Create').exists? }
124
+ assert_nothing_raised {browser.link(:text, 'Create').exists? }
124
125
  end
125
126
  end
126
127
 
@@ -132,14 +133,14 @@ class TC_Frame_Links < Test::Unit::TestCase
132
133
  end
133
134
 
134
135
  def test_links_in_frames
135
- assert($ie.frame("linkFrame").link(:text, "test1").exists?)
136
- assert(!$ie.frame("linkFrame").link(:text, "missing").exists?)
136
+ assert(browser.frame("linkFrame").link(:text, "test1").exists?)
137
+ assert_false(browser.frame("linkFrame").link(:text, "missing").exists?)
137
138
 
138
- assert_raises(UnknownObjectException, "UnknownObjectException was supposed to be thrown" ) { $ie.frame("linkFrame").link(:index, 199).href }
139
- assert_match(/links2/, $ie.frame("linkFrame").link(:index, 1).href)
139
+ assert_raises(UnknownObjectException, "UnknownObjectException was supposed to be thrown" ) { browser.frame("linkFrame").link(:index, 199).href }
140
+ assert_match(/links2/, browser.frame("linkFrame").link(:index, 1).href)
140
141
 
141
142
  count =0
142
- $ie.frame("linkFrame").links.each do |l|
143
+ browser.frame("linkFrame").links.each do |l|
143
144
  count+=1
144
145
  end
145
146
 
@@ -149,12 +150,13 @@ end
149
150
 
150
151
  require 'unittests/iostring'
151
152
  class TC_showlinks < Test::Unit::TestCase
153
+ tags :fails_on_firefox
152
154
  include MockStdoutTestCase
153
155
 
154
156
  def test_showLinks
155
157
  goto_page "links1.html"
156
158
  $stdout = @mockout
157
- $ie.showLinks
159
+ browser.showLinks
158
160
  expected = [/^index name +id +href + text\/src$/,
159
161
  get_path_regex(1, "links2.html", "test1"),
160
162
  get_path_regex(2, "link_pass.html", "test1"),