commonwatir 3.0.0.rc3 → 3.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (64) hide show
  1. data/README +24 -0
  2. data/Rakefile +3 -14
  3. data/commonwatir.gemspec +18 -0
  4. data/lib/watir.rb +1 -14
  5. metadata +19 -131
  6. data/CHANGES +0 -712
  7. data/LICENSE +0 -34
  8. data/README.rdoc +0 -101
  9. data/VERSION +0 -1
  10. data/lib/watir/assertions.rb +0 -44
  11. data/lib/watir/browser.rb +0 -149
  12. data/lib/watir/browsers.rb +0 -13
  13. data/lib/watir/element_extensions.rb +0 -69
  14. data/lib/watir/exceptions.rb +0 -50
  15. data/lib/watir/matches.rb +0 -23
  16. data/lib/watir/options.rb +0 -56
  17. data/lib/watir/testcase.rb +0 -97
  18. data/lib/watir/util.rb +0 -35
  19. data/lib/watir/version.rb +0 -4
  20. data/lib/watir/wait.rb +0 -41
  21. data/lib/watir/wait_helper.rb +0 -12
  22. data/lib/watir/waiter.rb +0 -98
  23. data/unittests/attach_to_existing_window_test.rb +0 -70
  24. data/unittests/browser_test.rb +0 -38
  25. data/unittests/buttons_test.rb +0 -288
  26. data/unittests/dd_test.rb +0 -84
  27. data/unittests/dl_test.rb +0 -82
  28. data/unittests/dt_test.rb +0 -82
  29. data/unittests/element_collections_test.rb +0 -22
  30. data/unittests/element_test.rb +0 -24
  31. data/unittests/em_test.rb +0 -81
  32. data/unittests/form2_test.rb +0 -22
  33. data/unittests/html/blankpage.html +0 -11
  34. data/unittests/html/buttons1.html +0 -40
  35. data/unittests/html/buttons2.html +0 -60
  36. data/unittests/html/definition_lists.html +0 -48
  37. data/unittests/html/elements.html +0 -13
  38. data/unittests/html/emphasis.html +0 -12
  39. data/unittests/html/entertainment_com.html +0 -667
  40. data/unittests/html/frame_buttons.html +0 -4
  41. data/unittests/html/images/button.jpg +0 -0
  42. data/unittests/html/pass.html +0 -10
  43. data/unittests/html/phrase_elements.html +0 -15
  44. data/unittests/html/select_lists.html +0 -18
  45. data/unittests/html/utf8.html +0 -12
  46. data/unittests/html/visibility.html +0 -90
  47. data/unittests/html/wait.html +0 -15
  48. data/unittests/html/watir_unit_tests.css +0 -64
  49. data/unittests/html/whitespace.html +0 -29
  50. data/unittests/options.yml.example +0 -13
  51. data/unittests/select_list_test.rb +0 -19
  52. data/unittests/setup.rb +0 -17
  53. data/unittests/setup/browser.rb +0 -14
  54. data/unittests/setup/capture_io_helper.rb +0 -17
  55. data/unittests/setup/filter.rb +0 -24
  56. data/unittests/setup/lib.rb +0 -22
  57. data/unittests/setup/options.rb +0 -29
  58. data/unittests/setup/testUnitAddons.rb +0 -8
  59. data/unittests/setup/watir-unittest.rb +0 -78
  60. data/unittests/strong_test.rb +0 -46
  61. data/unittests/utf8_test.rb +0 -24
  62. data/unittests/visibility_test.rb +0 -47
  63. data/unittests/wait_test.rb +0 -126
  64. data/unittests/whitespace_test.rb +0 -46
