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,55 +1,35 @@
1
1
  # feature tests for css
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
 
7
7
  class TC_CSS < Test::Unit::TestCase
8
8
 
9
- def divTester( message )
10
-
11
- divs = $ie.getIE.document.getElementsByTagName("DIV")
12
- puts "Found #{divs.length} div tags"
13
- divs.each do |d|
14
- puts "Checking div #{d.id}"
15
- puts "div #{d.invoke("id") } class is #{d.invoke("className") }"
16
- end
17
- end
18
-
19
9
  def isMessageDisplayed(message)
20
-
21
10
  s = false
22
- divs = $ie.getIE.document.getElementsByTagName("DIV")
23
- #puts "Found #{divs.length} div tags"
11
+ divs = browser.divs
24
12
  divs.each do |d|
25
- #puts "----Checking div #{d.id} innertext is ( #{d.innerText} )"
26
-
27
- if d.innerText.to_s.downcase.match( /#{message}/i )
28
-
29
- #puts "div #{d.invoke("id") } class is #{d.invoke("className") }"
30
- if d.invoke("className").to_s.downcase.match(/show/i)
31
- #puts "message is shown!!!"
13
+ if d.text.downcase.match( /#{message}/i )
14
+ if d.class_name.downcase.match(/show/i)
32
15
  s = true
33
16
  end
34
-
35
17
  end
36
18
  end
37
19
 
38
- #puts "Not Shown " if s== false
39
20
  return s
40
21
  end
41
22
 
42
- def test_SuccessMessage
23
+ def setup
43
24
  goto_page "cssTest.html"
44
- $ie.button( :caption , "Success").click
45
-
46
- #isMessageDisplayed( "Success" )
47
- #divTester( "Success" )
25
+ end
26
+
27
+ def test_SuccessMessage
28
+ browser.button( :caption , "Success").click
48
29
  assert( isMessageDisplayed("Success") )
49
30
 
50
- $ie.button( :caption , "Failure").click
51
-
52
- assert(!isMessageDisplayed("Success") )
31
+ browser.button(:caption, "Failure").click
32
+ assert_false(isMessageDisplayed("Success") )
53
33
  end
54
34
  end
55
35
 
@@ -1,45 +1,45 @@
1
1
  # tests of deferring when a Watir object is bound to a com object (lazy evaluation)
2
+ # revision: $Revision: 1546 $
2
3
 
3
- # revision: $Revision: 1348 $
4
-
5
- $LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..') if $0 == __FILE__
4
+ $LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..') unless $SETUP_LOADED
6
5
  require 'unittests/setup'
7
- require 'unittests/buttons_test.rb'
8
6
 
9
7
  class TC_Defer < Test::Unit::TestCase
10
8
  def teardown
11
- @ie_new.close if defined?(@ie_new)
12
- $ie.goto('about:blank')
9
+ @new_browser.close if defined?(@new_browser)
10
+ browser.goto('about:blank')
13
11
  end
12
+ tag_method :test_binding_to_newly_loaded_page, :fails_on_firefox, :attach
14
13
  def test_binding_to_newly_loaded_page
15
- @ie_new = Watir::IE.new
16
- text_field = @ie_new.text_field(:name, 'text1')
17
- button = @ie_new.button(:value, 'Clear Events Box')
18
- div = @ie_new.div(:name, 'divvy')
19
- @ie_new.goto($htmlRoot + "textfields1.html")
14
+ @new_browser = Watir::Browser.new
15
+ text_field = @new_browser.text_field(:name, 'text1')
16
+ button = @new_browser.button(:value, 'Clear Events Box')
17
+ div = @new_browser.div(:name, 'divvy')
18
+ @new_browser.goto($htmlRoot + "textfields1.html")
20
19
  assert_equal('Hello World', text_field.value)
21
20
  assert_equal('Clear Events Box', button.value)
22
21
  assert_equal('Div Text', div.text)
23
22
  end
24
23
  def test_binding_to_refreshed_page
25
24
  goto_page "textfields1.html"
26
- text_field = $ie.text_field(:name, 'text1')
27
- button = $ie.button(:value, 'Clear Events Box')
28
- div = $ie.div(:name, 'divvy')
29
- $ie.refresh
25
+ text_field = browser.text_field(:name, 'text1')
26
+ button = browser.button(:value, 'Clear Events Box')
27
+ div = browser.div(:name, 'divvy')
28
+ browser.refresh
30
29
  assert_equal('Hello World', text_field.value)
31
30
  assert(text_field.enabled?)
32
31
  assert_equal('Clear Events Box', button.value)
33
32
  assert_equal('Div Text', div.text)
34
33
  end
34
+ tag_method :test_exists, :fails_on_firefox, :attach
35
35
  def test_exists
36
- @ie_new = Watir::IE.new
37
- text_field = @ie_new.text_field(:name, 'text1')
38
- button = @ie_new.button(:value, 'Clear Events Box')
39
- div = @ie_new.div(:name, 'divvy')
40
- assert(!text_field.exists?)
41
- assert(!button.exists?)
42
- @ie_new.goto($htmlRoot + "textfields1.html")
36
+ @new_browser = Watir::Browser.new
37
+ text_field = @new_browser.text_field(:name, 'text1')
38
+ button = @new_browser.button(:value, 'Clear Events Box')
39
+ div = @new_browser.div(:name, 'divvy')
40
+ assert_false(text_field.exists?)
41
+ assert_false(button.exists?)
42
+ @new_browser.goto($htmlRoot + "textfields1.html")
43
43
  assert(text_field.exists?)
44
44
  assert(button.exists?)
45
45
  assert(div.exists?)
@@ -1,11 +1,12 @@
1
1
  # Feature tests for Dialog class
2
- # revision: $Revision: 1348 $
2
+ # revision: $Revision: 1551 $
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 'watir/dialog'
7
7
 
8
8
  class TC_Dialog_Test < Test::Unit::TestCase
9
+ tags :must_be_visible
9
10
  include Watir
10
11
 
11
12
  def setup
@@ -20,23 +21,22 @@ class TC_Dialog_Test < Test::Unit::TestCase
20
21
  end
21
22
 
22
23
  def test_alert_without_bonus_script
23
- $ie.button(:id, 'btnAlert').click_no_wait
24
+ browser.button(:id, 'btnAlert').click_no_wait
24
25
  sleep 0.4 # FIXME: need to be able to poll for window to exist
25
26
  dialog.button("OK").click
26
- assert_match(/Alert button!/, $ie.text_field(:id, "testResult").value)
27
+ assert_match(/Alert button!/, browser.text_field(:id, "testResult").value)
27
28
  end
28
29
 
29
30
  def test_button_name_not_found
30
- $ie.button(:id, 'btnAlert').click_no_wait
31
+ browser.button(:id, 'btnAlert').click_no_wait
31
32
  sleep 0.4 # FIXME replace with dialog.exists?
32
33
  assert_raises(UnknownObjectException) { dialog.button("Yes").click }
33
34
  dialog.button("OK").click
34
35
  end
35
36
 
36
37
  def xtest_exists
37
- autoit = WIN32OLE.new('AutoItX3.Control')
38
- assert(! dialog.exists?) # known bug: finds main window instead of dialog!
39
- $ie.button(:id, 'btnAlert').click_no_wait
38
+ assert_false( dialog.exists?) # known bug: finds main window instead of dialog!
39
+ browser.button(:id, 'btnAlert').click_no_wait
40
40
  sleep 0.4 # FIXME: need to add polling
41
41
  assert dialog.exists?
42
42
  dialog.button('OK').click
@@ -44,7 +44,7 @@ class TC_Dialog_Test < Test::Unit::TestCase
44
44
 
45
45
  def test_leaves_dialog_open
46
46
  # should be closed in teardown
47
- $ie.button(:id, 'btnAlert').click_no_wait
47
+ browser.button(:id, 'btnAlert').click_no_wait
48
48
  end
49
49
 
50
50
  def test_copy_array_elements
@@ -57,17 +57,17 @@ class TC_Dialog_Test < Test::Unit::TestCase
57
57
  end
58
58
 
59
59
  def test_confirm_ok
60
- $ie.button(:value, 'confirm').click_no_wait
60
+ browser.button(:value, 'confirm').click_no_wait
61
61
  assert dialog.exists?
62
62
  dialog.button('OK').click
63
- assert_equal "You pressed the Confirm and OK button!", $ie.text_field(:id, 'testResult').value
63
+ assert_equal "You pressed the Confirm and OK button!", browser.text_field(:id, 'testResult').value
64
64
  end
65
65
 
66
66
  def xtest_confirm_cancel
67
- $ie.button(:value, 'confirm').click_no_wait
67
+ browser.button(:value, 'confirm').click_no_wait
68
68
  assert dialog.exists?
69
69
  dialog.button('Cancel').click
70
- assert_equal "You pressed the Confirm and Cancel button!", $ie.text_field(:id, 'testResult').value
70
+ assert_equal "You pressed the Confirm and Cancel button!", browser.text_field(:id, 'testResult').value
71
71
  end
72
72
 
73
73
  def test_dialog_close
@@ -1,7 +1,7 @@
1
1
  # defect reproduction
2
2
  # revision: $Revision: 958 $
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_Divs_XPath2 < Test::Unit::TestCase
@@ -11,12 +11,12 @@ class TC_Divs_XPath2 < Test::Unit::TestCase
11
11
  def test_div_with_text
12
12
  # Note: this test fails, probably because of bad html to xml translation.
13
13
  # However... the same xpath expression finds the right object in Selenium!
14
- assert_equal('Add', $ie.div(:xpath, "//div[text()='Add' and @class='ButtonText']").text)
14
+ assert_equal('Add', browser.div(:xpath, "//div[text()='Add' and @class='ButtonText']").text)
15
15
  end
16
16
  def test_div_with_contains
17
17
  # Note: this test fails, probably because of bad html to xml translation.
18
18
  # However... the same xpath expression finds the right object in Selenium!
19
- assert_equal('Add', $ie.div(:xpath, "//div[contains(.,'Add') and @class='ButtonText']").text)
19
+ assert_equal('Add', browser.div(:xpath, "//div[contains(.,'Add') and @class='ButtonText']").text)
20
20
  end
21
21
 
22
22
  end
@@ -1,7 +1,7 @@
1
1
  # feature tests for Divs, Spans and P's
2
- # revision: $Revision: 1354 $
2
+ # revision: $Revision: 1506 $
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_Divs < Test::Unit::TestCase
@@ -22,6 +22,7 @@ class TC_Divs < Test::Unit::TestCase
22
22
  assert browser.text_field(:name, "text1").verify_contains("0")
23
23
  end
24
24
 
25
+ tag_method :test_div_properties, :fails_on_firefox
25
26
  def test_div_properties
26
27
  assert_raises(UnknownObjectException) { browser.div(:id, "div77").text }
27
28
  assert_raises(UnknownObjectException) { browser.div(:title, "div77").text }
@@ -73,7 +74,7 @@ class TC_Divs < Test::Unit::TestCase
73
74
 
74
75
  assert_equal(3, browser.div(:id, 'text_fields1').text_fields.length )
75
76
  browser.div(:id, 'text_fields1').text_field(:name, 'div_text1').set("drink me")
76
- assert_equal("drink me", browser.div(:id, 'text_fields1').text_field(:name, 'div_text1').getContents)
77
+ assert_equal("drink me", browser.div(:id, 'text_fields1').text_field(:name, 'div_text1').value)
77
78
  end
78
79
 
79
80
  def test_images_inside_a_div
@@ -84,27 +85,30 @@ class TC_Divs < Test::Unit::TestCase
84
85
 
85
86
  #---- Span Tests ---
86
87
  def test_spans
87
- assert_raises(UnknownObjectException) {browser.span(:id , "span77").click }
88
- assert_raises(UnknownObjectException) {browser.span(:title , "span77").click }
88
+ assert_raises(UnknownObjectException) {browser.span(:id, "span77").click }
89
+ assert_raises(UnknownObjectException) {browser.span(:title, "span77").click }
89
90
 
90
91
  assert(browser.text_field(:name, "text2").verify_contains("0") )
91
- browser.span(:id , "span3").click
92
+ browser.span(:id, "span3").click
92
93
  assert(browser.text_field(:name, "text2").verify_contains("1") )
93
94
 
94
- browser.span(:id , "span4").click
95
+ browser.span(:id, "span4").click
95
96
  assert(browser.text_field(:name, "text2").verify_contains("0") )
96
97
  end
97
98
 
99
+ tag_method :test_span_properties, :fails_on_firefox
98
100
  def test_span_properties
99
- assert_raises(UnknownObjectException) {browser.span(:id , "span77").text }
100
- assert_raises(UnknownObjectException) {browser.span(:title , "span77").text }
101
+ assert_raises(UnknownObjectException) {browser.span(:id, "span77").text }
102
+ assert_raises(UnknownObjectException) {browser.span(:title, "span77").text }
101
103
 
102
- assert_equal("This span has an onClick that increments text2" , browser.span(:id , "span3").text.strip )
103
- assert_equal("This text is in a span with an id of span1 and title of test2" , browser.span(:title , "Test2").text.strip )
104
+ assert_equal("This span has an onClick that increments text2",
105
+ browser.span(:id , "span3").text.strip )
106
+ assert_equal("This text is in a span with an id of span1 and title of test2",
107
+ browser.span(:title , "Test2").text.strip)
104
108
 
105
- assert_raises(UnknownObjectException) {browser.span(:id , "span77").class_name }
106
- assert_equal("blueText" , browser.span(:id , "span2").class_name )
107
- assert_equal("" , browser.span(:id , "span1").class_name )
109
+ assert_raises(UnknownObjectException) {browser.span(:id, "span77").class_name}
110
+ assert_equal("blueText", browser.span(:id, "span2").class_name)
111
+ assert_equal("", browser.span(:id, "span1").class_name)
108
112
 
109
113
  assert_raises(UnknownObjectException) {browser.span(:index , 44).class_name }
110
114
  assert_equal("span1" , browser.span(:index , 1).id )
@@ -133,12 +137,12 @@ class TC_Divs < Test::Unit::TestCase
133
137
 
134
138
  def test_objects_in_span
135
139
  assert(browser.span(:id, 'buttons1').button(:index,1).exists? )
136
- assert(!browser.span(:id, 'buttons1').button(:index,3).exists? )
140
+ assert_false(browser.span(:id, 'buttons1').button(:index,3).exists? )
137
141
  assert(browser.span(:id, 'buttons1').button(:name,'b1').exists? )
138
142
 
139
143
  assert(browser.span(:id, 'buttons2').button(:index,1).exists? )
140
144
  assert(browser.span(:id, 'buttons2').button(:index,2).exists? )
141
- assert(!browser.span(:id, 'buttons1').button(:index,3).exists? )
145
+ assert_false(browser.span(:id, 'buttons1').button(:index,3).exists? )
142
146
 
143
147
  browser.span(:id, 'buttons1').button(:index,1).click
144
148
  assert_equal( 'button1' , browser.span(:id , 'text_fields1').text_field(:index,1).value)
@@ -150,9 +154,9 @@ class TC_Divs < Test::Unit::TestCase
150
154
  assert(browser.p(:index, 3).exists?)
151
155
  assert(browser.p(:title, 'test_3').exists?)
152
156
 
153
- assert(!browser.p(:id, 'missing').exists?)
154
- assert(!browser.p(:index, 8).exists?)
155
- assert(!browser.p(:title, 'test_55').exists?)
157
+ assert_false(browser.p(:id, 'missing').exists?)
158
+ assert_false(browser.p(:index, 8).exists?)
159
+ assert_false(browser.p(:title, 'test_55').exists?)
156
160
 
157
161
  assert_raises( UnknownObjectException) {browser.p(:id , 'missing').class_name }
158
162
  assert_raises( UnknownObjectException) {browser.p(:id , 'missing').text }
@@ -1,7 +1,7 @@
1
1
  # feature tests for Divs, Spans and P's
2
- # revision: $Revision: 1348 $
2
+ # revision: $Revision: 1544 $
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_Divs_XPath < Test::Unit::TestCase
@@ -12,85 +12,85 @@ class TC_Divs_XPath < Test::Unit::TestCase
12
12
  end
13
13
 
14
14
  def test_divs
15
- assert_raises(UnknownObjectException) {$ie.div(:xpath , "//div[@id='div77']/").click }
16
- assert_raises(UnknownObjectException) {$ie.div(:xpath , "//div[@title='div77']/").click }
15
+ assert_raises(UnknownObjectException) {browser.div(:xpath , "//div[@id='div77']/").click }
16
+ assert_raises(UnknownObjectException) {browser.div(:xpath , "//div[@title='div77']/").click }
17
17
 
18
- assert($ie.text_field(:xpath, "//input[@name='text1']/").verify_contains("0") )
19
- $ie.div(:xpath , "//div[@id='div3']/").click
20
- assert($ie.text_field(:xpath, "//input[@name='text1']/").verify_contains("1") )
21
- $ie.div(:xpath , "//div[@id='div4']/").click
22
- assert($ie.text_field(:xpath, "//input[@name='text1']/").verify_contains("0") )
18
+ assert(browser.text_field(:xpath, "//input[@name='text1']/").verify_contains("0") )
19
+ browser.div(:xpath , "//div[@id='div3']/").click
20
+ assert(browser.text_field(:xpath, "//input[@name='text1']/").verify_contains("1") )
21
+ browser.div(:xpath , "//div[@id='div4']/").click
22
+ assert(browser.text_field(:xpath, "//input[@name='text1']/").verify_contains("0") )
23
23
  end
24
24
 
25
25
  def test_div_properties
26
- assert_raises(UnknownObjectException) {$ie.div(:xpath , "//div[@id='div77']/").text }
27
- assert_raises(UnknownObjectException) {$ie.div(:xpath , "//div[@title='div77']/").text }
26
+ assert_raises(UnknownObjectException) {browser.div(:xpath , "//div[@id='div77']/").text }
27
+ assert_raises(UnknownObjectException) {browser.div(:xpath , "//div[@title='div77']/").text }
28
28
 
29
29
  assert_equal("This div has an onClick that increments text1",
30
- $ie.div(:xpath , "//div[@id='div3']/").text.strip )
30
+ browser.div(:xpath , "//div[@id='div3']/").text.strip )
31
31
  assert_equal("This text is in a div with an id of div1 and title of test1",
32
- $ie.div(:xpath , "//div[@title='Test1']/").text.strip )
32
+ browser.div(:xpath , "//div[@title='Test1']/").text.strip )
33
33
 
