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
@@ -5,7 +5,7 @@
5
5
  # 1) Failure:
6
6
  # default_test(TC4_No_Test_Methods)
7
7
 
8
- $LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..', '..') if $0 == __FILE__
8
+ $LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..', '..') unless $SETUP_LOADED
9
9
 
10
10
  require 'watir/testcase'
11
11
 
@@ -1,7 +1,7 @@
1
1
  # feature tests for IE::contains_text
2
- # revision: $Revision: 1348 $
2
+ # revision: $Revision: 1579 $
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_contains_text < Test::Unit::TestCase
@@ -11,49 +11,52 @@ class TC_contains_text < Test::Unit::TestCase
11
11
  end
12
12
 
13
13
  def test_text_found
14
- assert($ie.contains_text('slings and arrows of outrageous fortune'))
14
+ assert(browser.contains_text('slings and arrows of outrageous fortune'))
15
15
  end
16
16
 
17
17
  def test_text_not_found
18
- assert(!$ie.contains_text('So are they all, all honourable men'))
18
+ assert_false(browser.contains_text('So are they all, all honourable men'))
19
19
  end
20
20
 
21
21
  def test_regexp_found
22
- assert($ie.contains_text(/bodkin.*fardels/))
22
+ assert(browser.contains_text(/bodkin.*fardels/))
23
23
  end
24
24
 
25
25
  def test_regexp_not_found
26
- assert(!$ie.contains_text(/winding.*watch.*wit/))
26
+ assert_false(browser.contains_text(/winding.*watch.*wit/))
27
27
  end
28
28
 
29
29
  def test_match_regexp_found
30
- $~ = $ie.contains_text(/Messages ([0-9]+)/)
30
+ $~ = browser.contains_text(/Messages ([0-9]+)/)
31
31
  assert_equal('42', $1)
32
32
  end
33
33
 
34
34
  def test_bad_search_argument
35
35
  assert_raises(ArgumentError) do
36
- $ie.contains_text
36
+ browser.contains_text
37
37
  end
38
38
  assert_raises(ArgumentError) do
39
- $ie.contains_text(nil)
39
+ browser.contains_text(nil)
40
40
  end
41
41
  assert_raises(ArgumentError) do
42
- $ie.contains_text(42)
42
+ browser.contains_text(42)
43
43
  end
44
44
  end
45
45
 
46
46
  end
47
47
 
48
48
  class TC_contains_text_in_new_ie < Test::Unit::TestCase
49
+ tags :fails_on_firefox
50
+ # Doesn't actually raise an error, but fails to close the window afterwards
51
+ # http://jira.openqa.org/browse/WTR-265
49
52
  def setup
50
- @ie = Watir::IE.new
53
+ @new_browser = Watir::Browser.new
51
54
  end
52
55
  def test_nothing_raised
53
- assert_nothing_raised {@ie.contains_text ''}
56
+ assert_nothing_raised {@new_browser.text.include? ''}
54
57
  end
55
58
  def teardown
56
- @ie.close
59
+ @new_browser.close
57
60
  end
58
61
  end
59
62
 
@@ -62,6 +65,6 @@ class TC_contains_text_in_frame < Test::Unit::TestCase
62
65
  goto_page "frame_links.html"
63
66
  end
64
67
  def test_in_frame
65
- assert $ie.frame('linkFrame').contains_text('The button is really a link')
68
+ assert browser.frame('linkFrame').contains_text('The button is really a link')
66
69
  end
67
70
  end
@@ -1,15 +1,16 @@
1
1
  # feature tests for relative navigation/specification
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/setup'
5
5
 
6
6
  class TC_Relative < Test::Unit::TestCase
7
7
 
8
8
  def setup
9
9
  goto_page "depot_store.html"
10
- @headline = $ie.h3(:text, 'Pragmatic Version Control')
10
+ @headline = browser.h3(:text, 'Pragmatic Version Control')
11
11
  end
12
-
12
+
13
+ tag_method :test_parent, :fails_on_firefox
13
14
  def test_parent
14
15
  catalog_entry = @headline.parent
15
16
  link = catalog_entry.link(:class, 'addtocart')
@@ -17,13 +18,15 @@ class TC_Relative < Test::Unit::TestCase
17
18
  assert_nothing_raised{link.click}
18
19
  end
19
20
 
21
+ tag_method :test_parent_page_container, :fails_on_firefox
20
22
  def test_parent_page_container
