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,114 @@
|
|
1
|
+
# feature tests for Tables
|
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_Tables_XPath < Test::Unit::TestCase
|
8
|
+
include Watir
|
9
|
+
|
10
|
+
def setup
|
11
|
+
gotoTablePage
|
12
|
+
end
|
13
|
+
|
14
|
+
def gotoTablePage
|
15
|
+
$ie.goto($htmlRoot + "table1.html")
|
16
|
+
end
|
17
|
+
|
18
|
+
def test_Table_Exists
|
19
|
+
assert(!$ie.table(:xpath , "//table[@id='missingTable']/").exists? )
|
20
|
+
assert($ie.table(:xpath , "//table[@id='t1']/").exists? )
|
21
|
+
end
|
22
|
+
|
23
|
+
def test_rows
|
24
|
+
assert_raises( UnknownObjectException ){ $ie.table(:xpath , "//table[@id='missingTable']/").row_count }
|
25
|
+
assert_equal( 5 , $ie.table(:xpath , "//table[@id='t1']/").row_count) # 4 rows and a header
|
26
|
+
end
|
27
|
+
|
28
|
+
def test_dynamic_tables
|
29
|
+
t = $ie.table(:xpath , "//table[@id='t1']/")
|
30
|
+
assert_equal( 5, t.row_count)
|
31
|
+
|
32
|
+
$ie.button(:xpath,"//input[@value='add row']/").click
|
33
|
+
assert_equal( 6, t.row_count)
|
34
|
+
end
|
35
|
+
|
36
|
+
def test_columns
|
37
|
+
assert_raises( UnknownObjectException ){ $ie.table(:xpath , "//table[@id='missingTable']/").column_count }
|
38
|
+
assert_equal( 1 , $ie.table(:xpath , "//table[@id='t1']/").column_count) # row one has 1 cell with a colspan of 2
|
39
|
+
end
|
40
|
+
|
41
|
+
def test_links_and_images_in_table
|
42
|
+
table = $ie.table(:xpath , "//table[@id='pic_table']/")
|
43
|
+
image = table[1][2].image(:index,1)
|
44
|
+
assert_equal("106", image.width)
|
45
|
+
|
46
|
+
link = table[1][4].link(:index,1)
|
47
|
+
assert_equal("Google", link.innerText)
|
48
|
+
end
|
49
|
+
|
50
|
+
def test_table_from_element
|
51
|
+
$ie.goto($htmlRoot + "simple_table_buttons.html")
|
52
|
+
|
53
|
+
button = $ie.button(:xpath , "//input[@id='b1']/")
|
54
|
+
table = Table.create_from_element($ie,button)
|
55
|
+
|
56
|
+
table[2][1].button(:index,1).click
|
57
|
+
assert($ie.text_field(:name,"confirmtext").verify_contains(/CLICK2/i))
|
58
|
+
end
|
59
|
+
|
60
|
+
def test_cell_directly
|
61
|
+
|
62
|
+
assert( $ie.cell(:xpath , "//td[@id='cell1']/").exists? )
|
63
|
+
assert(! $ie.cell(:xpath , "//td[@id='no_exist']/").exists? )
|
64
|
+
assert_equal( "Row 1 Col1", $ie.cell(:xpath , "//td[@id='cell1']/").to_s.strip )
|
65
|
+
end
|
66
|
+
|
67
|
+
def test_row_directly
|
68
|
+
assert( $ie.row(:xpath , "//tr[@id='row1']/").exists? )
|
69
|
+
assert(! $ie.row(:xpath , "//tr[@id='no_exist']/").exists? )
|
70
|
+
|
71
|
+
assert_equal('Row 2 Col1' , $ie.row(:xpath , "//tr[@id='row1']/")[1].to_s.strip )
|
72
|
+
end
|
73
|
+
|
74
|
+
|
75
|
+
def test_table_body
|
76
|
+
assert_equal( 3, $ie.table(:xpath , "//table[@id='body_test']/").bodies.length )
|
77
|
+
|
78
|
+
count = 1
|
79
|
+
$ie.table(:xpath , "//table[@id='body_test']/").bodies.each do |n|
|
80
|
+
|
81
|
+
# do something better here!
|
82
|
+
# n.flash # this line commented out to speed up the test
|
83
|
+
|
84
|
+
case count
|
85
|
+
when 1
|
86
|
+
compare_text = "This text is in the FRST TBODY."
|
87
|
+
when 2
|
88
|
+
compare_text = "This text is in the SECOND TBODY."
|
89
|
+
when 3
|
90
|
+
compare_text = "This text is in the THIRD TBODY."
|
91
|
+
end
|
92
|
+
|
93
|
+
assert_equal( compare_text , n[1][1].to_s.strip ) # this is the 1st cell of the first row of this particular body
|
94
|
+
|
95
|
+
count +=1
|
96
|
+
end
|
97
|
+
assert_equal( count-1, $ie.table(:xpath , "//table[@id='body_test']/").bodies.length )
|
98
|
+
|
99
|
+
assert_equal( "This text is in the THIRD TBODY." ,$ie.table(:xpath , "//table[@id='body_test']/").body(:index,3)[1][1].to_s.strip )
|
100
|
+
|
101
|
+
# iterate through all the rows in a table body
|
102
|
+
count = 1
|
103
|
+
$ie.table(:xpath , "//table[@id='body_test']/").body(:index,2).each do | row |
|
104
|
+
# row.flash # this line commented out, to speed up the tests
|
105
|
+
if count == 1
|
106
|
+
assert_equal('This text is in the SECOND TBODY.' , row[1].text.strip )
|
107
|
+
elsif count == 1
|
108
|
+
assert_equal('This text is also in the SECOND TBODY.' , row[1].text.strip )
|
109
|
+
end
|
110
|
+
count+=1
|
111
|
+
end
|
112
|
+
end
|
113
|
+
|
114
|
+
end
|
@@ -0,0 +1,81 @@
|
|
1
|
+
# feature tests for TextArea Fields
|
2
|
+
# revision: $Revision: 963 $
|
3
|
+
|
4
|
+
$LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..') if $0 == __FILE__
|
5
|
+
require 'unittests/setup'
|
6
|
+
|
7
|
+
class TC_TextArea < Test::Unit::TestCase
|
8
|
+
include Watir
|
9
|
+
|
10
|
+
def goto_page
|
11
|
+
$ie.goto($htmlRoot + "textArea.html")
|
12
|
+
end
|
13
|
+
|
14
|
+
def test_textarea_field_exists
|
15
|
+
goto_page
|
16
|
+
#test for existance of 4 text area
|
17
|
+
assert($ie.text_field(:name,"txtMultiLine1").exists?)
|
18
|
+
assert($ie.text_field(:name,"txtMultiLine2").exists?)
|
19
|
+
assert($ie.text_field(:name,"txtMultiLine3").exists?)
|
20
|
+
assert($ie.text_field(:name,"txtReadOnly").exists?)
|
21
|
+
|
22
|
+
assert($ie.text_field(:id,"txtMultiLine1").exists?)
|
23
|
+
assert($ie.text_field(:id,"txtMultiLine2").exists?)
|
24
|
+
assert($ie.text_field(:id,"txtMultiLine3").exists?)
|
25
|
+
assert($ie.text_field(:id,"txtReadOnly").exists?)
|
26
|
+
#test for missing
|
27
|
+
assert(!$ie.text_field(:name, "missing").exists?)
|
28
|
+
assert(!$ie.text_field(:name,"txtMultiLine4").exists?)
|
29
|
+
end
|
30
|
+
|
31
|
+
def test_textarea_to_s
|
32
|
+
# from a bug reported by Zeljko Filipin
|
33
|
+
assert_nothing_raised { $ie.text_field(:id,"txtMultiLine3").to_s }
|
34
|
+
end
|
35
|
+
|
36
|
+
def test_textarea_field
|
37
|
+
goto_page
|
38
|
+
|
39
|
+
# test for read only method
|
40
|
+
assert(!$ie.text_field(:name, "txtMultiLine1").readonly? )
|
41
|
+
assert($ie.text_field(:name,"txtReadOnly").readonly?)
|
42
|
+
|
43
|
+
# test for enabled? method
|
44
|
+
assert(!$ie.text_field(:name, "txtDisabled").enabled? )
|
45
|
+
assert($ie.text_field(:id, "txtMultiLine1").enabled? )
|
46
|
+
|
47
|
+
|
48
|
+
t1 = $ie.text_field(:name, "txtMultiLine1")
|
49
|
+
assert(t1.verify_contains("Hello World") )
|
50
|
+
assert(t1.verify_contains(/el/) )
|
51
|
+
t2 = $ie.text_field(:name, "txtMultiLine2")
|
52
|
+
assert(t2.verify_contains(/IE/))
|
53
|
+
assert_raises(UnknownObjectException , "UnknownObjectException was supposed to be thrown" ) { $ie.text_field(:name, "NoName").verify_contains("No field to get a value of") }
|
54
|
+
assert_raises(UnknownObjectException , "UnknownObjectException was supposed to be thrown" ) { $ie.text_field(:id, "noID").verify_contains("No field to get a value of") }
|
55
|
+
|
56
|
+
assert_raises(UnknownObjectException , "ObjectReadOnlyException was supposed to be thrown" ) { $ie.text_field(:name, "txtNone").append("Some Text") }
|
57
|
+
|
58
|
+
assert_raises(ObjectReadOnlyException , "ObjectReadOnlyException was supposed to be thrown" ) { $ie.text_field(:id, "txtReadOnly").append("Some Text") }
|
59
|
+
assert_raises(ObjectDisabledException , "ObjectDisabledException was supposed to be thrown" ) { $ie.text_field(:name, "txtDisabled").append("Some Text") }
|
60
|
+
assert_raises(UnknownObjectException , "UnknownObjectException was supposed to be thrown" ) { $ie.text_field(:name, "missing_field").append("Some Text") }
|
61
|
+
|
62
|
+
$ie.text_field(:name, "txtMultiLine1").append(" Some Text")
|
63
|
+
assert_equal( "Hello World Some Text" , $ie.text_field(:name, "txtMultiLine1").getContents )
|
64
|
+
|
65
|
+
assert_raises(ObjectReadOnlyException , "ObjectReadOnlyException was supposed to be thrown" ) { $ie.text_field(:id, "txtReadOnly").append("Some Text") }
|
66
|
+
assert_raises(ObjectDisabledException , "ObjectReadOnlyException was supposed to be thrown" ) { $ie.text_field(:name, "txtDisabled").append("Some Text") }
|
67
|
+
assert_raises(UnknownObjectException , "ObjectReadOnlyException was supposed to be thrown" ) { $ie.text_field(:name, "missing_field").append("Some Text") }
|
68
|
+
|
69
|
+
$ie.text_field(:name, "txtMultiLine1").set("watir IE Controller")
|
70
|
+
assert_equal( "watir IE Controller" , $ie.text_field(:name, "txtMultiLine1").getContents )
|
71
|
+
|
72
|
+
assert_raises(ObjectReadOnlyException , "ObjectReadOnlyException was supposed to be thrown" ) { $ie.text_field(:id, "txtReadOnly").append("Some Text") }
|
73
|
+
assert_raises(ObjectDisabledException , "ObjectReadOnlyException was supposed to be thrown" ) { $ie.text_field(:name, "txtDisabled").append("Some Text") }
|
74
|
+
assert_raises(UnknownObjectException , "ObjectReadOnlyException was supposed to be thrown" ) { $ie.text_field(:name, "missing_field").append("Some Text") }
|
75
|
+
|
76
|
+
$ie.text_field(:name, "txtMultiLine2").clear
|
77
|
+
assert_equal( "" , $ie.text_field(:name, "txtMultiLine2").getContents )
|
78
|
+
|
79
|
+
end
|
80
|
+
|
81
|
+
end
|
@@ -0,0 +1,82 @@
|
|
1
|
+
# feature tests for TextArea Fields
|
2
|
+
# revision: $Revision: 963 $
|
3
|
+
|
4
|
+
$LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..') if $0 == __FILE__
|
5
|
+
require 'unittests/setup'
|
6
|
+
|
7
|
+
class TC_TextArea_XPath < Test::Unit::TestCase
|
8
|
+
include Watir
|
9
|
+
|
10
|
+
def goto_page
|
11
|
+
$ie.goto($htmlRoot + "textArea.html")
|
12
|
+
end
|
13
|
+
|
14
|
+
def test_textarea_field_exists
|
15
|
+
goto_page
|
16
|
+
#test for existance of 4 text area
|
17
|
+
assert($ie.text_field(:xpath , "//textarea[@name='txtMultiLine1']/").exists?)
|
18
|
+
assert($ie.text_field(:xpath , "//textarea[@name='txtMultiLine2']/").exists?)
|
19
|
+
assert($ie.text_field(:xpath , "//textarea[@name='txtMultiLine3']/").exists?)
|
20
|
+
assert($ie.text_field(:xpath , "//textarea[@name='txtReadOnly']/").exists?)
|
21
|
+
|
22
|
+
assert($ie.text_field(:xpath , "//textarea[@id='txtMultiLine1']/").exists?)
|
23
|
+
assert($ie.text_field(:xpath , "//textarea[@id='txtMultiLine2']/").exists?)
|
24
|
+
assert($ie.text_field(:xpath , "//textarea[@id='txtMultiLine3']/").exists?)
|
25
|
+
assert($ie.text_field(:xpath , "//textarea[@id='txtReadOnly']/").exists?)
|
26
|
+
#test for missing
|
27
|
+
assert(!$ie.text_field(:xpath , "//textarea[@name='missing']/").exists?)
|
28
|
+
assert(!$ie.text_field(:xpath , "//textarea[@name='txtMultiLine4']/").exists?)
|
29
|
+
end
|
30
|
+
|
31
|
+
def test_textarea_to_s
|
32
|
+
# bug reported by Zeljko Filipin
|
33
|
+
# assert_nothing_raised { $ie.text_field(:xpath , "//textarea[@id='txtMultiLine3']/").to_s }
|
34
|
+
# The above assertion fails. No property or method called maxlength
|
35
|
+
end
|
36
|
+
|
37
|
+
def test_textarea_field
|
38
|
+
goto_page
|
39
|
+
|
40
|
+
# test for read only method
|
41
|
+
assert(!$ie.text_field(:xpath , "//textarea[@name='txtMultiLine1']/").readonly? )
|
42
|
+
assert($ie.text_field(:xpath , "//textarea[@name='txtReadOnly']/").readonly?)
|
43
|
+
|
44
|
+
# test for enabled? method
|
45
|
+
assert(!$ie.text_field(:xpath , "//textarea[@name='txtDisabled']/").enabled? )
|
46
|
+
assert($ie.text_field(:xpath , "//textarea[@id='txtMultiLine1']/").enabled? )
|
47
|
+
|
48
|
+
|
49
|
+
t1 = $ie.text_field(:xpath , "//textarea[@name='txtMultiLine1']/")
|
50
|
+
assert(t1.verify_contains("Hello World") )
|
51
|
+
assert(t1.verify_contains(/el/) )
|
52
|
+
t2 = $ie.text_field(:xpath , "//textarea[@name='txtMultiLine2']/")
|
53
|
+
assert(t2.verify_contains(/IE/))
|
54
|
+
assert_raises(UnknownObjectException , "UnknownObjectException was supposed to be thrown" ) { $ie.text_field(:xpath , "//textarea[@name='NoName']/").verify_contains("No field to get a value of") }
|
55
|
+
assert_raises(UnknownObjectException , "UnknownObjectException was supposed to be thrown" ) { $ie.text_field(:xpath , "//textarea[@id='noID']/").verify_contains("No field to get a value of") }
|
56
|
+
|
57
|
+
assert_raises(UnknownObjectException , "ObjectReadOnlyException was supposed to be thrown" ) { $ie.text_field(:xpath , "//textarea[@name='txtNone']/").append("Some Text") }
|
58
|
+
|
59
|
+
assert_raises(ObjectReadOnlyException , "ObjectReadOnlyException was supposed to be thrown" ) { $ie.text_field(:xpath , "//textarea[@id='txtReadOnly']/").append("Some Text") }
|
60
|
+
assert_raises(ObjectDisabledException , "ObjectDisabledException was supposed to be thrown" ) { $ie.text_field(:xpath , "//textarea[@name='txtDisabled']/").append("Some Text") }
|
61
|
+
assert_raises(UnknownObjectException , "UnknownObjectException was supposed to be thrown" ) { $ie.text_field(:xpath , "//textarea[@name='missing_field']/").append("Some Text") }
|
62
|
+
|
63
|
+
$ie.text_field(:xpath , "//textarea[@name='txtMultiLine1']/").append(" Some Text")
|
64
|
+
assert_equal( "Hello World Some Text" , $ie.text_field(:xpath , "//textarea[@name='txtMultiLine1']/").value)
|
65
|
+
|
66
|
+
assert_raises(ObjectReadOnlyException , "ObjectReadOnlyException was supposed to be thrown" ) { $ie.text_field(:xpath , "//textarea[@id='txtReadOnly']/").append("Some Text") }
|
67
|
+
assert_raises(ObjectDisabledException , "ObjectReadOnlyException was supposed to be thrown" ) { $ie.text_field(:xpath , "//textarea[@name='txtDisabled']/").append("Some Text") }
|
68
|
+
assert_raises(UnknownObjectException , "ObjectReadOnlyException was supposed to be thrown" ) { $ie.text_field(:xpath , "//textarea[@name='missing_field']/").append("Some Text") }
|
69
|
+
|
70
|
+
$ie.text_field(:xpath , "//textarea[@name='txtMultiLine1']/").set("watir IE Controller")
|
71
|
+
assert_equal( "watir IE Controller" , $ie.text_field(:xpath , "//textarea[@name='txtMultiLine1']/").value )
|
72
|
+
|
73
|
+
assert_raises(ObjectReadOnlyException , "ObjectReadOnlyException was supposed to be thrown" ) { $ie.text_field(:xpath , "//textarea[@id='txtReadOnly']/").append("Some Text") }
|
74
|
+
assert_raises(ObjectDisabledException , "ObjectReadOnlyException was supposed to be thrown" ) { $ie.text_field(:xpath , "//textarea[@name='txtDisabled']/").append("Some Text") }
|
75
|
+
assert_raises(UnknownObjectException , "ObjectReadOnlyException was supposed to be thrown" ) { $ie.text_field(:xpath , "//textarea[@name='missing_field']/").append("Some Text") }
|
76
|
+
|
77
|
+
$ie.text_field(:xpath , "//textarea[@name='txtMultiLine2']/").clear
|
78
|
+
assert_equal( "" , $ie.text_field(:xpath , "//textarea[@name='txtMultiLine2']/").value )
|
79
|
+
|
80
|
+
end
|
81
|
+
|
82
|
+
end
|
@@ -1,239 +1,215 @@
|
|
1
|
-
# feature tests for Text Fields
|
2
|
-
# revision: $Revision:
|
1
|
+
# feature tests for Text Fields & Labels
|
2
|
+
# revision: $Revision: 1196 $
|
3
3
|
|
4
4
|
$LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..') if $0 == __FILE__
|
5
5
|
require 'unittests/setup'
|
6
6
|
|
7
7
|
class TC_Fields < Test::Unit::TestCase
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
assert($ie.text_field(:id, "text2").exists?)
|
19
|
-
assert_false($ie.text_field(:id, "alsomissing").exists?)
|
20
|
-
|
21
|
-
assert($ie.text_field(:beforeText , "This Text After").exists? )
|
22
|
-
assert($ie.text_field(:afterText , "This Text Before").exists? )
|
23
|
-
|
24
|
-
assert($ie.text_field(:beforeText , /after/i).exists? )
|
25
|
-
assert($ie.text_field(:afterText , /before/i).exists? )
|
26
|
-
end
|
27
|
-
|
28
|
-
def test_text_field_dragContentsTo
|
29
|
-
$ie.text_field(:name, "text1").dragContentsTo(:id, "text2")
|
30
|
-
assert_equal($ie.text_field(:name, "text1").getContents, "" )
|
31
|
-
assert_equal($ie.text_field(:id, "text2").getContents, "goodbye allHello World" )
|
32
|
-
end
|
33
|
-
|
34
|
-
def test_text_field_VerifyContents
|
35
|
-
assert($ie.text_field(:name, "text1").verify_contains("Hello World") )
|
36
|
-
assert($ie.text_field(:name, "text1").verify_contains(/Hello\sW/ ) )
|
37
|
-
assert_false($ie.text_field(:name, "text1").verify_contains("Ruby") )
|
38
|
-
assert_false($ie.text_field(:name, "text1").verify_contains(/R/) )
|
39
|
-
assert_raises(UnknownObjectException , "UnknownObjectException was supposed to be thrown" ) { $ie.text_field(:name, "NoName").verify_contains("No field to get a value of") }
|
40
|
-
|
41
|
-
assert($ie.text_field(:id, "text2").verify_contains("goodbye all") )
|
42
|
-
assert_raises(UnknownObjectException , "UnknownObjectException was supposed to be thrown" ) { $ie.text_field(:id, "noID").verify_contains("No field to get a value of") }
|
43
|
-
|
44
|
-
end
|
45
|
-
|
46
|
-
def test_text_field_enabled
|
47
|
-
assert_false($ie.text_field(:name, "disabled").enabled? )
|
48
|
-
assert($ie.text_field(:name, "text1").enabled? )
|
49
|
-
assert($ie.text_field(:id, "text2").enabled? )
|
50
|
-
end
|
51
|
-
|
52
|
-
def test_text_field_readOnly
|
53
|
-
assert_false($ie.text_field(:name, "disabled").readonly? )
|
54
|
-
assert($ie.text_field(:name, "readOnly").readonly? )
|
55
|
-
assert($ie.text_field(:id, "readOnly2").readonly? )
|
56
|
-
end
|
57
|
-
|
58
|
-
def test_text_field_getContents()
|
59
|
-
assert_raises(UnknownObjectException , "ObjectReadOnlyException was supposed to be thrown" ) { $ie.text_field(:name, "missing_field").append("Some Text") }
|
60
|
-
assert_equal( "Hello World" , $ie.text_field(:name, "text1").getContents )
|
61
|
-
end
|
62
|
-
|
63
|
-
def test_TextField_to_s
|
64
|
-
expected = [build_to_s_regex("type", "text"),
|
65
|
-
build_to_s_regex("id", ""),
|
66
|
-
build_to_s_regex("name", "text1"),
|
67
|
-
build_to_s_regex("value", "Hello World"),
|
68
|
-
build_to_s_regex("disabled", "false"),
|
69
|
-
build_to_s_regex("length", "20"),
|
70
|
-
build_to_s_regex("max length", "2147483647"),
|
71
|
-
build_to_s_regex("read only", "false")]
|
72
|
-
items = $ie.text_field(:index, 1).to_s.split(/\n/)
|
73
|
-
expected.each_with_index{|regex, x| assert(regex =~ items[x]) }
|
74
|
-
expected[1] = build_to_s_regex("id", "text2")
|
75
|
-
expected[2] = build_to_s_regex("name", "")
|
76
|
-
expected[3] = build_to_s_regex("value", "goodbye all")
|
77
|
-
items = $ie.text_field(:index, 2).to_s.split(/\n/)
|
78
|
-
expected.each_with_index{|regex, x| assert(regex =~ items[x]) }
|
79
|
-
assert_raises(UnknownObjectException , "UnknownObjectException was supposed to be thrown" ) { $ie.text_field(:index, 999 ).to_s}
|
80
|
-
end
|
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(:name, "text1").exists?)
|
16
|
+
assert(!$ie.text_field(:name, "missing").exists?)
|
81
17
|
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
18
|
+
assert($ie.text_field(:id, "text2").exists?)
|
19
|
+
assert(!$ie.text_field(:id, "alsomissing").exists?)
|
20
|
+
|
21
|
+
assert($ie.text_field(:beforeText, "This Text After").exists? )
|
22
|
+
assert($ie.text_field(:afterText, "This Text Before").exists? )
|
23
|
+
|
24
|
+
assert($ie.text_field(:beforeText, /after/i).exists? )
|
25
|
+
assert($ie.text_field(:afterText, /before/i).exists? )
|
26
|
+
end
|
27
|
+
|
28
|
+
def test_text_field_dragContentsTo
|
29
|
+
$ie.text_field(:name, "text1").dragContentsTo(:id, "text2")
|
30
|
+
assert_equal($ie.text_field(:name, "text1").getContents, "")
|
31
|
+
assert_equal($ie.text_field(:id, "text2").getContents, "goodbye allHello World")
|
32
|
+
end
|
33
|
+
|
34
|
+
def test_text_field_verify_contains
|
35
|
+
assert($ie.text_field(:name, "text1").verify_contains("Hello World"))
|
36
|
+
assert($ie.text_field(:name, "text1").verify_contains(/Hello\sW/))
|
37
|
+
assert(!$ie.text_field(:name, "text1").verify_contains("Ruby"))
|
38
|
+
assert(!$ie.text_field(:name, "text1").verify_contains(/R/))
|
39
|
+
assert_raises(UnknownObjectException) { $ie.text_field(:name, "NoName").verify_contains("No field to get a value of") }
|
40
|
+
|
41
|
+
assert($ie.text_field(:id, "text2").verify_contains("goodbye all") )
|
42
|
+
assert_raises(UnknownObjectException) { $ie.text_field(:id, "noID").verify_contains("No field to get a value of") }
|
43
|
+
end
|
44
|
+
|
45
|
+
def test_text_field_enabled
|
46
|
+
assert(!$ie.text_field(:name, "disabled").enabled? )
|
47
|
+
assert($ie.text_field(:name, "text1").enabled? )
|
48
|
+
assert($ie.text_field(:id, "text2").enabled? )
|
49
|
+
end
|
50
|
+
|
51
|
+
def test_text_field_readonly
|
52
|
+
assert(!$ie.text_field(:name, "disabled").readonly? )
|
53
|
+
assert($ie.text_field(:name, "readOnly").readonly? )
|
54
|
+
assert($ie.text_field(:id, "readOnly2").readonly? )
|
55
|
+
end
|
56
|
+
|
57
|
+
def test_text_field_get_contents
|
58
|
+
assert_raises(UnknownObjectException) { $ie.text_field(:name, "missing_field").append("Some Text") }
|
59
|
+
assert_equal("Hello World", $ie.text_field(:name, "text1").getContents)
|
60
|
+
end
|
61
|
+
|
62
|
+
def test_text_field_to_s
|
63
|
+
expected = [
|
64
|
+
build_to_s_regex("type", "text"),
|
65
|
+
build_to_s_regex("id", ""),
|
66
|
+
build_to_s_regex("name", "text1"),
|
67
|
+
build_to_s_regex("value", "Hello World"),
|
68
|
+
build_to_s_regex("disabled", "false"),
|
69
|
+
build_to_s_regex("length", "20"),
|
70
|
+
build_to_s_regex("max length", "20"),
|
71
|
+
build_to_s_regex("read only", "false")
|
72
|
+
]
|
73
|
+
items = $ie.text_field(:index, 1).to_s.split(/\n/)
|
74
|
+
expected.each_with_index{|regex, x| assert_match(regex, items[x]) }
|
75
|
+
expected[1] = build_to_s_regex("id", "text2")
|
76
|
+
expected[2] = build_to_s_regex("name", "")
|
77
|
+
expected[3] = build_to_s_regex("value", "goodbye all")
|
78
|
+
expected[6] = build_to_s_regex("max length", "2147483647")
|
79
|
+
|
80
|
+
items = $ie.text_field(:index, 2).to_s.split(/\n/)
|
81
|
+
expected.each_with_index{|regex, x| assert_match(regex, items[x]) }
|
82
|
+
assert_raises(UnknownObjectException) { $ie.text_field(:index, 999).to_s }
|
83
|
+
end
|
84
|
+
|
85
|
+
def build_to_s_regex(lhs, rhs)
|
86
|
+
Regexp.new("^#{lhs}: +#{rhs}$")
|
87
|
+
end
|
88
|
+
|
89
|
+
def test_text_field_append
|
90
|
+
assert_raises(ObjectReadOnlyException) { $ie.text_field(:id, "readOnly2").append("Some Text") }
|
91
|
+
assert_raises(ObjectDisabledException) { $ie.text_field(:name, "disabled").append("Some Text") }
|
92
|
+
assert_raises(UnknownObjectException) { $ie.text_field(:name, "missing_field").append("Some Text") }
|
93
|
+
|
94
|
+
$ie.text_field(:name, "text1").append(" Some Text")
|
95
|
+
assert_equal("Hello World Some Text", $ie.text_field(:name, "text1").getContents)
|
96
|
+
end
|
97
|
+
|
98
|
+
def test_text_field_clear
|
99
|
+
$ie.text_field(:name, "text1").clear
|
100
|
+
assert_equal("", $ie.text_field(:name, "text1").getContents)
|
101
|
+
end
|
102
|
+
|
103
|
+
def test_text_field_set
|
104
|
+
$ie.text_field(:name, "text1").set("watir IE Controller")
|
105
|
+
assert_equal("watir IE Controller" , $ie.text_field(:name, "text1").getContents)
|
106
|
+
# adding for issue: http://jira.openqa.org/browse/WTR-89
|
107
|
+
$ie.text_field(:name, /reGex/i).set("pass")
|
108
|
+
assert_equal("pass", $ie.text_field(:name, /REgEx/i).getContents)
|
109
|
+
end
|
110
|
+
|
111
|
+
def test_text_field_properties
|
112
|
+
assert_raises(UnknownObjectException) { $ie.text_field(:index, 199).value }
|
113
|
+
assert_raises(UnknownObjectException) { $ie.text_field(:index, 199).name }
|
114
|
+
assert_raises(UnknownObjectException) { $ie.text_field(:index, 199).id }
|
115
|
+
assert_raises(UnknownObjectException) { $ie.text_field(:index, 199).disabled }
|
116
|
+
assert_raises(UnknownObjectException) { $ie.text_field(:index, 199).type }
|
117
|
+
|
118
|
+
assert_equal("Hello World" , $ie.text_field(:index, 1).value)
|
119
|
+
assert_equal("text" , $ie.text_field(:index, 1).type)
|
120
|
+
assert_equal("text1" , $ie.text_field(:index, 1).name)
|
121
|
+
assert_equal("" , $ie.text_field(:index, 1).id)
|
122
|
+
assert_equal(false , $ie.text_field(:index, 1).disabled)
|
123
|
+
|
124
|
+
assert_equal("" , $ie.text_field(:index, 2).name)
|
125
|
+
assert_equal("text2" , $ie.text_field(:index, 2).id)
|
126
|
+
|
127
|
+
assert($ie.text_field(:index, 4).disabled)
|
128
|
+
|
129
|
+
assert_equal("This used to test :afterText", $ie.text_field(:name, "aftertest").title)
|
130
|
+
assert_equal("", $ie.text_field(:index, 1).title)
|
131
|
+
# adding for issue: http://jira.openqa.org/browse/WTR-89
|
132
|
+
assert_equal("RegEx test", $ie.text_field(:name, /REgEx/i).value)
|
133
|
+
end
|
134
|
+
|
135
|
+
def test_text_field_iterators
|
136
|
+
assert_equal(13, $ie.text_fields.length)
|
137
|
+
|
138
|
+
# watir is 1 based, so this is the first text field
|
139
|
+
assert_equal("Hello World" , $ie.text_fields[1].value)
|
140
|
+
assert_equal("text1" , $ie.text_fields[1].name)
|
141
|
+
assert_equal("password" , $ie.text_fields[$ie.text_fields.length].type)
|
142
|
+
|
143
|
+
index = 1
|
144
|
+
$ie.text_fields.each do |t|
|
145
|
+
assert_equal($ie.text_field(:index, index).value, t.value)
|
146
|
+
assert_equal($ie.text_field(:index, index).id, t.id)
|
147
|
+
assert_equal($ie.text_field(:index, index).name, t.name)
|
148
|
+
index += 1
|
149
|
+
end
|
150
|
+
assert_equal(index - 1, $ie.text_fields.length)
|
151
|
+
end
|
152
|
+
|
153
|
+
def test_JS_Events
|
154
|
+
$ie.text_field(:name, 'events_tester').set('p')
|
155
|
+
|
156
|
+
# the following line has an extra keypress at the begining, as we mimic the delete key being pressed
|
157
|
+
assert_equal( "keypresskeydownkeypresskeyup" , $ie.text_field(:name , 'events_text').value.gsub("\r\n" , "") )
|
158
|
+
$ie.button(:value , "Clear Events Box").click
|
159
|
+
$ie.text_field(:name , 'events_tester').set('ab')
|
160
|
+
|
161
|
+
# the following line has an extra keypress at the begining, as we mimic the delete key being pressed
|
162
|
+
assert_equal( "keypresskeydownkeypresskeyupkeydownkeypresskeyup" , $ie.text_field(:name , 'events_text').value.gsub("\r\n" , "") )
|
163
|
+
end
|
164
|
+
|
165
|
+
def test_password
|
166
|
+
$ie.text_field(:name , "password1").set("secret")
|
167
|
+
assert( 'secret' , $ie.text_field(:name , "password1").value )
|
168
|
+
|
169
|
+
$ie.text_field(:id , "password1").set("top_secret")
|
170
|
+
assert( 'top_secret' , $ie.text_field(:id, "password1").value )
|
171
|
+
end
|
172
|
+
|
173
|
+
def test_labels_iterator
|
174
|
+
assert_equal(3, $ie.labels.length)
|
175
|
+
assert_equal('Label For this Field' , $ie.labels[1].innerText.strip )
|
176
|
+
assert_equal('Password With ID ( the text here is a label for it )' , $ie.labels[3].innerText )
|
177
|
+
|
178
|
+
count=0
|
179
|
+
$ie.labels.each do |l|
|
180
|
+
count +=1
|
181
|
+
end
|
182
|
+
assert_equal(count, $ie.labels.length)
|
183
|
+
end
|
184
|
+
|
185
|
+
def test_label_properties
|
186
|
+
assert_raises(UnknownObjectException) { $ie.label(:index,20).innerText }
|
187
|
+
assert_raises(UnknownObjectException) { $ie.label(:index,20).for }
|
188
|
+
assert_raises(UnknownObjectException) { $ie.label(:index,20).name }
|
189
|
+
assert_raises(UnknownObjectException) { $ie.label(:index,20).type }
|
190
|
+
assert_raises(UnknownObjectException) { $ie.label(:index,20).id }
|
191
|
+
|
192
|
+
assert(!$ie.label(:index,10).exists?)
|
193
|
+
assert(!$ie.label(:id,'missing').exists?)
|
194
|
+
assert($ie.label(:index,1).exists?)
|
195
|
+
|
196
|
+
assert_equal("", $ie.label(:index,1).id)
|
197
|
+
assert(! $ie.label(:index,1).disabled?)
|
198
|
+
assert( $ie.label(:index,1).enabled?)
|
199
|
+
|
200
|
+
assert_equal("label2", $ie.label(:index,2).id )
|
201
|
+
|
202
|
+
assert_equal("Password With ID ( the text here is a label for it )" , $ie.label(:index,3).innerText)
|
203
|
+
assert_equal("password1", $ie.label(:index,3).for)
|
204
|
+
end
|
235
205
|
|
206
|
+
def test_max_length_is_not_exceeded
|
207
|
+
$ie.text_field(:name , 'text1').set("abcdefghijklmnopqrstuv")
|
208
|
+
assert_equal("abcdefghijklmnopqrst", $ie.text_field(:name , 'text1').value )
|
209
|
+
end
|
236
210
|
|
237
|
-
|
211
|
+
def test_max_length
|
212
|
+
assert_equal(20, $ie.text_field(:name , 'text1').maxLength )
|
238
213
|
|
214
|
+
end
|
239
215
|
end
|