@@ -1,23 +0,0 @@
1
- class String
2
- def matches(x)
3
- return self == x
4
- end
5
- end
6
-
7
- class Regexp
8
- def matches(x)
9
- return self.match(x)
10
- end
11
- end
12
-
13
- class Integer
14
- def matches(x)
15
- return self == x
16
- end
17
- end
18
-
19
- class Object
20
- def matches(x)
21
- raise TypeError, "#{self.class} is not supported as a locator"
22
- end
23
- end
@@ -1,56 +0,0 @@
1
- #--
2
- # watir/options
3
- require 'rubygems'
4
-
5
- require 'user-choices'
6
-
7
- module Watir
8
- @@options_file = nil
9
- @@options = nil
10
- class << self
11
- # Specify the location of a yaml file containing Watir options. Must be
12
- # specified before the options are parsed.
13
- def options_file= file
14
- @@options_file = file
15
- end
16
- def options_file
17
- @@options_file
18
- end
19
- def options= x
20
- @@options = x
21
- end
22
- # Return the Watir options, as a hash. If they haven't been parsed yet,
23
- # they will be now.
24
- def options
25
- @@options ||= Watir::WatirOptions.new.execute
26
- end
27
- end
28
-
29
- class WatirOptions < UserChoices::Command
30
- include UserChoices
31
- def add_sources builder
32
- builder.add_source EnvironmentSource, :with_prefix, 'watir_'
33
- if Watir.options_file
34
- builder.add_source YamlConfigFileSource, :from_complete_path,
35
- Watir.options_file
36
- end
37
- end
38
- def add_choices builder
39
- builder.add_choice :browser,
40
- :type => Watir::Browser.browser_names,
41
- :default => Watir::Browser.default
42
- builder.add_choice :speed,
43
- :type => ['slow', 'fast', 'zippy'],
44
- :default => 'fast'
45
- builder.add_choice :visible,
46
- :type => :boolean
47
- builder.add_choice :zero_based_indexing,
48
- :type => :boolean,
49
- :default => true
50
- end
51
- def execute
52
- @user_choices[:speed] = @user_choices[:speed].to_sym
53
- @user_choices
54
- end
55
- end
56
- end
@@ -1,97 +0,0 @@
1
- require 'test/unit'
2
- require 'watir/assertions'
3
-
4
- module Watir
5
-
6
- # This is a 'test/unit' testcase customized to exeucte test methods sequentially by default
7
- # and extra assertions
8
- #
9
- # Example Usage
10
- #
11
- # require 'watir/testcase'
12
- #
13
- # class MyTestCase < Watir::TestCase
14
- #
15
- # # some helpers
16
- # @@browser = nil
17
- # def browser
18
- # @browser ||= Watir::IE.start(:url, 'http://watir.com/")
19
- # end
20
- #
21
- # # TESTS
22
- # def test_text
23
- # browser.goto "http://watir.com/"
24
- # verify_match "Web Application Testing in Ruby", browser.text
25
- # end
26
- #
27
- # def test_title
28
- # verify browser.title == 'Watir'
29
- # end
30
- #
31
- # def test_link
32
- # verify_match 'watir.com', browser.link(:text, 'Home').href
33
- # end
34
- #
35
- # def test_navigate_to_examples
36
- # browser.div(:id, 'nav').link(:text, 'Examples').click
37
- # end
38
- #
39
- # def test_url
40
- # verify_equal browser.url, 'http://watir.com/examples/'
41
- # end
42
- #
43
- # end
44
- #
45
- class TestCase < Test::Unit::TestCase
46
- include Watir::Assertions
47
- @@order = :sequentially
48
- def initialize name
49
- throw :invalid_test if name == :default_test && self.class == Watir::TestCase
50
- super
51
- end
52
- class << self
53
- attr_accessor :test_methods, :order
54
- def test_methods
55
- @test_methods ||= []
56
- end
57
- def order
58
- @order || @@order
59
- end
60
- def default_order= order
61
- @@order = order
62
- end
63
- def sorted_test_methods
64
- case order
65
- when :alphabetically then test_methods.sort
66
- when :sequentially then test_methods
67
- when :reversed_sequentially then test_methods.reverse
68
- when :reversed_alphabetically then test_methods.sort.reverse
69
- else raise ArgumentError, "Execute option not supported: #{@order}"
70
- end
71
- end
72
- def suite
73
- suite = Test::Unit::TestSuite.new(name)
74
- sorted_test_methods.each do |test|
75
- catch :invalid_test do
76
- suite << new(test)
77
- end
78
- end
79
- if (suite.empty?)
80
- catch :invalid_test do
81
- suite << new(:default_test)
82
- end
83
- end
84
- return suite
85
- end
86
- def method_added id
87
- name = id.id2name
88
- test_methods << name if name =~ /^test./
89
- end
90
- def execute order
91
- @order = order
92
- end
93
- end
94
- public :add_assertion
95
- end
96
-
97
- end
@@ -1,35 +0,0 @@
1
- module Watir
2
- class Util
3
- class << self
4
- #
5
- # "Watir::Span" => "Span"
6
- #
7
- def demodulize(str)
8
- str.gsub(/^.*::/, '')
9
- end
10
-
11
- #
12
- # "FooBar" => "foo_bar"
13
- #
14
- def underscore(str)
15
- str.gsub(/\B[A-Z][^A-Z]/, '_\&').downcase.gsub(' ', '_')
16
- end
17
-
18
- #
19
- # "Checkboxes" => "Checkbox"
20
- # "Bodies" => "Body"
21
- # "Buttons" => "Button"
22
- #
23
- def singularize(str)
24
- case str.downcase
25
- when "checkboxes"
26
- str.chop.chop
27
- when "bodies"
28
- str.chop.chop.chop + "y"
29
- else
30
- str.chop
31
- end
32
- end
33
- end
34
- end
35
- end
@@ -1,4 +0,0 @@
1
- module Watir
2
- version_file = File.dirname(__FILE__) + '/../../VERSION'
3
- VERSION = File.exists?(version_file) ? File.read(version_file).strip : "0.0.0"
4
- end
@@ -1,41 +0,0 @@
1
- # encoding: utf-8
2
-
3
- module Watir
4
- module Wait
5
- extend self
6
-
7
- class TimeoutError < StandardError
8
- end
9
-
10
- #
11
- # Wait until the block evaluates to true or times out.
12
- #
13
-
14
- def until(timeout = 60, &block)
15
- end_time = ::Time.now + timeout
16
-
17
- until ::Time.now > end_time
18
- result = yield(self)
19
- return result if result
20
- sleep 0.1
21
- end
22
-
23
- raise TimeoutError, "timed out after #{timeout} seconds"
24
- end
25
-
26
- #
27
- # Wait while the block evaluates to true or times out.
28
- #
29
- def while(timeout = 60, &block)
30
- end_time = ::Time.now + timeout
31
-
32
- until ::Time.now > end_time
33
- return unless yield(self)
34
- sleep 0.1
35
- end
36
-
37
- raise TimeoutError, "timed out after #{timeout} seconds"
38
- end
39
-
40
- end # Wait
41
- end # Watir
@@ -1,12 +0,0 @@
1
- # include this module if there's a need to have wait_until and wait_while methods in some different scope
2
- module Watir
3
- module WaitHelper
4
- def wait_until(*args, &blk)
5
- Wait.until(*args, &blk)
6
- end
7
-
8
- def wait_while(*args, &blk)
9
- Wait.while(*args, &blk)
10
- end
11
- end
12
- end
@@ -1,98 +0,0 @@
1
- #######
2
- #
3
- # Using Watir::Waiter is DEPRECATED and will be removed in some newer version of Watir! Use Watir::Wait and Watir::ElementExtensions methods instead!
4
- #
5
- #######
6
- require 'watir/exceptions'
7
-
8
- module Watir
9
-
10
- def wait_until(*args)
11
- Waiter.wait_until(*args) {yield}
12
- end
13
-
14
- class TimeKeeper
15
- attr_reader :sleep_time
16
- def initialize
17
- @sleep_time = 0.0
18
- end
19
- def sleep seconds
20
- @sleep_time += Kernel.sleep seconds
21
- end
22
- def now
23
- ::Time.now
24
- end
25
- end
26
-
27
- class Waiter
28
- # This is an interface to a TimeKeeper which proxies
29
- # calls to "sleep" and "Time.now".
30
- # Useful for unit testing Waiter.
31
- attr_accessor :timer
32
-
33
- # How long to wait between each iteration through the wait_until
34
- # loop. In seconds.
35
- attr_accessor :polling_interval
36
-
37
- # Timeout for wait_until.
38
- attr_accessor :timeout
39
-
40
- @@default_polling_interval = 0.5
41
- @@default_timeout = 60.0
42
-
43
- def initialize(timeout=@@default_timeout,
44
- polling_interval=@@default_polling_interval)
45
- Kernel.warn "Using Watir::Waiter is DEPRECATED and will be removed in some newer version of Watir! Use Watir::Wait and Watir::ElementExtensions methods instead!"
46
- @timeout = timeout
47
- @polling_interval = polling_interval
48
- @timer = TimeKeeper.new
49
- end
50
-
51
- # Execute the provided block until either (1) it returns true, or
52
- # (2) the timeout (in seconds) has been reached. If the timeout is reached,
53
- # a TimeOutException will be raised. The block will always
54
- # execute at least once.
55
- #
56
- # waiter = Waiter.new(5)
57
- # waiter.wait_until {puts 'hello'}
58
- #
59
- # This code will print out "hello" for five seconds, and then raise a
60
- # Watir::TimeOutException.
61
- def wait_until # block
62
- start_time = now
63
- until yield do
64
- if (duration = now - start_time) > @timeout
65
- raise Watir::Exception::TimeOutException.new(duration, @timeout),
66
- "Timed out after #{duration} seconds."
67
- end
68
- sleep @polling_interval
69
- end
70
- end
71
-
72
- # Execute the provided block until either (1) it returns true, or
73
- # (2) the timeout (in seconds) has been reached. If the timeout is reached,
74
- # a TimeOutException will be raised. The block will always
75
- # execute at least once.
76
- #
77
- # Waiter.wait_until(5) {puts 'hello'}
78
- #
79
- # This code will print out "hello" for five seconds, and then raise a
80
- # Watir::TimeOutException.
81
-
82
- # IDEA: wait_until: remove defaults from Waiter.wait_until
83
- def self.wait_until(timeout=@@default_timeout,
84
- polling_interval=@@default_polling_interval)
85
- waiter = new(timeout, polling_interval)
86
- waiter.wait_until { yield }
87
- end
88
-
89
- private
90
- def sleep seconds
91
- @timer.sleep seconds
92
- end
93
- def now
94
- @timer.now
95
- end
96
- end
97
-
98
- end # module
@@ -1,70 +0,0 @@
1
- # feature tests for attaching to existing IE windows
2
-
3
- $LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..') unless $SETUP_LOADED
4
- require 'unittests/setup'
5
-
6
- class TC_ExistingWindow < Test::Unit::TestCase
7
- location __FILE__
8
- include Watir
9
-
10
- def setup
11
- @original_timeout = Browser.options[:attach_timeout]
12
- @browsers = []
13
- uses_page "pass.html"
14
- end
15
-
16
- def teardown
17
- Browser.set_options :attach_timeout => @original_timeout
18
- @browsers.each {|x| x.close}
19
- end
20
-
21
- def test_missing_window
22
- Browser.set_options :attach_timeout => 0.1
23
- assert_raises(NoMatchingWindowFoundException) { Browser.attach(:title, "missing") }
24
- assert_raises(NoMatchingWindowFoundException) { Browser.attach(:title, /missing/) }
25
- assert_raises(NoMatchingWindowFoundException) { Browser.attach(:url, "missing") }
26
- assert_raises(NoMatchingWindowFoundException) { Browser.attach(:url, /missing/) }
27
- end
28
-
29
- # Open a few browsers so that the test has a few windows to choose
30
- # from. The test harness has already opened a window that we won't
31
- # use.
32
- def open_several_windows
33
- ["buttons1.html", "whitespace.html"].each do |file|
34
- @browsers << Browser.start(self.class.html_root + file)
35
- end
36
- end
37
-
38
- def test_existing_window
39
- open_several_windows
40
-
41
- b1 = Browser.attach(:title , /buttons/i)
42
- assert_equal("Test page for buttons", b1.title)
43
-
44
- b2 = Browser.attach(:title , "Test page for buttons")
45
- assert_equal("Test page for buttons", b2.title)
46
-
47
- b3 = Browser.attach(:url, /buttons1.html/)
48
- assert_equal("Test page for buttons", b3.title)
49
- end
50
-
51
- def test_title_and_url_are_correct_after_reload
52
- uses_page "whitespace.html"
53
- assert_equal 'Test page for whitespace', browser.title
54
- assert_match /whitespace.html/, browser.url
55
- browser.link(:text, 'Login').click
56
- assert_equal 'Pass Page', browser.title
57
- assert_match /pass.html/, browser.url
58
- end
59
-
60
- tag_method :test_working_back_and_forth, :fails_on_firefox
61
- def test_working_back_and_forth
62
- open_several_windows
63
- buttons = Browser.attach(:url, /buttons1.html/)
64
- whitespace = Browser.attach(:url, /whitespace.html/)
65
- assert_match /This button is a submit/, buttons.text
66
- whitespace.link(:text, 'Login').click
67
- assert_match /pass/i, whitespace.text
68
- end
69
- end
70
-