34
- assert_raises(UnknownObjectException) {$ie.div(:xpath , "//div[@id='div77']/").class_name }
35
- assert_equal("blueText" , $ie.div(:xpath , "//div[@id='div2']/").class_name )
36
- assert_equal("" , $ie.div(:xpath , "//div[@id='div1']/").class_name )
34
+ assert_raises(UnknownObjectException) {browser.div(:xpath , "//div[@id='div77']/").class_name }
35
+ assert_equal("blueText" , browser.div(:xpath , "//div[@id='div2']/").class_name )
36
+ assert_equal("" , browser.div(:xpath , "//div[@id='div1']/").class_name )
37
37
  end
38
38
 
39
39
  def test_objects_in_div
40
- assert($ie.div(:xpath , "//div[@id='buttons1']/").button(:index,1).exists? )
41
- assert(!$ie.div(:xpath , "//div[@id='buttons1']/").button(:index,3).exists? )
42
- assert($ie.div(:xpath , "//div[@id='buttons1']/").button(:name,'b1').exists? )
40
+ assert(browser.div(:xpath , "//div[@id='buttons1']/").button(:index,1).exists? )
41
+ assert_false(browser.div(:xpath , "//div[@id='buttons1']/").button(:index,3).exists? )
42
+ assert(browser.div(:xpath , "//div[@id='buttons1']/").button(:name,'b1').exists? )
43
43
 
