watir 1.5.6 → 1.6.2
Sign up to get free protection for your applications and to get access to all the features.
- data/{changes.rb → CHANGES} +12 -3
- data/bin/watir-console +7 -1
- data/lib/changes.rb +3 -0
- data/{license.rb → lib/license.rb} +2 -1
- data/{readme.rb → lib/readme.rb} +4 -6
- data/{watir → lib/watir}/AutoItX3.dll +0 -0
- data/{watir → lib/watir}/IEDialog/Release/IEDialog.dll +0 -0
- data/{watir → lib/watir}/WindowHelper.rb +1 -1
- data/{watir → lib/watir}/camel_case.rb +0 -0
- data/{watir → lib/watir}/clickJSDialog.rb +0 -0
- data/{watir → lib/watir}/close_all.rb +1 -1
- data/{watir → lib/watir}/collections.rb +1 -1
- data/{watir → lib/watir}/container.rb +17 -8
- data/{watir → lib/watir}/contrib/enabled_popup.rb +0 -0
- data/{watir → lib/watir}/contrib/ie-new-process.rb +0 -0
- data/{watir → lib/watir}/contrib/page_checker.rb +0 -0
- data/{watir → lib/watir}/contrib/visible.rb +2 -2
- data/{watir → lib/watir}/cookiemanager.rb +0 -0
- data/{watir → lib/watir}/datahandler.rb +0 -0
- data/{watir → lib/watir}/dialog.rb +1 -1
- data/{watir → lib/watir}/element.rb +3 -7
- data/{watir → lib/watir}/element_collections.rb +0 -0
- data/{watir → lib/watir}/form.rb +31 -11
- data/{watir → lib/watir}/frame.rb +0 -0
- data/{watir/ie.rb → lib/watir/ie-class.rb} +22 -22
- data/{watir → lib/watir}/ie-process.rb +0 -0
- data/{watir.rb → lib/watir/ie.rb} +11 -27
- data/{watir → lib/watir}/image.rb +0 -0
- data/{watir → lib/watir}/input_elements.rb +33 -44
- data/{watir → lib/watir}/irb-history.rb +0 -0
- data/{watir → lib/watir}/link.rb +0 -0
- data/{watir → lib/watir}/locator.rb +56 -43
- data/{watir → lib/watir}/logger.rb +0 -0
- data/{watir → lib/watir}/modal_dialog.rb +0 -0
- data/{watir → lib/watir}/non_control_elements.rb +0 -0
- data/{watir → lib/watir}/page-container.rb +2 -2
- data/{watir → lib/watir}/popup.rb +0 -0
- data/{watir → lib/watir}/process.rb +0 -0
- data/{watir → lib/watir}/screen_capture.rb +0 -0
- data/{watir → lib/watir}/setFileDialog.rb +0 -0
- data/{watir → lib/watir}/table.rb +7 -2
- data/{watir → lib/watir}/utils.rb +0 -0
- data/lib/watir/version.rb +5 -0
- data/{watir → lib/watir}/watir_simple.rb +3 -3
- data/{watir → lib/watir}/win32.rb +0 -0
- data/lib/watir/win32ole.rb +6 -0
- data/lib/watir/win32ole/win32ole.so +0 -0
- data/{watir → lib/watir}/winClicker.rb +0 -0
- data/unittests/buttons_xpath_test.rb +32 -32
- data/unittests/checkbox_test.rb +113 -99
- data/unittests/checkbox_xpath_test.rb +57 -57
- data/unittests/core_tests.rb +10 -7
- data/unittests/css_test.rb +12 -32
- data/unittests/defer_test.rb +22 -22
- data/unittests/dialog_test.rb +13 -13
- data/unittests/div2_xpath_test.rb +3 -3
- data/unittests/div_test.rb +23 -19
- data/unittests/div_xpath_test.rb +50 -50
- data/unittests/errorchecker_test.rb +7 -9
- data/unittests/filefield_test.rb +12 -11
- data/unittests/filefield_xpath_test.rb +10 -10
- data/unittests/form_test.rb +144 -151
- data/unittests/form_xpath_test.rb +99 -99
- data/unittests/frame_test.rb +46 -44
- data/unittests/google_form_test.rb +2 -2
- data/unittests/html/checkboxes1.html +19 -16
- data/unittests/html/forms3.html +2 -2
- data/unittests/html/wallofcheckboxes.html +1003 -0
- data/unittests/ie_exists_test.rb +5 -3
- data/unittests/ie_test.rb +2 -2
- data/unittests/images_test.rb +83 -82
- data/unittests/images_xpath_test.rb +40 -40
- data/unittests/iostring_test.rb +1 -1
- data/unittests/links_multi_test.rb +7 -8
- data/unittests/links_test.rb +73 -71
- data/unittests/links_xpath_test.rb +15 -15
- data/unittests/lists_test.rb +10 -10
- data/unittests/map_test.rb +65 -65
- data/unittests/minmax_test.rb +10 -9
- data/unittests/navigate_test.rb +19 -23
- data/unittests/nbsp_xpath_test.rb +2 -2
- data/unittests/non_core_tests.rb +5 -2
- data/unittests/other/WindowLogonExample.rb +2 -2
- data/unittests/other/WindowLogonExtra.rb +1 -1
- data/unittests/other/navigate_exception_test.rb +14 -3
- data/unittests/other/screen_capture_test.rb +3 -2
- data/unittests/other/testcase_method_order_test.rb +1 -1
- data/unittests/pagecontainstext_test.rb +17 -14
- data/unittests/parent_child_test.rb +11 -7
- data/unittests/perf_test.rb +20 -0
- data/unittests/popups_test.rb +13 -14
- data/unittests/pre_test.rb +30 -28
- data/unittests/radios_test.rb +128 -107
- data/unittests/radios_xpath_test.rb +47 -47
- data/unittests/security_setting_test.rb +24 -0
- data/unittests/selectbox_test.rb +65 -157
- data/unittests/selectbox_xpath_test.rb +51 -51
- data/unittests/setup.rb +52 -48
- data/unittests/speed_settings_test.rb +31 -20
- data/unittests/table_cell_using_xpath_test.rb +12 -12
- data/unittests/table_test.rb +30 -16
- data/unittests/table_xpath_test.rb +25 -25
- data/unittests/test_tests.rb +9 -0
- data/unittests/textarea_test.rb +33 -33
- data/unittests/textarea_xpath_test.rb +37 -37
- data/unittests/textfield_for_ch_char_test.rb +9 -9
- data/unittests/textfields_test.rb +103 -98
- data/unittests/textfields_xpath_test.rb +50 -50
- data/unittests/windows/attach_to_existing_window_test.rb +2 -2
- data/unittests/windows/attach_to_new_window_test.rb +10 -10
- data/unittests/windows/close_window_test.rb +2 -2
- data/unittests/windows/frame_links_test.rb +6 -6
- data/unittests/windows/ie-each_test.rb +1 -1
- data/unittests/windows/iedialog_test.rb +4 -5
- data/unittests/windows/js_events_test.rb +14 -14
- data/unittests/windows/jscriptExtraAlert.rb +2 -1
- data/unittests/windows/jscriptExtraConfirmCancel.rb +1 -1
- data/unittests/windows/jscriptExtraConfirmOk.rb +1 -1
- data/unittests/windows/jscriptPushButton.rb +2 -1
- data/unittests/windows/jscript_test.rb +7 -7
- data/unittests/windows/modal_dialog_test.rb +28 -29
- data/unittests/windows/{new.rb → new_test.rb} +1 -1
- data/unittests/windows/open_close_test.rb +4 -7
- data/unittests/windows/send_keys_test.rb +11 -11
- data/unittests/xpath_tests.rb +4 -3
- metadata +82 -58
- data/unittests/buttons_test.rb +0 -107
- data/watir/assertions.rb +0 -44
- data/watir/exceptions.rb +0 -42
- data/watir/testcase.rb +0 -58
- data/watir/waiter.rb +0 -88
- data/watir/win32ole.rb +0 -8
- data/watir/win32ole/win32ole.so +0 -0
data/unittests/css_test.rb
CHANGED
@@ -1,55 +1,35 @@
|
|
1
1
|
# feature tests for css
|
2
|
-
# revision: $Revision:
|
2
|
+
# revision: $Revision: 1505 $
|
3
3
|
|
4
|
-
$LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..')
|
4
|
+
$LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..') unless $SETUP_LOADED
|
5
5
|
require 'unittests/setup'
|
6
6
|
|
7
7
|
class TC_CSS < Test::Unit::TestCase
|
8
8
|
|
9
|
-
def divTester( message )
|
10
|
-
|
11
|
-
divs = $ie.getIE.document.getElementsByTagName("DIV")
|
12
|
-
puts "Found #{divs.length} div tags"
|
13
|
-
divs.each do |d|
|
14
|
-
puts "Checking div #{d.id}"
|
15
|
-
puts "div #{d.invoke("id") } class is #{d.invoke("className") }"
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
9
|
def isMessageDisplayed(message)
|
20
|
-
|
21
10
|
s = false
|
22
|
-
divs =
|
23
|
-
#puts "Found #{divs.length} div tags"
|
11
|
+
divs = browser.divs
|
24
12
|
divs.each do |d|
|
25
|
-
|
26
|
-
|
27
|
-
if d.innerText.to_s.downcase.match( /#{message}/i )
|
28
|
-
|
29
|
-
#puts "div #{d.invoke("id") } class is #{d.invoke("className") }"
|
30
|
-
if d.invoke("className").to_s.downcase.match(/show/i)
|
31
|
-
#puts "message is shown!!!"
|
13
|
+
if d.text.downcase.match( /#{message}/i )
|
14
|
+
if d.class_name.downcase.match(/show/i)
|
32
15
|
s = true
|
33
16
|
end
|
34
|
-
|
35
17
|
end
|
36
18
|
end
|
37
19
|
|
38
|
-
#puts "Not Shown " if s== false
|
39
20
|
return s
|
40
21
|
end
|
41
22
|
|
42
|
-
def
|
23
|
+
def setup
|
43
24
|
goto_page "cssTest.html"
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
25
|
+
end
|
26
|
+
|
27
|
+
def test_SuccessMessage
|
28
|
+
browser.button( :caption , "Success").click
|
48
29
|
assert( isMessageDisplayed("Success") )
|
49
30
|
|
50
|
-
|
51
|
-
|
52
|
-
assert(!isMessageDisplayed("Success") )
|
31
|
+
browser.button(:caption, "Failure").click
|
32
|
+
assert_false(isMessageDisplayed("Success") )
|
53
33
|
end
|
54
34
|
end
|
55
35
|
|
data/unittests/defer_test.rb
CHANGED
@@ -1,45 +1,45 @@
|
|
1
1
|
# tests of deferring when a Watir object is bound to a com object (lazy evaluation)
|
2
|
+
# revision: $Revision: 1546 $
|
2
3
|
|
3
|
-
|
4
|
-
|
5
|
-
$LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..') if $0 == __FILE__
|
4
|
+
$LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..') unless $SETUP_LOADED
|
6
5
|
require 'unittests/setup'
|
7
|
-
require 'unittests/buttons_test.rb'
|
8
6
|
|
9
7
|
class TC_Defer < Test::Unit::TestCase
|
10
8
|
def teardown
|
11
|
-
@
|
12
|
-
|
9
|
+
@new_browser.close if defined?(@new_browser)
|
10
|
+
browser.goto('about:blank')
|
13
11
|
end
|
12
|
+
tag_method :test_binding_to_newly_loaded_page, :fails_on_firefox, :attach
|
14
13
|
def test_binding_to_newly_loaded_page
|
15
|
-
@
|
16
|
-
text_field = @
|
17
|
-
button = @
|
18
|
-
div = @
|
19
|
-
@
|
14
|
+
@new_browser = Watir::Browser.new
|
15
|
+
text_field = @new_browser.text_field(:name, 'text1')
|
16
|
+
button = @new_browser.button(:value, 'Clear Events Box')
|
17
|
+
div = @new_browser.div(:name, 'divvy')
|
18
|
+
@new_browser.goto($htmlRoot + "textfields1.html")
|
20
19
|
assert_equal('Hello World', text_field.value)
|
21
20
|
assert_equal('Clear Events Box', button.value)
|
22
21
|
assert_equal('Div Text', div.text)
|
23
22
|
end
|
24
23
|
def test_binding_to_refreshed_page
|
25
24
|
goto_page "textfields1.html"
|
26
|
-
text_field =
|
27
|
-
button =
|
28
|
-
div =
|
29
|
-
|
25
|
+
text_field = browser.text_field(:name, 'text1')
|
26
|
+
button = browser.button(:value, 'Clear Events Box')
|
27
|
+
div = browser.div(:name, 'divvy')
|
28
|
+
browser.refresh
|
30
29
|
assert_equal('Hello World', text_field.value)
|
31
30
|
assert(text_field.enabled?)
|
32
31
|
assert_equal('Clear Events Box', button.value)
|
33
32
|
assert_equal('Div Text', div.text)
|
34
33
|
end
|
34
|
+
tag_method :test_exists, :fails_on_firefox, :attach
|
35
35
|
def test_exists
|
36
|
-
@
|
37
|
-
text_field = @
|
38
|
-
button = @
|
39
|
-
div = @
|
40
|
-
|
41
|
-
|
42
|
-
@
|
36
|
+
@new_browser = Watir::Browser.new
|
37
|
+
text_field = @new_browser.text_field(:name, 'text1')
|
38
|
+
button = @new_browser.button(:value, 'Clear Events Box')
|
39
|
+
div = @new_browser.div(:name, 'divvy')
|
40
|
+
assert_false(text_field.exists?)
|
41
|
+
assert_false(button.exists?)
|
42
|
+
@new_browser.goto($htmlRoot + "textfields1.html")
|
43
43
|
assert(text_field.exists?)
|
44
44
|
assert(button.exists?)
|
45
45
|
assert(div.exists?)
|
data/unittests/dialog_test.rb
CHANGED
@@ -1,11 +1,12 @@
|
|
1
1
|
# Feature tests for Dialog class
|
2
|
-
# revision: $Revision:
|
2
|
+
# revision: $Revision: 1551 $
|
3
3
|
|
4
|
-
$LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..')
|
4
|
+
$LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..') unless $SETUP_LOADED
|
5
5
|
require 'unittests/setup'
|
6
6
|
require 'watir/dialog'
|
7
7
|
|
8
8
|
class TC_Dialog_Test < Test::Unit::TestCase
|
9
|
+
tags :must_be_visible
|
9
10
|
include Watir
|
10
11
|
|
11
12
|
def setup
|
@@ -20,23 +21,22 @@ class TC_Dialog_Test < Test::Unit::TestCase
|
|
20
21
|
end
|
21
22
|
|
22
23
|
def test_alert_without_bonus_script
|
23
|
-
|
24
|
+
browser.button(:id, 'btnAlert').click_no_wait
|
24
25
|
sleep 0.4 # FIXME: need to be able to poll for window to exist
|
25
26
|
dialog.button("OK").click
|
26
|
-
assert_match(/Alert button!/,
|
27
|
+
assert_match(/Alert button!/, browser.text_field(:id, "testResult").value)
|
27
28
|
end
|
28
29
|
|
29
30
|
def test_button_name_not_found
|
30
|
-
|
31
|
+
browser.button(:id, 'btnAlert').click_no_wait
|
31
32
|
sleep 0.4 # FIXME replace with dialog.exists?
|
32
33
|
assert_raises(UnknownObjectException) { dialog.button("Yes").click }
|
33
34
|
dialog.button("OK").click
|
34
35
|
end
|
35
36
|
|
36
37
|
def xtest_exists
|
37
|
-
|
38
|
-
|
39
|
-
$ie.button(:id, 'btnAlert').click_no_wait
|
38
|
+
assert_false( dialog.exists?) # known bug: finds main window instead of dialog!
|
39
|
+
browser.button(:id, 'btnAlert').click_no_wait
|
40
40
|
sleep 0.4 # FIXME: need to add polling
|
41
41
|
assert dialog.exists?
|
42
42
|
dialog.button('OK').click
|
@@ -44,7 +44,7 @@ class TC_Dialog_Test < Test::Unit::TestCase
|
|
44
44
|
|
45
45
|
def test_leaves_dialog_open
|
46
46
|
# should be closed in teardown
|
47
|
-
|
47
|
+
browser.button(:id, 'btnAlert').click_no_wait
|
48
48
|
end
|
49
49
|
|
50
50
|
def test_copy_array_elements
|
@@ -57,17 +57,17 @@ class TC_Dialog_Test < Test::Unit::TestCase
|
|
57
57
|
end
|
58
58
|
|
59
59
|
def test_confirm_ok
|
60
|
-
|
60
|
+
browser.button(:value, 'confirm').click_no_wait
|
61
61
|
assert dialog.exists?
|
62
62
|
dialog.button('OK').click
|
63
|
-
assert_equal "You pressed the Confirm and OK button!",
|
63
|
+
assert_equal "You pressed the Confirm and OK button!", browser.text_field(:id, 'testResult').value
|
64
64
|
end
|
65
65
|
|
66
66
|
def xtest_confirm_cancel
|
67
|
-
|
67
|
+
browser.button(:value, 'confirm').click_no_wait
|
68
68
|
assert dialog.exists?
|
69
69
|
dialog.button('Cancel').click
|
70
|
-
assert_equal "You pressed the Confirm and Cancel button!",
|
70
|
+
assert_equal "You pressed the Confirm and Cancel button!", browser.text_field(:id, 'testResult').value
|
71
71
|
end
|
72
72
|
|
73
73
|
def test_dialog_close
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# defect reproduction
|
2
2
|
# revision: $Revision: 958 $
|
3
3
|
|
4
|
-
$LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..')
|
4
|
+
$LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..') unless $SETUP_LOADED
|
5
5
|
require 'unittests/setup'
|
6
6
|
|
7
7
|
class TC_Divs_XPath2 < Test::Unit::TestCase
|
@@ -11,12 +11,12 @@ class TC_Divs_XPath2 < Test::Unit::TestCase
|
|
11
11
|
def test_div_with_text
|
12
12
|
# Note: this test fails, probably because of bad html to xml translation.
|
13
13
|
# However... the same xpath expression finds the right object in Selenium!
|
14
|
-
assert_equal('Add',
|
14
|
+
assert_equal('Add', browser.div(:xpath, "//div[text()='Add' and @class='ButtonText']").text)
|
15
15
|
end
|
16
16
|
def test_div_with_contains
|
17
17
|
# Note: this test fails, probably because of bad html to xml translation.
|
18
18
|
# However... the same xpath expression finds the right object in Selenium!
|
19
|
-
assert_equal('Add',
|
19
|
+
assert_equal('Add', browser.div(:xpath, "//div[contains(.,'Add') and @class='ButtonText']").text)
|
20
20
|
end
|
21
21
|
|
22
22
|
end
|
data/unittests/div_test.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# feature tests for Divs, Spans and P's
|
2
|
-
# revision: $Revision:
|
2
|
+
# revision: $Revision: 1506 $
|
3
3
|
|
4
|
-
$LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..')
|
4
|
+
$LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..') unless $SETUP_LOADED
|
5
5
|
require 'unittests/setup'
|
6
6
|
|
7
7
|
class TC_Divs < Test::Unit::TestCase
|
@@ -22,6 +22,7 @@ class TC_Divs < Test::Unit::TestCase
|
|
22
22
|
assert browser.text_field(:name, "text1").verify_contains("0")
|
23
23
|
end
|
24
24
|
|
25
|
+
tag_method :test_div_properties, :fails_on_firefox
|
25
26
|
def test_div_properties
|
26
27
|
assert_raises(UnknownObjectException) { browser.div(:id, "div77").text }
|
27
28
|
assert_raises(UnknownObjectException) { browser.div(:title, "div77").text }
|
@@ -73,7 +74,7 @@ class TC_Divs < Test::Unit::TestCase
|
|
73
74
|
|
74
75
|
assert_equal(3, browser.div(:id, 'text_fields1').text_fields.length )
|
75
76
|
browser.div(:id, 'text_fields1').text_field(:name, 'div_text1').set("drink me")
|
76
|
-
assert_equal("drink me", browser.div(:id, 'text_fields1').text_field(:name, 'div_text1').
|
77
|
+
assert_equal("drink me", browser.div(:id, 'text_fields1').text_field(:name, 'div_text1').value)
|
77
78
|
end
|
78
79
|
|
79
80
|
def test_images_inside_a_div
|
@@ -84,27 +85,30 @@ class TC_Divs < Test::Unit::TestCase
|
|
84
85
|
|
85
86
|
#---- Span Tests ---
|
86
87
|
def test_spans
|
87
|
-
assert_raises(UnknownObjectException) {browser.span(:id
|
88
|
-
assert_raises(UnknownObjectException) {browser.span(:title
|
88
|
+
assert_raises(UnknownObjectException) {browser.span(:id, "span77").click }
|
89
|
+
assert_raises(UnknownObjectException) {browser.span(:title, "span77").click }
|
89
90
|
|
90
91
|
assert(browser.text_field(:name, "text2").verify_contains("0") )
|
91
|
-
browser.span(:id
|
92
|
+
browser.span(:id, "span3").click
|
92
93
|
assert(browser.text_field(:name, "text2").verify_contains("1") )
|
93
94
|
|
94
|
-
browser.span(:id
|
95
|
+
browser.span(:id, "span4").click
|
95
96
|
assert(browser.text_field(:name, "text2").verify_contains("0") )
|
96
97
|
end
|
97
98
|
|
99
|
+
tag_method :test_span_properties, :fails_on_firefox
|
98
100
|
def test_span_properties
|
99
|
-
assert_raises(UnknownObjectException) {browser.span(:id
|
100
|
-
assert_raises(UnknownObjectException) {browser.span(:title
|
101
|
+
assert_raises(UnknownObjectException) {browser.span(:id, "span77").text }
|
102
|
+
assert_raises(UnknownObjectException) {browser.span(:title, "span77").text }
|
101
103
|
|
102
|
-
assert_equal("This span has an onClick that increments text2"
|
103
|
-
|
104
|
+
assert_equal("This span has an onClick that increments text2",
|
105
|
+
browser.span(:id , "span3").text.strip )
|
106
|
+
assert_equal("This text is in a span with an id of span1 and title of test2",
|
107
|
+
browser.span(:title , "Test2").text.strip)
|
104
108
|
|
105
|
-
assert_raises(UnknownObjectException) {browser.span(:id
|
106
|
-
assert_equal("blueText"
|
107
|
-
assert_equal(""
|
109
|
+
assert_raises(UnknownObjectException) {browser.span(:id, "span77").class_name}
|
110
|
+
assert_equal("blueText", browser.span(:id, "span2").class_name)
|
111
|
+
assert_equal("", browser.span(:id, "span1").class_name)
|
108
112
|
|
109
113
|
assert_raises(UnknownObjectException) {browser.span(:index , 44).class_name }
|
110
114
|
assert_equal("span1" , browser.span(:index , 1).id )
|
@@ -133,12 +137,12 @@ class TC_Divs < Test::Unit::TestCase
|
|
133
137
|
|
134
138
|
def test_objects_in_span
|
135
139
|
assert(browser.span(:id, 'buttons1').button(:index,1).exists? )
|
136
|
-
|
140
|
+
assert_false(browser.span(:id, 'buttons1').button(:index,3).exists? )
|
137
141
|
assert(browser.span(:id, 'buttons1').button(:name,'b1').exists? )
|
138
142
|
|
139
143
|
assert(browser.span(:id, 'buttons2').button(:index,1).exists? )
|
140
144
|
assert(browser.span(:id, 'buttons2').button(:index,2).exists? )
|
141
|
-
|
145
|
+
assert_false(browser.span(:id, 'buttons1').button(:index,3).exists? )
|
142
146
|
|
143
147
|
browser.span(:id, 'buttons1').button(:index,1).click
|
144
148
|
assert_equal( 'button1' , browser.span(:id , 'text_fields1').text_field(:index,1).value)
|
@@ -150,9 +154,9 @@ class TC_Divs < Test::Unit::TestCase
|
|
150
154
|
assert(browser.p(:index, 3).exists?)
|
151
155
|
assert(browser.p(:title, 'test_3').exists?)
|
152
156
|
|
153
|
-
|
154
|
-
|
155
|
-
|
157
|
+
assert_false(browser.p(:id, 'missing').exists?)
|
158
|
+
assert_false(browser.p(:index, 8).exists?)
|
159
|
+
assert_false(browser.p(:title, 'test_55').exists?)
|
156
160
|
|
157
161
|
assert_raises( UnknownObjectException) {browser.p(:id , 'missing').class_name }
|
158
162
|
assert_raises( UnknownObjectException) {browser.p(:id , 'missing').text }
|
data/unittests/div_xpath_test.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# feature tests for Divs, Spans and P's
|
2
|
-
# revision: $Revision:
|
2
|
+
# revision: $Revision: 1544 $
|
3
3
|
|
4
|
-
$LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..')
|
4
|
+
$LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..') unless $SETUP_LOADED
|
5
5
|
require 'unittests/setup'
|
6
6
|
|
7
7
|
class TC_Divs_XPath < Test::Unit::TestCase
|
@@ -12,85 +12,85 @@ class TC_Divs_XPath < Test::Unit::TestCase
|
|
12
12
|
end
|
13
13
|
|
14
14
|
def test_divs
|
15
|
-
assert_raises(UnknownObjectException) {
|
16
|
-
assert_raises(UnknownObjectException) {
|
15
|
+
assert_raises(UnknownObjectException) {browser.div(:xpath , "//div[@id='div77']/").click }
|
16
|
+
assert_raises(UnknownObjectException) {browser.div(:xpath , "//div[@title='div77']/").click }
|
17
17
|
|
18
|
-
assert(
|
19
|
-
|
20
|
-
assert(
|
21
|
-
|
22
|
-
assert(
|
18
|
+
assert(browser.text_field(:xpath, "//input[@name='text1']/").verify_contains("0") )
|
19
|
+
browser.div(:xpath , "//div[@id='div3']/").click
|
20
|
+
assert(browser.text_field(:xpath, "//input[@name='text1']/").verify_contains("1") )
|
21
|
+
browser.div(:xpath , "//div[@id='div4']/").click
|
22
|
+
assert(browser.text_field(:xpath, "//input[@name='text1']/").verify_contains("0") )
|
23
23
|
end
|
24
24
|
|
25
25
|
def test_div_properties
|
26
|
-
assert_raises(UnknownObjectException) {
|
27
|
-
assert_raises(UnknownObjectException) {
|
26
|
+
assert_raises(UnknownObjectException) {browser.div(:xpath , "//div[@id='div77']/").text }
|
27
|
+
assert_raises(UnknownObjectException) {browser.div(:xpath , "//div[@title='div77']/").text }
|
28
28
|
|
29
29
|
assert_equal("This div has an onClick that increments text1",
|
30
|
-
|
30
|
+
browser.div(:xpath , "//div[@id='div3']/").text.strip )
|
31
31
|
assert_equal("This text is in a div with an id of div1 and title of test1",
|
32
|
-
|
32
|
+
browser.div(:xpath , "//div[@title='Test1']/").text.strip )
|
33
33
|
|
34
|
-
assert_raises(UnknownObjectException) {
|
35
|
-
assert_equal("blueText" ,
|
36
|
-
assert_equal("" ,
|
34
|
+
assert_raises(UnknownObjectException) {browser.div(:xpath , "//div[@id='div77']/").class_name }
|
35
|
+
assert_equal("blueText" , browser.div(:xpath , "//div[@id='div2']/").class_name )
|
36
|
+
assert_equal("" , browser.div(:xpath , "//div[@id='div1']/").class_name )
|
37
37
|
end
|
38
38
|
|
39
39
|
def test_objects_in_div
|
40
|
-
assert(
|
41
|
-
|
42
|
-
assert(
|
40
|
+
assert(browser.div(:xpath , "//div[@id='buttons1']/").button(:index,1).exists? )
|
41
|
+
assert_false(browser.div(:xpath , "//div[@id='buttons1']/").button(:index,3).exists? )
|
42
|
+
assert(browser.div(:xpath , "//div[@id='buttons1']/").button(:name,'b1').exists? )
|
43
43
|
|
44
|
-
assert(
|
45
|
-
assert(
|
46
|
-
|
44
|
+
assert(browser.div(:xpath , "//div[@id='buttons2']/").button(:index,1).exists? )
|
45
|
+
assert(browser.div(:xpath , "//div[@id='buttons2']/").button(:index,2).exists? )
|
46
|
+
assert_false(browser.div(:xpath , "//div[@id='buttons1']/").button(:index,3).exists? )
|
47
47
|
|
48
|
-
|
48
|
+
browser.div(:xpath , "//div[@id='buttons1']/").button(:index,1).click
|
49
49
|
|
50
|
-
assert_equal( 'button1' ,
|
50
|
+
assert_equal( 'button1' , browser.div(:xpath , "//div[@id='text_fields1']/").text_field(:index,1).value)
|
51
51
|
|
52
|
-
assert_equal( 3 ,
|
52
|
+
assert_equal( 3 , browser.div(:xpath , "//div[@id='text_fields1']/").text_fields.length )
|
53
53
|
end
|
54
54
|
|
55
55
|
def test_span_properties
|
56
|
-
assert_raises(UnknownObjectException) {
|
57
|
-
assert_raises(UnknownObjectException) {
|
56
|
+
assert_raises(UnknownObjectException) {browser.span(:xpath , "//span[@id='span77']/").text }
|
57
|
+
assert_raises(UnknownObjectException) {browser.span(:xpath , "//span[@title='span77']/").text }
|
58
58
|
|
59
|
-
assert_equal("This span has an onClick that increments text2" ,
|
60
|
-
assert_equal("This text is in a span with an id of span1 and title of test2" ,
|
59
|
+
assert_equal("This span has an onClick that increments text2" , browser.span(:xpath , "//span[@id='span3']/").text.strip )
|
60
|
+
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 )
|
61
61
|
|
62
|
-
assert_raises(UnknownObjectException) {
|
63
|
-
assert_equal("blueText" ,
|
64
|
-
assert_equal("" ,
|
62
|
+
assert_raises(UnknownObjectException) {browser.span(:xpath , "//span[@id='span77']/").class_name }
|
63
|
+
assert_equal("blueText" , browser.span(:xpath , "//span[@id='span2']/").class_name )
|
64
|
+
assert_equal("" , browser.span(:xpath , "//span[@id='span1']/").class_name )
|
65
65
|
end
|
66
66
|
|
67
67
|
def test_objects_in_span
|
68
|
-
assert(
|
69
|
-
|
70
|
-
assert(
|
68
|
+
assert(browser.span(:xpath , "//span[@id='buttons1']/").button(:index,1).exists? )
|
69
|
+
assert_false(browser.span(:xpath , "//span[@id='buttons1']/").button(:index,3).exists? )
|
70
|
+
assert(browser.span(:xpath , "//span[@id='buttons1']/").button(:name,'b1').exists? )
|
71
71
|
|
72
|
-
assert(
|
73
|
-
assert(
|
74
|
-
|
72
|
+
assert(browser.span(:xpath , "//span[@id='buttons2']/").button(:index,1).exists? )
|
73
|
+
assert(browser.span(:xpath , "//span[@id='buttons2']/").button(:index,2).exists? )
|
74
|
+
assert_false(browser.span(:xpath , "//span[@id='buttons1']/").button(:index,3).exists? )
|
75
75
|
|
76
|
-
|
76
|
+
browser.span(:xpath , "//span[@id='buttons1']/").button(:index,1).click
|
77
77
|
|
78
|
-
assert_equal( 'button1' ,
|
78
|
+
assert_equal( 'button1' , browser.span(:xpath , "//span[@id='text_fields1']/").text_field(:index,1).value)
|
79
79
|
|
80
|
-
assert_equal( 3 ,
|
80
|
+
assert_equal( 3 , browser.span(:xpath , "//span[@id='text_fields1']/").text_fields.length )
|
81
81
|
end
|
82
82
|
|
83
83
|
def test_p
|
84
|
-
assert(
|
85
|
-
assert(
|
84
|
+
assert(browser.p(:xpath , "//p[@id='number1']/").exists?)
|
85
|
+
assert(browser.p(:xpath , "//p[@title='test_3']/").exists?)
|
86
86
|
|
87
|
-
|
88
|
-
|
87
|
+
assert_false(browser.p(:xpath , "//p[@id='missing']/").exists?)
|
88
|
+
assert_false(browser.p(:xpath , "//p[@title='test_55']/").exists?)
|
89
89
|
|
90
|
-
assert_raises( UnknownObjectException) {
|
91
|
-
assert_raises( UnknownObjectException) {
|
92
|
-
assert_raises( UnknownObjectException) {
|
93
|
-
assert_raises( UnknownObjectException) {
|
94
|
-
assert_raises( UnknownObjectException) {
|
90
|
+
assert_raises( UnknownObjectException) {browser.p(:xpath , "//p[@id='missing']/").class_name }
|
91
|
+
assert_raises( UnknownObjectException) {browser.p(:xpath , "//p[@id='missing']/").text }
|
92
|
+
assert_raises( UnknownObjectException) {browser.p(:xpath , "//p[@id='missing']/").title }
|
93
|
+
assert_raises( UnknownObjectException) {browser.p(:xpath , "//p[@id='missing']/").to_s }
|
94
|
+
assert_raises( UnknownObjectException) {browser.p(:xpath , "//p[@id='missing']/").disabled }
|
95
95
|
end
|
96
96
|
end
|