21
23
  catalog_entry = @headline.parent
22
24
  assert_not_nil catalog_entry.page_container
23
25
  end
24
-
26
+
27
+ tag_method :test_before_and_after, :fails_on_firefox
25
28
  def test_before_and_after
26
- link = $ie.link(:class => 'addtocart', :index => 2)
29
+ link = browser.link(:class => 'addtocart', :index => 2)
27
30
  assert_equal 'http://localhost:3000/store/add_to_cart/12', link.href
28
31
  assert(link.after?(@headline))
29
32
  assert(@headline.before?(link))
@@ -31,9 +34,10 @@ class TC_Relative < Test::Unit::TestCase
31
34
  assert !(@headline.after? link)
32
35
  assert !(link.after? link)
33
36
  end
34
-
37
+
38
+ tag_method :test_find_after, :fails_on_firefox
35
39
  def test_find_after
36
- link = $ie.link(:class => 'addtocart', :after? => @headline)
40
+ link = browser.link(:class => 'addtocart', :after? => @headline)
37
41
  assert_equal 'http://localhost:3000/store/add_to_cart/12', link.href
38
42
  end
39
43
 
@@ -0,0 +1,20 @@
1
+ $LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..') unless $SETUP_LOADED
2
+ require 'unittests/setup'
3
+
4
+ class TC_Performance < Test::Unit::TestCase
5
+ def setup
6
+ uses_page 'wallofcheckboxes.html'
7
+ end
8
+
9
+ # http://jira.openqa.org/browse/WTR-216
10
+ # This should take about a quarter of a second. When the bug showed up (because the
11
+ # fast_locate method was broken), it took nearly 10 seconds.
12
+ def test_access_checkbox
13
+ start_time = Time.now
14
+ browser.checkbox(:name, 'custom_monetary_value10:config.admin.required999').set
15
+ elapsed_time = Time.now - start_time
16
+ assert(elapsed_time < 1.5,
17
+ "Elapsed time is #{elapsed_time}, should be less than 1.5 seconds.")
18
+ end
19
+
20
+ end
@@ -1,44 +1,43 @@
1
+ # revision: $Revision: 1431 $
1
2
 
2
- # revision: $Revision: 958 $
3
-
4
- $LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..') if $0 == __FILE__
3
+ $LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..') unless $SETUP_LOADED
5
4
  require 'unittests/setup'
6
5
 
7
6
  class TC_PopUps < Test::Unit::TestCase
8
- include Watir
9
-
7
+ tags :must_be_visible, :creates_windows, :unreliable
8
+
10
9
  def setup
11
- $ie.goto("file://#{$myDir}/html/popups1.html")
10
+ browser.goto("file://#{$myDir}/html/popups1.html")
12
11
  end
13
12
 
14
13
  def startClicker( button , waitTime = 0.5)
15
14
  w = WinClicker.new
16
- longName = $ie.dir.gsub("/" , "\\" )
15
+ longName = browser.dir.gsub("/" , "\\" )
17
16
  shortName = w.getShortFileName(longName)
18
17
  c = "start rubyw #{shortName }\\watir\\clickJSDialog.rb #{button } #{ waitTime} "
19
18
  puts "Starting #{c}"
20
19
  w.winsystem(c )
21
- w=nil
20
+ w = nil
22
21
  end
23
22
 
24
23
  def test_simple
25
24
  startClicker("OK")
26
- $ie.button("Alert").click
25
+ browser.button("Alert").click
27
26
  end
28
27
 
29
28
  def test_confirm
30
29
  startClicker("OK")
31
- $ie.button("Confirm").click
32
- assert( $ie.text_field(:name , "confirmtext").verify_contains("OK") )
30
+ browser.button("Confirm").click
31
+ assert( browser.text_field(:name , "confirmtext").verify_contains("OK") )
33
32
 
34
33
  startClicker("Cancel")
35
- $ie.button("Confirm").click
36
- assert( $ie.text_field(:name , "confirmtext").verify_contains("Cancel") )
34
+ browser.button("Confirm").click
35
+ assert( browser.text_field(:name , "confirmtext").verify_contains("Cancel") )
37
36
  end
38
37
 
39
38
  def xtest_Prompt
40
39
  startClicker("OK")
41
- $ie.button("Prompt").click
40
+ browser.button("Prompt").click
42
41
  end
43
42
  end
44
43
 
@@ -1,7 +1,7 @@
1
1
  # feature tests for Pre
