watir-classic 3.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGES +721 -0
- data/LICENSE +34 -0
- data/README.rdoc +78 -0
- data/VERSION +1 -0
- data/bin/watir-console +5 -0
- data/lib/watir-classic.rb +14 -0
- data/lib/watir-classic/IEDialog/Release/IEDialog.dll +0 -0
- data/lib/watir-classic/assertions.rb +44 -0
- data/lib/watir-classic/browser.rb +149 -0
- data/lib/watir-classic/browsers.rb +7 -0
- data/lib/watir-classic/close_all.rb +31 -0
- data/lib/watir-classic/container.rb +110 -0
- data/lib/watir-classic/contrib/enabled_popup.rb +21 -0
- data/lib/watir-classic/contrib/ie-new-process.rb +27 -0
- data/lib/watir-classic/contrib/page_checker.rb +29 -0
- data/lib/watir-classic/cookies.rb +80 -0
- data/lib/watir-classic/core.rb +43 -0
- data/lib/watir-classic/dialogs/file_field.rb +34 -0
- data/lib/watir-classic/dialogs/javascript.rb +43 -0
- data/lib/watir-classic/drag_and_drop_helper.rb +68 -0
- data/lib/watir-classic/element.rb +438 -0
- data/lib/watir-classic/element_collection.rb +109 -0
- data/lib/watir-classic/element_extensions.rb +69 -0
- data/lib/watir-classic/exceptions.rb +50 -0
- data/lib/watir-classic/form.rb +96 -0
- data/lib/watir-classic/frame.rb +47 -0
- data/lib/watir-classic/ie-class.rb +767 -0
- data/lib/watir-classic/ie-process.rb +47 -0
- data/lib/watir-classic/ie.rb +20 -0
- data/lib/watir-classic/image.rb +111 -0
- data/lib/watir-classic/input_elements.rb +480 -0
- data/lib/watir-classic/irb-history.rb +31 -0
- data/lib/watir-classic/link.rb +46 -0
- data/lib/watir-classic/locator.rb +243 -0
- data/lib/watir-classic/logger.rb +19 -0
- data/lib/watir-classic/matches.rb +23 -0
- data/lib/watir-classic/modal_dialog.rb +72 -0
- data/lib/watir-classic/module.rb +12 -0
- data/lib/watir-classic/non_control_elements.rb +114 -0
- data/lib/watir-classic/options.rb +56 -0
- data/lib/watir-classic/page-container.rb +114 -0
- data/lib/watir-classic/process.rb +20 -0
- data/lib/watir-classic/screen_capture.rb +115 -0
- data/lib/watir-classic/supported_elements.rb +172 -0
- data/lib/watir-classic/table.rb +224 -0
- data/lib/watir-classic/testcase.rb +97 -0
- data/lib/watir-classic/util.rb +35 -0
- data/lib/watir-classic/version.rb +4 -0
- data/lib/watir-classic/wait.rb +41 -0
- data/lib/watir-classic/wait_helper.rb +12 -0
- data/lib/watir-classic/waiter.rb +98 -0
- data/lib/watir-classic/win32.rb +40 -0
- data/lib/watir-classic/win32ole.rb +16 -0
- data/lib/watir-classic/win32ole/1.8.7/win32ole.so +0 -0
- data/lib/watir-classic/win32ole/1.9.3/win32ole.so +0 -0
- data/lib/watir-classic/window.rb +68 -0
- data/lib/watir-classic/xpath_locator.rb +52 -0
- data/rakefile.rb +54 -0
- data/unittests/all_tests.rb +10 -0
- data/unittests/buttons_xpath_test.rb +68 -0
- data/unittests/checkbox_test.rb +163 -0
- data/unittests/checkbox_xpath_test.rb +106 -0
- data/unittests/click_no_wait_test.rb +23 -0
- data/unittests/close_all_test.rb +17 -0
- data/unittests/core_tests.rb +17 -0
- data/unittests/css_selector_test.rb +44 -0
- data/unittests/css_test.rb +38 -0
- data/unittests/dialog_test.rb +64 -0
- data/unittests/div2_xpath_test.rb +21 -0
- data/unittests/div_test.rb +170 -0
- data/unittests/div_xpath_test.rb +95 -0
- data/unittests/document_standards.rb +63 -0
- data/unittests/element_collection_indexes_test.rb +57 -0
- data/unittests/element_collections_test.rb +100 -0
- data/unittests/element_test.rb +47 -0
- data/unittests/errorchecker_test.rb +31 -0
- data/unittests/filefield_test.rb +43 -0
- data/unittests/filefield_xpath_test.rb +35 -0
- data/unittests/form_test.rb +282 -0
- data/unittests/form_xpath_test.rb +254 -0
- data/unittests/frame_test.rb +165 -0
- data/unittests/google_form_test.rb +15 -0
- data/unittests/html/JavascriptClick.html +39 -0
- data/unittests/html/blankpage.html +11 -0
- data/unittests/html/buttons1.html +40 -0
- data/unittests/html/checkboxes1.html +89 -0
- data/unittests/html/click_no_wait.html +14 -0
- data/unittests/html/complex_table.html +35 -0
- data/unittests/html/cssTest.html +42 -0
- data/unittests/html/depot_store.html +59 -0
- data/unittests/html/div.html +92 -0
- data/unittests/html/div_xml.html +21 -0
- data/unittests/html/fileupload.html +44 -0
- data/unittests/html/formTest1.html +38 -0
- data/unittests/html/forms2.html +44 -0
- data/unittests/html/forms3.html +131 -0
- data/unittests/html/forms4.html +26 -0
- data/unittests/html/frame_buttons.html +4 -0
- data/unittests/html/frame_links.html +4 -0
- data/unittests/html/frame_multi.html +5 -0
- data/unittests/html/google_india.html +119 -0
- data/unittests/html/ie7_document_standards.html +9 -0
- data/unittests/html/ie8_document_standards.html +9 -0
- data/unittests/html/ie9_document_standards.html +9 -0
- data/unittests/html/iframe.html +3 -0
- data/unittests/html/iframeTest.html +17 -0
- data/unittests/html/iframeTest1.html +7 -0
- data/unittests/html/iframeTest2.html +5 -0
- 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 +65 -0
- data/unittests/html/javascriptevents.html +33 -0
- data/unittests/html/link_pass.html +11 -0
- data/unittests/html/links1.html +37 -0
- data/unittests/html/links2.html +11 -0
- data/unittests/html/links_multi.html +12 -0
- data/unittests/html/list_matters.html +720 -0
- data/unittests/html/lists.html +18 -0
- data/unittests/html/map_test.html +30 -0
- data/unittests/html/modal_dialog.html +10 -0
- data/unittests/html/modal_dialog_launcher.html +12 -0
- data/unittests/html/multiple_specifiers.html +64 -0
- data/unittests/html/nestedFrames.html +6 -0
- data/unittests/html/new_browser.html +17 -0
- data/unittests/html/pass.html +13 -0
- data/unittests/html/popups1.html +59 -0
- data/unittests/html/pre.html +29 -0
- data/unittests/html/quirks_document_standards.html +8 -0
- data/unittests/html/radioButtons1.html +71 -0
- data/unittests/html/select_tealeaf.html +54 -0
- data/unittests/html/selectboxes1.html +52 -0
- data/unittests/html/simple_table.html +25 -0
- data/unittests/html/simple_table_buttons.html +104 -0
- data/unittests/html/simple_table_columns.html +75 -0
- data/unittests/html/table1.html +179 -0
- data/unittests/html/tableCell_using_xpath.html +19 -0
- data/unittests/html/table_and_tablerow_to_a.html +174 -0
- data/unittests/html/textarea.html +30 -0
- data/unittests/html/textfields1.html +100 -0
- data/unittests/html/textsearch.html +44 -0
- data/unittests/html/wallofcheckboxes.html +1003 -0
- data/unittests/html/xpath_nbsp.html +11 -0
- data/unittests/html/zeroindex.html +11 -0
- data/unittests/ie_exists_test.rb +16 -0
- data/unittests/ie_mock.rb +94 -0
- data/unittests/ie_test.rb +54 -0
- data/unittests/images_test.rb +156 -0
- data/unittests/images_xpath_test.rb +90 -0
- data/unittests/index_specifier_test.rb +31 -0
- data/unittests/js_events_test.rb +31 -0
- data/unittests/links_multi_test.rb +34 -0
- data/unittests/links_test.rb +131 -0
- data/unittests/links_xpath_test.rb +38 -0
- data/unittests/lists_test.rb +23 -0
- data/unittests/map_test.rb +98 -0
- data/unittests/minmax_test.rb +37 -0
- data/unittests/navigate_test.rb +38 -0
- data/unittests/nbsp_xpath_test.rb +16 -0
- data/unittests/no_wait_test.rb +28 -0
- data/unittests/non_core_tests.rb +12 -0
- data/unittests/other/all_tests_concurrent.rb +57 -0
- data/unittests/other/navigate_exception_test.rb +24 -0
- data/unittests/other/rexml_unit_test.rb +27 -0
- data/unittests/other/screen_capture_test.rb +53 -0
- data/unittests/other/testcase_method_order_test.rb +36 -0
- data/unittests/other/testcase_verify_test.rb +25 -0
- data/unittests/other/wait_until_test.rb +102 -0
- data/unittests/pagecontainstext_test.rb +69 -0
- data/unittests/parent_child_test.rb +27 -0
- data/unittests/perf_test.rb +20 -0
- data/unittests/pre_test.rb +49 -0
- data/unittests/radios_test.rb +181 -0
- data/unittests/radios_xpath_test.rb +100 -0
- data/unittests/security_setting_test.rb +24 -0
- data/unittests/selectbox_test.rb +144 -0
- data/unittests/selectbox_xpath_test.rb +102 -0
- data/unittests/setup.rb +69 -0
- data/unittests/speed_settings_test.rb +67 -0
- data/unittests/table_cell_using_xpath_test.rb +34 -0
- data/unittests/table_test.rb +296 -0
- data/unittests/table_xpath_test.rb +109 -0
- data/unittests/test_tests.rb +9 -0
- data/unittests/textarea_test.rb +92 -0
- data/unittests/textarea_xpath_test.rb +77 -0
- data/unittests/textfield_for_ch_char_test.rb +32 -0
- data/unittests/textfields_test.rb +184 -0
- data/unittests/textfields_xpath_test.rb +110 -0
- data/unittests/version_test.rb +15 -0
- data/unittests/win32ole_so_test.rb +35 -0
- data/unittests/window_tests.rb +10 -0
- data/unittests/windows/attach_to_existing_window_test.rb +52 -0
- data/unittests/windows/attach_to_new_window_test.rb +74 -0
- data/unittests/windows/close_window_test.rb +20 -0
- data/unittests/windows/frame_links_test.rb +23 -0
- data/unittests/windows/ie-each_test.rb +46 -0
- data/unittests/windows/modal_dialog_test.rb +95 -0
- data/unittests/windows/new_process_test.rb +24 -0
- data/unittests/windows/new_test.rb +58 -0
- data/unittests/windows/open_close_test.rb +19 -0
- data/unittests/windows/send_keys_test.rb +26 -0
- data/unittests/xpath_tests.rb +11 -0
- data/watir-rdoc.rb +7 -0
- metadata +370 -0
@@ -0,0 +1,95 @@
|
|
1
|
+
# feature tests for Divs, Spans and P's
|
2
|
+
|
3
|
+
$LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..') unless $SETUP_LOADED
|
4
|
+
require 'unittests/setup'
|
5
|
+
|
6
|
+
class TC_Divs_XPath < Test::Unit::TestCase
|
7
|
+
include Watir::Exception
|
8
|
+
|
9
|
+
def setup
|
10
|
+
goto_page "div.html"
|
11
|
+
end
|
12
|
+
|
13
|
+
def test_divs
|
14
|
+
assert_raises(UnknownObjectException) {browser.div(:xpath , "//div[@id='div77']/").click }
|
15
|
+
assert_raises(UnknownObjectException) {browser.div(:xpath , "//div[@title='div77']/").click }
|
16
|
+
|
17
|
+
assert(browser.text_field(:xpath, "//input[@name='text1']/").verify_contains("0") )
|
18
|
+
browser.div(:xpath , "//div[@id='div3']/").click
|
19
|
+
assert(browser.text_field(:xpath, "//input[@name='text1']/").verify_contains("1") )
|
20
|
+
browser.div(:xpath , "//div[@id='div4']/").click
|
21
|
+
assert(browser.text_field(:xpath, "//input[@name='text1']/").verify_contains("0") )
|
22
|
+
end
|
23
|
+
|
24
|
+
def test_div_properties
|
25
|
+
assert_raises(UnknownObjectException) {browser.div(:xpath , "//div[@id='div77']/").text }
|
26
|
+
assert_raises(UnknownObjectException) {browser.div(:xpath , "//div[@title='div77']/").text }
|
27
|
+
|
28
|
+
assert_equal("This div has an onClick that increments text1",
|
29
|
+
browser.div(:xpath , "//div[@id='div3']/").text.strip )
|
30
|
+
assert_equal("This text is in a div with an id of div1 and title of test1",
|
31
|
+
browser.div(:xpath , "//div[@title='Test1']/").text.strip )
|
32
|
+
|
33
|
+
assert_raises(UnknownObjectException) {browser.div(:xpath , "//div[@id='div77']/").class_name }
|
34
|
+
assert_equal("blueText" , browser.div(:xpath , "//div[@id='div2']/").class_name )
|
35
|
+
assert_equal("" , browser.div(:xpath , "//div[@id='div1']/").class_name )
|
36
|
+
end
|
37
|
+
|
38
|
+
def test_objects_in_div
|
39
|
+
assert(browser.div(:xpath , "//div[@id='buttons1']/").button(:index,0).exists? )
|
40
|
+
assert_false(browser.div(:xpath , "//div[@id='buttons1']/").button(:index,2).exists? )
|
41
|
+
assert(browser.div(:xpath , "//div[@id='buttons1']/").button(:name,'b1').exists? )
|
42
|
+
|
43
|
+
assert(browser.div(:xpath , "//div[@id='buttons2']/").button(:index,0).exists? )
|
44
|
+
assert(browser.div(:xpath , "//div[@id='buttons2']/").button(:index,1).exists? )
|
45
|
+
assert_false(browser.div(:xpath , "//div[@id='buttons1']/").button(:index,2).exists? )
|
46
|
+
|
47
|
+
browser.div(:xpath , "//div[@id='buttons1']/").button(:index,0).click
|
48
|
+
|
49
|
+
assert_equal( 'button1' , browser.div(:xpath , "//div[@id='text_fields1']/").text_field(:index,0).value)
|
50
|
+
|
51
|
+
assert_equal( 3 , browser.div(:xpath , "//div[@id='text_fields1']/").text_fields.length )
|
52
|
+
end
|
53
|
+
|
54
|
+
def test_span_properties
|
55
|
+
assert_raises(UnknownObjectException) {browser.span(:xpath , "//span[@id='span77']/").text }
|
56
|
+
assert_raises(UnknownObjectException) {browser.span(:xpath , "//span[@title='span77']/").text }
|
57
|
+
|
58
|
+
assert_equal("This span has an onClick that increments text2" , browser.span(:xpath , "//span[@id='span3']/").text.strip )
|
59
|
+
assert_equal("This text is in a span with an id of span1 and title of test2" , browser.span(:xpath , "//span[@title='Test2']/").text.strip )
|
60
|
+
|
61
|
+
assert_raises(UnknownObjectException) {browser.span(:xpath , "//span[@id='span77']/").class_name }
|
62
|
+
assert_equal("blueText" , browser.span(:xpath , "//span[@id='span2']/").class_name )
|
63
|
+
assert_equal("" , browser.span(:xpath , "//span[@id='span1']/").class_name )
|
64
|
+
end
|
65
|
+
|
66
|
+
def test_objects_in_span
|
67
|
+
assert(browser.span(:xpath , "//span[@id='buttons1']/").button(:index,0).exists? )
|
68
|
+
assert_false(browser.span(:xpath , "//span[@id='buttons1']/").button(:index,2).exists? )
|
69
|
+
assert(browser.span(:xpath , "//span[@id='buttons1']/").button(:name,'b1').exists? )
|
70
|
+
|
71
|
+
assert(browser.span(:xpath , "//span[@id='buttons2']/").button(:index,0).exists? )
|
72
|
+
assert(browser.span(:xpath , "//span[@id='buttons2']/").button(:index,1).exists? )
|
73
|
+
assert_false(browser.span(:xpath , "//span[@id='buttons1']/").button(:index,2).exists? )
|
74
|
+
|
75
|
+
browser.span(:xpath , "//span[@id='buttons1']/").button(:index,0).click
|
76
|
+
|
77
|
+
assert_equal( 'button1' , browser.span(:xpath , "//span[@id='text_fields1']/").text_field(:index,0).value)
|
78
|
+
|
79
|
+
assert_equal( 3 , browser.span(:xpath , "//span[@id='text_fields1']/").text_fields.length )
|
80
|
+
end
|
81
|
+
|
82
|
+
def test_p
|
83
|
+
assert(browser.p(:xpath , "//p[@id='number1']/").exists?)
|
84
|
+
assert(browser.p(:xpath , "//p[@title='test_3']/").exists?)
|
85
|
+
|
86
|
+
assert_false(browser.p(:xpath , "//p[@id='missing']/").exists?)
|
87
|
+
assert_false(browser.p(:xpath , "//p[@title='test_55']/").exists?)
|
88
|
+
|
89
|
+
assert_raises( UnknownObjectException) {browser.p(:xpath , "//p[@id='missing']/").class_name }
|
90
|
+
assert_raises( UnknownObjectException) {browser.p(:xpath , "//p[@id='missing']/").text }
|
91
|
+
assert_raises( UnknownObjectException) {browser.p(:xpath , "//p[@id='missing']/").title }
|
92
|
+
assert_raises( UnknownObjectException) {browser.p(:xpath , "//p[@id='missing']/").to_s }
|
93
|
+
assert_raises( UnknownObjectException) {browser.p(:xpath , "//p[@id='missing']/").disabled }
|
94
|
+
end
|
95
|
+
end
|
@@ -0,0 +1,63 @@
|
|
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
|
@@ -0,0 +1,57 @@
|
|
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
|
@@ -0,0 +1,100 @@
|
|
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
|
+
|
@@ -0,0 +1,47 @@
|
|
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
|
@@ -0,0 +1,31 @@
|
|
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
|
@@ -0,0 +1,43 @@
|
|
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
|
@@ -0,0 +1,35 @@
|
|
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
|