watir 3.0.0.rc3 → 3.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +5 -0
- data/lib/watir.rb +1 -0
- data/lib/watir/loader.rb +2 -0
- data/lib/watir/version.rb +3 -0
- data/watir.gemspec +18 -54
- metadata +32 -278
- data/CHANGES +0 -712
- data/LICENSE +0 -34
- data/README.rdoc +0 -101
- data/VERSION +0 -1
- data/bin/watir-console +0 -7
- data/lib/watir/IEDialog/Release/IEDialog.dll +0 -0
- data/lib/watir/close_all.rb +0 -31
- data/lib/watir/container.rb +0 -110
- data/lib/watir/contrib/enabled_popup.rb +0 -21
- data/lib/watir/contrib/ie-new-process.rb +0 -27
- data/lib/watir/contrib/page_checker.rb +0 -29
- data/lib/watir/cookies.rb +0 -80
- data/lib/watir/core.rb +0 -43
- data/lib/watir/dialogs/file_field.rb +0 -34
- data/lib/watir/dialogs/javascript.rb +0 -43
- data/lib/watir/drag_and_drop_helper.rb +0 -68
- data/lib/watir/element.rb +0 -441
- data/lib/watir/element_collection.rb +0 -109
- data/lib/watir/form.rb +0 -96
- data/lib/watir/frame.rb +0 -47
- data/lib/watir/ie-class.rb +0 -765
- data/lib/watir/ie-process.rb +0 -47
- data/lib/watir/ie.rb +0 -20
- data/lib/watir/image.rb +0 -111
- data/lib/watir/input_elements.rb +0 -480
- data/lib/watir/irb-history.rb +0 -31
- data/lib/watir/link.rb +0 -46
- data/lib/watir/locator.rb +0 -243
- data/lib/watir/logger.rb +0 -19
- data/lib/watir/modal_dialog.rb +0 -72
- data/lib/watir/module.rb +0 -12
- data/lib/watir/non_control_elements.rb +0 -114
- data/lib/watir/page-container.rb +0 -108
- data/lib/watir/process.rb +0 -20
- data/lib/watir/screen_capture.rb +0 -115
- data/lib/watir/supported_elements.rb +0 -172
- data/lib/watir/table.rb +0 -224
- data/lib/watir/win32.rb +0 -40
- data/lib/watir/win32ole.rb +0 -16
- data/lib/watir/win32ole/1.8.7/win32ole.so +0 -0
- data/lib/watir/win32ole/1.9.3/win32ole.so +0 -0
- data/lib/watir/window.rb +0 -68
- data/lib/watir/xpath_locator.rb +0 -52
- data/rakefile.rb +0 -54
- data/unittests/all_tests.rb +0 -10
- data/unittests/buttons_xpath_test.rb +0 -68
- data/unittests/checkbox_test.rb +0 -163
- data/unittests/checkbox_xpath_test.rb +0 -106
- data/unittests/click_no_wait_test.rb +0 -23
- data/unittests/close_all_test.rb +0 -17
- data/unittests/core_tests.rb +0 -17
- data/unittests/css_selector_test.rb +0 -44
- data/unittests/css_test.rb +0 -38
- data/unittests/dialog_test.rb +0 -64
- data/unittests/div2_xpath_test.rb +0 -21
- data/unittests/div_test.rb +0 -170
- data/unittests/div_xpath_test.rb +0 -95
- data/unittests/document_standards.rb +0 -63
- data/unittests/element_collection_indexes_test.rb +0 -57
- data/unittests/element_collections_test.rb +0 -100
- data/unittests/element_test.rb +0 -47
- data/unittests/errorchecker_test.rb +0 -31
- data/unittests/filefield_test.rb +0 -43
- data/unittests/filefield_xpath_test.rb +0 -35
- data/unittests/form_test.rb +0 -282
- data/unittests/form_xpath_test.rb +0 -254
- data/unittests/frame_test.rb +0 -165
- data/unittests/google_form_test.rb +0 -15
- data/unittests/html/JavascriptClick.html +0 -39
- data/unittests/html/blankpage.html +0 -11
- data/unittests/html/buttons1.html +0 -40
- data/unittests/html/checkboxes1.html +0 -89
- data/unittests/html/click_no_wait.html +0 -14
- data/unittests/html/complex_table.html +0 -35
- data/unittests/html/cssTest.html +0 -42
- data/unittests/html/depot_store.html +0 -59
- data/unittests/html/div.html +0 -92
- data/unittests/html/div_xml.html +0 -21
- data/unittests/html/fileupload.html +0 -44
- data/unittests/html/formTest1.html +0 -38
- data/unittests/html/forms2.html +0 -44
- data/unittests/html/forms3.html +0 -131
- data/unittests/html/forms4.html +0 -26
- data/unittests/html/frame_buttons.html +0 -4
- data/unittests/html/frame_links.html +0 -4
- data/unittests/html/frame_multi.html +0 -5
- data/unittests/html/google_india.html +0 -119
- data/unittests/html/ie7_document_standards.html +0 -9
- data/unittests/html/ie8_document_standards.html +0 -9
- data/unittests/html/ie9_document_standards.html +0 -9
- data/unittests/html/iframe.html +0 -3
- data/unittests/html/iframeTest.html +0 -17
- data/unittests/html/iframeTest1.html +0 -7
- data/unittests/html/iframeTest2.html +0 -5
- 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 +0 -65
- data/unittests/html/javascriptevents.html +0 -33
- data/unittests/html/link_pass.html +0 -11
- data/unittests/html/links1.html +0 -37
- data/unittests/html/links2.html +0 -11
- data/unittests/html/links_multi.html +0 -12
- data/unittests/html/list_matters.html +0 -720
- data/unittests/html/lists.html +0 -18
- data/unittests/html/map_test.html +0 -30
- data/unittests/html/modal_dialog.html +0 -10
- data/unittests/html/modal_dialog_launcher.html +0 -12
- data/unittests/html/multiple_specifiers.html +0 -64
- data/unittests/html/nestedFrames.html +0 -6
- data/unittests/html/new_browser.html +0 -17
- data/unittests/html/pass.html +0 -13
- data/unittests/html/popups1.html +0 -59
- data/unittests/html/pre.html +0 -29
- data/unittests/html/quirks_document_standards.html +0 -8
- data/unittests/html/radioButtons1.html +0 -71
- data/unittests/html/select_tealeaf.html +0 -54
- data/unittests/html/selectboxes1.html +0 -52
- data/unittests/html/simple_table.html +0 -25
- data/unittests/html/simple_table_buttons.html +0 -104
- data/unittests/html/simple_table_columns.html +0 -75
- data/unittests/html/table1.html +0 -179
- data/unittests/html/tableCell_using_xpath.html +0 -19
- data/unittests/html/table_and_tablerow_to_a.html +0 -174
- data/unittests/html/textarea.html +0 -30
- data/unittests/html/textfields1.html +0 -100
- data/unittests/html/textsearch.html +0 -44
- data/unittests/html/wallofcheckboxes.html +0 -1003
- data/unittests/html/xpath_nbsp.html +0 -11
- data/unittests/html/zeroindex.html +0 -11
- data/unittests/ie_exists_test.rb +0 -16
- data/unittests/ie_mock.rb +0 -94
- data/unittests/ie_test.rb +0 -54
- data/unittests/images_test.rb +0 -156
- data/unittests/images_xpath_test.rb +0 -90
- data/unittests/index_specifier_test.rb +0 -31
- data/unittests/js_events_test.rb +0 -31
- data/unittests/links_multi_test.rb +0 -34
- data/unittests/links_test.rb +0 -131
- data/unittests/links_xpath_test.rb +0 -38
- data/unittests/lists_test.rb +0 -23
- data/unittests/map_test.rb +0 -98
- data/unittests/minmax_test.rb +0 -37
- data/unittests/navigate_test.rb +0 -38
- data/unittests/nbsp_xpath_test.rb +0 -16
- data/unittests/no_wait_test.rb +0 -28
- data/unittests/non_core_tests.rb +0 -12
- data/unittests/other/all_tests_concurrent.rb +0 -57
- data/unittests/other/navigate_exception_test.rb +0 -24
- data/unittests/other/rexml_unit_test.rb +0 -27
- data/unittests/other/screen_capture_test.rb +0 -53
- data/unittests/other/testcase_method_order_test.rb +0 -36
- data/unittests/other/testcase_verify_test.rb +0 -25
- data/unittests/other/wait_until_test.rb +0 -102
- data/unittests/pagecontainstext_test.rb +0 -69
- data/unittests/parent_child_test.rb +0 -27
- data/unittests/perf_test.rb +0 -20
- data/unittests/pre_test.rb +0 -49
- data/unittests/radios_test.rb +0 -181
- data/unittests/radios_xpath_test.rb +0 -100
- data/unittests/security_setting_test.rb +0 -24
- data/unittests/selectbox_test.rb +0 -144
- data/unittests/selectbox_xpath_test.rb +0 -102
- data/unittests/setup.rb +0 -70
- data/unittests/speed_settings_test.rb +0 -67
- data/unittests/table_cell_using_xpath_test.rb +0 -34
- data/unittests/table_test.rb +0 -296
- data/unittests/table_xpath_test.rb +0 -109
- data/unittests/test_tests.rb +0 -9
- data/unittests/textarea_test.rb +0 -92
- data/unittests/textarea_xpath_test.rb +0 -77
- data/unittests/textfield_for_ch_char_test.rb +0 -32
- data/unittests/textfields_test.rb +0 -184
- data/unittests/textfields_xpath_test.rb +0 -110
- data/unittests/version_test.rb +0 -15
- data/unittests/win32ole_so_test.rb +0 -35
- data/unittests/window_tests.rb +0 -10
- data/unittests/windows/attach_to_existing_window_test.rb +0 -52
- data/unittests/windows/attach_to_new_window_test.rb +0 -74
- data/unittests/windows/close_window_test.rb +0 -20
- data/unittests/windows/frame_links_test.rb +0 -23
- data/unittests/windows/ie-each_test.rb +0 -46
- data/unittests/windows/modal_dialog_test.rb +0 -95
- data/unittests/windows/new_process_test.rb +0 -24
- data/unittests/windows/new_test.rb +0 -58
- data/unittests/windows/open_close_test.rb +0 -19
- data/unittests/windows/send_keys_test.rb +0 -26
- data/unittests/xpath_tests.rb +0 -11
- data/watir-rdoc.rb +0 -7
data/unittests/no_wait_test.rb
DELETED
@@ -1,28 +0,0 @@
|
|
1
|
-
$LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..') unless $SETUP_LOADED
|
2
|
-
require 'unittests/setup'
|
3
|
-
|
4
|
-
class TC_No_Wait_Commands < Test::Unit::TestCase
|
5
|
-
def test_fire_event_no_wait
|
6
|
-
goto_page "javascriptevents.html"
|
7
|
-
browser.text_field(:index, 0).fire_event_no_wait("onkeyup")
|
8
|
-
assert_nothing_raised{
|
9
|
-
Watir::Wait.until {browser.div(:id, 'event_name').text == 'onkeyup'}
|
10
|
-
}
|
11
|
-
end
|
12
|
-
|
13
|
-
def test_set_no_wait_text_field
|
14
|
-
goto_page "textfields1.html"
|
15
|
-
browser.text_field(:name, "text1").set_no_wait("watir IE Controller")
|
16
|
-
assert_nothing_raised{
|
17
|
-
Watir::Wait.until {browser.text_field(:name, "text1").value == "watir IE Controller"}
|
18
|
-
}
|
19
|
-
end
|
20
|
-
|
21
|
-
def test_select_no_wait_text_select_list
|
22
|
-
goto_page "selectboxes1.html"
|
23
|
-
browser.select_list(:name,'sel1').select_no_wait(/Option 1/)
|
24
|
-
assert_nothing_raised{
|
25
|
-
Watir::Wait.until {browser.select_list(:name , 'sel1').selected_options.first.text == 'Option 1'}
|
26
|
-
}
|
27
|
-
end
|
28
|
-
end
|
data/unittests/non_core_tests.rb
DELETED
@@ -1,12 +0,0 @@
|
|
1
|
-
TOPDIR = File.join(File.dirname(__FILE__), '..')
|
2
|
-
$LOAD_PATH.unshift TOPDIR
|
3
|
-
|
4
|
-
require 'unittests/setup.rb'
|
5
|
-
|
6
|
-
Dir.chdir TOPDIR
|
7
|
-
$all_tests.each {|x| require x}
|
8
|
-
|
9
|
-
Watir::UnitTest.filter = proc do |test|
|
10
|
-
test.class.to_s !~ /xpath/i &&
|
11
|
-
test.class.tags.include?(:must_be_visible)
|
12
|
-
end
|
@@ -1,57 +0,0 @@
|
|
1
|
-
# This is an UNFINISHED attempt to run the unit tests currently.
|
2
|
-
# The work on the harness is complete.
|
3
|
-
# The problem remaining is that the tests are not thread-safe.
|
4
|
-
# It's an open question whether getting this to work would actually save any execution time.
|
5
|
-
|
6
|
-
TOPDIR = File.join(File.dirname(__FILE__), '..')
|
7
|
-
$LOAD_PATH.unshift TOPDIR
|
8
|
-
Dir.chdir TOPDIR
|
9
|
-
#(Dir["unittests/*_test.rb"] - ["unittests/popups_test.rb"]).each {|x| require x}
|
10
|
-
|
11
|
-
require 'unittests/buttons_test'
|
12
|
-
require 'unittests/checkbox_test'
|
13
|
-
|
14
|
-
require 'test/unit/testsuite'
|
15
|
-
require 'thread'
|
16
|
-
class ConcurrentTestSuite < Test::Unit::TestSuite
|
17
|
-
|
18
|
-
# Runs the tests and/or suites contained in this TestSuite.
|
19
|
-
def run(result, &progress_block)
|
20
|
-
yield(STARTED, name)
|
21
|
-
threads = []
|
22
|
-
@tests.each do |test|
|
23
|
-
threads << Thread.new do
|
24
|
-
test.run(result, &progress_block)
|
25
|
-
end
|
26
|
-
end
|
27
|
-
threads.each {|t| t.join}
|
28
|
-
yield(FINISHED, name)
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
# create a suite
|
33
|
-
require 'test/unit/collector/objectspace'
|
34
|
-
|
35
|
-
require 'test/unit/collector'
|
36
|
-
include Test::Unit::Collector
|
37
|
-
|
38
|
-
|
39
|
-
@filters = []
|
40
|
-
suite = ConcurrentTestSuite.new('super suite')
|
41
|
-
sub_suites = []
|
42
|
-
::ObjectSpace.each_object(Class) do |klass|
|
43
|
-
if(Test::Unit::TestCase > klass)
|
44
|
-
puts sub_suites, klass.suite
|
45
|
-
add_suite(sub_suites, klass.suite)
|
46
|
-
end
|
47
|
-
end
|
48
|
-
sort(sub_suites).each{|s| suite << s}
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
# select a runner
|
53
|
-
require 'test/unit/ui/console/testrunner'
|
54
|
-
Test::Unit::UI::Console::TestRunner.run(suite)
|
55
|
-
|
56
|
-
|
57
|
-
# then subclass Test::Unit::TestSuite and override the run method to be multithreaded
|
@@ -1,24 +0,0 @@
|
|
1
|
-
# feature tests for navigation errors
|
2
|
-
|
3
|
-
$LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..', '..') unless $SETUP_LOADED
|
4
|
-
require 'unittests/setup'
|
5
|
-
require 'watir/contrib/page_checker'
|
6
|
-
# To add checkers, call the ie.add_checker method
|
7
|
-
#
|
8
|
-
# ie.
|
9
|
-
|
10
|
-
class TC_NavigateException < Test::Unit::TestCase
|
11
|
-
include Watir
|
12
|
-
|
13
|
-
def setup
|
14
|
-
browser.add_checker(PageCheckers::NAVIGATION_CHECKER)
|
15
|
-
end
|
16
|
-
def teardown
|
17
|
-
browser.disable_checker(PageCheckers::NAVIGATION_CHECKER)
|
18
|
-
end
|
19
|
-
|
20
|
-
def test_http_errors
|
21
|
-
assert_raises(NavigationException) { browser.goto('http://localhost:3001') } # Cannot find server or DNS Error
|
22
|
-
assert_raises(NavigationException) { browser.goto('http://www.fxruby.org/dfdf' ) } # HTTP 404 - File not found
|
23
|
-
end
|
24
|
-
end
|
@@ -1,27 +0,0 @@
|
|
1
|
-
require 'test/unit'
|
2
|
-
require 'nokogiri'
|
3
|
-
|
4
|
-
class XPathTest < Test::Unit::TestCase
|
5
|
-
def setup
|
6
|
-
file = File.open( "xpath_bug.xml" )
|
7
|
-
@doc = Nokogiri::HTML::Document.read_io(file, nil, nil, 2145)
|
8
|
-
end
|
9
|
-
def fixture xpath
|
10
|
-
matches = []
|
11
|
-
|
12
|
-
@doc.xpath(xpath).each() do |node|
|
13
|
-
matches << node
|
14
|
-
assert_equal('Add', node.text)
|
15
|
-
assert_equal('ButtonText', node['class'])
|
16
|
-
end
|
17
|
-
|
18
|
-
assert_equal(1, matches.length)
|
19
|
-
end
|
20
|
-
def test_text
|
21
|
-
fixture "//div[text()='Add' and @class='ButtonText']"
|
22
|
-
end
|
23
|
-
def test_contains
|
24
|
-
fixture "//div[contains(.,'Add') and @class='ButtonText']"
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
@@ -1,53 +0,0 @@
|
|
1
|
-
# feature tests for screen capture
|
2
|
-
|
3
|
-
$LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..') unless $SETUP_LOADED
|
4
|
-
require 'unittests/setup'
|
5
|
-
require 'watir/screen_capture'
|
6
|
-
|
7
|
-
class TC_Capture< Test::Unit::TestCase
|
8
|
-
tags :must_be_visible
|
9
|
-
include Watir
|
10
|
-
include Watir::ScreenCapture
|
11
|
-
|
12
|
-
def setup
|
13
|
-
delete_captured_files( [ 'jpeg1.jpg' , 'jpeg2.jpg' , 'bmp1.bmp', 'bmp2.bmp' ] )
|
14
|
-
browser.goto($htmlRoot + 'buttons1.html' )
|
15
|
-
@file_list = []
|
16
|
-
end
|
17
|
-
|
18
|
-
def teardown
|
19
|
-
delete_captured_files
|
20
|
-
end
|
21
|
-
|
22
|
-
def delete_captured_files(files=nil )
|
23
|
-
files = @file_list unless files
|
24
|
-
files.each do |f|
|
25
|
-
File.delete( f) if FileTest.exists?( f)
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
def test_jpeg
|
30
|
-
file_name= 'jpeg1.jpg'
|
31
|
-
@file_list << file_name
|
32
|
-
screen_capture( file_name )
|
33
|
-
assert(FileTest.exist?( file_name) )
|
34
|
-
|
35
|
-
file_name= 'jpeg2.jpg'
|
36
|
-
@file_list << file_name
|
37
|
-
screen_capture( file_name , true ) # just the active window
|
38
|
-
assert(FileTest.exist?( file_name) )
|
39
|
-
end
|
40
|
-
|
41
|
-
def test_bmp
|
42
|
-
file_name= 'bmp1.bmp'
|
43
|
-
@file_list << file_name
|
44
|
-
screen_capture( file_name , false, true )
|
45
|
-
assert(FileTest.exist?( file_name ) )
|
46
|
-
|
47
|
-
file_name= 'bmp2.bmp'
|
48
|
-
@file_list << file_name
|
49
|
-
screen_capture( file_name , true , true ) # just the active window
|
50
|
-
assert(FileTest.exist?( file_name) )
|
51
|
-
end
|
52
|
-
end
|
53
|
-
|
@@ -1,36 +0,0 @@
|
|
1
|
-
# the default behavior of Test::Unit::TestCase should be to execute test
|
2
|
-
# methods in alphabetical order.
|
3
|
-
# When executed, should print "A.B.C.D.E.F.G.H.I.J.K.L.F"
|
4
|
-
# The final F is actually an expected failure:
|
5
|
-
# 1) Failure:
|
6
|
-
# default_test(TC4_No_Test_Methods)
|
7
|
-
|
8
|
-
$LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..', '..') unless $SETUP_LOADED
|
9
|
-
|
10
|
-
require 'watir/testcase'
|
11
|
-
|
12
|
-
class TC1_Alphabetical_Default < Watir::TestCase
|
13
|
-
execute :alphabetically
|
14
|
-
def test_b; print 'B'; end
|
15
|
-
def test_a; print 'A'; end
|
16
|
-
def test_d; print 'D'; end
|
17
|
-
def test_c; print 'C'; end
|
18
|
-
end
|
19
|
-
|
20
|
-
class TC2_Sequential < Watir::TestCase
|
21
|
-
def test_b; print 'E'; end
|
22
|
-
def test_a; print 'F'; end
|
23
|
-
def test_d; print 'G'; end
|
24
|
-
def test_c; print 'H'; end
|
25
|
-
end
|
26
|
-
|
27
|
-
class TC3_Alphabetical_Specified < Watir::TestCase
|
28
|
-
execute :alphabetically
|
29
|
-
def test_b; print 'J'; end
|
30
|
-
def test_a; print 'I'; end
|
31
|
-
def test_d; print 'L'; end
|
32
|
-
def test_c; print 'K'; end
|
33
|
-
end
|
34
|
-
|
35
|
-
class TC4_No_Test_Methods < Watir::TestCase
|
36
|
-
end
|
@@ -1,25 +0,0 @@
|
|
1
|
-
# 3 tests, 10 assertions, 4 failures, 0 errors
|
2
|
-
|
3
|
-
require 'watir/testcase'
|
4
|
-
|
5
|
-
class VerifyTests < Watir::TestCase
|
6
|
-
|
7
|
-
def test_verify
|
8
|
-
verify true
|
9
|
-
assert true
|
10
|
-
verify false
|
11
|
-
assert true
|
12
|
-
end
|
13
|
-
|
14
|
-
def test_verify_equal
|
15
|
-
verify_equal 1, 1
|
16
|
-
verify_equal 1, 2
|
17
|
-
verify_equal 3, 4
|
18
|
-
end
|
19
|
-
|
20
|
-
def test_verify_match
|
21
|
-
verify_match /\d*/, '123'
|
22
|
-
verify_match 'foo', 'foobar'
|
23
|
-
verify_match '...', 'A'
|
24
|
-
end
|
25
|
-
end
|
@@ -1,102 +0,0 @@
|
|
1
|
-
# feature tests for wait_until
|
2
|
-
#
|
3
|
-
# Watir::Waiter is DEPRECATED! Use methods from Watir::Wait and Watir::ElementExtensions instead!
|
4
|
-
#
|
5
|
-
|
6
|
-
require 'watir/testcase'
|
7
|
-
require 'watir/waiter'
|
8
|
-
require 'watir'
|
9
|
-
require 'spec' # gem install rspec
|
10
|
-
|
11
|
-
# used for unit testing
|
12
|
-
class MockTimeKeeper < Watir::TimeKeeper
|
13
|
-
def sleep seconds
|
14
|
-
@sleep_time += seconds
|
15
|
-
end
|
16
|
-
def now
|
17
|
-
Time.now + @sleep_time
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
class WaitUntilInstanceTest < Watir::TestCase
|
22
|
-
|
23
|
-
def setup
|
24
|
-
@waiter = Watir::Waiter.new
|
25
|
-
@waiter.timeout = 10.0
|
26
|
-
@mock_checkee = Spec::Mocks::Mock.new "mock_checkee"
|
27
|
-
|
28
|
-
# remove this line to test with actual TimeKeeper intead of the Mock
|
29
|
-
# (slower, but more accurate)
|
30
|
-
@waiter.timer = MockTimeKeeper.new
|
31
|
-
end
|
32
|
-
|
33
|
-
def teardown
|
34
|
-
@mock_checkee.__verify if @test_passed
|
35
|
-
end
|
36
|
-
|
37
|
-
# Instance Method
|
38
|
-
|
39
|
-
def test_no_time_passes_if_true
|
40
|
-
@waiter.wait_until {true}
|
41
|
-
@waiter.timer.sleep_time.should_equal 0.0
|
42
|
-
end
|
43
|
-
|
44
|
-
def test_three_tries_before_true
|
45
|
-
@mock_checkee.should_receive(:check).exactly(3).times.and_return [false, false, true]
|
46
|
-
@waiter.wait_until {@mock_checkee.check}
|
47
|
-
@waiter.timer.sleep_time.should_equal 1.0
|
48
|
-
end
|
49
|
-
|
50
|
-
def test_timeout
|
51
|
-
@mock_checkee.should_receive(:check).any_number_of_times.and_return false
|
52
|
-
lambda{@waiter.wait_until {@mock_checkee.check}}.should_raise Watir::Exception::TimeOutException
|
53
|
-
@waiter.timer.sleep_time.should_be_close 10.25, 0.26
|
54
|
-
@waiter.timer.sleep_time.should_satisfy {|x| [10.0, 10.5].include? x}
|
55
|
-
end
|
56
|
-
|
57
|
-
def test_polling_interval
|
58
|
-
@waiter.polling_interval = 0.1
|
59
|
-
@mock_checkee.should_receive(:check).any_number_of_times.and_return false
|
60
|
-
lambda{@waiter.wait_until {@mock_checkee.check}}.should_raise Watir::Exception::TimeOutException
|
61
|
-
@waiter.timer.sleep_time.should_be_close 10.05, 0.07
|
62
|
-
end
|
63
|
-
|
64
|
-
def test_timeout_duration
|
65
|
-
@mock_checkee.should_receive(:check).any_number_of_times.and_return false
|
66
|
-
begin
|
67
|
-
@waiter.wait_until {@mock_checkee.check}
|
68
|
-
flunk
|
69
|
-
rescue Watir::Exception::TimeOutException => e
|
70
|
-
e.duration.should_be_close 10.25, 0.26
|
71
|
-
e.timeout.should_equal 10.0
|
72
|
-
end
|
73
|
-
end
|
74
|
-
end
|
75
|
-
|
76
|
-
class WaitUntilClassTest < Watir::TestCase
|
77
|
-
|
78
|
-
def setup
|
79
|
-
@mock_checkee = Spec::Mocks::Mock.new "mock_checkee"
|
80
|
-
@mock_checkee.should_receive(:check).exactly(3).times.and_return [false, false, true]
|
81
|
-
end
|
82
|
-
|
83
|
-
def teardown
|
84
|
-
@mock_checkee.__verify if @test_passed
|
85
|
-
end
|
86
|
-
# Class method
|
87
|
-
|
88
|
-
def test_class_method_with_args
|
89
|
-
Watir::Waiter.wait_until(5, 0.1) {@mock_checkee.check}
|
90
|
-
end
|
91
|
-
|
92
|
-
def test_class_method_with_defaults
|
93
|
-
Watir::Waiter.wait_until {@mock_checkee.check}
|
94
|
-
end
|
95
|
-
|
96
|
-
include Watir
|
97
|
-
def test_watir_method
|
98
|
-
wait_until {@mock_checkee.check}
|
99
|
-
end
|
100
|
-
|
101
|
-
end
|
102
|
-
|
@@ -1,69 +0,0 @@
|
|
1
|
-
# feature tests for IE::contains_text
|
2
|
-
|
3
|
-
$LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..') unless $SETUP_LOADED
|
4
|
-
require 'unittests/setup'
|
5
|
-
|
6
|
-
class TC_contains_text < Test::Unit::TestCase
|
7
|
-
|
8
|
-
def setup
|
9
|
-
goto_page "textsearch.html"
|
10
|
-
end
|
11
|
-
|
12
|
-
def test_text_found
|
13
|
-
assert(browser.contains_text('slings and arrows of outrageous fortune'))
|
14
|
-
end
|
15
|
-
|
16
|
-
def test_text_not_found
|
17
|
-
assert_false(browser.contains_text('So are they all, all honourable men'))
|
18
|
-
end
|
19
|
-
|
20
|
-
def test_regexp_found
|
21
|
-
assert(browser.contains_text(/bodkin.*fardels/))
|
22
|
-
end
|
23
|
-
|
24
|
-
def test_regexp_not_found
|
25
|
-
assert_false(browser.contains_text(/winding.*watch.*wit/))
|
26
|
-
end
|
27
|
-
|
28
|
-
def test_match_regexp_found
|
29
|
-
$~ = browser.contains_text(/Messages ([0-9]+)/)
|
30
|
-
assert_equal('42', $1)
|
31
|
-
end
|
32
|
-
|
33
|
-
def test_bad_search_argument
|
34
|
-
assert_raises(ArgumentError) do
|
35
|
-
browser.contains_text
|
36
|
-
end
|
37
|
-
assert_raises(ArgumentError) do
|
38
|
-
browser.contains_text(nil)
|
39
|
-
end
|
40
|
-
assert_raises(ArgumentError) do
|
41
|
-
browser.contains_text(42)
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
|
-
end
|
46
|
-
|
47
|
-
class TC_contains_text_in_new_ie < Test::Unit::TestCase
|
48
|
-
tags :fails_on_firefox
|
49
|
-
# Doesn't actually raise an error, but fails to close the window afterwards
|
50
|
-
# http://jira.openqa.org/browse/WTR-265
|
51
|
-
def setup
|
52
|
-
@new_browser = Watir::Browser.new
|
53
|
-
end
|
54
|
-
def test_nothing_raised
|
55
|
-
assert_nothing_raised {@new_browser.text.include? ''}
|
56
|
-
end
|
57
|
-
def teardown
|
58
|
-
@new_browser.close
|
59
|
-
end
|
60
|
-
end
|
61
|
-
|
62
|
-
class TC_contains_text_in_frame < Test::Unit::TestCase
|
63
|
-
def setup
|
64
|
-
goto_page "frame_links.html"
|
65
|
-
end
|
66
|
-
def test_in_frame
|
67
|
-
assert browser.frame(:name => 'linkFrame').contains_text('The button is really a link')
|
68
|
-
end
|
69
|
-
end
|