2
- # revision: $Revision: 1348 $
2
+ # revision: $Revision: 1595 $
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_Pre < Test::Unit::TestCase
@@ -11,41 +11,43 @@ class TC_Pre < Test::Unit::TestCase
11
11
  end
12
12
 
13
13
  def test_Pre_Count
14
- assert( $ie.pres.length == 3 )
14
+ assert( browser.pres.length == 3 )
15
15
  end
16
16
 
17
17
  def test_Pre_Exists
18
- assert(! $ie.pre( :id, 'missingPre' ).exists? )
19
- assert(! $ie.pre( :index, 33 ).exists? )
20
-
21
- assert( $ie.pre( :id, '1' ).exists? )
22
- assert( $ie.pre( :id, /[3-9]/ ).exists? )
23
-
24
- assert(! $ie.pre( :id, /missing_pre/ ).exists? )
25
-
26
- assert( $ie.pre( :index, 1 ).exists? )
27
- assert( $ie.pre( :index, 2 ).exists? )
28
- assert( $ie.pre( :index, 3 ).exists? )
29
-
30
- assert( $ie.pre( :name, '3' ).exists? )
31
- assert(! $ie.pre( :name, "name_missing" ).exists? )
18
+ assert_false( browser.pre( :index, 33 ).exists? )
19
+ assert( browser.pre( :index, 3 ).exists? )
20
+
21
+ assert( browser.pre( :id, '1' ).exists? )
22
+ assert( browser.pre( :id, /[3-9]/ ).exists? )
23
+ assert_false( browser.pre( :id, /missing_pre/ ).exists? )
24
+ assert_false( browser.pre( :id, 'missingPre' ).exists? )
25
+
26
+ assert( browser.pre( :name, '3' ).exists? )
27
+ assert_false( browser.pre( :name, "name_missing" ).exists? )
32
28
  end
33
-
29
+
34
30
  def test_simple_access
35
- pre = $ie.pre( :index, 1 )
31
+ pre = browser.pre( :index, 1 )
36
32
  assert( pre.text.include?( "simple pre space" ) )
37
- assert(! pre.text.include?( "A second block" ) )
38
-
39
- assert( pre.html.include?( "id=1 name=\"1\"" ) )
33
+ assert_false( pre.text.include?( "A second block" ) )
40
34
 
41
- pre = $ie.pre( :index, 2 )
35
+ pre = browser.pre( :index, 2 )
42
36
  assert( pre.text.include?( "A second block" ) )
43
- assert(! pre.text.include?( "this is the last block" ) )
44
-
45
- pre = $ie.pre( :index, 3 )
37
+ assert_false( pre.text.include?( "this is the last block" ) )
38
+ end
39
+
40
+ tag_method :test_embedded_spaces, :fails_on_firefox # http://jira.openqa.org/browse/WTR-267
41
+ def test_embedded_spaces
42
+ pre = browser.pre( :index, 3 )
46
43
  assert( pre.text.include?( "continue to work" ) )
47
- assert(! pre.text.include?( "Pre Tag Test" ) )
48
-
44
+ assert_false( pre.text.include?( "Pre Tag Test" ) )
45
+ end
46
+
47
+ tag_method :test_html, :fails_on_firefox # http://jira.openqa.org/browse/WTR-260
48
+ def test_html
49
+ pre = browser.pre(:index, 1)
50
+ assert( pre.html.include?( "id=1 name=\"1\"" ) )
49
51
  end
50
52
 
51
53
  end
@@ -1,7 +1,7 @@
1
1
  # feature tests for Radio Buttons
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_Radios < Test::Unit::TestCase
@@ -12,179 +12,200 @@ class TC_Radios < Test::Unit::TestCase
12
12
  end
13
13
 
14
14
  def test_Radio_Exists
15
- assert($ie.radio(:name, "box1").exists?)
16
- assert($ie.radio(:id, "box5").exists?)
15
+ assert(browser.radio(:name, "box1").exists?)
16
+ assert(browser.radio(:id, "box5").exists?)
17
17
 
18
- assert(!$ie.radio(:name, "missingname").exists?)
19
- assert(!$ie.radio(:id, "missingid").exists?)
18
+ assert_false(browser.radio(:name, "missingname").exists?)
19
+ assert_false(browser.radio(:id, "missingid").exists?)
20
20
  end
21
21
 
22
22
  def test_radio_class
