watir-classic 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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,31 @@
|
|
|
1
|
+
# snarfed from http://blog.nicksieger.com/articles/2006/04/23/tweaking-irb
|
|
2
|
+
module Readline
|
|
3
|
+
module History
|
|
4
|
+
@@log ||= File.join(Dir.pwd, 'console.log')
|
|
5
|
+
|
|
6
|
+
def self.log= log
|
|
7
|
+
@@log = log
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def self.write_log(line)
|
|
11
|
+
begin
|
|
12
|
+
File.open(@@log, 'ab') {|f| f << "#{line}\n"}
|
|
13
|
+
rescue
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def self.start_session_log
|
|
18
|
+
write_log("# session start: #{Time.now}")
|
|
19
|
+
at_exit { write_log("# session stop: #{Time.now}\n") }
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
alias :old_readline :readline
|
|
24
|
+
def readline(*args)
|
|
25
|
+
ln = old_readline(*args)
|
|
26
|
+
History.write_log(ln)
|
|
27
|
+
ln
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
Readline::History.start_session_log
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
module Watir
|
|
2
|
+
|
|
3
|
+
# This class is the means of accessing a link on a page
|
|
4
|
+
# Normally a user would not need to create this object as it is returned by the Watir::Container#link method
|
|
5
|
+
# many of the methods available to this object are inherited from the Element class
|
|
6
|
+
#
|
|
7
|
+
class Link < Element
|
|
8
|
+
attr_ole :type
|
|
9
|
+
attr_ole :href
|
|
10
|
+
|
|
11
|
+
# if an image is used as part of the link, this will return true
|
|
12
|
+
def link_has_image
|
|
13
|
+
assert_exists
|
|
14
|
+
return true if @o.getElementsByTagName("IMG").length > 0
|
|
15
|
+
return false
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
# this method returns the src of an image, if an image is used as part of the link
|
|
19
|
+
def src # BUG?
|
|
20
|
+
assert_exists
|
|
21
|
+
if @o.getElementsByTagName("IMG").length > 0
|
|
22
|
+
return @o.getElementsByTagName("IMG")[0.to_s].src
|
|
23
|
+
else
|
|
24
|
+
return ""
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def link_string_creator
|
|
29
|
+
n = []
|
|
30
|
+
n << "href:".ljust(TO_S_SIZE) + self.href
|
|
31
|
+
n << "inner text:".ljust(TO_S_SIZE) + self.text
|
|
32
|
+
n << "img src:".ljust(TO_S_SIZE) + self.src if self.link_has_image
|
|
33
|
+
return n
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
# returns a textual description of the link
|
|
37
|
+
def to_s
|
|
38
|
+
assert_exists
|
|
39
|
+
r = string_creator
|
|
40
|
+
r = r + link_string_creator
|
|
41
|
+
return r.join("\n")
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
end
|
|
@@ -0,0 +1,243 @@
|
|
|
1
|
+
module Watir
|
|
2
|
+
class Locator
|
|
3
|
+
include Watir
|
|
4
|
+
include Watir::Exception
|
|
5
|
+
include XpathLocator
|
|
6
|
+
|
|
7
|
+
def initialize container, specifiers, klass
|
|
8
|
+
@container = container
|
|
9
|
+
@specifiers = {:index => Watir::IE.base_index}.merge(normalize_specifiers(specifiers))
|
|
10
|
+
@tags = @specifiers.delete(:tag_name)
|
|
11
|
+
@klass = klass
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def each
|
|
15
|
+
if has_excluding_specifiers?
|
|
16
|
+
locate_elements_by_xpath_css_ole.each do |element|
|
|
17
|
+
yield element
|
|
18
|
+
end
|
|
19
|
+
else
|
|
20
|
+
@tags.each do |tag|
|
|
21
|
+
each_element(tag) do |element|
|
|
22
|
+
next unless type_matches?(element.ole_object) && match_with_specifiers?(element)
|
|
23
|
+
yield element
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
nil
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def document
|
|
31
|
+
@document ||= @container.document
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def normalize_specifiers(specifiers)
|
|
35
|
+
specifiers.reduce({}) do |memo, pair|
|
|
36
|
+
how, what = *pair
|
|
37
|
+
case how
|
|
38
|
+
when :index
|
|
39
|
+
what = what.to_i
|
|
40
|
+
when :url
|
|
41
|
+
how = :href
|
|
42
|
+
when :class
|
|
43
|
+
how = :class_name
|
|
44
|
+
when :caption
|
|
45
|
+
how = :value
|
|
46
|
+
when :method
|
|
47
|
+
how = :form_method
|
|
48
|
+
when :value
|
|
49
|
+
what = what.is_a?(Regexp) ? what : what.to_s
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
memo[how] = what
|
|
53
|
+
memo
|
|
54
|
+
end
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
def match_with_specifiers?(element)
|
|
58
|
+
return true if has_excluding_specifiers?
|
|
59
|
+
@specifiers.all? do |how, what|
|
|
60
|
+
how == :index ||
|
|
61
|
+
(how == :class_name && match_class?(element, what)) ||
|
|
62
|
+
match?(element, how, what)
|
|
63
|
+
end
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
def match_class? element, what
|
|
67
|
+
classes = element.class_name.split(/\s+/)
|
|
68
|
+
classes.any? {|clazz| what.matches(clazz)}
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
# return true if the element matches the provided how and what
|
|
72
|
+
def match? element, how, what
|
|
73
|
+
begin
|
|
74
|
+
attribute = element.send(how)
|
|
75
|
+
rescue NoMethodError
|
|
76
|
+
raise MissingWayOfFindingObjectException,
|
|
77
|
+
"#{how} is an unknown way of finding a <#{@tags.join(", ")}> element (#{what})"
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
what.matches(attribute)
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
def has_excluding_specifiers?
|
|
84
|
+
@specifiers.keys.any? {|specifier| [:css, :xpath, :ole_object].include? specifier}
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
def locate_by_id
|
|
88
|
+
# Searching through all elements returned by __ole_inner_elements
|
|
89
|
+
# is *significantly* slower than IE's getElementById() and
|
|
90
|
+
# getElementsByName() calls when how is :id. However
|
|
91
|
+
# IE doesn't match Regexps, so first we make sure what is a String.
|
|
92
|
+
# In addition, IE's getElementById() will also return an element
|
|
93
|
+
# where the :name matches, so we will only return the results of
|
|
94
|
+
# getElementById() if the matching element actually HAS a matching
|
|
95
|
+
# :id.
|
|
96
|
+
|
|
97
|
+
the_id = @specifiers[:id]
|
|
98
|
+
if the_id && the_id.class == String
|
|
99
|
+
element = document.getElementById(the_id) rescue nil
|
|
100
|
+
# Return if our fast match really HAS a matching :id
|
|
101
|
+
return element if element && element.invoke('id') == the_id && type_matches?(element) && match_with_specifiers?(create_element element)
|
|
102
|
+
end
|
|
103
|
+
|
|
104
|
+
nil
|
|
105
|
+
end
|
|
106
|
+
|
|
107
|
+
def locate_elements_by_xpath_css_ole
|
|
108
|
+
els = []
|
|
109
|
+
|
|
110
|
+
if @specifiers[:xpath]
|
|
111
|
+
els = elements_by_xpath(@specifiers[:xpath])
|
|
112
|
+
elsif @specifiers[:css]
|
|
113
|
+
els = elements_by_css(@specifiers[:css])
|
|
114
|
+
elsif @specifiers[:ole_object]
|
|
115
|
+
return [@specifiers[:ole_object]]
|
|
116
|
+
end
|
|
117
|
+
|
|
118
|
+
els.select {|element| type_matches?(element) && match_with_specifiers?(create_element element)}
|
|
119
|
+
end
|
|
120
|
+
|
|
121
|
+
def type_matches?(el)
|
|
122
|
+
@tags == ["*"] ||
|
|
123
|
+
@tags.include?(el.tagName.downcase) ||
|
|
124
|
+
@tags.include?(el.invoke('type').downcase) rescue false
|
|
125
|
+
end
|
|
126
|
+
|
|
127
|
+
def create_element ole_object
|
|
128
|
+
element = @klass.new(@container, @specifiers.merge(:ole_object => ole_object))
|
|
129
|
+
def element.locate; @o; end
|
|
130
|
+
element
|
|
131
|
+
end
|
|
132
|
+
end
|
|
133
|
+
|
|
134
|
+
class TaggedElementLocator < Locator
|
|
135
|
+
def each_element(tag)
|
|
136
|
+
document.getElementsByTagName(tag).each do |ole_object|
|
|
137
|
+
yield create_element ole_object
|
|
138
|
+
end
|
|
139
|
+
end
|
|
140
|
+
|
|
141
|
+
def locate
|
|
142
|
+
el = locate_by_id
|
|
143
|
+
return el if el
|
|
144
|
+
return locate_elements_by_xpath_css_ole[0] if has_excluding_specifiers?
|
|
145
|
+
|
|
146
|
+
count = Watir::IE.base_index - 1
|
|
147
|
+
each do |element|
|
|
148
|
+
count += 1
|
|
149
|
+
return element.ole_object if count == @specifiers[:index]
|
|
150
|
+
end # elements
|
|
151
|
+
nil
|
|
152
|
+
end
|
|
153
|
+
end
|
|
154
|
+
|
|
155
|
+
class FrameLocator < TaggedElementLocator
|
|
156
|
+
def each_element(tag)
|
|
157
|
+
frames = @container.page_container.document.frames
|
|
158
|
+
i = 0
|
|
159
|
+
document.getElementsByTagName(tag).each do |ole_object|
|
|
160
|
+
frame = create_element ole_object
|
|
161
|
+
frame.document = frames.item(i)
|
|
162
|
+
yield frame
|
|
163
|
+
i += 1
|
|
164
|
+
end
|
|
165
|
+
end
|
|
166
|
+
|
|
167
|
+
def locate
|
|
168
|
+
count = Watir::IE.base_index - 1
|
|
169
|
+
each do |frame|
|
|
170
|
+
count += 1
|
|
171
|
+
return frame.ole_object, frame.document if count == @specifiers[:index]
|
|
172
|
+
end
|
|
173
|
+
end
|
|
174
|
+
|
|
175
|
+
def locate_elements_by_xpath_css_ole
|
|
176
|
+
super.map do |frame|
|
|
177
|
+
frame = create_element frame
|
|
178
|
+
each_element(frame.tag_name) do |frame_with_document|
|
|
179
|
+
if frame_with_document == frame
|
|
180
|
+
frame = frame_with_document
|
|
181
|
+
break
|
|
182
|
+
end
|
|
183
|
+
end
|
|
184
|
+
frame
|
|
185
|
+
end
|
|
186
|
+
end
|
|
187
|
+
end
|
|
188
|
+
|
|
189
|
+
class FormLocator < TaggedElementLocator
|
|
190
|
+
def each_element(tag)
|
|
191
|
+
document.forms.each do |form|
|
|
192
|
+
yield create_element form
|
|
193
|
+
end
|
|
194
|
+
end
|
|
195
|
+
end
|
|
196
|
+
|
|
197
|
+
class InputElementLocator < Locator
|
|
198
|
+
def each_element
|
|
199
|
+
elements = locate_by_name || @container.__ole_inner_elements
|
|
200
|
+
elements.each do |object|
|
|
201
|
+
yield create_element object
|
|
202
|
+
end
|
|
203
|
+
nil
|
|
204
|
+
end
|
|
205
|
+
|
|
206
|
+
def locate
|
|
207
|
+
el = locate_by_id
|
|
208
|
+
return el if el
|
|
209
|
+
return locate_elements_by_xpath_css_ole[0] if has_excluding_specifiers?
|
|
210
|
+
|
|
211
|
+
count = Watir::IE.base_index - 1
|
|
212
|
+
each do |element|
|
|
213
|
+
count += 1
|
|
214
|
+
return element.ole_object if count == @specifiers[:index]
|
|
215
|
+
end
|
|
216
|
+
end
|
|
217
|
+
|
|
218
|
+
def each
|
|
219
|
+
if has_excluding_specifiers?
|
|
220
|
+
locate_elements_by_xpath_css_ole.each do |element|
|
|
221
|
+
yield element
|
|
222
|
+
end
|
|
223
|
+
else
|
|
224
|
+
each_element do |element|
|
|
225
|
+
next unless type_matches?(element.ole_object) && match_with_specifiers?(element)
|
|
226
|
+
yield element
|
|
227
|
+
end
|
|
228
|
+
end
|
|
229
|
+
nil
|
|
230
|
+
end
|
|
231
|
+
|
|
232
|
+
private
|
|
233
|
+
|
|
234
|
+
def locate_by_name
|
|
235
|
+
the_name = @specifiers[:name]
|
|
236
|
+
if the_name && the_name.class == String
|
|
237
|
+
return document.getElementsByName(the_name) rescue nil
|
|
238
|
+
end
|
|
239
|
+
nil
|
|
240
|
+
end
|
|
241
|
+
end
|
|
242
|
+
|
|
243
|
+
end
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
module Watir
|
|
2
|
+
class WatirLogger < Logger
|
|
3
|
+
def initialize(filName, logsToKeep, maxLogSize)
|
|
4
|
+
super(filName, logsToKeep, maxLogSize)
|
|
5
|
+
self.level = Logger::DEBUG
|
|
6
|
+
self.datetime_format = "%d-%b-%Y %H:%M:%S"
|
|
7
|
+
self.debug("Watir starting")
|
|
8
|
+
end
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
class DefaultLogger < Logger
|
|
12
|
+
def initialize
|
|
13
|
+
super(STDERR)
|
|
14
|
+
self.level = Logger::WARN
|
|
15
|
+
self.datetime_format = "%d-%b-%Y %H:%M:%S"
|
|
16
|
+
self.info "Log started"
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
class String
|
|
2
|
+
def matches(x)
|
|
3
|
+
return self == x
|
|
4
|
+
end
|
|
5
|
+
end
|
|
6
|
+
|
|
7
|
+
class Regexp
|
|
8
|
+
def matches(x)
|
|
9
|
+
return self.match(x)
|
|
10
|
+
end
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
class Integer
|
|
14
|
+
def matches(x)
|
|
15
|
+
return self == x
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
class Object
|
|
20
|
+
def matches(x)
|
|
21
|
+
raise TypeError, "#{self.class} is not supported as a locator"
|
|
22
|
+
end
|
|
23
|
+
end
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
class WinClicker
|
|
2
|
+
def initialize
|
|
3
|
+
raise NotImplementedError, 'Watir no longer supports WinClicker. Please use click_no_wait and the javascript_dialog method.'
|
|
4
|
+
end
|
|
5
|
+
end
|
|
6
|
+
|
|
7
|
+
module Watir
|
|
8
|
+
class ModalDialog
|
|
9
|
+
include Container
|
|
10
|
+
include PageContainer
|
|
11
|
+
include Win32
|
|
12
|
+
|
|
13
|
+
def initialize(container)
|
|
14
|
+
set_container container
|
|
15
|
+
@modal = ::RAutomation::Window.new(:hwnd=>@container.hwnd).child(:class => 'Internet Explorer_TridentDlgFrame')
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def locate
|
|
19
|
+
@modal.wait_until_present rescue raise NoMatchingWindowFoundException
|
|
20
|
+
|
|
21
|
+
intUnknown = 0
|
|
22
|
+
Watir::until_with_timeout do
|
|
23
|
+
intPointer = " " * 4 # will contain the int value of the IUnknown*
|
|
24
|
+
GetUnknown.call(hwnd, intPointer)
|
|
25
|
+
intArray = intPointer.unpack('L')
|
|
26
|
+
intUnknown = intArray.first
|
|
27
|
+
intUnknown > 0
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
WIN32OLE.connect_unknown(intUnknown)
|
|
31
|
+
rescue NoMatchingWindowFoundException, Wait::TimeoutError
|
|
32
|
+
raise NoMatchingWindowFoundException,
|
|
33
|
+
"Unable to attach to Modal Window."
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
alias_method :document, :locate
|
|
37
|
+
|
|
38
|
+
def title
|
|
39
|
+
document.title
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
def close(timeout=5)
|
|
43
|
+
return unless exists?
|
|
44
|
+
document.parentWindow.close
|
|
45
|
+
Watir::Wait.until(timeout) {!exists?} rescue nil
|
|
46
|
+
wait
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
def attach_command
|
|
50
|
+
"Watir::IE.find(:hwnd, #{@container.hwnd}).modal_dialog"
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
def wait(no_sleep=false)
|
|
54
|
+
@container.page_container.wait unless exists?
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
def hwnd
|
|
58
|
+
@modal.hwnd
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
def active?
|
|
62
|
+
@modal.active?
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
def exists?
|
|
66
|
+
@modal.exists?
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
alias_method :exist?, :exists?
|
|
70
|
+
|
|
71
|
+
end
|
|
72
|
+
end
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
module Watir
|
|
2
|
+
include Watir::Exception
|
|
3
|
+
|
|
4
|
+
# Directory containing the watir.rb file
|
|
5
|
+
@@dir = File.expand_path(File.dirname(__FILE__))
|
|
6
|
+
|
|
7
|
+
# Like regular Ruby "until", except that a Wait::TimeoutError is raised
|
|
8
|
+
# if the timeout is exceeded. Timeout is IE.attach_timeout.
|
|
9
|
+
def self.until_with_timeout # block
|
|
10
|
+
Wait.until(IE.attach_timeout) { yield }
|
|
11
|
+
end
|
|
12
|
+
end
|