44
- assert($ie.div(:xpath , "//div[@id='buttons2']/").button(:index,1).exists? )
45
- assert($ie.div(:xpath , "//div[@id='buttons2']/").button(:index,2).exists? )
46
- assert(!$ie.div(:xpath , "//div[@id='buttons1']/").button(:index,3).exists? )
44
+ assert(browser.div(:xpath , "//div[@id='buttons2']/").button(:index,1).exists? )
45
+ assert(browser.div(:xpath , "//div[@id='buttons2']/").button(:index,2).exists? )
46
+ assert_false(browser.div(:xpath , "//div[@id='buttons1']/").button(:index,3).exists? )
47
47
 
48
- $ie.div(:xpath , "//div[@id='buttons1']/").button(:index,1).click
48
+ browser.div(:xpath , "//div[@id='buttons1']/").button(:index,1).click
49
49
 
50
- assert_equal( 'button1' , $ie.div(:xpath , "//div[@id='text_fields1']/").text_field(:index,1).value)
50
+ assert_equal( 'button1' , browser.div(:xpath , "//div[@id='text_fields1']/").text_field(:index,1).value)
51
51
 
52
- assert_equal( 3 , $ie.div(:xpath , "//div[@id='text_fields1']/").text_fields.length )
52
+ assert_equal( 3 , browser.div(:xpath , "//div[@id='text_fields1']/").text_fields.length )
53
53
  end