23
- assert_raises(UnknownObjectException , "UnknownObjectException was supposed to be thrown" ) { $ie.radio(:name, "noName").class_name }
24
- assert_equal("radio_style" , $ie.radio(:name, "box1").class_name)
25
- assert_equal("" , $ie.radio(:id, "box5").class_name)
23
+ assert_raises(UnknownObjectException) { browser.radio(:name, "noName").class_name }
24
+ assert_equal("radio_style", browser.radio(:name, "box1").class_name)
25
+ assert_equal("", browser.radio(:id, "box5").class_name)
26
26
  end
27
27
 
28
28
  def test_Radio_Enabled
29
- assert_raises(UnknownObjectException, "UnknownObjectException was supposed to be thrown" ) { $ie.radio(:name, "noName").enabled? }
30
- assert_raises(UnknownObjectException, "UnknownObjectException was supposed to be thrown" ) { $ie.radio(:id, "noName").enabled? }
31
- assert_raises(UnknownObjectException, "UnknownObjectException was supposed to be thrown" ) { $ie.radio(:name, "box4" , 6).enabled? }
29
+ assert_raises(UnknownObjectException, "UnknownObjectException was supposed to be thrown" ) { browser.radio(:name, "noName").enabled? }
30
+ assert_raises(UnknownObjectException, "UnknownObjectException was supposed to be thrown" ) { browser.radio(:id, "noName").enabled? }
31
+ assert_raises(UnknownObjectException, "UnknownObjectException was supposed to be thrown" ) { browser.radio(:name, "box4" , 6).enabled? }
32
32
 
33
- assert(!$ie.radio(:name, "box2").enabled?)
34
- assert($ie.radio(:id, "box5").enabled?)
35
- assert($ie.radio(:name, "box1").enabled?)
33
+ assert_false(browser.radio(:name, "box2").enabled?)
34
+ assert(browser.radio(:id, "box5").enabled?)
35
+ assert(browser.radio(:name, "box1").enabled?)
36
36
  end
37
37
 
38
38
  def test_little
39
- assert(!$ie.button(:value , "foo").enabled?)
39
+ assert_false(browser.button(:value, "foo").enabled?)
40
40
  end
41
41
 
42
42
  def test_onClick
43
43
 
44
- assert(!$ie.radio(:name, "box5").isSet?)
45
- assert(!$ie.button(:value , "foo").enabled?)
44
+ assert_false(browser.radio(:name, "box5").isSet?)
45
+ assert_false(browser.button(:value , "foo").enabled?)
46
46
 
47
47
  # first click the button is enabled and the radio is set
48
- $ie.radio(:name, "box5" , 1).set
49
- assert($ie.radio(:name, "box5",1).isSet?)
50
- assert($ie.radio(:name, "box5",1).checked?)
51
- assert($ie.button(:value , "foo").enabled?)
48
+ browser.radio(:name, "box5", 1).set
49
+ assert(browser.radio(:name, "box5",1).isSet?)
50
+ assert(browser.radio(:name, "box5",1).checked?)
51
+ assert(browser.button(:value, "foo").enabled?)
52
52
 
53
53
  # second click the button is disabled and the radio is still set
54
- $ie.radio(:name, "box5", 1).set
55
- assert($ie.radio(:name, "box5",1).isSet?)
56
- assert($ie.radio(:name, "box5",1).checked?)
57
- assert(!$ie.button(:value , "foo").enabled?)
54
+ browser.radio(:name, "box5", 1).set
55
+ assert(browser.radio(:name, "box5",1).isSet?)
56
+ assert(browser.radio(:name, "box5",1).checked?)
57
+ assert_false(browser.button(:value, "foo").enabled?)
58
58
 
59
59
  # third click the button is enabled and the radio is still set
60
- $ie.radio(:name, "box5", 1).set
61
- assert($ie.radio(:name, "box5",1 ).isSet?)
62
- assert($ie.radio(:name, "box5",1 ).checked?)
63
- assert($ie.button(:value , "foo").enabled?)
60
+ browser.radio(:name, "box5", 1).set
61
+ assert(browser.radio(:name, "box5", 1).isSet?)
62
+ assert(browser.radio(:name, "box5", 1).checked?)
63
+ assert(browser.button(:value, "foo").enabled?)
64
64
 
65
65
  # click the radio with a value of 2 , button is disabled and the radio is still set
