watir 1.4.1 → 1.5.2
Sign up to get free protection for your applications and to get access to all the features.
- data/bin/watir-console +1 -0
- data/changes.rb +119 -0
- data/license.rb +37 -0
- data/readme.rb +55 -120
- data/unittests/buttons_test.rb +107 -104
- data/unittests/buttons_xpath_test.rb +69 -0
- data/unittests/checkbox_test.rb +154 -141
- data/unittests/checkbox_xpath_test.rb +107 -0
- data/unittests/core_tests.rb +6 -2
- data/unittests/css_test.rb +50 -50
- data/unittests/defer_test.rb +47 -0
- data/unittests/dialog_test.rb +78 -0
- data/unittests/div2_xpath_test.rb +22 -0
- data/unittests/div_test.rb +159 -159
- data/unittests/div_xpath_test.rb +96 -0
- data/unittests/errorchecker_test.rb +22 -22
- data/unittests/filefield_test.rb +30 -23
- data/unittests/filefield_xpath_test.rb +35 -0
- data/unittests/form_test.rb +250 -229
- data/unittests/form_xpath_test.rb +253 -0
- data/unittests/frame_test.rb +123 -108
- data/unittests/google_form_test.rb +17 -0
- data/unittests/html/JavascriptClick.html +39 -0
- data/unittests/html/buttons1.html +3 -2
- data/unittests/html/checkboxes1.html +32 -14
- data/unittests/html/complex_table.html +1 -1
- data/unittests/html/depot_store.html +59 -0
- data/unittests/html/div.html +3 -21
- data/unittests/html/div_xml.html +21 -0
- data/unittests/html/fileupload.html +2 -2
- data/unittests/html/forms2.html +3 -3
- data/unittests/html/forms3.html +2 -2
- data/unittests/html/frame_links.html +2 -2
- data/unittests/html/google_india.html +119 -0
- data/unittests/html/iframeTest.html +2 -2
- data/unittests/html/images/map.GIF +0 -0
- data/unittests/html/images/map2.gif +0 -0
- data/unittests/html/images1.html +17 -2
- data/unittests/html/javascriptevents.html +3 -7
- data/unittests/html/links1.html +9 -8
- data/unittests/html/links_multi.html +14 -0
- data/unittests/html/list_matters.html +720 -0
- data/unittests/html/lists.html +18 -0
- data/unittests/html/map_test.html +31 -0
- data/unittests/html/modal_dialog.html +10 -0
- data/unittests/html/modal_dialog_launcher.html +12 -0
- data/unittests/html/new_browser.html +17 -0
- data/unittests/html/pass.html +3 -0
- data/unittests/html/popups1.html +1 -1
- data/unittests/html/pre.html +28 -0
- data/unittests/html/radioButtons1.html +6 -5
- data/unittests/html/selectboxes1.html +12 -11
- data/unittests/html/simple_table.html +1 -1
- data/unittests/html/simple_table_columns.html +1 -1
- data/unittests/html/table1.html +1 -1
- data/unittests/html/tableCell_using_xpath.html +19 -0
- data/unittests/html/textfields1.html +6 -4
- data/unittests/html/xpath_nbsp.html +12 -0
- data/unittests/ie_exists_test.rb +32 -0
- data/unittests/ie_mock.rb +78 -79
- data/unittests/ie_test.rb +39 -39
- data/unittests/images_test.rb +132 -155
- data/unittests/images_xpath_test.rb +91 -0
- data/unittests/links_multi_test.rb +36 -0
- data/unittests/links_test.rb +158 -152
- data/unittests/links_xpath_test.rb +40 -0
- data/unittests/lists_test.rb +29 -0
- data/unittests/map_test.rb +99 -0
- data/unittests/minmax_test.rb +23 -23
- data/unittests/navigate_test.rb +43 -51
- data/unittests/nbsp_xpath_test.rb +18 -0
- data/unittests/other/WindowLogonExample.rb +28 -0
- data/unittests/{WindowLogonExtra.rb → other/WindowLogonExtra.rb} +0 -0
- data/unittests/{all_tests_concurrent.rb → other/all_tests_concurrent.rb} +23 -23
- data/unittests/other/navigate_exception_test.rb +14 -0
- data/unittests/other/rexml_unit_test.rb +24 -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 +99 -0
- data/unittests/pagecontainstext_test.rb +56 -37
- data/unittests/parent_child_test.rb +55 -0
- data/unittests/popups_test.rb +37 -37
- data/unittests/pre_test.rb +52 -0
- data/unittests/radios_test.rb +186 -155
- data/unittests/radios_xpath_test.rb +101 -0
- data/unittests/screen_capture_test.rb +41 -41
- data/unittests/selectbox_test.rb +223 -181
- data/unittests/selectbox_xpath_test.rb +113 -0
- data/unittests/setup.rb +29 -25
- data/unittests/speed_settings_test.rb +22 -0
- data/unittests/table_cell_using_xpath_test.rb +40 -0
- data/unittests/table_test.rb +315 -284
- data/unittests/table_xpath_test.rb +114 -0
- data/unittests/textarea_test.rb +81 -0
- data/unittests/textarea_xpath_test.rb +82 -0
- data/unittests/textfields_test.rb +205 -229
- data/unittests/textfields_xpath_test.rb +111 -0
- data/unittests/window_tests.rb +7 -0
- data/unittests/windows/attach_to_existing_window_test.rb +52 -0
- data/unittests/windows/attach_to_new_window_test.rb +82 -0
- data/unittests/windows/close_window_test.rb +22 -0
- data/unittests/windows/frame_links_test.rb +25 -0
- data/unittests/windows/ie-each_test.rb +48 -0
- data/unittests/windows/iedialog_test.rb +55 -0
- data/unittests/windows/js_events_test.rb +57 -0
- data/unittests/windows/jscriptExtraAlert.rb +6 -0
- data/unittests/windows/jscriptExtraConfirmCancel.rb +7 -0
- data/unittests/windows/jscriptExtraConfirmOk.rb +7 -0
- data/unittests/{jscriptPushButton.rb → windows/jscriptPushButton.rb} +1 -1
- data/unittests/windows/jscript_test.rb +64 -0
- data/unittests/windows/modal_dialog_test.rb +127 -0
- data/unittests/windows/new.rb +56 -0
- data/unittests/windows/open_close_test.rb +22 -0
- data/unittests/windows/send_keys_test.rb +34 -0
- data/unittests/xpath_tests.rb +10 -0
- data/watir.rb +4344 -3565
- data/watir/IEDialog/Release/IEDialog.dll +0 -0
- data/watir/WindowHelper.rb +13 -11
- data/watir/assertions.rb +36 -0
- data/watir/camel_case.rb +14 -5
- data/watir/close_all.rb +38 -0
- data/watir/contrib/enabled_popup.rb +21 -0
- data/watir/contrib/ie-new-process.rb +27 -0
- data/watir/contrib/page_checker.rb +29 -0
- data/watir/contrib/visible.rb +47 -0
- data/watir/cookiemanager.rb +4 -4
- data/watir/datahandler.rb +107 -0
- data/watir/dialog.rb +46 -0
- data/watir/elements.rb +65 -0
- data/watir/exceptions.rb +18 -36
- data/watir/ie-process.rb +40 -0
- data/watir/irb-history.rb +31 -0
- data/watir/process.rb +20 -0
- data/watir/testUnitAddons.rb +3 -42
- data/watir/testcase.rb +58 -0
- data/watir/utils.rb +20 -0
- data/watir/waiter.rb +88 -0
- data/watir/watir_simple.rb +4 -4
- data/watir/win32ole.rb +8 -0
- data/watir/win32ole/win32ole.so +0 -0
- data/watir/winClicker.rb +374 -400
- metadata +209 -128
- data/unittests/WindowLogonExample.rb +0 -30
- data/unittests/attachToExistingWindow_test.rb +0 -40
- data/unittests/js_events_test.rb +0 -77
- data/unittests/jscriptExtraAlert.rb +0 -6
- data/unittests/jscriptExtraConfirmCancel.rb +0 -7
- data/unittests/jscriptExtraConfirmOk.rb +0 -7
- data/unittests/jscript_test.rb +0 -57
- data/unittests/send_keys_test.rb +0 -29
- data/unittests/textAreafields_test.rb +0 -81
@@ -0,0 +1,111 @@
|
|
1
|
+
# feature tests for Text Fields
|
2
|
+
# revision: $Revision: 962 $
|
3
|
+
|
4
|
+
$LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..') if $0 == __FILE__
|
5
|
+
require 'unittests/setup'
|
6
|
+
|
7
|
+
class TC_Fields_XPath < Test::Unit::TestCase
|
8
|
+
include Watir
|
9
|
+
|
10
|
+
def setup
|
11
|
+
$ie.goto($htmlRoot + "textfields1.html")
|
12
|
+
end
|
13
|
+
|
14
|
+
def test_text_field_exists
|
15
|
+
assert($ie.text_field(:xpath , "//input[@name='text1']/").exists?)
|
16
|
+
assert(!$ie.text_field(:xpath , "//input[@name='missing']/").exists?)
|
17
|
+
|
18
|
+
assert($ie.text_field(:xpath , "//input[@id='text2']/").exists?)
|
19
|
+
assert(!$ie.text_field(:xpath , "//input[@id='alsomissing']/").exists?)
|
20
|
+
|
21
|
+
#assert($ie.text_field(:xpath , "//input[@beforeText='This Text After']/").exists? )
|
22
|
+
#assert($ie.text_field(:xpath , "//input[@afterText='This Text Before']/").exists? )
|
23
|
+
end
|
24
|
+
|
25
|
+
def test_text_field_dragContentsTo
|
26
|
+
$ie.text_field(:xpath , "//input[@name='text1']/").dragContentsTo(:xpath , "//input[@id='text2']/")
|
27
|
+
assert_equal($ie.text_field(:xpath , "//input[@name='text1']/").value, "" )
|
28
|
+
assert_equal($ie.text_field(:xpath , "//input[@id='text2']/").value, "goodbye allHello World" )
|
29
|
+
end
|
30
|
+
|
31
|
+
def test_text_field_VerifyContents
|
32
|
+
assert($ie.text_field(:xpath , "//input[@name='text1']/").verify_contains("Hello World") )
|
33
|
+
assert($ie.text_field(:xpath , "//input[@name='text1']/").verify_contains(/Hello\sW/ ) )
|
34
|
+
assert(!$ie.text_field(:xpath , "//input[@name='text1']/").verify_contains("Ruby") )
|
35
|
+
assert(!$ie.text_field(:xpath , "//input[@name='text1']/").verify_contains(/R/) )
|
36
|
+
assert_raises(UnknownObjectException , "UnknownObjectException was supposed to be thrown" ) { $ie.text_field(:xpath , "//input[@name='NoName']/").verify_contains("No field to get a value of") }
|
37
|
+
|
38
|
+
assert($ie.text_field(:xpath , "//input[@id='text2']/").verify_contains("goodbye all") )
|
39
|
+
assert_raises(UnknownObjectException , "UnknownObjectException was supposed to be thrown" ) { $ie.text_field(:xpath , "//input[@id='noID']/").verify_contains("No field to get a value of") }
|
40
|
+
end
|
41
|
+
|
42
|
+
def test_text_field_enabled
|
43
|
+
assert(!$ie.text_field(:xpath , "//input[@name='disabled']/").enabled? )
|
44
|
+
assert($ie.text_field(:xpath , "//input[@name='text1']/").enabled? )
|
45
|
+
assert($ie.text_field(:xpath , "//input[@id='text2']/").enabled? )
|
46
|
+
end
|
47
|
+
|
48
|
+
def test_text_field_readOnly
|
49
|
+
assert(!$ie.text_field(:xpath , "//input[@name='disabled']/").readonly? )
|
50
|
+
assert($ie.text_field(:xpath , "//input[@name='readOnly']/").readonly? )
|
51
|
+
assert($ie.text_field(:xpath , "//input[@id='readOnly2']/").readonly? )
|
52
|
+
end
|
53
|
+
|
54
|
+
def test_text_field_value
|
55
|
+
assert_raises(UnknownObjectException , "ObjectReadOnlyException was supposed to be thrown" ) { $ie.text_field(:xpath , "//input[@name='missing_field']/").append("Some Text") }
|
56
|
+
assert_equal( "Hello World" , $ie.text_field(:xpath , "//input[@name='text1']/").value )
|
57
|
+
end
|
58
|
+
|
59
|
+
def build_to_s_regex(lhs, rhs)
|
60
|
+
Regexp.new("^#{lhs}: +#{rhs}$")
|
61
|
+
end
|
62
|
+
|
63
|
+
def test_text_field_Append
|
64
|
+
assert_raises(ObjectReadOnlyException , "ObjectReadOnlyException was supposed to be thrown" ) { $ie.text_field(:xpath , "//input[@id='readOnly2']/").append("Some Text") }
|
65
|
+
assert_raises(ObjectDisabledException , "ObjectDisabledException was supposed to be thrown" ) { $ie.text_field(:xpath , "//input[@name='disabled']/").append("Some Text") }
|
66
|
+
assert_raises(UnknownObjectException , "UnknownObjectException was supposed to be thrown" ) { $ie.text_field(:xpath , "//input[@name='missing_field']/").append("Some Text") }
|
67
|
+
|
68
|
+
$ie.text_field(:xpath , "//input[@name='text1']/").append(" Some Text")
|
69
|
+
assert_equal( "Hello World Some Text" , $ie.text_field(:xpath , "//input[@name='text1']/").value )
|
70
|
+
end
|
71
|
+
|
72
|
+
|
73
|
+
def test_text_field_Clear
|
74
|
+
assert_raises(ObjectReadOnlyException , "ObjectReadOnlyException was supposed to be thrown" ) { $ie.text_field(:xpath , "//input[@id='readOnly2']/").append("Some Text") }
|
75
|
+
assert_raises(ObjectDisabledException , "ObjectReadOnlyException was supposed to be thrown" ) { $ie.text_field(:xpath , "//input[@name='disabled']/").append("Some Text") }
|
76
|
+
assert_raises(UnknownObjectException , "ObjectReadOnlyException was supposed to be thrown" ) { $ie.text_field(:xpath , "//input[@name='missing_field']/").append("Some Text") }
|
77
|
+
|
78
|
+
$ie.text_field(:xpath , "//input[@name='text1']/").clear
|
79
|
+
assert_equal( "" , $ie.text_field(:xpath , "//input[@name='text1']/").value )
|
80
|
+
end
|
81
|
+
|
82
|
+
def test_text_field_Set
|
83
|
+
assert_raises(ObjectReadOnlyException , "ObjectReadOnlyException was supposed to be thrown" ) { $ie.text_field(:xpath , "//input[@id='readOnly2']/").append("Some Text") }
|
84
|
+
assert_raises(ObjectDisabledException , "ObjectReadOnlyException was supposed to be thrown" ) { $ie.text_field(:xpath , "//input[@name='disabled']/").append("Some Text") }
|
85
|
+
assert_raises(UnknownObjectException , "ObjectReadOnlyException was supposed to be thrown" ) { $ie.text_field(:xpath , "//input[@name='missing_field']/").append("Some Text") }
|
86
|
+
|
87
|
+
$ie.text_field(:xpath , "//input[@name='text1']/").set("watir IE Controller")
|
88
|
+
assert_equal( "watir IE Controller" , $ie.text_field(:xpath , "//input[@name='text1']/").value )
|
89
|
+
end
|
90
|
+
|
91
|
+
def test_JS_Events
|
92
|
+
$ie.text_field(:xpath , "//input[@name='events_tester']/").set('p')
|
93
|
+
|
94
|
+
# the following line has an extra keypress at the begining, as we mimic the delete key being pressed
|
95
|
+
assert_equal( "keypresskeydownkeypresskeyup" , $ie.text_field(:xpath , "//textarea[@name='events_text']/").value.gsub("\r\n" , "") )
|
96
|
+
$ie.button(:value , "Clear Events Box").click
|
97
|
+
$ie.text_field(:xpath , "//input[@name='events_tester']/").set('ab')
|
98
|
+
|
99
|
+
# the following line has an extra keypress at the begining, as we mimic the delete key being pressed
|
100
|
+
assert_equal( "keypresskeydownkeypresskeyupkeydownkeypresskeyup" , $ie.text_field(:xpath , "//textarea[@name='events_text']/").value.gsub("\r\n" , "") )
|
101
|
+
end
|
102
|
+
|
103
|
+
def test_password
|
104
|
+
$ie.text_field(:xpath , "//input[@name='password1']/").set("secret")
|
105
|
+
assert( 'secret' , $ie.text_field(:xpath , "//input[@name='password1']/").value )
|
106
|
+
|
107
|
+
$ie.text_field(:xpath , "//input[@id='password1']/").set("top_secret")
|
108
|
+
assert( 'top_secret' , $ie.text_field(:xpath , "//input[@id='password1']/").value )
|
109
|
+
end
|
110
|
+
|
111
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
# feature tests for attaching to existing IE windows
|
2
|
+
# revision: $Revision: 1230 $
|
3
|
+
|
4
|
+
$LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..', '..') if $0 == __FILE__
|
5
|
+
require 'unittests/setup'
|
6
|
+
|
7
|
+
class TC_ExistingWindow< Test::Unit::TestCase
|
8
|
+
include Watir
|
9
|
+
|
10
|
+
def setup
|
11
|
+
$ie.goto($htmlRoot + 'buttons1.html')
|
12
|
+
end
|
13
|
+
def teardown
|
14
|
+
IE.reset_attach_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,82 @@
|
|
1
|
+
# feature tests for attaching to new IE windows
|
2
|
+
# revision: $Revision: 1230 $
|
3
|
+
|
4
|
+
$LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..', '..') if $0 == __FILE__
|
5
|
+
require 'unittests/setup'
|
6
|
+
require 'watir/testcase'
|
7
|
+
|
8
|
+
class TC_NewWindow< Watir::TestCase
|
9
|
+
include Watir
|
10
|
+
|
11
|
+
def setup
|
12
|
+
$ie.goto($htmlRoot + "new_browser.html")
|
13
|
+
end
|
14
|
+
def teardown
|
15
|
+
IE.reset_attach_timeout
|
16
|
+
end
|
17
|
+
|
18
|
+
def test_simply_attach_to_new_window
|
19
|
+
IE.attach_timeout = 0.2
|
20
|
+
$ie.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_separate_process
|
27
|
+
$ie.eval_in_spawned_process "link(:text, 'New Window').click"
|
28
|
+
IE.attach_timeout = 6.0
|
29
|
+
ie_new = IE.attach(:title, 'Pass Page')
|
30
|
+
assert(ie_new.text.include?('PASS'))
|
31
|
+
ie_new.close
|
32
|
+
end
|
33
|
+
|
34
|
+
def test_attach_to_new_window_using_click_no_wait
|
35
|
+
# this test is sometimes failing with a "Canvas does not allow drawing" error
|
36
|
+
# this is with IE7. I think the problem could be with the highlighting of the
|
37
|
+
# button from the separate process.
|
38
|
+
$ie.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_click_no_wait_works_in_a_container
|
46
|
+
$ie.p(:index, 1).link(:text, 'New Window').click_no_wait
|
47
|
+
IE.attach_timeout = 6.0
|
48
|
+
ie_new = IE.attach(:title, 'Pass Page')
|
49
|
+
assert(ie_new.text.include?('PASS'))
|
50
|
+
ie_new.close
|
51
|
+
end
|
52
|
+
|
53
|
+
def test_attach_to_slow_window_works_with_delay
|
54
|
+
$ie.span(:text, 'New Window Slowly').click
|
55
|
+
IE.attach_timeout = 4.0
|
56
|
+
sleep 1.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_to_slow_window_works_without_waiting
|
63
|
+
$ie.span(:text, 'New Window Slowly').click
|
64
|
+
IE.attach_timeout = 3.0
|
65
|
+
ie_new = IE.attach(:title, 'Test page for buttons')
|
66
|
+
assert(ie_new.text.include?('Blank page to fill in the frames'))
|
67
|
+
ie_new.close
|
68
|
+
end
|
69
|
+
|
70
|
+
def test_attach_timesout_when_window_takes_too_long
|
71
|
+
IE.attach_timeout = 0.2
|
72
|
+
$ie.text_field(:name, 'delay').set('2')
|
73
|
+
$ie.span(:text, 'New Window Slowly').click
|
74
|
+
assert_raise(Watir::Exception::NoMatchingWindowFoundException) do
|
75
|
+
IE.attach(:title, 'Test page for buttons')
|
76
|
+
end
|
77
|
+
sleep 2.0 # clean up
|
78
|
+
IE.attach_timeout = 6.0
|
79
|
+
IE.attach(:title, 'Test page for buttons').close
|
80
|
+
end
|
81
|
+
|
82
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# feature tests for closed windows
|
2
|
+
# revision: $Revision: 958 $
|
3
|
+
|
4
|
+
$LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..', '..') if $0 == __FILE__
|
5
|
+
require 'unittests/setup'
|
6
|
+
|
7
|
+
class TC_CloseWindow < Watir::TestCase
|
8
|
+
include Watir
|
9
|
+
execute :sequentially
|
10
|
+
|
11
|
+
def setup
|
12
|
+
$ie.goto($htmlRoot + "new_browser.html")
|
13
|
+
end
|
14
|
+
|
15
|
+
# reproduces defect http://jira.openqa.org/browse/WTR-16
|
16
|
+
def test_close_window_with_button
|
17
|
+
$ie.link(:text, 'New Window').click
|
18
|
+
ie_new = IE.attach(:title, 'Pass Page')
|
19
|
+
assert(ie_new.text.include?('PASS'))
|
20
|
+
assert_nothing_raised {ie_new.close}
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# tests of click_no_wait for links in frames
|
2
|
+
# revision: $Revision: 1078 $
|
3
|
+
|
4
|
+
$LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..', '..') if $0 == __FILE__
|
5
|
+
require 'unittests/setup'
|
6
|
+
|
7
|
+
class TC_Frame_Links < Test::Unit::TestCase
|
8
|
+
include Watir
|
9
|
+
|
10
|
+
def setup
|
11
|
+
$ie.goto($htmlRoot + "frame_links.html")
|
12
|
+
end
|
13
|
+
|
14
|
+
def test_click_in_a_frame
|
15
|
+
$ie.frame('linkFrame').link(:text, 'test1').click
|
16
|
+
assert($ie.frame('linkFrame').text.include?('Links2-Pass'))
|
17
|
+
end
|
18
|
+
|
19
|
+
def test_click_no_wait_in_a_frame
|
20
|
+
$ie.frame('linkFrame').link(:text, 'test1').click_no_wait
|
21
|
+
wait_until(2){$ie.frame('linkFrame').text.include?('Links2-Pass')}
|
22
|
+
assert($ie.frame('linkFrame').text.include?('Links2-Pass'))
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
# Not intended to be run as part of a larger suite.
|
2
|
+
|
3
|
+
$LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..', '..') if $0 == __FILE__
|
4
|
+
require 'test/unit'
|
5
|
+
require 'watir'
|
6
|
+
require 'watir/process'
|
7
|
+
require 'watir/waiter'
|
8
|
+
|
9
|
+
class TC_IE_Each < Test::Unit::TestCase
|
10
|
+
def setup
|
11
|
+
assert_equal 0, Watir::IE.process_count
|
12
|
+
@hits = 0
|
13
|
+
@ie = []
|
14
|
+
end
|
15
|
+
|
16
|
+
def hit_me
|
17
|
+
@hits += 1
|
18
|
+
end
|
19
|
+
|
20
|
+
def test_zero_windows
|
21
|
+
Watir::IE.each {hit_me}
|
22
|
+
assert_equal 0, @hits
|
23
|
+
end
|
24
|
+
|
25
|
+
def test_one_window
|
26
|
+
@ie << Watir::IE.new_process
|
27
|
+
Watir::IE.each {hit_me}
|
28
|
+
assert_equal 1, @hits
|
29
|
+
end
|
30
|
+
|
31
|
+
def test_two_windows
|
32
|
+
@ie << Watir::IE.new_process
|
33
|
+
@ie << Watir::IE.new_process
|
34
|
+
Watir::IE.each {hit_me}
|
35
|
+
assert_equal 2, @hits
|
36
|
+
end
|
37
|
+
|
38
|
+
def test_return_type
|
39
|
+
@ie << Watir::IE.new_process
|
40
|
+
Watir::IE.each {|ie| assert_equal(Watir::IE, ie.class)}
|
41
|
+
end
|
42
|
+
|
43
|
+
include Watir
|
44
|
+
def teardown
|
45
|
+
@ie.each {|ie| ie.close }
|
46
|
+
wait_until {Watir::IE.process_count == 0}
|
47
|
+
end
|
48
|
+
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
# unit tests for iedialog.dll and customized win32ole.so
|
2
|
+
# revision: $Revision: 1177 $
|
3
|
+
|
4
|
+
$LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..', '..') if $0 == __FILE__
|
5
|
+
require 'unittests/setup'
|
6
|
+
require 'Win32API'
|
7
|
+
|
8
|
+
if VERSION == '1.8.2'
|
9
|
+
class TC_IEDialog < Test::Unit::TestCase
|
10
|
+
include Watir
|
11
|
+
|
12
|
+
# this will find the IEDialog.dll file in its build location
|
13
|
+
@@iedialog_file = (File.expand_path(File.dirname(__FILE__)) + "/../watir/IEDialog/Release/IEDialog.dll").gsub('/', '\\')
|
14
|
+
|
15
|
+
# commented out because it currently requires a manual click
|
16
|
+
# a better idea would be to automate the click...
|
17
|
+
def xtest_connect_to_iedialog
|
18
|
+
# make sure we can connect to the IEDialog.dll
|
19
|
+
fnShowString = Win32API.new(@@iedialog_file, 'ShowString', ['p'], 'v')
|
20
|
+
fnShowString.call("from ruby!") # blocks
|
21
|
+
end
|
22
|
+
|
23
|
+
def test_find_window
|
24
|
+
$ie.goto($htmlRoot + "pass.html")
|
25
|
+
fnFindWindow = Win32API.new('user32.dll', 'FindWindow', ['p', 'p'], 'l')
|
26
|
+
hwnd = fnFindWindow.call(nil, "Pass Page - Microsoft Internet Explorer")
|
27
|
+
assert(hwnd != 0)
|
28
|
+
end
|
29
|
+
|
30
|
+
def test_all
|
31
|
+
$ie.goto($htmlRoot + "pass.html")
|
32
|
+
|
33
|
+
fnFindWindow = Win32API.new('user32.dll', 'FindWindow', ['p', 'p'], 'l')
|
34
|
+
hwnd = fnFindWindow.call(nil, "Pass Page - Microsoft Internet Explorer")
|
35
|
+
|
36
|
+
fnGetUnknown = Win32API.new(@@iedialog_file, 'GetUnknown', ['l', 'p'], 'v')
|
37
|
+
intPointer = " " * 4 # will contain the int value of the IUnknown*
|
38
|
+
fnGetUnknown.call(hwnd, intPointer)
|
39
|
+
|
40
|
+
intArray = intPointer.unpack('L')
|
41
|
+
intUnknown = intArray.first
|
42
|
+
|
43
|
+
assert(intUnknown > 0)
|
44
|
+
|
45
|
+
htmlDoc = nil
|
46
|
+
assert_nothing_raised{htmlDoc = WIN32OLE.connect_unknown(intUnknown)}
|
47
|
+
scriptEngine = htmlDoc.Script
|
48
|
+
|
49
|
+
# now we get the HTML DOM object!
|
50
|
+
doc2 = scriptEngine.document
|
51
|
+
body = doc2.body
|
52
|
+
assert_match(/^PASS/, body.innerHTML.strip)
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
@@ -0,0 +1,57 @@
|
|
1
|
+
# feature tests for JavaScript events
|
2
|
+
# revision: $Revision: 1177 $
|
3
|
+
|
4
|
+
$LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..', '..') if $0 == __FILE__
|
5
|
+
require 'unittests/setup'
|
6
|
+
|
7
|
+
class TC_JSEvents < Test::Unit::TestCase
|
8
|
+
include Watir
|
9
|
+
|
10
|
+
def setup
|
11
|
+
$ie.goto($htmlRoot + "javascriptevents.html")
|
12
|
+
end
|
13
|
+
|
14
|
+
def test_Button_disabled
|
15
|
+
assert(! $ie.button(:caption, "Button 1").enabled?)
|
16
|
+
end
|
17
|
+
|
18
|
+
def test_Button_Enabled
|
19
|
+
$ie.text_field(:name, "entertext").fire_event("onkeyup")
|
20
|
+
assert($ie.button(:caption, "Button 1").enabled?)
|
21
|
+
end
|
22
|
+
|
23
|
+
def test_Button_click
|
24
|
+
# Firing event to make button enabled
|
25
|
+
$ie.text_field(:name, "entertext").fire_event("onKeyUp")
|
26
|
+
# Clicking the button
|
27
|
+
$ie.button(:caption, "Button 1").click
|
28
|
+
assert($ie.text.include?("PASS") )
|
29
|
+
end
|
30
|
+
|
31
|
+
#onMouseOver tests
|
32
|
+
#window status
|
33
|
+
|
34
|
+
def test_no_status_bar_exception
|
35
|
+
$ie.link(:text, "New Window No Status Bar").click
|
36
|
+
status_bar_test_win = nil
|
37
|
+
# Note: this test will fail if the Google toolbar popup blocker is turned on
|
38
|
+
assert_nothing_raised { status_bar_test_win = Watir::IE.attach(:title, "Pass Page") }
|
39
|
+
assert_raises( Watir::NoStatusBarException ) { status_bar_test_win.status }
|
40
|
+
status_bar_test_win.close
|
41
|
+
status_bar_test_win = nil
|
42
|
+
end
|
43
|
+
|
44
|
+
def test_page_nostatus
|
45
|
+
assert_equal("Done", $ie.status)
|
46
|
+
end
|
47
|
+
|
48
|
+
def test_set_page_status
|
49
|
+
$ie.link(:text, "Check the Status").fire_event("onMouseOver")
|
50
|
+
assert_equal("It worked", $ie.status)
|
51
|
+
end
|
52
|
+
|
53
|
+
def test_clear_page_status
|
54
|
+
$ie.link(:text, "Clear the Status").fire_event("onMouseOver")
|
55
|
+
assert_equal("Done", $ie.status)
|
56
|
+
end
|
57
|
+
end
|