watir-classic 3.0.0 → 3.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +7 -0
- data/.gitmodules +3 -0
- data/.rspec +1 -0
- data/.yardopts +5 -0
- data/CHANGES +20 -10
- data/CONTRIBUTORS.txt +55 -0
- data/Gemfile +3 -0
- data/Gemfile.lock +78 -0
- data/README.rdoc +8 -14
- data/Rakefile +32 -0
- data/VERSION +1 -1
- data/lib/watir-classic.rb +0 -1
- data/lib/watir-classic/IEDialog/IEDialog.cpp +225 -0
- data/lib/watir-classic/IEDialog/IEDialog.h +15 -0
- data/lib/watir-classic/IEDialog/IEDialog.vcproj +159 -0
- data/lib/watir-classic/IEDialog/ReadMe.txt +40 -0
- data/lib/watir-classic/IEDialog/stdafx.cpp +8 -0
- data/lib/watir-classic/IEDialog/stdafx.h +21 -0
- data/lib/watir-classic/browser.rb +1 -1
- data/lib/watir-classic/container.rb +4 -33
- data/lib/watir-classic/core.rb +1 -3
- data/lib/watir-classic/dialogs/alert.rb +46 -0
- data/lib/watir-classic/dialogs/file_field.rb +1 -0
- data/lib/watir-classic/drag_and_drop_helper.rb +18 -6
- data/lib/watir-classic/element.rb +0 -2
- data/lib/watir-classic/ext/json2.js +487 -0
- data/lib/watir-classic/ie-class.rb +10 -164
- data/lib/watir-classic/ie.rb +2 -0
- data/lib/watir-classic/input_elements.rb +1 -1
- data/lib/watir-classic/modal_dialog.rb +1 -7
- data/lib/watir-classic/module.rb +1 -10
- data/lib/watir-classic/non_control_elements.rb +11 -0
- data/lib/watir-classic/page-container.rb +22 -24
- data/lib/watir-classic/screenshot.rb +33 -0
- data/lib/watir-classic/win32ole/1.8.7/win32ole.patch +56 -0
- data/lib/watir-classic/win32ole/1.9.3/win32ole.patch +63 -0
- data/lib/watir-classic/win32ole/build_notes.txt +18 -0
- data/lib/watir-classic/win32ole/history.txt +88 -0
- data/spec/browser_spec.rb +34 -0
- data/spec/implementation.rb +18 -0
- data/watir-classic.gemspec +40 -0
- data/watir.gif +0 -0
- metadata +159 -192
- data/bin/watir-console +0 -5
- data/lib/watir-classic/assertions.rb +0 -44
- data/lib/watir-classic/dialogs/javascript.rb +0 -43
- data/lib/watir-classic/irb-history.rb +0 -31
- data/lib/watir-classic/logger.rb +0 -19
- data/lib/watir-classic/screen_capture.rb +0 -115
- data/lib/watir-classic/testcase.rb +0 -97
- data/lib/watir-classic/waiter.rb +0 -98
- data/rakefile.rb +0 -54
- data/unittests/all_tests.rb +0 -10
- data/unittests/buttons_xpath_test.rb +0 -68
- data/unittests/checkbox_test.rb +0 -163
- data/unittests/checkbox_xpath_test.rb +0 -106
- data/unittests/click_no_wait_test.rb +0 -23
- data/unittests/close_all_test.rb +0 -17
- data/unittests/core_tests.rb +0 -17
- data/unittests/css_selector_test.rb +0 -44
- data/unittests/css_test.rb +0 -38
- data/unittests/dialog_test.rb +0 -64
- data/unittests/div2_xpath_test.rb +0 -21
- data/unittests/div_test.rb +0 -170
- data/unittests/div_xpath_test.rb +0 -95
- data/unittests/document_standards.rb +0 -63
- data/unittests/element_collection_indexes_test.rb +0 -57
- data/unittests/element_collections_test.rb +0 -100
- data/unittests/element_test.rb +0 -47
- data/unittests/errorchecker_test.rb +0 -31
- data/unittests/filefield_test.rb +0 -43
- data/unittests/filefield_xpath_test.rb +0 -35
- data/unittests/form_test.rb +0 -282
- data/unittests/form_xpath_test.rb +0 -254
- data/unittests/frame_test.rb +0 -165
- data/unittests/google_form_test.rb +0 -15
- data/unittests/html/JavascriptClick.html +0 -39
- data/unittests/html/blankpage.html +0 -11
- data/unittests/html/buttons1.html +0 -40
- data/unittests/html/checkboxes1.html +0 -89
- data/unittests/html/click_no_wait.html +0 -14
- data/unittests/html/complex_table.html +0 -35
- data/unittests/html/cssTest.html +0 -42
- data/unittests/html/depot_store.html +0 -59
- data/unittests/html/div.html +0 -92
- data/unittests/html/div_xml.html +0 -21
- data/unittests/html/fileupload.html +0 -44
- data/unittests/html/formTest1.html +0 -38
- data/unittests/html/forms2.html +0 -44
- data/unittests/html/forms3.html +0 -131
- data/unittests/html/forms4.html +0 -26
- data/unittests/html/frame_buttons.html +0 -4
- data/unittests/html/frame_links.html +0 -4
- data/unittests/html/frame_multi.html +0 -5
- data/unittests/html/google_india.html +0 -119
- data/unittests/html/ie7_document_standards.html +0 -9
- data/unittests/html/ie8_document_standards.html +0 -9
- data/unittests/html/ie9_document_standards.html +0 -9
- data/unittests/html/iframe.html +0 -3
- data/unittests/html/iframeTest.html +0 -17
- data/unittests/html/iframeTest1.html +0 -7
- data/unittests/html/iframeTest2.html +0 -5
- data/unittests/html/images/1.gif +0 -0
- data/unittests/html/images/2.GIF +0 -0
- data/unittests/html/images/3.GIF +0 -0
- data/unittests/html/images/button.jpg +0 -0
- data/unittests/html/images/circle.jpg +0 -0
- data/unittests/html/images/map.GIF +0 -0
- data/unittests/html/images/map2.gif +0 -0
- data/unittests/html/images/minus.GIF +0 -0
- data/unittests/html/images/originaltriangle.jpg +0 -0
- data/unittests/html/images/plus.gif +0 -0
- data/unittests/html/images/square.jpg +0 -0
- data/unittests/html/images/triangle.jpg +0 -0
- data/unittests/html/images1.html +0 -65
- data/unittests/html/javascriptevents.html +0 -33
- data/unittests/html/link_pass.html +0 -11
- data/unittests/html/links1.html +0 -37
- data/unittests/html/links2.html +0 -11
- data/unittests/html/links_multi.html +0 -12
- data/unittests/html/list_matters.html +0 -720
- data/unittests/html/lists.html +0 -18
- data/unittests/html/map_test.html +0 -30
- data/unittests/html/modal_dialog.html +0 -10
- data/unittests/html/modal_dialog_launcher.html +0 -12
- data/unittests/html/multiple_specifiers.html +0 -64
- data/unittests/html/nestedFrames.html +0 -6
- data/unittests/html/new_browser.html +0 -17
- data/unittests/html/pass.html +0 -13
- data/unittests/html/popups1.html +0 -59
- data/unittests/html/pre.html +0 -29
- data/unittests/html/quirks_document_standards.html +0 -8
- data/unittests/html/radioButtons1.html +0 -71
- data/unittests/html/select_tealeaf.html +0 -54
- data/unittests/html/selectboxes1.html +0 -52
- data/unittests/html/simple_table.html +0 -25
- data/unittests/html/simple_table_buttons.html +0 -104
- data/unittests/html/simple_table_columns.html +0 -75
- data/unittests/html/table1.html +0 -179
- data/unittests/html/tableCell_using_xpath.html +0 -19
- data/unittests/html/table_and_tablerow_to_a.html +0 -174
- data/unittests/html/textarea.html +0 -30
- data/unittests/html/textfields1.html +0 -100
- data/unittests/html/textsearch.html +0 -44
- data/unittests/html/wallofcheckboxes.html +0 -1003
- data/unittests/html/xpath_nbsp.html +0 -11
- data/unittests/html/zeroindex.html +0 -11
- data/unittests/ie_exists_test.rb +0 -16
- data/unittests/ie_mock.rb +0 -94
- data/unittests/ie_test.rb +0 -54
- data/unittests/images_test.rb +0 -156
- data/unittests/images_xpath_test.rb +0 -90
- data/unittests/index_specifier_test.rb +0 -31
- data/unittests/js_events_test.rb +0 -31
- data/unittests/links_multi_test.rb +0 -34
- data/unittests/links_test.rb +0 -131
- data/unittests/links_xpath_test.rb +0 -38
- data/unittests/lists_test.rb +0 -23
- data/unittests/map_test.rb +0 -98
- data/unittests/minmax_test.rb +0 -37
- data/unittests/navigate_test.rb +0 -38
- data/unittests/nbsp_xpath_test.rb +0 -16
- data/unittests/no_wait_test.rb +0 -28
- data/unittests/non_core_tests.rb +0 -12
- data/unittests/other/all_tests_concurrent.rb +0 -57
- data/unittests/other/navigate_exception_test.rb +0 -24
- data/unittests/other/rexml_unit_test.rb +0 -27
- data/unittests/other/screen_capture_test.rb +0 -53
- data/unittests/other/testcase_method_order_test.rb +0 -36
- data/unittests/other/testcase_verify_test.rb +0 -25
- data/unittests/other/wait_until_test.rb +0 -102
- data/unittests/pagecontainstext_test.rb +0 -69
- data/unittests/parent_child_test.rb +0 -27
- data/unittests/perf_test.rb +0 -20
- data/unittests/pre_test.rb +0 -49
- data/unittests/radios_test.rb +0 -181
- data/unittests/radios_xpath_test.rb +0 -100
- data/unittests/security_setting_test.rb +0 -24
- data/unittests/selectbox_test.rb +0 -144
- data/unittests/selectbox_xpath_test.rb +0 -102
- data/unittests/setup.rb +0 -69
- data/unittests/speed_settings_test.rb +0 -67
- data/unittests/table_cell_using_xpath_test.rb +0 -34
- data/unittests/table_test.rb +0 -296
- data/unittests/table_xpath_test.rb +0 -109
- data/unittests/test_tests.rb +0 -9
- data/unittests/textarea_test.rb +0 -92
- data/unittests/textarea_xpath_test.rb +0 -77
- data/unittests/textfield_for_ch_char_test.rb +0 -32
- data/unittests/textfields_test.rb +0 -184
- data/unittests/textfields_xpath_test.rb +0 -110
- data/unittests/version_test.rb +0 -15
- data/unittests/win32ole_so_test.rb +0 -35
- data/unittests/window_tests.rb +0 -10
- data/unittests/windows/attach_to_existing_window_test.rb +0 -52
- data/unittests/windows/attach_to_new_window_test.rb +0 -74
- data/unittests/windows/close_window_test.rb +0 -20
- data/unittests/windows/frame_links_test.rb +0 -23
- data/unittests/windows/ie-each_test.rb +0 -46
- data/unittests/windows/modal_dialog_test.rb +0 -95
- data/unittests/windows/new_process_test.rb +0 -24
- data/unittests/windows/new_test.rb +0 -58
- data/unittests/windows/open_close_test.rb +0 -19
- data/unittests/windows/send_keys_test.rb +0 -26
- data/unittests/xpath_tests.rb +0 -11
- data/watir-rdoc.rb +0 -7
@@ -1,63 +0,0 @@
|
|
1
|
-
|
2
|
-
$LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..') unless $SETUP_LOADED
|
3
|
-
require 'unittests/setup'
|
4
|
-
|
5
|
-
class TC_DocumentStandards_Quirks < Test::Unit::TestCase
|
6
|
-
include Watir::Exception
|
7
|
-
|
8
|
-
def setup
|
9
|
-
goto_page 'quirks_document_standards.html'
|
10
|
-
end
|
11
|
-
|
12
|
-
def test_elements_exist_or_not
|
13
|
-
assert(browser.text_field(:name,"quirks_text").exists?)
|
14
|
-
browser.text_field(:name,"quirks_text").set "test"
|
15
|
-
browser.text_field(:name,"quirks_text").fire_event "onClick"
|
16
|
-
assert(browser.text_field(:name,"quirks_text").value == 'test')
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
class TC_DocumentStandards_IE7 < Test::Unit::TestCase
|
21
|
-
include Watir::Exception
|
22
|
-
|
23
|
-
def setup
|
24
|
-
goto_page 'ie7_document_standards.html'
|
25
|
-
end
|
26
|
-
|
27
|
-
def test_elements_exist_or_not
|
28
|
-
assert(browser.text_field(:name,"ie7_text").exists?)
|
29
|
-
browser.text_field(:name,"ie7_text").set "test"
|
30
|
-
browser.text_field(:name,"ie7_text").fire_event "onClick"
|
31
|
-
assert(browser.text_field(:name,"ie7_text").value == 'test')
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
|
-
class TC_DocumentStandards_IE8 < Test::Unit::TestCase
|
36
|
-
include Watir::Exception
|
37
|
-
|
38
|
-
def setup
|
39
|
-
goto_page 'ie8_document_standards.html'
|
40
|
-
end
|
41
|
-
|
42
|
-
def test_elements_exist_or_not
|
43
|
-
assert(browser.text_field(:name,"ie8_text").exists?)
|
44
|
-
browser.text_field(:name,"ie8_text").set "test"
|
45
|
-
browser.text_field(:name,"ie8_text").fire_event "onClick"
|
46
|
-
assert(browser.text_field(:name,"ie8_text").value == 'test')
|
47
|
-
end
|
48
|
-
end
|
49
|
-
|
50
|
-
class TC_DocumentStandards_IE9 < Test::Unit::TestCase
|
51
|
-
include Watir::Exception
|
52
|
-
|
53
|
-
def setup
|
54
|
-
goto_page 'ie9_document_standards.html'
|
55
|
-
end
|
56
|
-
|
57
|
-
def test_elements_exist_or_not
|
58
|
-
assert(browser.text_field(:name,"ie9_text").exists?)
|
59
|
-
browser.text_field(:name,"ie9_text").set "test"
|
60
|
-
browser.text_field(:name,"ie9_text").fire_event "onClick"
|
61
|
-
assert(browser.text_field(:name,"ie9_text").value == 'test')
|
62
|
-
end
|
63
|
-
end
|
@@ -1,57 +0,0 @@
|
|
1
|
-
$LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..') unless $SETUP_LOADED
|
2
|
-
require 'unittests/setup'
|
3
|
-
|
4
|
-
|
5
|
-
class TC_TestElementCollectionIndexingForOneBasedIndexes < Test::Unit::TestCase
|
6
|
-
|
7
|
-
def setup
|
8
|
-
close_browser
|
9
|
-
Watir.options[:zero_based_indexing] = false
|
10
|
-
goto_page "zeroindex.html"
|
11
|
-
end
|
12
|
-
|
13
|
-
def teardown
|
14
|
-
Watir.options[:zero_based_indexing] = true
|
15
|
-
close_browser
|
16
|
-
end
|
17
|
-
|
18
|
-
def test_one_based_index
|
19
|
-
assert browser.table(:id, 'a_table').rows.length == 6
|
20
|
-
|
21
|
-
#row 1
|
22
|
-
r = browser.table(:id, 'a_table').rows[1]
|
23
|
-
assert r.id == 'first'
|
24
|
-
|
25
|
-
#something in the middle
|
26
|
-
r = browser.table(:id, 'a_table').rows[2]
|
27
|
-
assert r.id == 'second'
|
28
|
-
|
29
|
-
#the last row
|
30
|
-
r = browser.table(:id, 'a_table').rows[6]
|
31
|
-
assert r.id == 'sixth'
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
|
-
class TC_TestElementCollectionIndexingForZeroBasedIndexes < Test::Unit::TestCase
|
36
|
-
|
37
|
-
def setup
|
38
|
-
#currently the watir default is zero based index
|
39
|
-
goto_page "zeroindex.html"
|
40
|
-
end
|
41
|
-
|
42
|
-
def test_zero_based_index
|
43
|
-
assert browser.table(:id, 'a_table').rows.length == 6
|
44
|
-
|
45
|
-
#row 1
|
46
|
-
r = browser.table(:id, 'a_table').rows[0]
|
47
|
-
assert r.id == 'first'
|
48
|
-
|
49
|
-
#something in the middle
|
50
|
-
r = browser.table(:id, 'a_table').rows[2]
|
51
|
-
assert r.id == 'third'
|
52
|
-
|
53
|
-
#last row
|
54
|
-
r = browser.table(:id, 'a_table').rows[5]
|
55
|
-
assert r.id == 'sixth'
|
56
|
-
end
|
57
|
-
end
|
@@ -1,100 +0,0 @@
|
|
1
|
-
$LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..') unless $SETUP_LOADED
|
2
|
-
require 'unittests/setup'
|
3
|
-
|
4
|
-
class TC_ElementCollections < Test::Unit::TestCase
|
5
|
-
include Watir::Exception
|
6
|
-
|
7
|
-
def setup
|
8
|
-
goto_page "multiple_specifiers.html"
|
9
|
-
end
|
10
|
-
|
11
|
-
def test_input_element_specifiers
|
12
|
-
buttons = browser.buttons(:class, "two")
|
13
|
-
assert 1, buttons.length
|
14
|
-
assert "testbutton", buttons[0].name
|
15
|
-
assert "two", buttons[0].class_name
|
16
|
-
|
17
|
-
buttons = browser.buttons(:name, "testbutton")
|
18
|
-
assert 2, buttons.length
|
19
|
-
buttons.each do |btn|
|
20
|
-
assert Watir::Button, btn.class
|
21
|
-
end
|
22
|
-
assert "testbutton", buttons[0].name
|
23
|
-
assert "one", buttons[0].class_name
|
24
|
-
assert "testbutton", buttons[1].name
|
25
|
-
assert "two", buttons[1].class_name
|
26
|
-
end
|
27
|
-
|
28
|
-
def test_brackets
|
29
|
-
assert browser.buttons[0], browser.buttons(:class => "one")
|
30
|
-
assert browser.buttons[1].exists?
|
31
|
-
assert browser.buttons[2].exists? == false
|
32
|
-
assert_raise(Watir::Exception::UnknownObjectException) {browser.buttons[2].click}
|
33
|
-
end
|
34
|
-
|
35
|
-
def test_first
|
36
|
-
assert browser.buttons.first, browser.buttons(:class, "one")
|
37
|
-
end
|
38
|
-
|
39
|
-
def test_last
|
40
|
-
assert browser.buttons.last, browser.buttons(:class => "two")
|
41
|
-
end
|
42
|
-
|
43
|
-
def test_frames_specifiers
|
44
|
-
frames = browser.frames(:name => "testframe")
|
45
|
-
assert 2, frames.length
|
46
|
-
frames.each do |frame|
|
47
|
-
assert Watir::Frame, frame.class
|
48
|
-
end
|
49
|
-
end
|
50
|
-
|
51
|
-
def test_forms_specifiers
|
52
|
-
forms = browser.forms(:name => "testform")
|
53
|
-
assert 2, forms.size
|
54
|
-
forms.each do |form|
|
55
|
-
assert Watir::Form, form.class
|
56
|
-
end
|
57
|
-
end
|
58
|
-
|
59
|
-
def test_elements_specifiers
|
60
|
-
elements = browser.elements(:name => "testdivs")
|
61
|
-
assert 2, elements.size
|
62
|
-
elements.each do |element|
|
63
|
-
assert Watir::Div, element.class
|
64
|
-
end
|
65
|
-
|
66
|
-
elements = browser.elements(:css => "div")
|
67
|
-
assert 2, elements.size
|
68
|
-
elements.each do |element|
|
69
|
-
assert Watir::Div, element.class
|
70
|
-
end
|
71
|
-
end
|
72
|
-
|
73
|
-
def test_multiple_specifiers
|
74
|
-
links = browser.links(:name => /test/, :class => /one|two/)
|
75
|
-
assert 2, links.size
|
76
|
-
|
77
|
-
links.each do |link|
|
78
|
-
assert Watir::Link, link.class
|
79
|
-
end
|
80
|
-
assert "one", links[0].class_name
|
81
|
-
assert "testlink", links[0].name
|
82
|
-
assert "two", links[1].class_name
|
83
|
-
assert "testlink", links[1].name
|
84
|
-
end
|
85
|
-
|
86
|
-
def test_unallowed_index_specifier
|
87
|
-
assert_raises(Watir::Exception::MissingWayOfFindingObjectException) {browser.divs(:index, 1)}
|
88
|
-
end
|
89
|
-
|
90
|
-
def test_table_rows
|
91
|
-
rows = browser.table.rows
|
92
|
-
assert 2, rows.size
|
93
|
-
rows.each_with_index do |row, i|
|
94
|
-
assert Watir::TableRow, row.class
|
95
|
-
assert i == 0 ? "one" : "two", row.class_name
|
96
|
-
end
|
97
|
-
end
|
98
|
-
|
99
|
-
end
|
100
|
-
|
data/unittests/element_test.rb
DELETED
@@ -1,47 +0,0 @@
|
|
1
|
-
# feature tests for element and the elements collection
|
2
|
-
|
3
|
-
$LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..') unless $SETUP_LOADED
|
4
|
-
require 'unittests/setup'
|
5
|
-
|
6
|
-
class TC_Elements < Test::Unit::TestCase
|
7
|
-
include Watir::Exception
|
8
|
-
|
9
|
-
def setup
|
10
|
-
uses_page "div.html"
|
11
|
-
end
|
12
|
-
|
13
|
-
def test_element
|
14
|
-
assert_raises(UnknownObjectException) { browser.element(:id, "div77").click }
|
15
|
-
assert_raises(UnknownObjectException) { browser.element(:title, "div77").click }
|
16
|
-
assert_equal 'div2', browser.element(:class, 'blueText').id
|
17
|
-
assert_equal 'blueText', browser.element(:id, /div2/).class_name
|
18
|
-
assert_equal Watir::HTMLElement, browser.element(:id, 'div2').class
|
19
|
-
end
|
20
|
-
|
21
|
-
def test_element_iterator
|
22
|
-
assert_equal 3, browser.elements(:class, 'blueText').length
|
23
|
-
assert_equal 3, browser.elements(:class, 'blueText').size
|
24
|
-
assert_equal("number3", browser.elements(:class, 'blueText')[2].id)
|
25
|
-
|
26
|
-
index = 0
|
27
|
-
browser.elements(:id, /div/).each do |s|
|
28
|
-
assert_equal(browser.div(:index,index).name, s.name)
|
29
|
-
assert_equal(browser.div(:index,index).id, s.id)
|
30
|
-
assert_equal(browser.div(:index,index).class_name , s.class_name)
|
31
|
-
index += 1
|
32
|
-
end
|
33
|
-
assert_equal(index, browser.elements(:id, /div/).length)
|
34
|
-
end
|
35
|
-
|
36
|
-
def test_element_enumerable
|
37
|
-
match = browser.elements(:class, 'blueText').detect {|d| d.html =~ /SPAN/}
|
38
|
-
assert_equal('span2', match.id)
|
39
|
-
end
|
40
|
-
|
41
|
-
def test_objects_in_element
|
42
|
-
assert browser.element(:id, 'buttons1').button(:index,0).exists?
|
43
|
-
assert !browser.element(:id, 'buttons1').button(:index,2).exists?
|
44
|
-
assert browser.element(:id, 'buttons1').button(:name,'b1').exists?
|
45
|
-
end
|
46
|
-
|
47
|
-
end
|
@@ -1,31 +0,0 @@
|
|
1
|
-
# feature tests for Goto
|
2
|
-
|
3
|
-
$LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..') unless $SETUP_LOADED
|
4
|
-
require 'unittests/setup'
|
5
|
-
|
6
|
-
class TC_error_checker < Test::Unit::TestCase
|
7
|
-
|
8
|
-
def test_simple_checker
|
9
|
-
button_checker = Proc.new do |ie|
|
10
|
-
raise RuntimeError, "text 'buttons' is missing" if ! ie.contains_text(/buttons/)
|
11
|
-
end
|
12
|
-
|
13
|
-
browser.add_checker button_checker
|
14
|
-
assert_raises( RuntimeError ) { goto_page('forms3.html') }
|
15
|
-
assert_nothing_raised { goto_page('buttons1.html') }
|
16
|
-
ensure
|
17
|
-
browser.disable_checker button_checker
|
18
|
-
assert_nothing_raised { goto_page('forms3.html') }
|
19
|
-
end
|
20
|
-
|
21
|
-
def test_browser_close_with_failing_checker
|
22
|
-
failing_checker = lambda {|ie| raise "Browser should be closed without throwing this exception!"}
|
23
|
-
ie = Watir::IE.new
|
24
|
-
ie.add_checker failing_checker
|
25
|
-
assert_nothing_raised {ie.close}
|
26
|
-
ensure
|
27
|
-
ie.disable_checker failing_checker
|
28
|
-
ie.close if ie.exists?
|
29
|
-
end
|
30
|
-
|
31
|
-
end
|
data/unittests/filefield_test.rb
DELETED
@@ -1,43 +0,0 @@
|
|
1
|
-
# feature tests for file Fields
|
2
|
-
|
3
|
-
$LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..') unless $SETUP_LOADED
|
4
|
-
require 'unittests/setup'
|
5
|
-
require 'uri'
|
6
|
-
|
7
|
-
class TC_FileField < Test::Unit::TestCase
|
8
|
-
tags :must_be_visible, :creates_windows
|
9
|
-
include Watir
|
10
|
-
|
11
|
-
def setup
|
12
|
-
goto_page "fileupload.html"
|
13
|
-
end
|
14
|
-
|
15
|
-
def test_file_field_Exists
|
16
|
-
# test for existance of 4 file area
|
17
|
-
assert(browser.file_field(:name,"file1").exists?)
|
18
|
-
assert(browser.file_field(:id,"file2").exists?)
|
19
|
-
|
20
|
-
# test for missing
|
21
|
-
assert_false(browser.file_field(:name, "missing").exists?)
|
22
|
-
assert_false(browser.file_field(:name,"totallybogus").exists?)
|
23
|
-
|
24
|
-
# pop one open and put something in it.
|
25
|
-
file = $htmlRoot + "fileupload.html"
|
26
|
-
file.gsub! 'file:///', ''
|
27
|
-
file.gsub! '/', '\\'
|
28
|
-
browser.file_field(:name,"file3").set(file)
|
29
|
-
Watir::Wait.until {browser.file_field(:name,"file3").value!= ''}
|
30
|
-
assert_equal file, browser.file_field(:name,"file3").value
|
31
|
-
|
32
|
-
# click the upload button
|
33
|
-
browser.button(:name,"upload").click
|
34
|
-
assert(browser.text.include?("PASS"))
|
35
|
-
uri = URI.parse(browser.url)
|
36
|
-
assert uri.query =~ /fileupload.html&upload=upload/
|
37
|
-
end
|
38
|
-
|
39
|
-
def test_iterator
|
40
|
-
assert_equal(6, browser.file_fields.length)
|
41
|
-
end
|
42
|
-
|
43
|
-
end
|
@@ -1,35 +0,0 @@
|
|
1
|
-
# feature tests for TextArea Fields
|
2
|
-
|
3
|
-
$LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..') unless $SETUP_LOADED
|
4
|
-
require 'unittests/setup'
|
5
|
-
|
6
|
-
class TC_FileField_XPath < Test::Unit::TestCase
|
7
|
-
include Watir
|
8
|
-
|
9
|
-
def setup
|
10
|
-
goto_page "fileupload.html"
|
11
|
-
end
|
12
|
-
|
13
|
-
def test_file_field_Exists
|
14
|
-
#test for existance of 4 file area
|
15
|
-
assert(browser.file_field(:xpath, "//input[@name='file1']/").exists?)
|
16
|
-
assert(browser.file_field(:xpath, "//input[@id='file2']/").exists?)
|
17
|
-
#test for missing
|
18
|
-
assert_false(browser.file_field(:xpath, "//input[@name='missing']/").exists?)
|
19
|
-
assert_false(browser.file_field(:xpath, "//input[@name='totallybogus']/").exists?)
|
20
|
-
#pop one open and put something in it.
|
21
|
-
file = $htmlRoot + "fileupload.html"
|
22
|
-
file.gsub! 'file:///', ''
|
23
|
-
file.gsub! '/', '\\'
|
24
|
-
browser.file_field(:xpath, "//input[@name='file1']/").set(file)
|
25
|
-
#click the upload button
|
26
|
-
browser.button(:xpath, "//input[@name='upload']/").click
|
27
|
-
|
28
|
-
assert(browser.text.include?("PASS"))
|
29
|
-
end
|
30
|
-
|
31
|
-
def test_iterator
|
32
|
-
assert_equal(6, browser.file_fields.length)
|
33
|
-
end
|
34
|
-
|
35
|
-
end
|
data/unittests/form_test.rb
DELETED
@@ -1,282 +0,0 @@
|
|
1
|
-
# feature tests for Forms
|
2
|
-
|
3
|
-
$LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..') unless $SETUP_LOADED
|
4
|
-
require 'unittests/setup'
|
5
|
-
|
6
|
-
class TC_Forms2 < Test::Unit::TestCase # Note: there is no TC_Forms1
|
7
|
-
def setup
|
8
|
-
uses_page "forms2.html"
|
9
|
-
end
|
10
|
-
|
11
|
-
def test_form_exists
|
12
|
-
assert(browser.form(:name, "test2").exists?)
|
13
|
-
assert_false(browser.form(:name, "missing").exists?)
|
14
|
-
|
15
|
-
assert(browser.form(:index, 0).exists?)
|
16
|
-
assert_false(browser.form(:index, 87).exists?)
|
17
|
-
|
18
|
-
assert(browser.form(:method, "get").exists?)
|
19
|
-
assert_false(browser.form(:method, "missing").exists?)
|
20
|
-
|
21
|
-
assert(browser.form(:id, 'f2').exists?)
|
22
|
-
assert_false(browser.form(:id, 'missing').exists?)
|
23
|
-
|
24
|
-
assert(browser.form(:action, /pass.html/).exists?)
|
25
|
-
assert_false(browser.form(:action, "missing").exists?)
|
26
|
-
end
|
27
|
-
|
28
|
-
def test_multiple_attribute
|
29
|
-
assert_true(browser.form(:name => 'test2', :id => 'f2').exists?)
|
30
|
-
assert_true(browser.form(:name => 'test2', :method => 'get', :action => 'pass2.html'))
|
31
|
-
end
|
32
|
-
|
33
|
-
def test_button_in_form
|
34
|
-
assert(browser.form(:name, "test2").button(:caption, "Submit").exists?)
|
35
|
-
end
|
36
|
-
def test_form_sub_element
|
37
|
-
assert_equal('Click Me', browser.form(:index, 0).button(:name, 'b1').value)
|
38
|
-
end
|
39
|
-
|
40
|
-
# The following tests form bug 2261
|
41
|
-
tag_method :test_form_outer_html, :fails_on_firefox
|
42
|
-
|
43
|
-
def test_form_outer_html
|
44
|
-
expected = "\r\n<FORM id=f2 name=test2 action=pass2.html method=get><BR><INPUT type=submit value=Submit> </FORM>"
|
45
|
-
actual = browser.form(:name, 'test2').html
|
46
|
-
actual.sub!('style=""','') # ie9 adds in a style tag so just strip it out
|
47
|
-
#ie9 also has som additional formatting so remove that too
|
48
|
-
actual.gsub!('"','')
|
49
|
-
actual.gsub!(/\n/,'')
|
50
|
-
# ignore attributes order by sorting them
|
51
|
-
sorted_expected, sorted_actual = [expected, actual].map! do |html|
|
52
|
-
html.strip.downcase.scan(%r{<form (.*)><br><(.*)>\s*</form>}).flatten.
|
53
|
-
map {|part| part.split(" ").sort.join(" ")}.join("><br><")
|
54
|
-
end
|
55
|
-
assert_not_equal("", sorted_expected)
|
56
|
-
assert_not_equal("", sorted_actual)
|
57
|
-
assert_equal(sorted_expected, sorted_actual)
|
58
|
-
end
|
59
|
-
|
60
|
-
tag_method :test_form_inner_html, :fails_on_ie
|
61
|
-
def test_form_inner_html
|
62
|
-
expected = "\n<br><input value=\"Submit\" type=\"submit\">\n"
|
63
|
-
assert_equal(expected, browser.form(:name, 'test2').html)
|
64
|
-
end
|
65
|
-
def test_form_flash
|
66
|
-
assert_nothing_raised{ browser.form(:name, 'test2').flash }
|
67
|
-
end
|
68
|
-
end
|
69
|
-
|
70
|
-
class TC_Forms_Collection < Test::Unit::TestCase
|
71
|
-
def setup
|
72
|
-
goto_page "forms2.html"
|
73
|
-
end
|
74
|
-
|
75
|
-
def test_forms_collection
|
76
|
-
forms = browser.forms
|
77
|
-
assert_equal(4, forms.length)
|
78
|
-
assert(forms.first.action =~ /pass.html$/)
|
79
|
-
assert_equal('test2', forms.last.name)
|
80
|
-
end
|
81
|
-
end
|
82
|
-
|
83
|
-
class TC_Forms3 < Test::Unit::TestCase
|
84
|
-
def setup
|
85
|
-
goto_page "forms3.html"
|
86
|
-
end
|
87
|
-
|
88
|
-
# The following tests form bug 2261
|
89
|
-
def test_p_in_form
|
90
|
-
assert_equal "This form has a submit button that is an image",
|
91
|
-
browser.form(:name, 'buttonsubmit').p(:index, 0).text
|
92
|
-
end
|
93
|
-
|
94
|
-
# test for bug reported by Scott Pack, http://rubyforge.org/pipermail/wtr-general/2005-June/002223.html
|
95
|
-
def test_index_other_element_before_it
|
96
|
-
assert_equal("check1" , browser.checkbox(:index,0).name)
|
97
|
-
end
|
98
|
-
|
99
|
-
tag_method :test_reset, :fails_on_firefox
|
100
|
-
def test_reset
|
101
|
-
browser.text_field(:id, "t1").set("Hello, reset test!")
|
102
|
-
assert_equal(browser.text_field(:id, 't1').value, 'Hello, reset test!')
|
103
|
-
|
104
|
-
browser.button(:id, "reset_button").click
|
105
|
-
assert_equal("" , browser.text_field(:id, 't1').value)
|
106
|
-
|
107
|
-
# also verify it works under a form
|
108
|
-
browser.text_field(:id, "t1").set("reset test - using a form")
|
109
|
-
assert_equal(browser.text_field(:id, 't1').value, 'reset test - using a form')
|
110
|
-
|
111
|
-
browser.form(:index,1).button(:index,1).click
|
112
|
-
assert_equal("" , browser.text_field(:id, 't1').value)
|
113
|
-
|
114
|
-
# also verify it works under a form, this time using the :id attribute
|
115
|
-
browser.text_field(:id, "t1").set("reset test - using a form")
|
116
|
-
assert_equal(browser.text_field(:id, 't1').value, 'reset test - using a form')
|
117
|
-
|
118
|
-
browser.form(:index,1).button(:id,'reset_button').click
|
119
|
-
assert_equal("" , browser.text_field(:id, 't1').value)
|
120
|
-
end
|
121
|
-
|
122
|
-
def test_flash1
|
123
|
-
assert_nothing_raised do
|
124
|
-
browser.form(:name, "test2").button(:caption , "Submit").flash
|
125
|
-
end
|
126
|
-
end
|
127
|
-
|
128
|
-
def test_objects_with_same_name
|
129
|
-
assert_equal('textfield' ,browser.text_field( :name, 'g1').value )
|
130
|
-
assert_equal('button' ,browser.button( :name, 'g1').value )
|
131
|
-
assert_equal('1' ,browser.checkbox( :name, 'g1').value )
|
132
|
-
assert_equal('2' ,browser.radio( :name, 'g1').value )
|
133
|
-
|
134
|
-
assert_equal('textfield' ,browser.text_field( :name, /g1/).value )
|
135
|
-
assert_equal('button' ,browser.button( :name, /g1/).value )
|
136
|
-
assert_equal('1' ,browser.checkbox( :name, /g1/).value )
|
137
|
-
assert_equal('2' ,browser.radio( :name, /g1/).value )
|
138
|
-
|
139
|
-
assert_equal('textfield_id' ,browser.text_field( :id, 'g1').value )
|
140
|
-
assert_equal('button_id' ,browser.button( :id, 'g1').value )
|
141
|
-
assert_equal('1_id' ,browser.checkbox( :id, 'g1').value )
|
142
|
-
assert_equal('2_id' ,browser.radio( :id, 'g1').value )
|
143
|
-
|
144
|
-
assert_equal('textfield_id' ,browser.text_field( :id, /g1/).value )
|
145
|
-
assert_equal('button_id' ,browser.button( :id, /g1/).value )
|
146
|
-
assert_equal('1_id' ,browser.checkbox( :id, /g1/).value )
|
147
|
-
assert_equal('2_id' ,browser.radio( :id, /g1/).value )
|
148
|
-
end
|
149
|
-
|
150
|
-
def test_flash2
|
151
|
-
browser.button(:value, 'Click Me').flash
|
152
|
-
assert_raises(UnknownObjectException) { browser.text_field( :name , 'g177').flash }
|
153
|
-
end
|
154
|
-
|
155
|
-
def test_submitWithImage
|
156
|
-
assert( browser.button(:alt, "submit").exists? )
|
157
|
-
assert( browser.button(:alt, /sub/).exists? )
|
158
|
-
|
159
|
-
assert_false( browser.button(:alt, "missing").exists? )
|
160
|
-
assert_false( browser.button(:alt, /missing/).exists? )
|
161
|
-
|
162
|
-
#assert( browser.button(:src , "file:///#{$myDir}/html/images/button.jpg").exists? ) # this doesnt work for everybody
|
163
|
-
assert( browser.button(:src, /button/).exists? )
|
164
|
-
|
165
|
-
assert_false( browser.button(:src, "missing").exists? )
|
166
|
-
assert_false( browser.button(:src, /missing/).exists? )
|
167
|
-
assert_nothing_raised("raised an exception when it shouldnt have") { browser.button(:src , /button/).click }
|
168
|
-
|
169
|
-
assert( browser.text.include?("PASS") )
|
170
|
-
end
|
171
|
-
end
|
172
|
-
|
173
|
-
class TC_Forms4 < Test::Unit::TestCase
|
174
|
-
def setup
|
175
|
-
uses_page "forms4.html"
|
176
|
-
end
|
177
|
-
|
178
|
-
def test_find_text_field_ignoring_form
|
179
|
-
assert_equal(browser.text_field(:name, 'name').value, 'apple')
|
180
|
-
end
|
181
|
-
|
182
|
-
def test_correct_form_field_is_found_using_form_name
|
183
|
-
assert_equal(browser.form(:name, 'apple_form').text_field(:name, 'name').value, 'apple')
|
184
|
-
assert_equal(browser.form(:name, 'banana_form').text_field(:name, 'name').value, 'banana')
|
185
|
-
end
|
186
|
-
|
187
|
-
def test_correct_form_field_is_found_using_form_index
|
188
|
-
assert_equal(browser.form(:index, 0).text_field(:name, 'name').value, 'apple')
|
189
|
-
assert_equal(browser.form(:index, 1).text_field(:name, 'name').value, 'banana')
|
190
|
-
end
|
191
|
-
|
192
|
-
def test_using_text_on_form
|
193
|
-
browser.form(:name, 'apple_form').text_field(:name, 'name').set('strudel')
|
194
|
-
assert_equal(browser.form(:index, 0).text_field(:name, 'name').value, 'strudel')
|
195
|
-
end
|
196
|
-
|
197
|
-
def test_submit
|
198
|
-
browser.form(:name, 'apple_form').submit
|
199
|
-
assert(browser.text.include?("PASS"))
|
200
|
-
end
|
201
|
-
end
|
202
|
-
|
203
|
-
class TC_Hidden_Fields < Test::Unit::TestCase
|
204
|
-
def setup
|
205
|
-
goto_page "forms3.html"
|
206
|
-
end
|
207
|
-
|
208
|
-
def test_hidden
|
209
|
-
|
210
|
-
# test using index
|
211
|
-
assert( browser.hidden(:index, 0).exists? )
|
212
|
-
assert( browser.hidden(:index, 1).exists? )
|
213
|
-
assert_false( browser.hidden(:index, 2).exists? )
|
214
|
-
|
215
|
-
browser.hidden(:index, 0).value = 44
|
216
|
-
browser.hidden(:index, 1).value = 55
|
217
|
-
|
218
|
-
browser.button(:value, "Show Hidden").click
|
219
|
-
|
220
|
-
assert_equal("44", browser.text_field(:name, "vis1").value )
|
221
|
-
assert_equal("55", browser.text_field(:name, "vis2").value )
|
222
|
-
|
223
|
-
# test using name and ID
|
224
|
-
assert( browser.hidden(:name, "hid1").exists? )
|
225
|
-
assert( browser.hidden(:id, "hidden_1").exists? )
|
226
|
-
assert_false( browser.hidden(:name, "hidden_44").exists? )
|
227
|
-
assert_false( browser.hidden(:id, "hidden_55").exists? )
|
228
|
-
|
229
|
-
browser.hidden(:name, "hid1").value = 444
|
230
|
-
browser.hidden(:id, "hidden_1").value = 555
|
231
|
-
|
232
|
-
browser.button(:value, "Show Hidden").click
|
233
|
-
|
234
|
-
assert_equal("444", browser.text_field(:name, "vis1").value)
|
235
|
-
assert_equal("555", browser.text_field(:name, "vis2").value)
|
236
|
-
|
237
|
-
# test the over-ridden append method
|
238
|
-
browser.hidden(:name, "hid1").append("a")
|
239
|
-
browser.button(:value, "Show Hidden").click
|
240
|
-
assert_equal("444a", browser.text_field(:name, "vis1").value )
|
241
|
-
assert_equal("555", browser.text_field(:name, "vis2").value )
|
242
|
-
|
243
|
-
# test the over-ridden clear method
|
244
|
-
browser.hidden(:name, "hid1").clear
|
245
|
-
browser.button(:value, "Show Hidden").click
|
246
|
-
assert_equal("", browser.text_field(:name, "vis1").value)
|
247
|
-
assert_equal("555", browser.text_field(:name, "vis2").value)
|
248
|
-
|
249
|
-
# test using a form
|
250
|
-
assert( browser.form(:name, "has_a_hidden").hidden(:name, "hid1").exists? )
|
251
|
-
assert( browser.form(:name, "has_a_hidden").hidden(:id, "hidden_1").exists? )
|
252
|
-
assert_false( browser.form(:name, "has_a_hidden").hidden(:name, "hidden_44").exists? )
|
253
|
-
assert_false( browser.form(:name, "has_a_hidden").hidden(:id, "hidden_55").exists? )
|
254
|
-
|
255
|
-
browser.form(:name, "has_a_hidden").hidden(:name, "hid1").value = 222
|
256
|
-
browser.form(:name, "has_a_hidden").hidden(:id, "hidden_1").value = 333
|
257
|
-
|
258
|
-
browser.button(:value, "Show Hidden").click
|
259
|
-
|
260
|
-
assert_equal("222", browser.text_field(:name, "vis1").value)
|
261
|
-
assert_equal("333", browser.text_field(:name, "vis2").value)
|
262
|
-
|
263
|
-
# iterators
|
264
|
-
assert_equal(2, browser.hiddens.length)
|
265
|
-
count = 1
|
266
|
-
browser.hiddens.each do |h|
|
267
|
-
case count
|
268
|
-
when 1
|
269
|
-
assert_equal("", h.id)
|
270
|
-
assert_equal("hid1", h.name)
|
271
|
-
when 2
|
272
|
-
assert_equal("", h.name)
|
273
|
-
assert_equal("hidden_1", h.id)
|
274
|
-
end
|
275
|
-
count += 1
|
276
|
-
end
|
277
|
-
|
278
|
-
assert_equal("hid1", browser.hiddens[0].name)
|
279
|
-
assert_equal("hidden_1", browser.hiddens[1].id)
|
280
|
-
end
|
281
|
-
end
|
282
|
-
|