66
- $ie.radio(:name, "box5", 2).set
67
- assert(!$ie.radio(:name, "box5" ,1).isSet?)
68
- assert(!$ie.radio(:name, "box5" ,1).checked?)
69
- assert($ie.radio(:name, "box5" ,2).isSet?)
70
- assert($ie.radio(:name, "box5" ,2).checked?)
71
- assert(!$ie.button(:value , "foo").enabled?)
66
+ browser.radio(:name, "box5", 2).set
67
+ assert_false(browser.radio(:name, "box5", 1).isSet?)
68
+ assert_false(browser.radio(:name, "box5", 1).checked?)
69
+ assert(browser.radio(:name, "box5", 2).isSet?)
70
+ assert(browser.radio(:name, "box5", 2).checked?)
71
+ assert_false(browser.button(:value, "foo").enabled?)
72
72
  end
73
73
 
74
74
  def test_Radio_isSet
75
- assert_raises(UnknownObjectException , "UnknownObjectException was supposed to be thrown" ) { $ie.radio(:name, "noName").isSet? }
75
+ assert_raises(UnknownObjectException) { browser.radio(:name, "noName").isSet? }
76
76
 
77
- assert(!$ie.radio(:name, "box1").isSet?)
78
- assert( $ie.radio(:name, "box3").isSet?)
79
- assert(!$ie.radio(:name, "box2").isSet?)
80
- assert( $ie.radio(:name, "box4" , 1 ).isSet?)
81
- assert(!$ie.radio(:name, "box4" , 2 ).isSet?)
77
+ assert_false(browser.radio(:name, "box1").isSet?)
78
+ assert( browser.radio(:name, "box3").isSet?)
79
+ assert_false(browser.radio(:name, "box2").isSet?)
80
+ assert( browser.radio(:name, "box4", 1).isSet?)
81
+ assert_false(browser.radio(:name, "box4", 2).isSet?)
82
82
 
83
- assert(!$ie.radio(:name, "box1").checked?)
84
- assert( $ie.radio(:name, "box3").checked?)
85
- assert(!$ie.radio(:name, "box2").checked?)
86
- assert( $ie.radio(:name, "box4" , 1 ).checked?)
87
- assert(!$ie.radio(:name, "box4" , 2 ).checked?)
83
+ assert_false(browser.radio(:name, "box1").checked?)
84
+ assert( browser.radio(:name, "box3").checked?)
85
+ assert_false(browser.radio(:name, "box2").checked?)
86
+ assert( browser.radio(:name, "box4", 1).checked?)
87
+ assert_false(browser.radio(:name, "box4", 2).checked?)
88
88
  end
89
89
 
90
90
  def test_radio_clear
91
- assert_raises(UnknownObjectException , "UnknownObjectException was supposed to be thrown" ) { $ie.radio(:name, "noName").clear }
91
+ assert_raises(UnknownObjectException) { browser.radio(:name, "noName").clear }
92
92
 
93
- $ie.radio(:name, "box1").clear
94
- assert(!$ie.radio(:name, "box1").isSet?)
93
+ browser.radio(:name, "box1").clear
94
+ assert_false(browser.radio(:name, "box1").isSet?)
95
95
 
96
- assert_raises(ObjectDisabledException, "ObjectDisabledException was supposed to be thrown" ) { $ie.radio(:name, "box2").clear }
97
- assert(!$ie.radio(:name, "box2").isSet?)
96
+ assert_raises(ObjectDisabledException, "ObjectDisabledException was supposed to be thrown" ) { browser.radio(:name, "box2").clear }
97
+ assert_false(browser.radio(:name, "box2").isSet?)
98
98
 
99
- $ie.radio(:name, "box3").clear
100
- assert(!$ie.radio(:name, "box3").isSet?)
99
+ browser.radio(:name, "box3").clear
100
+ assert_false(browser.radio(:name, "box3").isSet?)
101
101
 
102
- $ie.radio(:name, "box4" , 1).clear
103
- assert(!$ie.radio(:name, "box4" , 1).isSet?)
102
+ browser.radio(:name, "box4" , 1).clear
103
+ assert_false(browser.radio(:name, "box4" , 1).isSet?)
104
104
  end
105
105
 
106
106
  def test_radio_getState
107
- assert_raises(UnknownObjectException, "UnknownObjectException was supposed to be thrown" ) { $ie.radio(:name, "noName").getState }
107
+ assert_raises(UnknownObjectException, "UnknownObjectException was supposed to be thrown" ) { browser.radio(:name, "noName").getState }
108
108
 
