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,110 @@
|
|
1
|
+
# feature tests for Text Fields
|
2
|
+
|
3
|
+
$LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..') unless $SETUP_LOADED
|
4
|
+
require 'unittests/setup'
|
5
|
+
|
6
|
+
class TC_Fields_XPath < Test::Unit::TestCase
|
7
|
+
include Watir::Exception
|
8
|
+
|
9
|
+
def setup
|
10
|
+
goto_page "textfields1.html"
|
11
|
+
end
|
12
|
+
|
13
|
+
def test_text_field_exists
|
14
|
+
assert(browser.text_field(:xpath , "//input[@name='text1']/").exists?)
|
15
|
+
assert_false(browser.text_field(:xpath , "//input[@name='missing']/").exists?)
|
16
|
+
|
17
|
+
assert(browser.text_field(:xpath , "//input[@id='text2']/").exists?)
|
18
|
+
assert_false(browser.text_field(:xpath , "//input[@id='alsomissing']/").exists?)
|
19
|
+
|
20
|
+
#assert(browser.text_field(:xpath , "//input[@beforeText='This Text After']/").exists? )
|
21
|
+
#assert(browser.text_field(:xpath , "//input[@afterText='This Text Before']/").exists? )
|
22
|
+
end
|
23
|
+
|
24
|
+
def test_text_field_dragContentsTo
|
25
|
+
browser.text_field(:xpath , "//input[@name='text1']/").dragContentsTo(:xpath , "//input[@id='text2']/")
|
26
|
+
assert_equal(browser.text_field(:xpath , "//input[@name='text1']/").value, "" )
|
27
|
+
assert_equal(browser.text_field(:xpath , "//input[@id='text2']/").value, "goodbye allHello World" )
|
28
|
+
end
|
29
|
+
|
30
|
+
def test_text_field_VerifyContents
|
31
|
+
assert(browser.text_field(:xpath , "//input[@name='text1']/").verify_contains("Hello World") )
|
32
|
+
assert(browser.text_field(:xpath , "//input[@name='text1']/").verify_contains(/Hello\sW/ ) )
|
33
|
+
assert_false(browser.text_field(:xpath , "//input[@name='text1']/").verify_contains("Ruby") )
|
34
|
+
assert_false(browser.text_field(:xpath , "//input[@name='text1']/").verify_contains(/R/) )
|
35
|
+
assert_raises(UnknownObjectException) { browser.text_field(:xpath , "//input[@name='NoName']/").verify_contains("No field to get a value of") }
|
36
|
+
|
37
|
+
assert(browser.text_field(:xpath , "//input[@id='text2']/").verify_contains("goodbye all") )
|
38
|
+
assert_raises(UnknownObjectException) { browser.text_field(:xpath , "//input[@id='noID']/").verify_contains("No field to get a value of") }
|
39
|
+
end
|
40
|
+
|
41
|
+
def test_text_field_enabled
|
42
|
+
assert_false(browser.text_field(:xpath , "//input[@name='disabled']/").enabled? )
|
43
|
+
assert(browser.text_field(:xpath , "//input[@name='text1']/").enabled? )
|
44
|
+
assert(browser.text_field(:xpath , "//input[@id='text2']/").enabled? )
|
45
|
+
end
|
46
|
+
|
47
|
+
def test_text_field_readOnly
|
48
|
+
assert_false(browser.text_field(:xpath , "//input[@name='disabled']/").readonly? )
|
49
|
+
assert(browser.text_field(:xpath , "//input[@name='readOnly']/").readonly? )
|
50
|
+
assert(browser.text_field(:xpath , "//input[@id='readOnly2']/").readonly? )
|
51
|
+
end
|
52
|
+
|
53
|
+
def test_text_field_value
|
54
|
+
assert_raises(UnknownObjectException , "ObjectReadOnlyException was supposed to be thrown" ) { browser.text_field(:xpath , "//input[@name='missing_field']/").append("Some Text") }
|
55
|
+
assert_equal( "Hello World" , browser.text_field(:xpath , "//input[@name='text1']/").value )
|
56
|
+
end
|
57
|
+
|
58
|
+
def build_to_s_regex(lhs, rhs)
|
59
|
+
Regexp.new("^#{lhs}: +#{rhs}$")
|
60
|
+
end
|
61
|
+
|
62
|
+
def test_text_field_Append
|
63
|
+
assert_raises(ObjectReadOnlyException , "ObjectReadOnlyException was supposed to be thrown" ) { browser.text_field(:xpath , "//input[@id='readOnly2']/").append("Some Text") }
|
64
|
+
assert_raises(ObjectDisabledException , "ObjectDisabledException was supposed to be thrown" ) { browser.text_field(:xpath , "//input[@name='disabled']/").append("Some Text") }
|
65
|
+
assert_raises(UnknownObjectException , "UnknownObjectException was supposed to be thrown" ) { browser.text_field(:xpath , "//input[@name='missing_field']/").append("Some Text") }
|
66
|
+
|
67
|
+
browser.text_field(:xpath , "//input[@name='text1']/").append(" Some Text")
|
68
|
+
assert_equal( "Hello World Some Text" , browser.text_field(:xpath , "//input[@name='text1']/").value )
|
69
|
+
end
|
70
|
+
|
71
|
+
|
72
|
+
def test_text_field_Clear
|
73
|
+
assert_raises(ObjectReadOnlyException , "ObjectReadOnlyException was supposed to be thrown" ) { browser.text_field(:xpath , "//input[@id='readOnly2']/").append("Some Text") }
|
74
|
+
assert_raises(ObjectDisabledException , "ObjectReadOnlyException was supposed to be thrown" ) { browser.text_field(:xpath , "//input[@name='disabled']/").append("Some Text") }
|
75
|
+
assert_raises(UnknownObjectException , "ObjectReadOnlyException was supposed to be thrown" ) { browser.text_field(:xpath , "//input[@name='missing_field']/").append("Some Text") }
|
76
|
+
|
77
|
+
browser.text_field(:xpath , "//input[@name='text1']/").clear
|
78
|
+
assert_equal( "" , browser.text_field(:xpath , "//input[@name='text1']/").value )
|
79
|
+
end
|
80
|
+
|
81
|
+
def test_text_field_Set
|
82
|
+
assert_raises(ObjectReadOnlyException , "ObjectReadOnlyException was supposed to be thrown" ) { browser.text_field(:xpath , "//input[@id='readOnly2']/").append("Some Text") }
|
83
|
+
assert_raises(ObjectDisabledException , "ObjectReadOnlyException was supposed to be thrown" ) { browser.text_field(:xpath , "//input[@name='disabled']/").append("Some Text") }
|
84
|
+
assert_raises(UnknownObjectException , "ObjectReadOnlyException was supposed to be thrown" ) { browser.text_field(:xpath , "//input[@name='missing_field']/").append("Some Text") }
|
85
|
+
|
86
|
+
browser.text_field(:xpath , "//input[@name='text1']/").set("watir IE Controller")
|
87
|
+
assert_equal( "watir IE Controller" , browser.text_field(:xpath , "//input[@name='text1']/").value )
|
88
|
+
end
|
89
|
+
|
90
|
+
def test_JS_Events
|
91
|
+
browser.text_field(:xpath , "//input[@name='events_tester']/").set('p')
|
92
|
+
|
93
|
+
# the following line has an extra keypress at the begining, as we mimic the delete key being pressed
|
94
|
+
assert_equal( "keypresskeydownkeypresskeyup" , browser.text_field(:xpath , "//textarea[@name='events_text']/").value.gsub(/(\n|\r)/ , "") )
|
95
|
+
browser.button(:value , "Clear Events Box").click
|
96
|
+
browser.text_field(:xpath , "//input[@name='events_tester']/").set('ab')
|
97
|
+
|
98
|
+
# the following line has an extra keypress at the begining, as we mimic the delete key being pressed
|
99
|
+
assert_equal( "keypresskeydownkeypresskeyupkeydownkeypresskeyup" , browser.text_field(:xpath , "//textarea[@name='events_text']/").value.gsub(/(\n|\r)/, "") )
|
100
|
+
end
|
101
|
+
|
102
|
+
def test_password
|
103
|
+
browser.text_field(:xpath , "//input[@name='password1']/").set("secret")
|
104
|
+
assert( 'secret' , browser.text_field(:xpath , "//input[@name='password1']/").value )
|
105
|
+
|
106
|
+
browser.text_field(:xpath , "//input[@id='password1']/").set("top_secret")
|
107
|
+
assert( 'top_secret' , browser.text_field(:xpath , "//input[@id='password1']/").value )
|
108
|
+
end
|
109
|
+
|
110
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
|
2
|
+
$LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..') unless $SETUP_LOADED
|
3
|
+
require 'unittests/setup'
|
4
|
+
|
5
|
+
class TC_Version < Test::Unit::TestCase
|
6
|
+
|
7
|
+
def test_full_version
|
8
|
+
assert !Watir::IE.version.nil?
|
9
|
+
end
|
10
|
+
|
11
|
+
def test_version_part
|
12
|
+
assert Watir::IE.version_parts[0] =~ /^\d+$/
|
13
|
+
end
|
14
|
+
|
15
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
$LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..')
|
2
|
+
require 'Win32API'
|
3
|
+
require 'unittests/setup'
|
4
|
+
|
5
|
+
# This test makes sure that the win32ole changes will return
|
6
|
+
# the dom using GetUnknown, which is added via the win32ole patch
|
7
|
+
class TC_Win32OLE < Test::Unit::TestCase
|
8
|
+
|
9
|
+
def setup
|
10
|
+
# this will find the IEDialog.dll file in its build location
|
11
|
+
@iedialog_file = (File.expand_path(File.dirname(__FILE__)) + "/../lib/watir-classic/IEDialog/Release/IEDialog.dll").gsub('/', '\\')
|
12
|
+
|
13
|
+
@ie = Watir::IE.new
|
14
|
+
@ie.goto 'www.google.com'
|
15
|
+
end
|
16
|
+
|
17
|
+
def teardown
|
18
|
+
@ie.close
|
19
|
+
end
|
20
|
+
|
21
|
+
def test_win32ole_modifications
|
22
|
+
fnGetUnknown = Win32API.new(@iedialog_file, 'GetUnknown', ['p', 'p'], 'v')
|
23
|
+
intPointer = " " * 4 # will contain the int value of the IUnknown*
|
24
|
+
fnGetUnknown.call(@ie.hwnd, intPointer)
|
25
|
+
assert_true intPointer
|
26
|
+
intArray = intPointer.unpack('L')
|
27
|
+
intUnknown = intArray.first
|
28
|
+
htmlDoc = WIN32OLE.connect_unknown(intUnknown);
|
29
|
+
scriptEngine = htmlDoc.Script
|
30
|
+
|
31
|
+
# now we get the HTML DOM object!
|
32
|
+
body = scriptEngine.document.body
|
33
|
+
assert(body.innerHTML =~ /html/)
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,52 @@
|
|
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
|
+
include Watir
|
8
|
+
|
9
|
+
def setup
|
10
|
+
goto_page 'buttons1.html'
|
11
|
+
@original_timeout = IE.attach_timeout
|
12
|
+
end
|
13
|
+
def teardown
|
14
|
+
IE.attach_timeout = @original_timeout
|
15
|
+
end
|
16
|
+
|
17
|
+
def test_find_window
|
18
|
+
ie = IE.find(:title, 'Test page for buttons')
|
19
|
+
assert_equal("Test page for buttons", ie.title)
|
20
|
+
end
|
21
|
+
|
22
|
+
def test_find_window_misses
|
23
|
+
ie = IE.find(:title, 'no such window')
|
24
|
+
assert_nil ie
|
25
|
+
end
|
26
|
+
|
27
|
+
def test_missing_window
|
28
|
+
IE.attach_timeout = 0.1
|
29
|
+
assert_raises(NoMatchingWindowFoundException) { IE.attach(:title, "missing") }
|
30
|
+
assert_raises(NoMatchingWindowFoundException) { IE.attach(:title, /missing/) }
|
31
|
+
assert_raises(NoMatchingWindowFoundException) { IE.attach(:url, "missing") }
|
32
|
+
assert_raises(NoMatchingWindowFoundException) { IE.attach(:url, /missing/) }
|
33
|
+
end
|
34
|
+
|
35
|
+
def test_existing_window
|
36
|
+
ie3 = nil
|
37
|
+
ie3 = IE.attach(:title , /buttons/i)
|
38
|
+
assert_equal("Test page for buttons", ie3.title)
|
39
|
+
ie3 = nil
|
40
|
+
|
41
|
+
ie3 = IE.attach(:title , "Test page for buttons")
|
42
|
+
assert_equal("Test page for buttons", ie3.title)
|
43
|
+
ie3 = nil
|
44
|
+
|
45
|
+
ie3 = IE.attach(:url, /buttons1.html/)
|
46
|
+
assert_equal("Test page for buttons", ie3.title)
|
47
|
+
ie3 = nil
|
48
|
+
|
49
|
+
#hard to test :url with explicit text
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
@@ -0,0 +1,74 @@
|
|
1
|
+
# feature tests for attaching to new IE windows
|
2
|
+
|
3
|
+
$LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..', '..') unless $SETUP_LOADED
|
4
|
+
require 'unittests/setup'
|
5
|
+
require 'watir-classic/testcase'
|
6
|
+
|
7
|
+
class TC_NewWindow< Watir::TestCase
|
8
|
+
include Watir
|
9
|
+
|
10
|
+
def setup
|
11
|
+
@original_timeout = IE.attach_timeout
|
12
|
+
goto_page "new_browser.html"
|
13
|
+
end
|
14
|
+
def teardown
|
15
|
+
IE.attach_timeout = @original_timeout
|
16
|
+
end
|
17
|
+
|
18
|
+
def test_simply_attach_to_new_window
|
19
|
+
IE.attach_timeout = 0.2
|
20
|
+
browser.link(:text, 'New Window').click
|
21
|
+
ie_new = IE.attach(:title, 'Pass Page')
|
22
|
+
assert(ie_new.text.include?('PASS'))
|
23
|
+
ie_new.close
|
24
|
+
end
|
25
|
+
|
26
|
+
def test_attach_to_new_window_using_click_no_wait
|
27
|
+
# this test is sometimes failing with a "Canvas does not allow drawing" error
|
28
|
+
# this is with IE7. I think the problem could be with the highlighting of the
|
29
|
+
# button from the separate process.
|
30
|
+
browser.link(:text, 'New Window').click_no_wait
|
31
|
+
IE.attach_timeout = 6.0
|
32
|
+
ie_new = IE.attach(:title, 'Pass Page')
|
33
|
+
assert(ie_new.text.include?('PASS'))
|
34
|
+
ie_new.close
|
35
|
+
end
|
36
|
+
|
37
|
+
def test_click_no_wait_works_in_a_container
|
38
|
+
browser.p(:index, 0).link(:text, 'New Window').click_no_wait
|
39
|
+
IE.attach_timeout = 6.0
|
40
|
+
ie_new = IE.attach(:title, 'Pass Page')
|
41
|
+
assert(ie_new.text.include?('PASS'))
|
42
|
+
ie_new.close
|
43
|
+
end
|
44
|
+
|
45
|
+
def test_attach_to_slow_window_works_with_delay
|
46
|
+
browser.span(:text, 'New Window Slowly').click
|
47
|
+
IE.attach_timeout = 4.0
|
48
|
+
sleep 1.0
|
49
|
+
ie_new = IE.attach(:title, 'Test page for buttons')
|
50
|
+
assert(ie_new.text.include?('Blank page to fill in the frames'))
|
51
|
+
ie_new.close
|
52
|
+
end
|
53
|
+
|
54
|
+
def test_attach_to_slow_window_works_without_waiting
|
55
|
+
browser.span(:text, 'New Window Slowly').click
|
56
|
+
IE.attach_timeout = 3.0
|
57
|
+
ie_new = IE.attach(:title, 'Test page for buttons')
|
58
|
+
assert(ie_new.text.include?('Blank page to fill in the frames'))
|
59
|
+
ie_new.close
|
60
|
+
end
|
61
|
+
|
62
|
+
def test_attach_timesout_when_window_takes_too_long
|
63
|
+
IE.attach_timeout = 0.2
|
64
|
+
browser.text_field(:name, 'delay').set('2')
|
65
|
+
browser.span(:text, 'New Window Slowly').click
|
66
|
+
assert_raise(Watir::Exception::NoMatchingWindowFoundException) do
|
67
|
+
IE.attach(:title, 'Test page for buttons')
|
68
|
+
end
|
69
|
+
sleep 2.0 # clean up
|
70
|
+
IE.attach_timeout = 6.0
|
71
|
+
IE.attach(:title, 'Test page for buttons').close
|
72
|
+
end
|
73
|
+
|
74
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# feature tests for closed windows
|
2
|
+
|
3
|
+
$LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..', '..') unless $SETUP_LOADED
|
4
|
+
require 'unittests/setup'
|
5
|
+
|
6
|
+
class TC_CloseWindow < Watir::TestCase
|
7
|
+
execute :sequentially
|
8
|
+
|
9
|
+
def setup
|
10
|
+
goto_page "new_browser.html"
|
11
|
+
end
|
12
|
+
|
13
|
+
# reproduces defect http://jira.openqa.org/browse/WTR-16
|
14
|
+
def test_close_window_with_button
|
15
|
+
browser.link(:text, 'New Window').click
|
16
|
+
ie_new = Watir::IE.attach(:title, 'Pass Page')
|
17
|
+
assert(ie_new.text.include?('PASS'))
|
18
|
+
assert_nothing_raised {ie_new.close}
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# tests of click_no_wait for links in frames
|
2
|
+
|
3
|
+
$LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..', '..') unless $SETUP_LOADED
|
4
|
+
require 'unittests/setup'
|
5
|
+
|
6
|
+
class TC_Frame_Links < Test::Unit::TestCase
|
7
|
+
|
8
|
+
def setup
|
9
|
+
goto_page "frame_links.html"
|
10
|
+
end
|
11
|
+
|
12
|
+
def test_click_in_a_frame
|
13
|
+
browser.frame(:name, 'linkFrame').link(:text, 'test1').click
|
14
|
+
assert(browser.frame(:name, 'linkFrame').text.include?('Links2-Pass'))
|
15
|
+
end
|
16
|
+
|
17
|
+
def test_click_no_wait_in_a_frame
|
18
|
+
browser.frame(:name, 'linkFrame').link(:text, 'test1').click_no_wait
|
19
|
+
Watir::Wait.until(10){browser.frame(:name, 'linkFrame').text.include?('Links2-Pass')}
|
20
|
+
assert(browser.frame(:name, 'linkFrame').text.include?('Links2-Pass'))
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
# Not intended to be run as part of a larger suite.
|
2
|
+
|
3
|
+
$LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..', '..') unless $SETUP_LOADED
|
4
|
+
require 'test/unit'
|
5
|
+
require 'watir-classic'
|
6
|
+
require 'watir-classic/process'
|
7
|
+
|
8
|
+
class TC_IE_Each < Test::Unit::TestCase
|
9
|
+
def setup
|
10
|
+
assert_equal 0, Watir::IE.process_count
|
11
|
+
@hits = 0
|
12
|
+
@ie = []
|
13
|
+
end
|
14
|
+
|
15
|
+
def hit_me
|
16
|
+
@hits += 1
|
17
|
+
end
|
18
|
+
|
19
|
+
def test_zero_windows
|
20
|
+
Watir::IE.each {hit_me}
|
21
|
+
assert_equal 0, @hits
|
22
|
+
end
|
23
|
+
|
24
|
+
def test_one_window
|
25
|
+
@ie << Watir::IE.new_process
|
26
|
+
Watir::IE.each {hit_me}
|
27
|
+
assert_equal 1, @hits
|
28
|
+
end
|
29
|
+
|
30
|
+
def test_two_windows
|
31
|
+
@ie << Watir::IE.new_process
|
32
|
+
@ie << Watir::IE.new_process
|
33
|
+
Watir::IE.each {hit_me}
|
34
|
+
assert_equal 2, @hits
|
35
|
+
end
|
36
|
+
|
37
|
+
def test_return_type
|
38
|
+
@ie << Watir::IE.new_process
|
39
|
+
Watir::IE.each {|ie| assert_equal(Watir::IE, ie.class)}
|
40
|
+
end
|
41
|
+
|
42
|
+
def teardown
|
43
|
+
@ie.each {|ie| ie.close }
|
44
|
+
Watir::Wait.until {Watir::IE.process_count == 0}
|
45
|
+
end
|
46
|
+
end
|
@@ -0,0 +1,95 @@
|
|
1
|
+
# feature tests for modal web dialog support
|
2
|
+
|
3
|
+
$LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..', '..') unless $SETUP_LOADED
|
4
|
+
require 'unittests/setup'
|
5
|
+
require 'watir-classic/close_all'
|
6
|
+
|
7
|
+
class TC_ModalDialog < Watir::TestCase
|
8
|
+
include Watir
|
9
|
+
|
10
|
+
def setup
|
11
|
+
@original_timeout = IE.attach_timeout
|
12
|
+
goto_page 'modal_dialog_launcher.html'
|
13
|
+
IE.attach_timeout = 10.0
|
14
|
+
end
|
15
|
+
|
16
|
+
def teardown
|
17
|
+
if browser
|
18
|
+
while browser.modal_dialog.exists?(0) do
|
19
|
+
browser.modal_dialog.close
|
20
|
+
sleep 0.5
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
|
26
|
+
def test_modal_simple_use_case
|
27
|
+
browser.button(:value, 'Launch Dialog').click_no_wait
|
28
|
+
modal = browser.modal_dialog
|
29
|
+
|
30
|
+
assert(modal.text.include?('Enter some text:'))
|
31
|
+
modal.text_field(:name, 'modal_text').set('hello')
|
32
|
+
modal.button(:value, 'Close').click
|
33
|
+
assert_equal('hello', browser.text_field(:name, 'modaloutput').value)
|
34
|
+
end
|
35
|
+
|
36
|
+
def test_wait_should_not_block
|
37
|
+
browser.button(:value, 'Launch Dialog').click_no_wait
|
38
|
+
modal = browser.modal_dialog
|
39
|
+
|
40
|
+
modal.text_field(:name, 'modal_text').set('hello')
|
41
|
+
modal.wait
|
42
|
+
|
43
|
+
modal.button(:value, 'Close').click
|
44
|
+
end
|
45
|
+
|
46
|
+
def test_modal_dialog_use_case_default
|
47
|
+
browser.button(:value, 'Launch Dialog').click_no_wait
|
48
|
+
|
49
|
+
modal = browser.modal_dialog
|
50
|
+
assert_not_nil modal
|
51
|
+
|
52
|
+
# Make sure that we have attached to modal and that the hwnd method
|
53
|
+
# is working properly to show the HWND of our parent.
|
54
|
+
assert_not_equal(browser.hwnd, modal.hwnd)
|
55
|
+
|
56
|
+
# Once attached just treat the modal_dialog like any IE or Frame
|
57
|
+
# object.
|
58
|
+
assert(modal.text.include?('Enter some text:'))
|
59
|
+
modal.text_field(:name, 'modal_text').set('hello')
|
60
|
+
modal.button(:value, 'Close').click
|
61
|
+
|
62
|
+
assert !browser.modal_dialog.exists?
|
63
|
+
assert_equal('hello', browser.text_field(:name, 'modaloutput').value)
|
64
|
+
end
|
65
|
+
|
66
|
+
def test_double_modal
|
67
|
+
browser.button(:value, 'Launch Dialog').click_no_wait
|
68
|
+
browser.modal_dialog.button(:text, 'Another Modal').click_no_wait
|
69
|
+
assert_nothing_raised {
|
70
|
+
Watir::Wait.until {browser.modal_dialog.title == 'Pass Page'}
|
71
|
+
}
|
72
|
+
browser.modal_dialog.close
|
73
|
+
browser.modal_dialog.close
|
74
|
+
end
|
75
|
+
|
76
|
+
def xtest_modal_with_frames
|
77
|
+
browser.button(:value, 'Launch Dialog').click_no_wait
|
78
|
+
modal1 = browser.modal_dialog
|
79
|
+
modal1.button(:value, 'Modal with Frames').click_no_wait
|
80
|
+
modal2 = browser.modal_dialog
|
81
|
+
modal2.frame('buttonFrame').button(:value, 'Click Me').click
|
82
|
+
assert(modal2.frame('buttonFrame').text.include?('PASS'))
|
83
|
+
modal2.frame('buttonFrame').button(:value, 'Close Window').click
|
84
|
+
modal1.close
|
85
|
+
end
|
86
|
+
|
87
|
+
def test_modal_exists
|
88
|
+
browser.button(:value, 'Launch Dialog').click_no_wait
|
89
|
+
modal = browser.modal_dialog
|
90
|
+
assert(modal.exists?)
|
91
|
+
modal.button(:value, 'Close').click
|
92
|
+
assert_false(modal.exists?)
|
93
|
+
end
|
94
|
+
|
95
|
+
end
|