54
54
 
55
55
  def test_span_properties
56
- assert_raises(UnknownObjectException) {$ie.span(:xpath , "//span[@id='span77']/").text }
57
- assert_raises(UnknownObjectException) {$ie.span(:xpath , "//span[@title='span77']/").text }
56
+ assert_raises(UnknownObjectException) {browser.span(:xpath , "//span[@id='span77']/").text }
57
+ assert_raises(UnknownObjectException) {browser.span(:xpath , "//span[@title='span77']/").text }
58
58
 
59
- assert_equal("This span has an onClick that increments text2" , $ie.span(:xpath , "//span[@id='span3']/").text.strip )
60
- assert_equal("This text is in a span with an id of span1 and title of test2" , $ie.span(:xpath , "//span[@title='Test2']/").text.strip )
59
+ assert_equal("This span has an onClick that increments text2" , browser.span(:xpath , "//span[@id='span3']/").text.strip )
60
+ assert_equal("This text is in a span with an id of span1 and title of test2" , browser.span(:xpath , "//span[@title='Test2']/").text.strip )
61
61
 
62
- assert_raises(UnknownObjectException) {$ie.span(:xpath , "//span[@id='span77']/").class_name }
63
- assert_equal("blueText" , $ie.span(:xpath , "//span[@id='span2']/").class_name )
64
- assert_equal("" , $ie.span(:xpath , "//span[@id='span1']/").class_name )
62
+ assert_raises(UnknownObjectException) {browser.span(:xpath , "//span[@id='span77']/").class_name }
63
+ assert_equal("blueText" , browser.span(:xpath , "//span[@id='span2']/").class_name )
64
+ assert_equal("" , browser.span(:xpath , "//span[@id='span1']/").class_name )
65
65
  end
