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,11 @@
|
|
1
|
+
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
2
|
+
<html>
|
3
|
+
<table id="a_table">
|
4
|
+
<tr id="first"><td>alt_1 - boring text</td></tr>
|
5
|
+
<tr id="second"><td>alt_2 - great text</td></tr>
|
6
|
+
<tr id="third"><td>alt_1 - the best text ever<td></tr>
|
7
|
+
<tr id="fourth"><td>alt_2 - okay text<td></tr>
|
8
|
+
<tr id="fifth"><td>alt_1 - supreme text<td></tr>
|
9
|
+
<tr id="sixth"><td>alt_2 - middle of the road text<td></tr>
|
10
|
+
</table>
|
11
|
+
</html>
|
@@ -0,0 +1,16 @@
|
|
1
|
+
# test IE#exists?
|
2
|
+
|
3
|
+
$LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..') unless $SETUP_LOADED
|
4
|
+
require 'unittests/setup'
|
5
|
+
|
6
|
+
class TC_IENotExists < Test::Unit::TestCase
|
7
|
+
def setup
|
8
|
+
@ie = Watir::IE.new
|
9
|
+
end
|
10
|
+
|
11
|
+
def test_some_one_else_closed_it
|
12
|
+
@ie.ie.quit
|
13
|
+
sleep 0.3 # give it some time to close
|
14
|
+
assert_false(@ie.exists?)
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,94 @@
|
|
1
|
+
# mock library for testing the IE controller
|
2
|
+
require 'watir-classic'
|
3
|
+
|
4
|
+
class FakeFrame
|
5
|
+
def length
|
6
|
+
return 0
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
class FakeDoc
|
11
|
+
|
12
|
+
attr_accessor :links, :all
|
13
|
+
|
14
|
+
def initialize
|
15
|
+
@links = ""
|
16
|
+
@doc = self
|
17
|
+
end
|
18
|
+
|
19
|
+
def getElementsByTagName(tag)
|
20
|
+
@doc.links
|
21
|
+
end
|
22
|
+
|
23
|
+
def frames
|
24
|
+
return FakeFrame.new
|
25
|
+
end
|
26
|
+
|
27
|
+
def readyState
|
28
|
+
return "complete"
|
29
|
+
end
|
30
|
+
|
31
|
+
def addLink(value)
|
32
|
+
if @links.nil?
|
33
|
+
@links = value
|
34
|
+
else
|
35
|
+
@links << value
|
36
|
+
end
|
37
|
+
end
|
38
|
+
def location
|
39
|
+
self
|
40
|
+
end
|
41
|
+
def url
|
42
|
+
return "file://fake"
|
43
|
+
end
|
44
|
+
alias :href :url
|
45
|
+
end
|
46
|
+
|
47
|
+
class StubExplorer
|
48
|
+
|
49
|
+
attr_accessor :timeToWait
|
50
|
+
|
51
|
+
def initialize
|
52
|
+
@timeToWait = 1
|
53
|
+
@visible = $HIDE_IE
|
54
|
+
@document = FakeDoc.new
|
55
|
+
end
|
56
|
+
|
57
|
+
def document
|
58
|
+
return @document
|
59
|
+
end
|
60
|
+
|
61
|
+
def busy
|
62
|
+
sleep @timeToWait
|
63
|
+
return FALSE
|
64
|
+
end
|
65
|
+
|
66
|
+
def readyState
|
67
|
+
return 4
|
68
|
+
end
|
69
|
+
|
70
|
+
def visible=(value)
|
71
|
+
end
|
72
|
+
|
73
|
+
def visible
|
74
|
+
end
|
75
|
+
|
76
|
+
end
|
77
|
+
|
78
|
+
class TestIE < Watir::IE
|
79
|
+
|
80
|
+
def create_browser_window
|
81
|
+
@ie = StubExplorer.new
|
82
|
+
end
|
83
|
+
|
84
|
+
def addLink(link)
|
85
|
+
@ie.document.addLink(link)
|
86
|
+
end
|
87
|
+
|
88
|
+
def setTimeToWait(time = 1)
|
89
|
+
@ie.timeToWait = time
|
90
|
+
end
|
91
|
+
|
92
|
+
def goto(url)
|
93
|
+
end
|
94
|
+
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
# Unit Test for Internet Explorer
|
2
|
+
|
3
|
+
$LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..') unless $SETUP_LOADED
|
4
|
+
require 'unittests/setup'
|
5
|
+
require 'unittests/ie_mock'
|
6
|
+
|
7
|
+
class TC_ie < Test::Unit::TestCase
|
8
|
+
include Watir::Exception
|
9
|
+
|
10
|
+
def setup
|
11
|
+
@faked_ie = TestIE.new
|
12
|
+
end
|
13
|
+
|
14
|
+
def test_waitForIE
|
15
|
+
wait_time = 1
|
16
|
+
# @faked_ie.logger.level = Logger::DEBUG
|
17
|
+
|
18
|
+
@faked_ie.setTimeToWait wait_time
|
19
|
+
begin_time = Time.now
|
20
|
+
@faked_ie.wait
|
21
|
+
elapsed_time = Time.now - begin_time
|
22
|
+
assert_in_delta(wait_time, elapsed_time, 0.5)
|
23
|
+
end
|
24
|
+
|
25
|
+
def test_getLink_ByIndexReturnsNilOnNoLinks
|
26
|
+
assert_false(@faked_ie.link(:index, 0).exists?)
|
27
|
+
end
|
28
|
+
|
29
|
+
def test_getLink_ByBadHow
|
30
|
+
@faked_ie.addLink "foo"
|
31
|
+
assert_raise(UnknownObjectException) do
|
32
|
+
@faked_ie.link(:no_such_mechanism, "verifying error handling").click
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
def test_execute_script
|
37
|
+
script = %q[
|
38
|
+
var x = 'something';
|
39
|
+
var y = " else";
|
40
|
+
x + y;
|
41
|
+
]
|
42
|
+
assert_equal "something else", browser.execute_script(script)
|
43
|
+
end
|
44
|
+
|
45
|
+
def test_getLink_ByUrlReturnsNilOnNoLinks
|
46
|
+
assert_false(@faked_ie.link(:url, "whatever").exists?)
|
47
|
+
end
|
48
|
+
|
49
|
+
def test_getLink_ByTextReturnsNilOnNoLinks
|
50
|
+
assert_false(@faked_ie.link(:text, "whatever").exists?)
|
51
|
+
end
|
52
|
+
|
53
|
+
end
|
54
|
+
|
@@ -0,0 +1,156 @@
|
|
1
|
+
# feature tests for Images
|
2
|
+
|
3
|
+
$LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..') unless $SETUP_LOADED
|
4
|
+
require 'unittests/setup'
|
5
|
+
require 'ftools'
|
6
|
+
require 'webrick'
|
7
|
+
require 'watir-classic/cookiemanager'
|
8
|
+
|
9
|
+
class TC_Images < Test::Unit::TestCase
|
10
|
+
tags :must_be_visible, :creates_windows
|
11
|
+
include Watir
|
12
|
+
|
13
|
+
def setup
|
14
|
+
goto_page "images1.html"
|
15
|
+
@saved_img_path = build_path("sample.img.dat");
|
16
|
+
clean_saved_image
|
17
|
+
end
|
18
|
+
|
19
|
+
def teardown
|
20
|
+
clean_saved_image
|
21
|
+
end
|
22
|
+
|
23
|
+
def test_imageExists
|
24
|
+
assert( ! browser.image(:name , "missing_name").exists? )
|
25
|
+
assert( browser.image(:name , "circle").exists? )
|
26
|
+
assert( browser.image(:name , /circ/ ).exists? )
|
27
|
+
|
28
|
+
assert( ! browser.image(:id , "missing_id").exists? )
|
29
|
+
assert( browser.image(:id , "square").exists? )
|
30
|
+
assert( browser.image(:id , /squ/ ).exists? )
|
31
|
+
|
32
|
+
assert( ! browser.image(:src, "missingsrc.gif").exists? )
|
33
|
+
|
34
|
+
assert( browser.image(:src, "file:///#{$myDir}/html/images/triangle.jpg").exists? )
|
35
|
+
assert( browser.image(:src , /triangle/ ).exists? )
|
36
|
+
|
37
|
+
assert( browser.image(:alt , "circle" ).exists? )
|
38
|
+
assert( browser.image(:alt , /cir/ ).exists? )
|
39
|
+
|
40
|
+
assert( ! browser.image(:alt , "triangle" ).exists? )
|
41
|
+
assert( ! browser.image(:alt , /tri/ ).exists? )
|
42
|
+
|
43
|
+
assert( browser.image(:title, 'square_image').exists? )
|
44
|
+
assert( ! browser.image(:title, 'pentagram').exists? )
|
45
|
+
end
|
46
|
+
|
47
|
+
def test_image_click
|
48
|
+
assert_raises(UnknownObjectException) { browser.image(:name, "no_image_with_this").click }
|
49
|
+
assert_raises(UnknownObjectException) { browser.image(:id, "no_image_with_this").click }
|
50
|
+
assert_raises(UnknownObjectException) { browser.image(:src, "no_image_with_this").click}
|
51
|
+
assert_raises(UnknownObjectException) { browser.image(:alt, "no_image_with_this").click}
|
52
|
+
|
53
|
+
# test for bug 1882
|
54
|
+
browser.text_field(:name , "text1").clear
|
55
|
+
browser.button(:value , /Pos/ ).click
|
56
|
+
assert_equal('clicked' , browser.text_field(:name , "text1" ).value )
|
57
|
+
|
58
|
+
# test for disabled button
|
59
|
+
assert( ! browser.image(:name , 'disabler_test').disabled )
|
60
|
+
browser.button(:name , 'disable_img').click
|
61
|
+
|
62
|
+
assert( browser.image(:name , 'disabler_test').disabled )
|
63
|
+
browser.button(:name , 'disable_img').click
|
64
|
+
|
65
|
+
browser.image(:src, /button/).click
|
66
|
+
assert(browser.text.include?("PASS") )
|
67
|
+
end
|
68
|
+
|
69
|
+
def test_imageHasLoaded
|
70
|
+
assert_raises(UnknownObjectException) { browser.image(:name, "no_image_with_this").hasLoaded? }
|
71
|
+
assert_raises(UnknownObjectException) { browser.image(:id, "no_image_with_this").hasLoaded? }
|
72
|
+
assert_raises(UnknownObjectException) { browser.image(:src, "no_image_with_this").hasLoaded? }
|
73
|
+
assert_raises(UnknownObjectException) { browser.image(:alt, "no_image_with_this").hasLoaded? }
|
74
|
+
|
75
|
+
assert( ! browser.image(:name, "themissingimage").hasLoaded? )
|
76
|
+
assert( browser.image(:name, "circle").hasLoaded? )
|
77
|
+
|
78
|
+
assert( browser.image(:alt, "circle").hasLoaded? )
|
79
|
+
assert( browser.image(:alt, /cir/ ).hasLoaded? )
|
80
|
+
end
|
81
|
+
|
82
|
+
def test_image_properties
|
83
|
+
assert_raises(UnknownObjectException) { browser.image(:name, "no_image_with_this").hasLoaded? }
|
84
|
+
assert_raises(UnknownObjectException) { browser.image(:id, "no_image_with_this").hasLoaded? }
|
85
|
+
assert_raises(UnknownObjectException) { browser.image(:src, "no_image_with_this").hasLoaded? }
|
86
|
+
assert_raises(UnknownObjectException) { browser.image(:index, 82).hasLoaded? }
|
87
|
+
|
88
|
+
assert_raises(UnknownObjectException) { browser.image(:index, 82).name }
|
89
|
+
assert_raises(UnknownObjectException) { browser.image(:index, 82).id }
|
90
|
+
assert_raises(UnknownObjectException) { browser.image(:index, 82).src }
|
91
|
+
assert_raises(UnknownObjectException) { browser.image(:index, 82).value }
|
92
|
+
assert_raises(UnknownObjectException) { browser.image(:index, 82).height }
|
93
|
+
assert_raises(UnknownObjectException) { browser.image(:index, 82).width }
|
94
|
+
assert_raises(UnknownObjectException) { browser.image(:index, 82).fileCreatedDate }
|
95
|
+
assert_raises(UnknownObjectException) { browser.image(:index, 82).fileSize }
|
96
|
+
assert_raises(UnknownObjectException) { browser.image(:index, 82).alt}
|
97
|
+
assert_raises(UnknownObjectException) { browser.image(:index, 82).title}
|
98
|
+
|
99
|
+
assert_equal( "" , browser.image(:index, 1).name )
|
100
|
+
assert_equal( "square" , browser.image(:index, 1).id )
|
101
|
+
assert_match( /square\.jpg/i ,browser.image(:index, 1).src )
|
102
|
+
assert_equal( "" , browser.image(:index, 1).value )
|
103
|
+
assert_equal( 88 , browser.image(:index, 1).height )
|
104
|
+
assert_equal( 88 , browser.image(:index, 1).width )
|
105
|
+
|
106
|
+
# this line fails, as the date is when it is installed on the local oc, not the date the file was really created
|
107
|
+
#assert_equal( "03/10/2005" , browser.image(:index, 2).fileCreatedDate )
|
108
|
+
assert_equal( 788, browser.image(:index, 1).fileSize )
|
109
|
+
|
110
|
+
# tool tips: alt text + title
|
111
|
+
assert_equal('circle' , browser.image(:index, 5).alt)
|
112
|
+
assert_equal( "" , browser.image(:index, 1).alt)
|
113
|
+
assert_equal('square_image', browser.image(:id, 'square').title)
|
114
|
+
|
115
|
+
# TODO: to string tests -- output should be verified!
|
116
|
+
browser.image(:name , "circle").to_s
|
117
|
+
browser.image(:index , 1).to_s
|
118
|
+
end
|
119
|
+
|
120
|
+
def test_image_iterator
|
121
|
+
assert_equal(6 , browser.images.length)
|
122
|
+
assert_equal("" , browser.images[1].name )
|
123
|
+
assert_equal("square", browser.images[1].id )
|
124
|
+
assert_match(/square/, browser.images[1].src )
|
125
|
+
|
126
|
+
index = 0
|
127
|
+
browser.images.each do |i|
|
128
|
+
assert_equal( browser.image(:index, index).id , i.id )
|
129
|
+
assert_equal( browser.image(:index, index).name , i.name )
|
130
|
+
assert_equal( browser.image(:index, index).src , i.src )
|
131
|
+
assert_equal( browser.image(:index, index).height , i.height )
|
132
|
+
assert_equal( browser.image(:index, index).width , i.width )
|
133
|
+
|
134
|
+
index += 1
|
135
|
+
end
|
136
|
+
assert_equal(index, browser.images.length)
|
137
|
+
end
|
138
|
+
|
139
|
+
def test_save_local_image
|
140
|
+
browser.images[1].save(build_windows_path("sample.img.dat"))
|
141
|
+
assert(File.compare(@saved_img_path, browser.images[1].src.gsub(/^file:\/\/\//, '')))
|
142
|
+
end
|
143
|
+
|
144
|
+
def clean_saved_image
|
145
|
+
File.delete(@saved_img_path) if (File.exists?(@saved_img_path))
|
146
|
+
end
|
147
|
+
|
148
|
+
def build_windows_path(part)
|
149
|
+
build_path(part).gsub(/\//, "\\")
|
150
|
+
end
|
151
|
+
|
152
|
+
def build_path(part)
|
153
|
+
"#{$myDir}/#{part}"
|
154
|
+
end
|
155
|
+
end
|
156
|
+
|
@@ -0,0 +1,90 @@
|
|
1
|
+
# feature tests for Images
|
2
|
+
|
3
|
+
$LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..') unless $SETUP_LOADED
|
4
|
+
require 'unittests/setup'
|
5
|
+
require 'ftools'
|
6
|
+
require 'webrick'
|
7
|
+
require 'watir-classic/cookiemanager'
|
8
|
+
|
9
|
+
class TC_Images_XPath < Test::Unit::TestCase
|
10
|
+
include Watir
|
11
|
+
|
12
|
+
def setup
|
13
|
+
gotoImagePage
|
14
|
+
end
|
15
|
+
|
16
|
+
def gotoImagePage
|
17
|
+
goto_page "images1.html"
|
18
|
+
end
|
19
|
+
|
20
|
+
def test_imageExists
|
21
|
+
assert_false( browser.image(:xpath , "//img[@name='missing_name']/").exists? )
|
22
|
+
assert( browser.image(:xpath , "//img[@name='circle']/").exists? )
|
23
|
+
# assert( browser.image(:name , /circ/ ).exists? )
|
24
|
+
|
25
|
+
assert_false( browser.image(:xpath , "//img[@id='missing_id']/").exists? )
|
26
|
+
assert( browser.image(:xpath , "//img[@id='square']/").exists? )
|
27
|
+
# assert( browser.image(:id , /squ/ ).exists? )
|
28
|
+
|
29
|
+
assert_false( browser.image(:xpath , "//img[@src='missingsrc.gif']/").exists? )
|
30
|
+
|
31
|
+
# BP -- This fails for me but not for Paul. It doesn't make sense to me that it should pass.
|
32
|
+
# assert( browser.image(:src , "file:///#{$myDir}/html/images/triangle.jpg").exists? )
|
33
|
+
# assert( browser.image(:src , /triangle/ ).exists? )
|
34
|
+
|
35
|
+
assert( browser.image(:alt , "circle" ).exists? )
|
36
|
+
# assert( browser.image(:alt , /cir/ ).exists? )
|
37
|
+
|
38
|
+
assert_false( browser.image(:alt , "triangle" ).exists? )
|
39
|
+
# assert_false( browser.image(:alt , /tri/ ).exists? )
|
40
|
+
end
|
41
|
+
|
42
|
+
def test_image_click
|
43
|
+
assert_raises(UnknownObjectException ) { browser.image(:xpath , "//img[@name='no_image_with_this']/").click }
|
44
|
+
assert_raises(UnknownObjectException ) { browser.image(:xpath , "//img[@id='no_image_with_this']/").click }
|
45
|
+
assert_raises(UnknownObjectException ) { browser.image(:xpath , "//img[@src='no_image_with_this']/").click}
|
46
|
+
assert_raises(UnknownObjectException ) { browser.image(:xpath , "//img[@alt='no_image_with_this']/").click}
|
47
|
+
|
48
|
+
# test for bug 1882
|
49
|
+
browser.text_field(:name , "text1").clear
|
50
|
+
browser.button(:value , /Pos/ ).click
|
51
|
+
assert_equal('clicked' , browser.text_field(:name , "text1" ).value )
|
52
|
+
|
53
|
+
# test for disabled button
|
54
|
+
# assert_false( browser.image(:name , 'disabler_test').disabled )
|
55
|
+
# browser.button(:name , 'disable_img').click
|
56
|
+
|
57
|
+
# assert( browser.image(:name , 'disabler_test').disabled )
|
58
|
+
# browser.button(:name , 'disable_img').click
|
59
|
+
|
60
|
+
# browser.image(:src, /button/).click
|
61
|
+
# assert(browser.text.include?("PASS") )
|
62
|
+
|
63
|
+
end
|
64
|
+
|
65
|
+
|
66
|
+
|
67
|
+
def test_imageHasLoaded
|
68
|
+
assert_raises(UnknownObjectException ) { browser.image(:xpath , "//img[@name='no_image_with_this']/").hasLoaded? }
|
69
|
+
assert_raises(UnknownObjectException ) { browser.image(:xpath , "//img[@id='no_image_with_this']/").hasLoaded? }
|
70
|
+
assert_raises(UnknownObjectException ) { browser.image(:xpath , "//img[@src='no_image_with_this']/").hasLoaded? }
|
71
|
+
assert_raises(UnknownObjectException ) { browser.image(:xpath , "//img[@alt='no_image_with_this']/").hasLoaded? }
|
72
|
+
|
73
|
+
assert_false( browser.image(:xpath , "//img[@name='themissingimage']/").hasLoaded? )
|
74
|
+
assert( browser.image(:xpath , "//img[@name='circle']/").hasLoaded? )
|
75
|
+
|
76
|
+
assert( browser.image(:xpath , "//img[@alt='circle']/").hasLoaded? )
|
77
|
+
# assert( browser.image(:alt, /cir/ ).hasLoaded? )
|
78
|
+
end
|
79
|
+
|
80
|
+
def test_image_properties
|
81
|
+
assert_raises(UnknownObjectException ) { browser.image(:xpath , "//img[@name='no_image_with_this']/").hasLoaded? }
|
82
|
+
assert_raises(UnknownObjectException ) { browser.image(:xpath , "//img[@id='no_image_with_this']/").hasLoaded? }
|
83
|
+
assert_raises(UnknownObjectException ) { browser.image(:xpath , "//img[@src='no_image_with_this']/").hasLoaded? }
|
84
|
+
|
85
|
+
# to string tests -- output should be verified!
|
86
|
+
puts browser.image(:xpath , "//img[@name='circle']/").to_s
|
87
|
+
end
|
88
|
+
|
89
|
+
end
|
90
|
+
|
@@ -0,0 +1,31 @@
|
|
1
|
+
$LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..') unless $SETUP_LOADED
|
2
|
+
require 'unittests/setup'
|
3
|
+
|
4
|
+
class TC_BaseIndex < Test::Unit::TestCase
|
5
|
+
include Watir::Exception
|
6
|
+
|
7
|
+
def setup
|
8
|
+
goto_page "multiple_specifiers.html"
|
9
|
+
end
|
10
|
+
|
11
|
+
def test_default_index
|
12
|
+
assert "one", browser.table.row.cell.class_name
|
13
|
+
end
|
14
|
+
|
15
|
+
def test_zero_based_indexing
|
16
|
+
assert "one", browser.button(:index => 0).class_name
|
17
|
+
assert "two", browser.button(:index => 1).class_name
|
18
|
+
|
19
|
+
Watir::IE.zero_based_indexing = false
|
20
|
+
|
21
|
+
assert "one", browser.button(:index => 1).class_name
|
22
|
+
assert "two", browser.button(:index => 2).class_name
|
23
|
+
|
24
|
+
Watir::IE.zero_based_indexing = true
|
25
|
+
|
26
|
+
assert "one", browser.button(:index => 0).class_name
|
27
|
+
assert "two", browser.button(:index => 1).class_name
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
31
|
+
|