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.
- data/README +24 -0
- data/Rakefile +3 -14
- data/commonwatir.gemspec +18 -0
- data/lib/watir.rb +1 -14
- metadata +19 -131
- data/CHANGES +0 -712
- data/LICENSE +0 -34
- data/README.rdoc +0 -101
- data/VERSION +0 -1
- data/lib/watir/assertions.rb +0 -44
- data/lib/watir/browser.rb +0 -149
- data/lib/watir/browsers.rb +0 -13
- data/lib/watir/element_extensions.rb +0 -69
- data/lib/watir/exceptions.rb +0 -50
- data/lib/watir/matches.rb +0 -23
- data/lib/watir/options.rb +0 -56
- data/lib/watir/testcase.rb +0 -97
- data/lib/watir/util.rb +0 -35
- data/lib/watir/version.rb +0 -4
- data/lib/watir/wait.rb +0 -41
- data/lib/watir/wait_helper.rb +0 -12
- data/lib/watir/waiter.rb +0 -98
- data/unittests/attach_to_existing_window_test.rb +0 -70
- data/unittests/browser_test.rb +0 -38
- data/unittests/buttons_test.rb +0 -288
- data/unittests/dd_test.rb +0 -84
- data/unittests/dl_test.rb +0 -82
- data/unittests/dt_test.rb +0 -82
- data/unittests/element_collections_test.rb +0 -22
- data/unittests/element_test.rb +0 -24
- data/unittests/em_test.rb +0 -81
- data/unittests/form2_test.rb +0 -22
- data/unittests/html/blankpage.html +0 -11
- data/unittests/html/buttons1.html +0 -40
- data/unittests/html/buttons2.html +0 -60
- data/unittests/html/definition_lists.html +0 -48
- data/unittests/html/elements.html +0 -13
- data/unittests/html/emphasis.html +0 -12
- data/unittests/html/entertainment_com.html +0 -667
- data/unittests/html/frame_buttons.html +0 -4
- data/unittests/html/images/button.jpg +0 -0
- data/unittests/html/pass.html +0 -10
- data/unittests/html/phrase_elements.html +0 -15
- data/unittests/html/select_lists.html +0 -18
- data/unittests/html/utf8.html +0 -12
- data/unittests/html/visibility.html +0 -90
- data/unittests/html/wait.html +0 -15
- data/unittests/html/watir_unit_tests.css +0 -64
- data/unittests/html/whitespace.html +0 -29
- data/unittests/options.yml.example +0 -13
- data/unittests/select_list_test.rb +0 -19
- data/unittests/setup.rb +0 -17
- data/unittests/setup/browser.rb +0 -14
- data/unittests/setup/capture_io_helper.rb +0 -17
- data/unittests/setup/filter.rb +0 -24
- data/unittests/setup/lib.rb +0 -22
- data/unittests/setup/options.rb +0 -29
- data/unittests/setup/testUnitAddons.rb +0 -8
- data/unittests/setup/watir-unittest.rb +0 -78
- data/unittests/strong_test.rb +0 -46
- data/unittests/utf8_test.rb +0 -24
- data/unittests/visibility_test.rb +0 -47
- data/unittests/wait_test.rb +0 -126
- data/unittests/whitespace_test.rb +0 -46
@@ -1,78 +0,0 @@
|
|
1
|
-
$htmlRoot = "file:///#{$myDir}/html/"
|
2
|
-
|
3
|
-
module Watir::UnitTest
|
4
|
-
# navigate the browser to the specified page in unittests/html
|
5
|
-
def goto_page page
|
6
|
-
new_url = self.class.html_root + page
|
7
|
-
browser.goto new_url
|
8
|
-
end
|
9
|
-
# navigate the browser to the specified page in unittests/html IF the browser is not already on that page.
|
10
|
-
def uses_page page # only works with IE
|
11
|
-
new_url = self.class.html_root + page
|
12
|
-
browser.goto new_url unless browser.url == new_url
|
13
|
-
end
|
14
|
-
def browser
|
15
|
-
return $browser if $browser && $browser.exists?
|
16
|
-
$browser = Watir::Browser.new
|
17
|
-
end
|
18
|
-
def close_browser
|
19
|
-
$browser.close if $browser.exists?
|
20
|
-
end
|
21
|
-
|
22
|
-
def assert_class element, klass
|
23
|
-
assert_match(Regexp.new(klass, Regexp::IGNORECASE), element.class.to_s, "element class should be #{klass}; got #{element.class}")
|
24
|
-
end
|
25
|
-
|
26
|
-
@@filter = []
|
27
|
-
class << self
|
28
|
-
def filter
|
29
|
-
@@filter
|
30
|
-
end
|
31
|
-
def filter= proc
|
32
|
-
@@filter = proc
|
33
|
-
end
|
34
|
-
# Add a filter that excludes tests matching the provided block
|
35
|
-
def filter_out &block
|
36
|
-
@@filter << Proc.new do |test|
|
37
|
-
block.call(test) ? false : nil
|
38
|
-
end
|
39
|
-
end
|
40
|
-
def filter_out_tests_tagged tag
|
41
|
-
filter_out do |test|
|
42
|
-
test.tagged? tag
|
43
|
-
end
|
44
|
-
end
|
45
|
-
end
|
46
|
-
end
|
47
|
-
|
48
|
-
class Test::Unit::TestCase
|
49
|
-
include Watir::UnitTest
|
50
|
-
include Watir::Exception
|
51
|
-
|
52
|
-
class << self
|
53
|
-
def tags *names
|
54
|
-
@tags ||= []
|
55
|
-
@tags += names
|
56
|
-
end
|
57
|
-
def tag_method method_name, *tags
|
58
|
-
self.method_tags[method_name.to_s] = tags
|
59
|
-
end
|
60
|
-
def method_tags
|
61
|
-
@method_tags ||= Hash.new []
|
62
|
-
end
|
63
|
-
def html_root
|
64
|
-
return "file:///#{File.expand_path @html_dir}/" if @html_dir
|
65
|
-
$htmlRoot
|
66
|
-
end
|
67
|
-
def location path
|
68
|
-
@html_dir = File.join File.dirname(path), 'html'
|
69
|
-
end
|
70
|
-
end
|
71
|
-
|
72
|
-
def tagged? tag
|
73
|
-
self.class.tags.include?(tag) ||
|
74
|
-
self.class.method_tags[@method_name].include?(tag)
|
75
|
-
end
|
76
|
-
|
77
|
-
end
|
78
|
-
|
data/unittests/strong_test.rb
DELETED
@@ -1,46 +0,0 @@
|
|
1
|
-
$LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..') unless $SETUP_LOADED
|
2
|
-
require 'unittests/setup'
|
3
|
-
|
4
|
-
class TC_Strong < Test::Unit::TestCase
|
5
|
-
include Watir::Exception
|
6
|
-
location __FILE__
|
7
|
-
|
8
|
-
def setup
|
9
|
-
uses_page "phrase_elements.html"
|
10
|
-
end
|
11
|
-
|
12
|
-
def test_exists
|
13
|
-
assert browser.strong(:id, "strong_id").exists?, "Could not find <strong> by :id"
|
14
|
-
assert browser.strong(:class, "strong_class").exists?, "Could not find <strong> by :class"
|
15
|
-
assert browser.strong(:xpath, "//strong[@id='strong_id']").exists?, "Could not find <strong> by :xpath"
|
16
|
-
assert browser.strong(:index, 1).exists?, "Could not find <strong> by :index"
|
17
|
-
assert browser.strong(:text, /this is a/).exists?, "Could not finr <strong> by :text"
|
18
|
-
end
|
19
|
-
|
20
|
-
tag_method :test_strong_iterator, :fails_on_ie
|
21
|
-
def test_strong_iterator
|
22
|
-
assert_equal(2, browser.strongs.length)
|
23
|
-
assert_equal("this is a strong", browser.strongs[1].text)
|
24
|
-
|
25
|
-
browser.strongs.each_with_index do |strong, idx|
|
26
|
-
assert_equal(browser.strong(:index,idx+1).text, strong.text)
|
27
|
-
assert_equal(browser.strong(:index,idx+1).id, strong.id)
|
28
|
-
assert_equal(browser.strong(:index,idx+1).class_name , strong.class_name)
|
29
|
-
assert_equal(browser.strong(:index,idx+1).title, strong.title)
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
tag_method :test_strong_iterator_ie, :fails_on_firefox
|
34
|
-
def test_strong_iterator_ie
|
35
|
-
assert_equal(2, browser.strongs.length)
|
36
|
-
assert_equal("this is a strong", browser.strongs[0].text)
|
37
|
-
|
38
|
-
browser.strongs.each_with_index do |strong, idx|
|
39
|
-
assert_equal(browser.strong(:index,idx).text, strong.text)
|
40
|
-
assert_equal(browser.strong(:index,idx).id, strong.id)
|
41
|
-
assert_equal(browser.strong(:index,idx).class_name , strong.class_name)
|
42
|
-
assert_equal(browser.strong(:index,idx).title, strong.title)
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
46
|
-
end
|
data/unittests/utf8_test.rb
DELETED
@@ -1,24 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
$LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..') unless $SETUP_LOADED
|
4
|
-
require 'unittests/setup'
|
5
|
-
|
6
|
-
class TC_Utf8 < Test::Unit::TestCase
|
7
|
-
location __FILE__
|
8
|
-
|
9
|
-
def setup
|
10
|
-
uses_page "utf8.html"
|
11
|
-
end
|
12
|
-
|
13
|
-
def test_is_correct_encoding
|
14
|
-
txt = browser.div(:id, 'utf8_string').text
|
15
|
-
if RUBY_VERSION =~ /^1\.8/
|
16
|
-
assert_equal("\303\246\303\270\303\245", txt)
|
17
|
-
else
|
18
|
-
assert(txt.force_encoding("UTF-8").valid_encoding?, "#{txt.inspect} is not valid UTF-8")
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
end
|
23
|
-
|
24
|
-
|
@@ -1,47 +0,0 @@
|
|
1
|
-
# feature tests for Visibility
|
2
|
-
|
3
|
-
$LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..') unless $SETUP_LOADED
|
4
|
-
require 'unittests/setup'
|
5
|
-
|
6
|
-
class TC_Visibility < Test::Unit::TestCase
|
7
|
-
location __FILE__
|
8
|
-
|
9
|
-
def setup
|
10
|
-
uses_page "visibility.html"
|
11
|
-
end
|
12
|
-
|
13
|
-
# will check for divs which are visible on the screen (not inline style)
|
14
|
-
def test_initial_divs
|
15
|
-
assert_equal(true, browser.div(:id, "div1").visible?)
|
16
|
-
assert_equal(false, browser.div(:id, "div2").visible?)
|
17
|
-
assert_equal(false, browser.div(:id, "div3").visible?)
|
18
|
-
end
|
19
|
-
|
20
|
-
# will check for textfields which are visible on the screen (not inline style)
|
21
|
-
# if any textfields style displays true, it checks if all the parents are true else displays false
|
22
|
-
def test_initial_text_fields
|
23
|
-
assert_equal(true, browser.text_field(:id, "lgnId1").visible?)
|
24
|
-
assert_equal(false, browser.text_field(:id, "lgnId2").visible?)
|
25
|
-
assert_equal(false, browser.text_field(:id, "lgnId3").visible?)
|
26
|
-
end
|
27
|
-
|
28
|
-
# Check if the second div becomes visible (inline visibility test)
|
29
|
-
def test_make_visible_second_div
|
30
|
-
browser.link(:id, "div2vis").click
|
31
|
-
#wait_until { browser.div(:id, "div2").visible? }
|
32
|
-
assert_equal(true, browser.div(:id, "div2").visible? )
|
33
|
-
assert_equal(true, browser.text_field(:id, "lgnId2").visible? )
|
34
|
-
end
|
35
|
-
|
36
|
-
# Check if the second div becomes visible (inline Display block test)
|
37
|
-
def test_make_display_third_div
|
38
|
-
browser.link(:id, "div3blk").click
|
39
|
-
#wait_until { browser.div(:id, "div3").visible? }
|
40
|
-
assert_equal(true, browser.div(:id, "div3").visible? )
|
41
|
-
assert_equal(true, browser.text_field(:id, "lgnId3").visible? )
|
42
|
-
end
|
43
|
-
|
44
|
-
def test_hidden_element
|
45
|
-
assert_equal(false, browser.hidden(:id, 'hidden-type').visible? )
|
46
|
-
end
|
47
|
-
end
|
data/unittests/wait_test.rb
DELETED
@@ -1,126 +0,0 @@
|
|
1
|
-
$LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..') unless $SETUP_LOADED
|
2
|
-
require 'unittests/setup'
|
3
|
-
|
4
|
-
class Wait < Test::Unit::TestCase
|
5
|
-
include Watir::Exception
|
6
|
-
location __FILE__
|
7
|
-
|
8
|
-
def setup
|
9
|
-
uses_page "wait.html"
|
10
|
-
browser.refresh
|
11
|
-
end
|
12
|
-
|
13
|
-
def test_wait_until
|
14
|
-
div = browser.div(:id => "div1")
|
15
|
-
assert div.visible?
|
16
|
-
browser.link(:id => "link1").click
|
17
|
-
|
18
|
-
browser.wait_until(2) {not div.visible?}
|
19
|
-
assert !div.visible?
|
20
|
-
end
|
21
|
-
|
22
|
-
def test_wait_until_exception
|
23
|
-
assert_raises(Watir::Wait::TimeoutError) {browser.wait_until(0.1) {false}}
|
24
|
-
end
|
25
|
-
|
26
|
-
def test_wait_while
|
27
|
-
div = browser.div(:id => "div1")
|
28
|
-
assert div.visible?
|
29
|
-
browser.link(:id => "link1").click
|
30
|
-
|
31
|
-
browser.wait_while(2) {div.visible?}
|
32
|
-
assert !div.visible?
|
33
|
-
end
|
34
|
-
|
35
|
-
def test_wait_while_exception
|
36
|
-
assert_raises(Watir::Wait::TimeoutError) {browser.wait_while(0.1) {true}}
|
37
|
-
end
|
38
|
-
|
39
|
-
def test_present?
|
40
|
-
div = browser.div(:id => "div1")
|
41
|
-
assert div.exists?
|
42
|
-
assert div.visible?
|
43
|
-
assert div.present?
|
44
|
-
|
45
|
-
browser.link(:id => "link1").click
|
46
|
-
browser.wait_until(2) {!div.visible?}
|
47
|
-
assert div.exists?
|
48
|
-
assert !div.visible?
|
49
|
-
assert !div.present?
|
50
|
-
|
51
|
-
non_existing_div = browser.div(:id => "non-existing")
|
52
|
-
assert !non_existing_div.exists?
|
53
|
-
assert_raises(Watir::Exception::UnknownObjectException) {non_existing_div.visible?}
|
54
|
-
assert !non_existing_div.present?
|
55
|
-
end
|
56
|
-
|
57
|
-
def test_when_present
|
58
|
-
browser.link(:id => "link1").click
|
59
|
-
div = browser.div(:id => "div1")
|
60
|
-
assert_equal "div1", div.when_present(2).text
|
61
|
-
assert div.visible?
|
62
|
-
end
|
63
|
-
|
64
|
-
def test_when_present_block
|
65
|
-
browser.link(:id => "link1").click
|
66
|
-
div = browser.div(:id => "div1")
|
67
|
-
div.when_present(2) do |d|
|
68
|
-
assert_equal "div1", d.text
|
69
|
-
end
|
70
|
-
assert div.visible?
|
71
|
-
end
|
72
|
-
|
73
|
-
def test_when_present_exceptions
|
74
|
-
assert_raises(NoMethodError) {browser.div(:id => "div1").when_present(0.1).non_existing_method}
|
75
|
-
assert_raises(Watir::Wait::TimeoutError) {browser.div(:id => "non-existing").when_present(0.1).text}
|
76
|
-
end
|
77
|
-
|
78
|
-
def test_when_present_element_id
|
79
|
-
browser.link(:id => "link1").click
|
80
|
-
div = browser.div(:id => "div1")
|
81
|
-
assert_equal "div1", div.when_present(2).id
|
82
|
-
assert div.visible?
|
83
|
-
end
|
84
|
-
|
85
|
-
def test_wait_until_present
|
86
|
-
browser.link(:id => "link1").click
|
87
|
-
|
88
|
-
div = browser.div(:id => "div1")
|
89
|
-
browser.link(:id => "link1").click
|
90
|
-
div.wait_until_present(2)
|
91
|
-
assert div.visible?
|
92
|
-
end
|
93
|
-
|
94
|
-
def test_wait_until_present_exception
|
95
|
-
assert_raises(Watir::Wait::TimeoutError) {browser.div(:id => "non-existing").wait_until_present(0.1)}
|
96
|
-
end
|
97
|
-
|
98
|
-
def test_wait_while_present
|
99
|
-
div = browser.div(:id => "div1")
|
100
|
-
browser.link(:id => "link1").click
|
101
|
-
div.wait_while_present(2)
|
102
|
-
assert !div.visible?
|
103
|
-
end
|
104
|
-
|
105
|
-
def test_wait_while_present_exception
|
106
|
-
assert_raises(Watir::Wait::TimeoutError) {browser.div(:id => "div1").wait_while_present(0.1)}
|
107
|
-
end
|
108
|
-
|
109
|
-
def test_wait_module_until
|
110
|
-
div = browser.div(:id => "div1")
|
111
|
-
assert div.visible?
|
112
|
-
browser.link(:id => "link1").click
|
113
|
-
|
114
|
-
Watir::Wait.until(2) {not div.visible?}
|
115
|
-
assert !div.visible?
|
116
|
-
end
|
117
|
-
|
118
|
-
def test_wait_module_while
|
119
|
-
div = browser.div(:id => "div1")
|
120
|
-
assert div.visible?
|
121
|
-
browser.link(:id => "link1").click
|
122
|
-
|
123
|
-
Watir::Wait.while(2) {div.visible?}
|
124
|
-
assert !div.visible?
|
125
|
-
end
|
126
|
-
end
|
@@ -1,46 +0,0 @@
|
|
1
|
-
# feature tests for white space
|
2
|
-
|
3
|
-
$LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..') unless $SETUP_LOADED
|
4
|
-
require 'unittests/setup'
|
5
|
-
|
6
|
-
class TC_WhiteSpace < Test::Unit::TestCase
|
7
|
-
location __FILE__
|
8
|
-
|
9
|
-
def setup
|
10
|
-
uses_page "whitespace.html"
|
11
|
-
end
|
12
|
-
|
13
|
-
tag_method :test_text_with_nbsp, :fails_on_ie
|
14
|
-
def test_text_with_nbsp
|
15
|
-
assert_equal 'Login', browser.link(:index => 1).text
|
16
|
-
end
|
17
|
-
|
18
|
-
tag_method :test_text_with_nbsp_ie, :fails_on_firefox
|
19
|
-
def test_text_with_nbsp_ie
|
20
|
-
assert_equal 'Login', browser.link(:index => 0).text
|
21
|
-
end
|
22
|
-
|
23
|
-
def test_nbsp_beginning_and_end
|
24
|
-
assert browser.link(:text, 'Login').exists?
|
25
|
-
end
|
26
|
-
|
27
|
-
def test_single_nbsp
|
28
|
-
assert_equal "Test for nbsp.", browser.span(:id, 'single_nbsp').text
|
29
|
-
end
|
30
|
-
|
31
|
-
def test_multiple_spaces
|
32
|
-
assert_equal "Test for multiple spaces.", browser.span(:id, 'multiple_spaces').text
|
33
|
-
end
|
34
|
-
|
35
|
-
def test_multiple_spaces_access
|
36
|
-
assert_equal 'multiple_spaces', browser.span(:text, "Test for multiple spaces.").id
|
37
|
-
end
|
38
|
-
|
39
|
-
def test_space_tab
|
40
|
-
assert_equal "Test for space and tab.", browser.span(:id, 'space_tab').text
|
41
|
-
end
|
42
|
-
|
43
|
-
def test_space_w_cr
|
44
|
-
assert_equal "Test for space and cr.", browser.span(:id, 'space_w_cr').text
|
45
|
-
end
|
46
|
-
end
|