66
66
 
67
67
  def test_objects_in_span
68
- assert($ie.span(:xpath , "//span[@id='buttons1']/").button(:index,1).exists? )
69
- assert(!$ie.span(:xpath , "//span[@id='buttons1']/").button(:index,3).exists? )
70
- assert($ie.span(:xpath , "//span[@id='buttons1']/").button(:name,'b1').exists? )
68
+ assert(browser.span(:xpath , "//span[@id='buttons1']/").button(:index,1).exists? )
69
+ assert_false(browser.span(:xpath , "//span[@id='buttons1']/").button(:index,3).exists? )
70
+ assert(browser.span(:xpath , "//span[@id='buttons1']/").button(:name,'b1').exists? )
71
71
 
72
- assert($ie.span(:xpath , "//span[@id='buttons2']/").button(:index,1).exists? )
73
- assert($ie.span(:xpath , "//span[@id='buttons2']/").button(:index,2).exists? )
74
- assert(!$ie.span(:xpath , "//span[@id='buttons1']/").button(:index,3).exists? )
72
+ assert(browser.span(:xpath , "//span[@id='buttons2']/").button(:index,1).exists? )
73
+ assert(browser.span(:xpath , "//span[@id='buttons2']/").button(:index,2).exists? )
74
+ assert_false(browser.span(:xpath , "//span[@id='buttons1']/").button(:index,3).exists? )
75
75
 