109
- assert_equal( false , $ie.radio(:name, "box1").getState )
110
- assert_equal( true , $ie.radio(:name, "box3").getState)
109
+ assert_equal( false , browser.radio(:name, "box1").getState )
110
+ assert_equal( true , browser.radio(:name, "box3").getState)
111
111
 
112
112
  # radioes that have the same name but different values
113
- assert_equal( false , $ie.radio(:name, "box4" , 2).getState )
114
- assert_equal( true , $ie.radio(:name, "box4" , 1).getState)
113
+ assert_equal( false , browser.radio(:name, "box4" , 2).getState )
114
+ assert_equal( true , browser.radio(:name, "box4" , 1).getState)
115
115
  end
116
116
 
117
117
  def test_radio_set
118
- assert_raises(UnknownObjectException, "UnknownObjectException was supposed to be thrown" ) { $ie.radio(:name, "noName").set }
119
- $ie.radio(:name, "box1").set
120
- assert($ie.radio(:name, "box1").isSet?)
118
+ assert_raises(UnknownObjectException, "UnknownObjectException was supposed to be thrown" ) { browser.radio(:name, "noName").set }
119
+ browser.radio(:name, "box1").set
120
+ assert(browser.radio(:name, "box1").isSet?)
121
121
 
122
- assert_raises(ObjectDisabledException, "ObjectDisabledException was supposed to be thrown" ) { $ie.radio(:name, "box2").set }
122
+ assert_raises(ObjectDisabledException, "ObjectDisabledException was supposed to be thrown" ) { browser.radio(:name, "box2").set }
123
123
 
124
- $ie.radio(:name, "box3").set
125
- assert($ie.radio(:name, "box3").isSet?)
124
+ browser.radio(:name, "box3").set
125
+ assert(browser.radio(:name, "box3").isSet?)
126
126
 
127
127
  # radioes that have the same name but different values
128
- $ie.radio(:name, "box4" , 3).set
129
- assert($ie.radio(:name, "box4" , 3).isSet?)
128
+ browser.radio(:name, "box4" , 3).set
129
+ assert(browser.radio(:name, "box4" , 3).isSet?)
130
130
  end
131
131
 
132
132
  def test_radio_properties
133
133
 
134
- assert_raises(UnknownObjectException, "UnknownObjectException was supposed to be thrown" ) { $ie.radio(:index, 199).value}
135
- assert_raises(UnknownObjectException, "UnknownObjectException was supposed to be thrown" ) { $ie.radio(:index, 199).name }
136
- assert_raises(UnknownObjectException, "UnknownObjectException was supposed to be thrown" ) { $ie.radio(:index, 199).id }
137
- assert_raises(UnknownObjectException, "UnknownObjectException was supposed to be thrown" ) { $ie.radio(:index, 199).disabled }
138
- assert_raises(UnknownObjectException, "UnknownObjectException was supposed to be thrown" ) { $ie.radio(:index, 199).type }
134
+ assert_raises(UnknownObjectException, "UnknownObjectException was supposed to be thrown" ) { browser.radio(:index, 199).value}
135
+ assert_raises(UnknownObjectException, "UnknownObjectException was supposed to be thrown" ) { browser.radio(:index, 199).name }
136
+ assert_raises(UnknownObjectException, "UnknownObjectException was supposed to be thrown" ) { browser.radio(:index, 199).id }
137
+ assert_raises(UnknownObjectException, "UnknownObjectException was supposed to be thrown" ) { browser.radio(:index, 199).disabled }
138
+ assert_raises(UnknownObjectException, "UnknownObjectException was supposed to be thrown" ) { browser.radio(:index, 199).type }
139
139
 
140
- assert_equal("on" , $ie.radio(:index, 1).value)
141
- assert_equal("box1" , $ie.radio(:index, 1).name )
142
- assert_equal("" , $ie.radio(:index, 1).id )
143
- assert_equal("radio", $ie.radio(:index, 1).type )
140
+ assert_equal("on" , browser.radio(:index, 1).value)
141
+ assert_equal("box1" , browser.radio(:index, 1).name )
142
+ assert_equal("" , browser.radio(:index, 1).id )
143
+ assert_equal("radio", browser.radio(:index, 1).type )
144
144
 
