operawatir 0.3-jruby
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/.gitmodules +3 -0
- data/.yardopts +5 -0
- data/AUTHORS +7 -0
- data/Gemfile +9 -0
- data/LICENSE +30 -0
- data/README.md +158 -0
- data/Rakefile +59 -0
- data/VERSION +1 -0
- data/bin/desktopwatir +106 -0
- data/bin/operawatir +95 -0
- data/lib/operadriver/APACHE_2.0_LICENSE.txt +204 -0
- data/lib/operadriver/NEW_BSD_LICENSE.txt +36 -0
- data/lib/operadriver/commons-jxpath-1.3.jar +0 -0
- data/lib/operadriver/protobuf-java-2.3.0.jar +0 -0
- data/lib/operadriver/selenium-common.jar +0 -0
- data/lib/operadriver/webdriver-opera.jar +0 -0
- data/lib/operawatir.rb +46 -0
- data/lib/operawatir/browser.rb +181 -0
- data/lib/operawatir/collection.rb +133 -0
- data/lib/operawatir/compat.rb +25 -0
- data/lib/operawatir/compat/browser.rb +20 -0
- data/lib/operawatir/compat/collection.rb +99 -0
- data/lib/operawatir/compat/deprecation.rb +46 -0
- data/lib/operawatir/compat/element.rb +165 -0
- data/lib/operawatir/compat/element_finders.rb +159 -0
- data/lib/operawatir/compat/window.rb +27 -0
- data/lib/operawatir/element.rb +228 -0
- data/lib/operawatir/exceptions.rb +38 -0
- data/lib/operawatir/helper.rb +53 -0
- data/lib/operawatir/selector.rb +111 -0
- data/lib/operawatir/version.rb +15 -0
- data/lib/operawatir/window.rb +174 -0
- data/spec/fire_event/fire_event.rb +268 -0
- data/spec/fire_event/interactive/onBlur.html +45 -0
- data/spec/fire_event/interactive/onChange.html +47 -0
- data/spec/fire_event/interactive/onClick.html +45 -0
- data/spec/fire_event/interactive/onDblClick.html +45 -0
- data/spec/fire_event/interactive/onFocus.html +45 -0
- data/spec/fire_event/interactive/onMouseDown.html +45 -0
- data/spec/fire_event/interactive/onMouseMove.html +45 -0
- data/spec/fire_event/interactive/onMouseOut.html +45 -0
- data/spec/fire_event/interactive/onMouseOver.html +45 -0
- data/spec/fire_event/interactive/onMouseUp.html +45 -0
- data/spec/fire_event/interactive/onScroll.html +14 -0
- data/spec/legacy_watirspec/area_spec.rb +106 -0
- data/spec/legacy_watirspec/areas_spec.rb +38 -0
- data/spec/legacy_watirspec/browser_spec.rb +297 -0
- data/spec/legacy_watirspec/button_spec.rb +260 -0
- data/spec/legacy_watirspec/buttons_spec.rb +54 -0
- data/spec/legacy_watirspec/checkbox_spec.rb +280 -0
- data/spec/legacy_watirspec/checkboxes_spec.rb +38 -0
- data/spec/legacy_watirspec/collections_spec.rb +18 -0
- data/spec/legacy_watirspec/dd_spec.rb +140 -0
- data/spec/legacy_watirspec/dds_spec.rb +38 -0
- data/spec/legacy_watirspec/del_spec.rb +181 -0
- data/spec/legacy_watirspec/dels_spec.rb +62 -0
- data/spec/legacy_watirspec/div_spec.rb +244 -0
- data/spec/legacy_watirspec/divs_spec.rb +38 -0
- data/spec/legacy_watirspec/dl_spec.rb +140 -0
- data/spec/legacy_watirspec/dls_spec.rb +38 -0
- data/spec/legacy_watirspec/dt_spec.rb +140 -0
- data/spec/legacy_watirspec/dts_spec.rb +38 -0
- data/spec/legacy_watirspec/element_spec.rb +86 -0
- data/spec/legacy_watirspec/em_spec.rb +114 -0
- data/spec/legacy_watirspec/ems_spec.rb +38 -0
- data/spec/legacy_watirspec/filefield_spec.rb +127 -0
- data/spec/legacy_watirspec/filefields_spec.rb +38 -0
- data/spec/legacy_watirspec/fixtures/2000_spans.html +2009 -0
- data/spec/legacy_watirspec/fixtures/bug_duplicate_attributes.html +14 -0
- data/spec/legacy_watirspec/fixtures/bug_javascript_001.html +11 -0
- data/spec/legacy_watirspec/fixtures/buttons_with_duplicate_ids.html +18 -0
- data/spec/legacy_watirspec/fixtures/collections.html +15 -0
- data/spec/legacy_watirspec/fixtures/definition_lists.html +48 -0
- data/spec/legacy_watirspec/fixtures/euc-jp_text.html +17 -0
- data/spec/legacy_watirspec/fixtures/forms_with_input_elements.html +126 -0
- data/spec/legacy_watirspec/fixtures/frame_1.html +18 -0
- data/spec/legacy_watirspec/fixtures/frame_2.html +16 -0
- data/spec/legacy_watirspec/fixtures/frames.html +11 -0
- data/spec/legacy_watirspec/fixtures/iframes.html +12 -0
- data/spec/legacy_watirspec/fixtures/images.html +27 -0
- data/spec/legacy_watirspec/fixtures/images/1.gif +0 -0
- data/spec/legacy_watirspec/fixtures/images/2.gif +0 -0
- data/spec/legacy_watirspec/fixtures/images/3.gif +0 -0
- data/spec/legacy_watirspec/fixtures/images/button.jpg +0 -0
- data/spec/legacy_watirspec/fixtures/images/circle.jpg +0 -0
- data/spec/legacy_watirspec/fixtures/images/map.gif +0 -0
- data/spec/legacy_watirspec/fixtures/images/map2.gif +0 -0
- data/spec/legacy_watirspec/fixtures/images/minus.gif +0 -0
- data/spec/legacy_watirspec/fixtures/images/originaltriangle.jpg +0 -0
- data/spec/legacy_watirspec/fixtures/images/plus.gif +0 -0
- data/spec/legacy_watirspec/fixtures/images/square.jpg +0 -0
- data/spec/legacy_watirspec/fixtures/images/triangle.jpg +0 -0
- data/spec/legacy_watirspec/fixtures/iso-2022-jp_text.html +17 -0
- data/spec/legacy_watirspec/fixtures/javascript/helpers.js +16 -0
- data/spec/legacy_watirspec/fixtures/jquery.html +28 -0
- data/spec/legacy_watirspec/fixtures/latin1_text.html +17 -0
- data/spec/legacy_watirspec/fixtures/multiple_ids.html +14 -0
- data/spec/legacy_watirspec/fixtures/non_control_elements.html +135 -0
- data/spec/legacy_watirspec/fixtures/parser_bug_001.html +12 -0
- data/spec/legacy_watirspec/fixtures/prevent_form_submit.html +20 -0
- data/spec/legacy_watirspec/fixtures/right_click.html +11 -0
- data/spec/legacy_watirspec/fixtures/shift_jis_text.html +17 -0
- data/spec/legacy_watirspec/fixtures/tables.html +121 -0
- data/spec/legacy_watirspec/fixtures/timeout.html +16 -0
- data/spec/legacy_watirspec/fixtures/timeout_window_location.html +19 -0
- data/spec/legacy_watirspec/fixtures/tiny_mce.html +27 -0
- data/spec/legacy_watirspec/fixtures/utf8_text.html +15 -0
- data/spec/legacy_watirspec/fixtures/watirspec.css +0 -0
- data/spec/legacy_watirspec/form_spec.rb +73 -0
- data/spec/legacy_watirspec/forms_spec.rb +39 -0
- data/spec/legacy_watirspec/frame_spec.rb +161 -0
- data/spec/legacy_watirspec/frames_spec.rb +75 -0
- data/spec/legacy_watirspec/guards.rb +38 -0
- data/spec/legacy_watirspec/hidden_spec.rb +120 -0
- data/spec/legacy_watirspec/hiddens_spec.rb +38 -0
- data/spec/legacy_watirspec/hn_spec.rb +101 -0
- data/spec/legacy_watirspec/hns_spec.rb +39 -0
- data/spec/legacy_watirspec/image_spec.rb +237 -0
- data/spec/legacy_watirspec/images_spec.rb +38 -0
- data/spec/legacy_watirspec/ins_spec.rb +181 -0
- data/spec/legacy_watirspec/inses_spec.rb +62 -0
- data/spec/legacy_watirspec/label_spec.rb +85 -0
- data/spec/legacy_watirspec/labels_spec.rb +38 -0
- data/spec/legacy_watirspec/li_spec.rb +135 -0
- data/spec/legacy_watirspec/link_spec.rb +194 -0
- data/spec/legacy_watirspec/links_spec.rb +39 -0
- data/spec/legacy_watirspec/lis_spec.rb +38 -0
- data/spec/legacy_watirspec/map_spec.rb +100 -0
- data/spec/legacy_watirspec/maps_spec.rb +38 -0
- data/spec/legacy_watirspec/meta_spec.rb +26 -0
- data/spec/legacy_watirspec/metas_spec.rb +36 -0
- data/spec/legacy_watirspec/ol_spec.rb +86 -0
- data/spec/legacy_watirspec/ols_spec.rb +38 -0
- data/spec/legacy_watirspec/option_spec.rb +187 -0
- data/spec/legacy_watirspec/p_spec.rb +167 -0
- data/spec/legacy_watirspec/pre_spec.rb +133 -0
- data/spec/legacy_watirspec/pres_spec.rb +38 -0
- data/spec/legacy_watirspec/ps_spec.rb +38 -0
- data/spec/legacy_watirspec/radio_spec.rb +286 -0
- data/spec/legacy_watirspec/radios_spec.rb +35 -0
- data/spec/legacy_watirspec/select_list_spec.rb +326 -0
- data/spec/legacy_watirspec/select_lists_spec.rb +39 -0
- data/spec/legacy_watirspec/server.rb +91 -0
- data/spec/legacy_watirspec/span_spec.rb +181 -0
- data/spec/legacy_watirspec/spans_spec.rb +64 -0
- data/spec/legacy_watirspec/spec_helper.rb +12 -0
- data/spec/legacy_watirspec/strong_spec.rb +97 -0
- data/spec/legacy_watirspec/strongs_spec.rb +39 -0
- data/spec/legacy_watirspec/table_bodies_spec.rb +61 -0
- data/spec/legacy_watirspec/table_body_spec.rb +119 -0
- data/spec/legacy_watirspec/table_cell_spec.rb +76 -0
- data/spec/legacy_watirspec/table_cells_spec.rb +71 -0
- data/spec/legacy_watirspec/table_footer_spec.rb +94 -0
- data/spec/legacy_watirspec/table_footers_spec.rb +61 -0
- data/spec/legacy_watirspec/table_header_spec.rb +98 -0
- data/spec/legacy_watirspec/table_headers_spec.rb +59 -0
- data/spec/legacy_watirspec/table_row_spec.rb +104 -0
- data/spec/legacy_watirspec/table_rows_spec.rb +64 -0
- data/spec/legacy_watirspec/table_spec.rb +170 -0
- data/spec/legacy_watirspec/tables_spec.rb +40 -0
- data/spec/legacy_watirspec/text_field_spec.rb +315 -0
- data/spec/legacy_watirspec/text_fields_spec.rb +38 -0
- data/spec/legacy_watirspec/ul_spec.rb +84 -0
- data/spec/legacy_watirspec/uls_spec.rb +40 -0
- data/spec/legacy_watirspec/watir_compatibility_spec.rb +176 -0
- data/spec/legacy_watirspec/watirspec_helper.rb +57 -0
- data/utils/Rakefile +79 -0
- data/utils/launchers/launcher-linux-i686 +0 -0
- data/utils/launchers/launcher-linux-x86_64 +0 -0
- data/utils/launchers/launcher-win32-i86pc.exe +0 -0
- metadata +404 -0
@@ -0,0 +1,159 @@
|
|
1
|
+
module OperaWatir::Compat::ElementFinders
|
2
|
+
|
3
|
+
def self.def_element(tag, plural, opts={}, &blk)
|
4
|
+
blk = block_given? ? blk : lambda {|selector| selector.tag tag}
|
5
|
+
|
6
|
+
default_method = opts[:how] || :id
|
7
|
+
|
8
|
+
define_method tag do |*arguments|
|
9
|
+
OperaWatir::Collection.new(self).tap do |c|
|
10
|
+
blk.call c.selector
|
11
|
+
c.add_selector_from_arguments arguments, default_method
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
define_method plural do |*arguments|
|
16
|
+
OperaWatir::Collection.new(self).tap do |c|
|
17
|
+
blk.call c.selector
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
|
23
|
+
def_element :area, :areas
|
24
|
+
|
25
|
+
def_element :button, :buttons, :how => :value do |selector|
|
26
|
+
selector.join do |elm|
|
27
|
+
elm.tag(:button)
|
28
|
+
elm.tag(:input).join do |input|
|
29
|
+
input.attribute :type => 'submit'
|
30
|
+
input.attribute :type => 'button'
|
31
|
+
input.attribute :type => 'image'
|
32
|
+
input.attribute :type => 'reset'
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
def_element :checkbox, :checkboxes, :how => :name do |selector|
|
38
|
+
selector.tag(:input).attribute :type => 'checkbox'
|
39
|
+
end
|
40
|
+
|
41
|
+
def_element :dd, :dds
|
42
|
+
|
43
|
+
def_element :del, :dels
|
44
|
+
|
45
|
+
def_element :div, :divs
|
46
|
+
|
47
|
+
def_element :dl, :dls
|
48
|
+
|
49
|
+
def_element :dt, :dts
|
50
|
+
|
51
|
+
def_element :dt, :dts
|
52
|
+
|
53
|
+
def_element :em, :ems
|
54
|
+
|
55
|
+
def_element :file_field, :file_fields, :how => :name do |selector|
|
56
|
+
selector.tag(:input).attribute :type => 'file'
|
57
|
+
end
|
58
|
+
|
59
|
+
def_element :form, :forms
|
60
|
+
|
61
|
+
def_element :hidden, :hiddens, :how => :name do |selector|
|
62
|
+
selector.tag(:input).attribute :type => 'hidden'
|
63
|
+
end
|
64
|
+
|
65
|
+
def_element :h1, :h1s
|
66
|
+
|
67
|
+
def_element :h2, :h2s
|
68
|
+
|
69
|
+
def_element :h3, :h3s
|
70
|
+
|
71
|
+
def_element :h4, :h4s
|
72
|
+
|
73
|
+
def_element :h5, :h5s
|
74
|
+
|
75
|
+
def_element :h6, :h6s
|
76
|
+
|
77
|
+
def_element :image, :images, :how => :src do |selector|
|
78
|
+
selector.tag :img
|
79
|
+
end
|
80
|
+
|
81
|
+
def_element :ins, :inses
|
82
|
+
|
83
|
+
def_element :label, :labels, :how => :text
|
84
|
+
|
85
|
+
def_element :li, :lis
|
86
|
+
|
87
|
+
# Oh, nevermind the ACTUAL LINK ELEMENT
|
88
|
+
def_element :link, :links, :how => :href do |selector|
|
89
|
+
selector.tag :a
|
90
|
+
end
|
91
|
+
|
92
|
+
def_element :map, :maps
|
93
|
+
|
94
|
+
def_element :meta, :metas
|
95
|
+
|
96
|
+
def_element :ol, :ols
|
97
|
+
|
98
|
+
def_element :option, :options, :how => :text
|
99
|
+
|
100
|
+
def_element :p, :ps
|
101
|
+
|
102
|
+
def_element :pre, :pres
|
103
|
+
|
104
|
+
def_element :radio, :radios, :how => :name do |selector|
|
105
|
+
selector.tag(:input).attribute :type => 'radio'
|
106
|
+
end
|
107
|
+
|
108
|
+
def_element :select_list, :select_lists do |selector|
|
109
|
+
selector.tag :select
|
110
|
+
end
|
111
|
+
|
112
|
+
def_element :span, :spans
|
113
|
+
|
114
|
+
def_element :strong, :strongs
|
115
|
+
|
116
|
+
# Oh, nevermind the ACTUAL BODY ELEMENT
|
117
|
+
def_element :body, :bodies do |selector|
|
118
|
+
selector.tag :tbody
|
119
|
+
end
|
120
|
+
|
121
|
+
def_element :cell, :cells do |selector|
|
122
|
+
selector.tag :td
|
123
|
+
end
|
124
|
+
|
125
|
+
def_element :table_footer, :table_footers do |selector|
|
126
|
+
selector.tag :tfoot
|
127
|
+
end
|
128
|
+
|
129
|
+
def_element :table_header, :table_headers do |selector|
|
130
|
+
selector.tag :thead
|
131
|
+
end
|
132
|
+
|
133
|
+
def_element :table_row, :table_rows do |selector|
|
134
|
+
selector.tag :tr
|
135
|
+
end
|
136
|
+
|
137
|
+
def_element :table, :tables
|
138
|
+
|
139
|
+
def_element :text_field, :text_fields do |selector|
|
140
|
+
selector.join do |elm|
|
141
|
+
# TODO First test in element_spec.rb fails because we don't
|
142
|
+
# treat inputs with unknown type attributes as text fields. We
|
143
|
+
# could reverse this selector to include anything EXCEPT
|
144
|
+
# checkbox, radio, submit, reset, file, hidden, image and
|
145
|
+
# button. This would future proof it somewhat, but HTML5 types
|
146
|
+
# such as "range" do not allow values to be typed in (at least
|
147
|
+
# not in Opera)
|
148
|
+
|
149
|
+
# empty type is text
|
150
|
+
elm.tag(:input).attribute :type => ''
|
151
|
+
elm.tag(:input).attribute :type => 'text'
|
152
|
+
elm.tag(:input).attribute :type => 'password'
|
153
|
+
elm.tag :textarea
|
154
|
+
end
|
155
|
+
end
|
156
|
+
|
157
|
+
def_element :ul, :uls
|
158
|
+
|
159
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module OperaWatir
|
2
|
+
module Compat
|
3
|
+
module Window
|
4
|
+
|
5
|
+
# Checks whether the body has the given text in it.
|
6
|
+
#
|
7
|
+
# @param [String] str Text to search for.
|
8
|
+
# @return [Boolean] true if the body contains the given text,
|
9
|
+
# false otherwise
|
10
|
+
def contains_text(str)
|
11
|
+
text.index(str)
|
12
|
+
end
|
13
|
+
|
14
|
+
# Find elements that match the given XPath.
|
15
|
+
#
|
16
|
+
# @param [String] value The XPath expression to search for.
|
17
|
+
# @return [OperaWatir::Collection] A collection of matching
|
18
|
+
# elements.
|
19
|
+
def elements_by_xpath(value)
|
20
|
+
find_by_xpath(value)
|
21
|
+
end
|
22
|
+
|
23
|
+
alias_method :element_by_xpath, :elements_by_xpath
|
24
|
+
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,228 @@
|
|
1
|
+
class OperaWatir::Element
|
2
|
+
extend Forwardable
|
3
|
+
|
4
|
+
def initialize(node)
|
5
|
+
self.node = node
|
6
|
+
end
|
7
|
+
|
8
|
+
# TODO Need support for this in Webdriver
|
9
|
+
def hash
|
10
|
+
node.hashCode
|
11
|
+
end
|
12
|
+
|
13
|
+
def ==(other)
|
14
|
+
node.equals other.node
|
15
|
+
end
|
16
|
+
|
17
|
+
def eql?(other)
|
18
|
+
is_a?(other.class) && self == other
|
19
|
+
end
|
20
|
+
|
21
|
+
def hash
|
22
|
+
node.hashCode
|
23
|
+
end
|
24
|
+
|
25
|
+
|
26
|
+
# Attributes
|
27
|
+
|
28
|
+
def attr(name)
|
29
|
+
node.getAttribute(name.to_s)
|
30
|
+
end
|
31
|
+
|
32
|
+
# TODO Move to Webdriver
|
33
|
+
# Relies on getAttribute returning nil
|
34
|
+
def has_attribute?(name)
|
35
|
+
!attr(name).nil?
|
36
|
+
end
|
37
|
+
|
38
|
+
def method_missing(name, *args, &blk)
|
39
|
+
if !(block_given? || !args.empty?) && has_attribute?(name)
|
40
|
+
attr(name)
|
41
|
+
else
|
42
|
+
super
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
def id
|
47
|
+
attr(:id)
|
48
|
+
end
|
49
|
+
|
50
|
+
def type
|
51
|
+
attr(:type)
|
52
|
+
end
|
53
|
+
|
54
|
+
def class_name
|
55
|
+
attr(:class)
|
56
|
+
end
|
57
|
+
|
58
|
+
|
59
|
+
def_delegator :node, :isEnabled, :enabled?
|
60
|
+
def_delegator :node, :isSelected, :checked?
|
61
|
+
|
62
|
+
alias_method :set?, :checked?
|
63
|
+
|
64
|
+
def_delegator :node, :isSelected, :selected?
|
65
|
+
|
66
|
+
def_delegator :node, :toggle, :toggle_check!
|
67
|
+
|
68
|
+
def_delegator :node, :getText, :text
|
69
|
+
def_delegator :node, :getHTML, :html
|
70
|
+
|
71
|
+
alias_method :to_s, :text
|
72
|
+
|
73
|
+
def_delegator :node, :getValue, :value
|
74
|
+
def_delegator :node, :getElementName, :tag_name
|
75
|
+
def_delegator :node, :clear, :clear
|
76
|
+
|
77
|
+
def disabled?
|
78
|
+
!enabled?
|
79
|
+
end
|
80
|
+
|
81
|
+
def check!
|
82
|
+
result = node.toggle
|
83
|
+
if(result != true)
|
84
|
+
node.toggle
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
def uncheck!
|
89
|
+
result = node.toggle
|
90
|
+
if(result != false)
|
91
|
+
node.toggle
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
|
96
|
+
# Events
|
97
|
+
|
98
|
+
def click!(x=0, y=0)
|
99
|
+
node.click(x.to_i, y.to_i)
|
100
|
+
end
|
101
|
+
|
102
|
+
def click_async
|
103
|
+
node.click 1
|
104
|
+
end
|
105
|
+
|
106
|
+
def double_click
|
107
|
+
node.click 2
|
108
|
+
end
|
109
|
+
|
110
|
+
def triple_click
|
111
|
+
node.click 3
|
112
|
+
end
|
113
|
+
|
114
|
+
def quadruple_click
|
115
|
+
node.click 4
|
116
|
+
end
|
117
|
+
|
118
|
+
def right_click
|
119
|
+
node.rightClick
|
120
|
+
end
|
121
|
+
|
122
|
+
def drag_and_drop_on(other)
|
123
|
+
node.dragAndDropOn other.node
|
124
|
+
end
|
125
|
+
|
126
|
+
def drag_and_drop_by(x, y)
|
127
|
+
node.dragAndDropBy(x.to_i, y.to_i)
|
128
|
+
end
|
129
|
+
|
130
|
+
def_delegator :node, :submit, :submit!
|
131
|
+
|
132
|
+
def text=(string)
|
133
|
+
# Focus before typing
|
134
|
+
node.click
|
135
|
+
node.sendKeys(string.split('').to_java(:string))
|
136
|
+
end
|
137
|
+
|
138
|
+
alias_method :set, :text=
|
139
|
+
|
140
|
+
def trigger!(event, x = 0, y = 0)
|
141
|
+
loc = location
|
142
|
+
x += loc[:x]
|
143
|
+
y += loc[:y]
|
144
|
+
|
145
|
+
# In the case that event is given as symbol, we convert it to a
|
146
|
+
# string.
|
147
|
+
event = event.to_s
|
148
|
+
event =~ /on(.*)/i
|
149
|
+
event = $1 if $1
|
150
|
+
event = event.downcase.to_sym
|
151
|
+
|
152
|
+
# TODO Should this be moved to OperaDriver instead?
|
153
|
+
case event
|
154
|
+
when :abort, :blur, :change, :error, :focus, :load, :reset,
|
155
|
+
:resize, :scroll, :submit, :unload
|
156
|
+
type = 'HTMLEvents';
|
157
|
+
init = "initEvent(\"#{event.to_s}\", true, true)"
|
158
|
+
when :click, :dblclick, :mousedown, :mousemove, :mouseout,
|
159
|
+
:mouseover, :mouseup
|
160
|
+
type = 'MouseEvents'
|
161
|
+
init = "initMouseEvent(\"#{event.to_s}\", true, true, window, 1, 0, 0, 0, 0, false, false, false, false, 0, null)"
|
162
|
+
else
|
163
|
+
raise Exceptions::NotImplementedException,
|
164
|
+
"Event on#{event} is not a valid ECMAscript event for OperaWatir."
|
165
|
+
end
|
166
|
+
|
167
|
+
script = "var event = document.createEvent(\"#{type}\"); " +
|
168
|
+
"event.#{init}; " +
|
169
|
+
"locator.dispatchEvent(event);"
|
170
|
+
|
171
|
+
node.callMethod(script)
|
172
|
+
end
|
173
|
+
|
174
|
+
def visible?
|
175
|
+
node.isVisible()
|
176
|
+
end
|
177
|
+
|
178
|
+
# UI
|
179
|
+
|
180
|
+
def screenshot(file_name, time_out)
|
181
|
+
node.saveScreenshot(file_name, time_out)
|
182
|
+
end
|
183
|
+
|
184
|
+
def_delegator :node, :getImageHash, :visual_hash
|
185
|
+
|
186
|
+
def location
|
187
|
+
loc = node.getLocation
|
188
|
+
{:x => loc.x.to_i, :y => loc.y.to_i}
|
189
|
+
end
|
190
|
+
|
191
|
+
|
192
|
+
private
|
193
|
+
|
194
|
+
attr_accessor :node
|
195
|
+
|
196
|
+
# Finders
|
197
|
+
|
198
|
+
def find_elements_by_id(value)
|
199
|
+
node.findElementsById(value).to_a.map do |n|
|
200
|
+
OperaWatir::Element.new(n)
|
201
|
+
end
|
202
|
+
end
|
203
|
+
|
204
|
+
def find_elements_by_class_name(value)
|
205
|
+
node.findElementsByClassName(value).to_a.map do |n|
|
206
|
+
OperaWatir::Element.new(n)
|
207
|
+
end
|
208
|
+
end
|
209
|
+
|
210
|
+
def find_elements_by_tag_name(value)
|
211
|
+
node.findElementsByTagName(value).to_a.map do |n|
|
212
|
+
OperaWatir::Element.new(n)
|
213
|
+
end
|
214
|
+
end
|
215
|
+
|
216
|
+
def find_elements_by_css(value)
|
217
|
+
node.findElementsByCssSelector(value).to_a.map do |n|
|
218
|
+
OperaWatir::Element.new(n)
|
219
|
+
end
|
220
|
+
end
|
221
|
+
|
222
|
+
def find_elements_by_xpath(value)
|
223
|
+
node.findElementsByXPath(value).to_a.map do |n|
|
224
|
+
OperaWatir::Element.new(n)
|
225
|
+
end
|
226
|
+
end
|
227
|
+
|
228
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
module OperaWatir::Exceptions
|
2
|
+
|
3
|
+
# Superclass for all OperaWatir exceptions.
|
4
|
+
#
|
5
|
+
# @example
|
6
|
+
# begin
|
7
|
+
# ...
|
8
|
+
# rescue OperaWatirException
|
9
|
+
# end
|
10
|
+
class OperaWatirException < RuntimeError; end
|
11
|
+
|
12
|
+
# Raised when a method is called on an object which doesn't have a
|
13
|
+
# corresponding element.
|
14
|
+
class UnknownObjectException < OperaWatirException; end
|
15
|
+
|
16
|
+
# Raised when specifying an unknown way of finding an element.
|
17
|
+
#
|
18
|
+
# @example browser.divs(:weird_method, 10)
|
19
|
+
class MissingWayOfFindingObjectException < OperaWatirException; end
|
20
|
+
|
21
|
+
# Raised when trying to switch to an unknown frame.
|
22
|
+
class UnknownFrameException < OperaWatirException; end
|
23
|
+
|
24
|
+
# Raised when performing an action which has not yet been
|
25
|
+
# implemented by OperaWatir.
|
26
|
+
class NotImplementedException < OperaWatirException; end
|
27
|
+
|
28
|
+
# TODO Document this
|
29
|
+
class NoValueFoundException < OperaWatirException; end
|
30
|
+
|
31
|
+
# Raised when trying to perform an action on an element which is
|
32
|
+
# disabled.
|
33
|
+
class ObjectDisabledException < OperaWatirException; end
|
34
|
+
|
35
|
+
# Raised when trying to access a table cell that doesn't exist.
|
36
|
+
class UnknownCellException < OperaWatirException; end
|
37
|
+
|
38
|
+
end
|