76
- $ie.span(:xpath , "//span[@id='buttons1']/").button(:index,1).click
76
+ browser.span(:xpath , "//span[@id='buttons1']/").button(:index,1).click
77
77
 
78
- assert_equal( 'button1' , $ie.span(:xpath , "//span[@id='text_fields1']/").text_field(:index,1).value)
78
+ assert_equal( 'button1' , browser.span(:xpath , "//span[@id='text_fields1']/").text_field(:index,1).value)
79
79
 
80
- assert_equal( 3 , $ie.span(:xpath , "//span[@id='text_fields1']/").text_fields.length )
80
+ assert_equal( 3 , browser.span(:xpath , "//span[@id='text_fields1']/").text_fields.length )
81
81
  end
82
82
 
83
83
  def test_p
84
- assert($ie.p(:xpath , "//p[@id='number1']/").exists?)
85
- assert($ie.p(:xpath , "//p[@title='test_3']/").exists?)
84
+ assert(browser.p(:xpath , "//p[@id='number1']/").exists?)
85
+ assert(browser.p(:xpath , "//p[@title='test_3']/").exists?)
86
86
 
87
- assert(!$ie.p(:xpath , "//p[@id='missing']/").exists?)
88
- assert(!$ie.p(:xpath , "//p[@title='test_55']/").exists?)
87
+ assert_false(browser.p(:xpath , "//p[@id='missing']/").exists?)
88
+ assert_false(browser.p(:xpath , "//p[@title='test_55']/").exists?)
89
89
 
90
- assert_raises( UnknownObjectException) {$ie.p(:xpath , "//p[@id='missing']/").class_name }
91
- assert_raises( UnknownObjectException) {$ie.p(:xpath , "//p[@id='missing']/").text }
92
- assert_raises( UnknownObjectException) {$ie.p(:xpath , "//p[@id='missing']/").title }
93
- assert_raises( UnknownObjectException) {$ie.p(:xpath , "//p[@id='missing']/").to_s }
94
- assert_raises( UnknownObjectException) {$ie.p(:xpath , "//p[@id='missing']/").disabled }
90
+ assert_raises( UnknownObjectException) {browser.p(:xpath , "//p[@id='missing']/").class_name }
91
+ assert_raises( UnknownObjectException) {browser.p(:xpath , "//p[@id='missing']/").text }
92
+ assert_raises( UnknownObjectException) {browser.p(:xpath , "//p[@id='missing']/").title }
93
+ assert_raises( UnknownObjectException) {browser.p(:xpath , "//p[@id='missing']/").to_s }
94
+ assert_raises( UnknownObjectException) {browser.p(:xpath , "//p[@id='missing']/").disabled }
95
95
  end
96
96
  end