145
- assert_equal( false, $ie.radio(:index, 1).disabled )
146
- assert_equal( true, $ie.radio(:index, 3).disabled )
147
-
148
- assert_equal("box5" , $ie.radio(:index, 2).id )
149
- assert_equal("" , $ie.radio(:index, 2).name )
150
-
151
- assert_equal("box4-value5", $ie.radio(:name , "box4" , 5 ).title )
152
- assert_equal("", $ie.radio(:name , "box4" , 4 ).title )
145
+ assert_equal( false, browser.radio(:index, 1).disabled )
146
+ assert_equal( true, browser.radio(:index, 3).disabled )
153
147
 
148
+ assert_equal("box5" , browser.radio(:index, 2).id )
149
+ assert_equal("" , browser.radio(:index, 2).name )
154
150
 
151
+ assert_equal("box4-value5", browser.radio(:name , "box4" , 5 ).title )
152
+ assert_equal("", browser.radio(:name , "box4" , 4 ).title )
155
153
  end
156
154
 
157
155
  def test_radio_iterators
158
-
159
- assert_equal(13, $ie.radios.length)
160
- assert_equal("box5" , $ie.radios[2].id )
161
- assert_equal(true , $ie.radios[3].disabled )
162
- assert_equal(false , $ie.radios[1].disabled )
156
+ assert_equal(13, browser.radios.length)
157
+ assert_equal("box5" , browser.radios[2].id )
158
+ assert_equal(true , browser.radios[3].disabled )
159
+ assert_equal(false , browser.radios[1].disabled )
163
160
 
164
161
  index = 1
165
- $ie.radios.each do |r|
166
- assert_equal( $ie.radio(:index, index).name , r.name )
167
- assert_equal( $ie.radio(:index, index).id , r.id )
168
- assert_equal( $ie.radio(:index, index).value, r.value)
169
- assert_equal( $ie.radio(:index, index).disabled , r.disabled )
162
+ browser.radios.each do |r|
163
+ assert_equal( browser.radio(:index, index).name , r.name )
164
+ assert_equal( browser.radio(:index, index).id , r.id )
165
+ assert_equal( browser.radio(:index, index).value, r.value)
166
+ assert_equal( browser.radio(:index, index).disabled , r.disabled )
170
167
  index+=1
171
168
  end
172
- assert_equal(index -1, $ie.radios.length)
169
+ assert_equal(index -1, browser.radios.length)
173
170
  end
174
171
 
175
172
  # test radio buttons that have a string as a value
176
173
  def test_value_string
177
- assert($ie.radio(:name, 'box6', 'Tea').exists?)
178
- assert($ie.radio(:name, 'box6', 'Milk').exists?)
179
- $ie.radio(:name, "box6" , 'Milk').set
180
- assert($ie.radio(:name, "box6" , 'Milk').isSet?)
181
- assert(!$ie.radio(:name, "box6" , 'Tea').isSet?)
174
+ tea = browser.radio(:name, 'box6', 'Tea')
175
+ milk = browser.radio(:name, 'box6', 'Milk')
176
+
177
+ assert(tea.exists?)
178
+ assert(milk.exists?)
179
+
180
+ milk.set
181
+ assert(milk.isSet?)
182
+ assert_false(tea.isSet?)
183
+
184
+ tea.set
185
+ assert_false(milk.isSet?)
186
+ assert(tea.isSet?)
187
+
188
+ tea.clear
189
+ assert_false(tea.isSet?)
190
+ end
191
+
192
+ def test_value_specified
193
+ tea = browser.radio(:name => 'box6', :value => 'Tea')
194
+ milk = browser.radio(:name => 'box6', :value => 'Milk')
195
+
196
+ assert(tea.exists?)
197
+ assert(milk.exists?)
198
+
199
+ milk.set
200
+ assert(milk.isSet?)
201
+ assert_false(tea.isSet?)
202
+
203
+ tea.set
204
+ assert_false(milk.isSet?)
205
+ assert(tea.isSet?)
182
206
 
183
- $ie.radio(:name, "box6" , 'Tea').set
184
- assert(!$ie.radio(:name, "box6" , 'Milk').isSet?)
185
- assert($ie.radio(:name, "box6" , 'Tea').isSet?)
186
- $ie.radio(:name, "box6", 'Tea').clear
187
- assert(!$ie.radio(:name, "box6" , 'Tea').isSet?)
207
+ tea.clear
208
+ assert_false(tea.isSet?)
188
209
  end
189
210
 
190
211
  end