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,107 +0,0 @@
1
- # feature tests for Buttons
2
- # revision: $Revision: 1348 $
3
-
4
- $LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..') if $0 == __FILE__
5
- require 'unittests/setup'
6
-
7
- class TC_Button < Test::Unit::TestCase
8
- include Watir::Exception
9
- def setup
10
- goto_page "buttons1.html"
11
- end
12
-
13
- def test_to_s
14
- b4 = [
15
- 'type: *button',
16
- 'id: *b5',
17
- 'name: *b4',
18
- 'value: *Disabled Button',
19
- 'disabled: *true']
20
- b1 = [
21
- 'type: *button',
22
- 'id: *b2',
23
- 'name: *b1',
24
- 'value: *Click Me',
25
- 'disabled: *false']
26
- assert_match(Regexp.new(b4.join("\n")), browser.button(:name, "b4").to_s)
27
- assert_match(Regexp.new(b1.join("\n")), browser.button(:caption, "Click Me").to_s)
28
- assert_match(Regexp.new(b1.join("\n")), browser.button(:index, 1).to_s)
29
- assert_raises(UnknownObjectException) { browser.button(:name, "noName").to_s }
30
- end
31
-
32
- def test_properties
33
- assert_raises(UnknownObjectException) { browser.button(:name, "noName").id }
34
- assert_raises(UnknownObjectException) { browser.button(:name, "noName").name }
35
- assert_raises(UnknownObjectException) { browser.button(:name, "noName").disabled }
36
- assert_raises(UnknownObjectException) { browser.button(:name, "noName").type }
37
- assert_raises(UnknownObjectException) { browser.button(:name, "noName").value }
38
-
39
- assert_equal("b1", browser.button(:index, 1).name)
40
- assert_equal("b2", browser.button(:index, 1).id)
41
- assert_equal("button", browser.button(:index, 1).type)
42
- assert_equal("Click Me", browser.button(:index, 1).value)
43
- assert_equal(false, browser.button(:index, 1).disabled)
44
- assert_equal("italic_button", browser.button(:name, "b1").class_name)
45
- assert_equal("", browser.button(:name , "b4").class_name)
46
-
47
- assert_equal("b1" , browser.button(:id, "b2").name )
48
- assert_equal("b2" , browser.button(:id, "b2").id )
49
- assert_equal("button" , browser.button(:id, "b2").type )
50
-
51
- assert_equal("b4" , browser.button(:index, 2).name )
52
- assert_equal("b5" , browser.button(:index, 2).id )
53
- assert_equal("button" , browser.button(:index, 2).type )
54
- assert_equal("Disabled Button" , browser.button(:index, 2).value )
55
- assert_equal(true , browser.button(:index, 2).disabled )
56
-
57
- assert_equal( "" , browser.button(:index, 2).title )
58
- assert_equal( "this is button1" , browser.button(:index, 1).title )
59
- end
60
-
61
- def test_default_how
62
- assert_raises(UnknownObjectException) { browser.button( "Missing Caption").click }
63
-
64
- browser.button("Click Me").click
65
- assert(browser.text.include?("PASS") )
66
- end
67
-
68
- def test_click
69
- assert_raises(UnknownObjectException) { browser.button(:caption, "Missing Caption").click }
70
- assert_raises(UnknownObjectException) { browser.button(:id, "missingID").click }
71
- assert_raises(ObjectDisabledException) { browser.button(:caption, "Disabled Button").click }
72
-
73
- browser.button(:caption, "Click Me").click
74
- assert(browser.text.include?("PASS"))
75
- end
76
-
77
- def test_exists
78
- assert(browser.button(:caption, "Click Me").exists?)
79
- assert(browser.button(:caption, "Submit").exists?)
80
- assert(browser.button(:name, "b1").exists?)
81
- assert(browser.button(:id, "b2").exists?)
82
- assert(browser.button(:caption, /sub/i).exists?)
83
-
84
- assert(!browser.button(:caption, "missingcaption").exists?)
85
- assert(!browser.button(:name, "missingname").exists?)
86
- assert(!browser.button(:id, "missingid").exists?)
87
- assert(!browser.button(:caption, /missing/i).exists?)
88
- end
89
-
90
- def test_enabled
91
- assert($ie.button(:caption, "Click Me").enabled?)
92
- assert(!browser.button(:caption, "Disabled Button").enabled?)
93
- assert(!browser.button(:name, "b4").enabled?)
94
- assert(!browser.button(:id, "b5").enabled?)
95
-
96
- assert_raises(UnknownObjectException , "UnknownObjectException was supposed to be thrown" ) { browser.button(:name, "noName").enabled? }
97
- end
98
-
99
- def test_in_frame
100
- goto_page "frame_buttons.html"
101
- assert(browser.frame("buttonFrame").button(:caption, "Click Me").enabled?)
102
- # frame must be specified
103
- assert_raises(UnknownObjectException) { browser.button(:caption, "Disabled Button").enabled?}
104
- end
105
-
106
- end
107
-
@@ -1,44 +0,0 @@
1
- require 'test/unit/assertions'
2
-
3
- module Watir
4
- # Verification methods
5
- module Assertions
6
- include Test::Unit::Assertions
7
-
8
- # Log a failure if the boolean is true. The message is the failure
9
- # message logged.
10
- # Whether true or false, the assertion count is incremented.
11
- def verify boolean, message = 'verify failed.'
12
- add_assertion
13
- add_failure message.to_s, caller unless boolean
14
- end
15
-
16
- def verify_equal expected, actual, message=nil
17
- full_message = build_message(message, <<EOT, expected, actual)
18
- <?> expected but was
19
- <?>.
20
- EOT
21
- verify(expected == actual, full_message)
22
- end
23
- def verify_match pattern, string, message=nil
24
- pattern = case(pattern)
25
- when String
26
- Regexp.new(Regexp.escape(pattern))
27
- else
28
- pattern
29
- end
30
- full_message = build_message(message, "<?> expected to be =~\n<?>.", string, pattern)
31
- verify(string =~ pattern, full_message)
32
- end
33
-
34
- end
35
-
36
- end
37
- module Test::Unit::Assertions
38
- def assert_false(boolean, message=nil)
39
- _wrap_assertion do
40
- assert_block("assert should not be called with a block.") { !block_given? }
41
- assert_block(build_message(message, "<?> is not false.", boolean)) { !boolean }
42
- end
43
- end
44
- end
@@ -1,42 +0,0 @@
1
- module Watir
2
- module Exception
3
-
4
- # Root class for all Watir Exceptions
5
- class WatirException < RuntimeError
6
- def initialize(message="")
7
- super(message)
8
- end
9
- end
10
-
11
- # This exception is thrown if an attempt is made to access an object that doesn't exist
12
- class UnknownObjectException < WatirException; end
13
- # This exception is thrown if an attempt is made to access an object that is in a disabled state
14
- class ObjectDisabledException < WatirException; end
15
- # This exception is thrown if an attempt is made to access a frame that cannot be found
16
- class UnknownFrameException< WatirException; end
17
- # This exception is thrown if an attempt is made to access a form that cannot be found
18
- class UnknownFormException< WatirException; end
19
- # This exception is thrown if an attempt is made to access an object that is in a read only state
20
- class ObjectReadOnlyException < WatirException; end
21
- # This exception is thrown if an attempt is made to access an object when the specified value cannot be found
22
- class NoValueFoundException < WatirException; end
23
- # This exception gets raised if part of finding an object is missing
24
- class MissingWayOfFindingObjectException < WatirException; end
25
- # this exception is raised if an attempt is made to access a table cell that doesnt exist
26
- class UnknownCellException < WatirException; end
27
- # This exception is thrown if the window cannot be found
28
- class NoMatchingWindowFoundException < WatirException; end
29
- # This exception is thrown if an attemp is made to acces the status bar of the browser when it doesnt exist
30
- class NoStatusBarException < WatirException; end
31
- # This exception is thrown if an http error, such as a 404, 500 etc is encountered while navigating
32
- class NavigationException < WatirException; end
33
- # This exception is raised if a timeout is exceeded
34
- class TimeOutException < WatirException
35
- def initialize(duration, timeout)
36
- @duration, @timeout = duration, timeout
37
- end
38
- attr_reader :duration, :timeout
39
- end
40
-
41
- end
42
- end
@@ -1,58 +0,0 @@
1
- require 'test/unit'
2
- require 'watir/assertions'
3
-
4
- module Watir
5
-
6
- class TestCase < Test::Unit::TestCase
7
- include Watir::Assertions
8
- @@order = :sequentially
9
- def initialize name
10
- throw :invalid_test if name == :default_test && self.class == Watir::TestCase
11
- super
12
- end
13
- class << self
14
- attr_accessor :test_methods, :order
15
- def test_methods
16
- @test_methods ||= []
17
- end
18
- def order
19
- @order || @@order
20
- end
21
- def default_order= order
22
- @@order = order
23
- end
24
- def sorted_test_methods
25
- case order
26
- when :alphabetically: test_methods.sort
27
- when :sequentially: test_methods
28
- when :reversed_sequentially: test_methods.reverse
29
- when :reversed_alphabetically: test_methods.sort.reverse
30
- else raise ArgumentError, "Execute option not supported: #{@order}"
31
- end
32
- end
33
- def suite
34
- suite = Test::Unit::TestSuite.new(name)
35
- sorted_test_methods.each do |test|
36
- catch :invalid_test do
37
- suite << new(test)
38
- end
39
- end
40
- if (suite.empty?)
41
- catch :invalid_test do
42
- suite << new(:default_test)
43
- end
44
- end
45
- return suite
46
- end
47
- def method_added id
48
- name = id.id2name
49
- test_methods << name if name =~ /^test./
50
- end
51
- def execute order
52
- @order = order
53
- end
54
- end
55
- public :add_assertion
56
- end
57
-
58
- end
@@ -1,88 +0,0 @@
1
- require 'watir/exceptions'
2
-
3
- module Watir
4
-
5
- class TimeKeeper
6
- attr_reader :sleep_time
7
- def initialize
8
- @sleep_time = 0.0
9
- end
10
- def sleep seconds
11
- @sleep_time += Kernel.sleep seconds
12
- end
13
- def now
14
- Time.now
15
- end
16
- end
17
-
18
- class Waiter
19
- # This is an interface to a TimeKeeper which proxies
20
- # calls to "sleep" and "Time.now".
21
- # Useful for unit testing Waiter.
22
- attr_accessor :timer
23
-
24
- # How long to wait between each iteration through the wait_until
25
- # loop. In seconds.
26
- attr_accessor :polling_interval
27
-
28
- # Timeout for wait_until.
29
- attr_accessor :timeout
30
-
31
- @@default_polling_interval = 0.5
32
- @@default_timeout = 60.0
33
-
34
- def initialize(timeout=@@default_timeout,
35
- polling_interval=@@default_polling_interval)
36
- @timeout = timeout
37
- @polling_interval = polling_interval
38
- @timer = TimeKeeper.new
39
- end
40
-
41
- # Execute the provided block until either (1) it returns true, or
42
- # (2) the timeout (in seconds) has been reached. If the timeout is reached,
43
- # a TimeOutException will be raised. The block will always
44
- # execute at least once.
45
- #
46
- # waiter = Waiter.new(5)
47
- # waiter.wait_until {puts 'hello'}
48
- #
49
- # This code will print out "hello" for five seconds, and then raise a
50
- # Watir::TimeOutException.
51
- def wait_until # block
52
- start_time = now
53
- until yield do
54
- if (duration = now - start_time) > @timeout
55
- raise Watir::Exception::TimeOutException.new(duration, @timeout),
56
- "Timed out after #{duration} seconds."
57
- end
58
- sleep @polling_interval
59
- end
60
- end
61
-
62
- # Execute the provided block until either (1) it returns true, or
63
- # (2) the timeout (in seconds) has been reached. If the timeout is reached,
64
- # a TimeOutException will be raised. The block will always
65
- # execute at least once.
66
- #
67
- # Waiter.wait_until(5) {puts 'hello'}
68
- #
69
- # This code will print out "hello" for five seconds, and then raise a
70
- # Watir::TimeOutException.
71
-
72
- # IDEA: wait_until: remove defaults from Waiter.wait_until
73
- def self.wait_until(timeout=@@default_timeout,
74
- polling_interval=@@default_polling_interval)
75
- waiter = new(timeout, polling_interval)
76
- waiter.wait_until { yield }
77
- end
78
-
79
- private
80
- def sleep seconds
81
- @timer.sleep seconds
82
- end
83
- def now
84
- @timer.now
85
- end
86
- end
87
-
88
- end # module
@@ -1,8 +0,0 @@
1
- # load the correct version of win32ole
2
-
3
- # Use our modified win32ole library for Ruby 1.8.2 only
4
- if RUBY_VERSION == '1.8.2'
5
- $LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..', 'watir', 'win32ole')
6
- end
7
- require 'win32ole'
8
-
Binary file