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,53 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
|
3
|
+
# TODO
|
4
|
+
# You need to set the OPERA_LAUNCHER and OPERA_PATH environment variables
|
5
|
+
# for this Helper to work.
|
6
|
+
|
7
|
+
require 'operawatir'
|
8
|
+
require 'rspec'
|
9
|
+
require 'rbconfig'
|
10
|
+
|
11
|
+
module OperaWatir::Helper
|
12
|
+
extend self
|
13
|
+
|
14
|
+
def settings
|
15
|
+
OperaWatir::Browser.settings
|
16
|
+
end
|
17
|
+
|
18
|
+
def browser
|
19
|
+
@browser ||= OperaWatir::Browser.new
|
20
|
+
end
|
21
|
+
|
22
|
+
def configure_rspec!
|
23
|
+
RSpec.configure do |config|
|
24
|
+
|
25
|
+
# Set every RSpec option
|
26
|
+
settings.each do |key, value|
|
27
|
+
config.send("#{key}=", value) if config.respond_to?("#{key}=")
|
28
|
+
end
|
29
|
+
|
30
|
+
config.include SpecHelpers
|
31
|
+
|
32
|
+
config.after(:suite) { browser.quit! if browser }
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
def run!(settings={})
|
37
|
+
OperaWatir::Browser.settings = settings
|
38
|
+
configure_rspec!
|
39
|
+
RSpec::Core::Runner.autorun
|
40
|
+
end
|
41
|
+
|
42
|
+
private
|
43
|
+
|
44
|
+
module SpecHelpers
|
45
|
+
def browser
|
46
|
+
OperaWatir::Helper.browser
|
47
|
+
end
|
48
|
+
|
49
|
+
def window
|
50
|
+
browser.active_window
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
@@ -0,0 +1,111 @@
|
|
1
|
+
class OperaWatir::Selector
|
2
|
+
BASE_TYPES = [:id, :class_name, :tag_name, :css, :xpath]
|
3
|
+
COLLECTION_TYPES = [:index, :attribute]
|
4
|
+
META_TYPES = [:join, :antijoin]
|
5
|
+
|
6
|
+
TYPES = BASE_TYPES + COLLECTION_TYPES + META_TYPES
|
7
|
+
|
8
|
+
attr_accessor :collection, :sexp
|
9
|
+
|
10
|
+
def initialize(collection, sexp=nil)
|
11
|
+
self.collection, self.sexp = collection, sexp
|
12
|
+
end
|
13
|
+
|
14
|
+
def eval(exp=sexp)
|
15
|
+
exp.is_a?(Array) ? apply(*optimise(exp).map {|x| eval(x)}) : exp
|
16
|
+
end
|
17
|
+
|
18
|
+
def apply(fn, *args)
|
19
|
+
elms = args.shift
|
20
|
+
|
21
|
+
# Say hello to the the ol' send trick.
|
22
|
+
#
|
23
|
+
# Private methods can be called when using send. This "bug" was
|
24
|
+
# briefly disabled in 1.9 but people complained because it's very
|
25
|
+
# handy (but bad).
|
26
|
+
if elms.nil?
|
27
|
+
collection.parent.send("find_elements_by_#{fn}", *args)
|
28
|
+
else
|
29
|
+
collection.send(:_elms=, elms)
|
30
|
+
if META_TYPES.include?(fn)
|
31
|
+
send("apply_#{fn}", elms, args)
|
32
|
+
else
|
33
|
+
collection.send("find_elements_by_#{fn}", *args)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
(BASE_TYPES + COLLECTION_TYPES).each do |name|
|
39
|
+
define_method name do |val|
|
40
|
+
self.sexp = [name, sexp, val]
|
41
|
+
self
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
META_TYPES.each do |name|
|
46
|
+
define_method name do |&blk|
|
47
|
+
list = BlockBuilder.new(self)
|
48
|
+
blk.call(list)
|
49
|
+
self.sexp = list.items.inject([name]) do |items, item|
|
50
|
+
items << item.sexp
|
51
|
+
end
|
52
|
+
self
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
# Handy shortcut
|
57
|
+
|
58
|
+
alias_method :tag, :tag_name
|
59
|
+
|
60
|
+
private
|
61
|
+
|
62
|
+
def optimise(sexp)
|
63
|
+
# [:attribute, [:tag_name, nil, TAG], {:id => ID}]
|
64
|
+
# =>
|
65
|
+
# [:tag_name, [:id, nil, ID], TAG]
|
66
|
+
if (
|
67
|
+
sexp.first == :attribute and
|
68
|
+
sexp[1].first == :tag_name and sexp[1][1].nil? and
|
69
|
+
sexp.last.length == 1 and sexp.last.has_key?(:id) and
|
70
|
+
sexp.last[:id].is_a?(String)
|
71
|
+
)
|
72
|
+
# Need to uppercase the tag name as Element.tag_name is alway uppercase
|
73
|
+
[:attribute, [:id, nil, sexp.last[:id]], {:tag_name => sexp[1].last.to_s.upcase}]
|
74
|
+
else
|
75
|
+
sexp
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
def apply_join(base, elms)
|
80
|
+
elms.inject(base) do |col, elm|
|
81
|
+
col | elm
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
def apply_antijoin(base, elms)
|
86
|
+
elms.inject(base) do |col, elm|
|
87
|
+
col - elm
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
def apply_antijoin(elms)
|
92
|
+
elms.inject([]) do |result, elm|
|
93
|
+
result - elm
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
class BlockBuilder
|
98
|
+
attr_accessor :selector, :items
|
99
|
+
|
100
|
+
def initialize(selector)
|
101
|
+
self.selector, self.items = selector, []
|
102
|
+
end
|
103
|
+
|
104
|
+
def method_missing(*args, &blk)
|
105
|
+
OperaWatir::Selector.new(selector.collection, selector.sexp).send(*args, &blk).tap do |s|
|
106
|
+
items << s
|
107
|
+
end
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
111
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module OperaWatir
|
2
|
+
|
3
|
+
# @private
|
4
|
+
VERSION = File.read(File.join(File.dirname(__FILE__), '../..', 'VERSION')).strip.freeze
|
5
|
+
|
6
|
+
# Fetches OperaWatir's version number. Note that this is not the
|
7
|
+
# same as OperaDriver's version number.
|
8
|
+
#
|
9
|
+
# @return [String] current version of OperaWatir
|
10
|
+
def self.version
|
11
|
+
VERSION
|
12
|
+
end
|
13
|
+
|
14
|
+
end
|
15
|
+
|
@@ -0,0 +1,174 @@
|
|
1
|
+
class OperaWatir::Window
|
2
|
+
|
3
|
+
attr_accessor :browser
|
4
|
+
|
5
|
+
def initialize(browser)
|
6
|
+
self.browser = browser
|
7
|
+
end
|
8
|
+
|
9
|
+
|
10
|
+
# Navigation
|
11
|
+
|
12
|
+
def back
|
13
|
+
driver.navigate.back
|
14
|
+
end
|
15
|
+
|
16
|
+
def forward
|
17
|
+
driver.navigate.forward
|
18
|
+
end
|
19
|
+
|
20
|
+
def stop
|
21
|
+
driver.stop
|
22
|
+
end
|
23
|
+
|
24
|
+
# FIXME No window management support
|
25
|
+
def close
|
26
|
+
driver.close
|
27
|
+
end
|
28
|
+
|
29
|
+
def refresh
|
30
|
+
driver.navigate.refresh
|
31
|
+
end
|
32
|
+
|
33
|
+
def title
|
34
|
+
driver.getTitle
|
35
|
+
end
|
36
|
+
|
37
|
+
def url
|
38
|
+
driver.getCurrentUrl
|
39
|
+
end
|
40
|
+
|
41
|
+
def url=(url)
|
42
|
+
driver.get(url)
|
43
|
+
end
|
44
|
+
alias_method :goto, :url= # deprecate?
|
45
|
+
|
46
|
+
def text
|
47
|
+
driver.getText
|
48
|
+
end
|
49
|
+
|
50
|
+
def html
|
51
|
+
driver.getPageSource
|
52
|
+
end
|
53
|
+
|
54
|
+
# TODO: Expose window querying from driver
|
55
|
+
def exists?
|
56
|
+
url != ''
|
57
|
+
end
|
58
|
+
|
59
|
+
def document
|
60
|
+
end
|
61
|
+
|
62
|
+
def eval_js(js)
|
63
|
+
object = driver.executeScript(js, [].to_java(:string))
|
64
|
+
end
|
65
|
+
alias_method :execute_script, :eval_js
|
66
|
+
|
67
|
+
|
68
|
+
# Keyboard
|
69
|
+
|
70
|
+
def key(key)
|
71
|
+
driver.key(key)
|
72
|
+
end
|
73
|
+
|
74
|
+
def key_down(key)
|
75
|
+
driver.keyDown(key)
|
76
|
+
end
|
77
|
+
|
78
|
+
def key_up(key)
|
79
|
+
driver.keyUp(key)
|
80
|
+
end
|
81
|
+
|
82
|
+
def type(text)
|
83
|
+
driver.type(text)
|
84
|
+
end
|
85
|
+
|
86
|
+
|
87
|
+
# Opera-specific
|
88
|
+
|
89
|
+
def screenshot(file_name, hashes=[], time_out=2)
|
90
|
+
driver.saveScreenshot(file_name, time_out, hashes.to_java(:string))
|
91
|
+
end
|
92
|
+
|
93
|
+
def visual_hash(time_out=50)
|
94
|
+
document.visual_hash timeout
|
95
|
+
end
|
96
|
+
|
97
|
+
# Raw finders
|
98
|
+
|
99
|
+
OperaWatir::Selector::BASE_TYPES.each do |type|
|
100
|
+
define_method("find_by_#{type}") do |name|
|
101
|
+
OperaWatir::Collection.new(self).tap do |c|
|
102
|
+
c.selector.send(type, name.to_s)
|
103
|
+
end
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
107
|
+
alias_method :find_by_class, :find_by_class_name
|
108
|
+
alias_method :find_by_tag, :find_by_tag_name
|
109
|
+
|
110
|
+
def elements
|
111
|
+
find_by_tag('*')
|
112
|
+
end
|
113
|
+
|
114
|
+
def method_missing(tag, *args)
|
115
|
+
OperaWatir::Collection.new(self).tap do |c|
|
116
|
+
c.selector.tag_name tag
|
117
|
+
c.add_selector_from_arguments args
|
118
|
+
end
|
119
|
+
end
|
120
|
+
|
121
|
+
|
122
|
+
private
|
123
|
+
|
124
|
+
# Locate elements by id.
|
125
|
+
#
|
126
|
+
# @return [Array] an array of found elements
|
127
|
+
def find_elements_by_id(value)
|
128
|
+
driver.findElementsById(value).to_a.map do |node|
|
129
|
+
OperaWatir::Element.new(node)
|
130
|
+
end
|
131
|
+
end
|
132
|
+
|
133
|
+
# Locate elements by class.
|
134
|
+
#
|
135
|
+
# @return [Array] an array of found elements
|
136
|
+
def find_elements_by_class_name(value)
|
137
|
+
driver.findElementsByClassName(value).to_a.map do |node|
|
138
|
+
OperaWatir::Element.new(node)
|
139
|
+
end
|
140
|
+
end
|
141
|
+
|
142
|
+
# Locate elements by tag name.
|
143
|
+
#
|
144
|
+
# @return [Array] an array of found elements
|
145
|
+
def find_elements_by_tag_name(value)
|
146
|
+
driver.findElementsByTagName(value).to_a.map do |node|
|
147
|
+
OperaWatir::Element.new(node)
|
148
|
+
end
|
149
|
+
end
|
150
|
+
|
151
|
+
# Locate elements by CSS selector.
|
152
|
+
#
|
153
|
+
# @return [Array] an array of found elements
|
154
|
+
def find_elements_by_css(value)
|
155
|
+
driver.findElementsByCssSelector(value).to_a.map do |node|
|
156
|
+
OperaWatir::Element.new(node)
|
157
|
+
end
|
158
|
+
end
|
159
|
+
|
160
|
+
# Locate elements by XPath expression.
|
161
|
+
#
|
162
|
+
# @return [Array] an array of found elements
|
163
|
+
def find_elements_by_xpath(value)
|
164
|
+
driver.findElementsByXPath(value).to_a.map do |node|
|
165
|
+
OperaWatir::Element.new(node)
|
166
|
+
end
|
167
|
+
end
|
168
|
+
|
169
|
+
# @private
|
170
|
+
def driver
|
171
|
+
browser.driver
|
172
|
+
end
|
173
|
+
|
174
|
+
end
|
@@ -0,0 +1,268 @@
|
|
1
|
+
require "operawatir/helper"
|
2
|
+
|
3
|
+
describe "fire_event" do
|
4
|
+
after(:each) do
|
5
|
+
browser.p(:id, "result").verify_contains("PASS").should == true
|
6
|
+
end
|
7
|
+
|
8
|
+
# onMouseOver
|
9
|
+
it "should fire event onMouseOver with symbol" do
|
10
|
+
browser.goto files + "onMouseOver.html"
|
11
|
+
browser.elements(:xpath, "//form/*").each { |e| e.fire_event(:onMouseOver) }
|
12
|
+
end
|
13
|
+
|
14
|
+
it "should fire event onMouseOver with lowercase symbol" do
|
15
|
+
browser.goto files + "onMouseOver.html"
|
16
|
+
browser.elements(:xpath, "//form/*").each { |e| e.fire_event(:onmouseover) }
|
17
|
+
end
|
18
|
+
|
19
|
+
it "should fire event onMouseOver with string" do
|
20
|
+
browser.goto files + "onMouseOver.html"
|
21
|
+
browser.elements(:xpath, "//form/*").each { |e| e.fire_event("onMouseOver") }
|
22
|
+
end
|
23
|
+
|
24
|
+
it "should fire event onMouseOver with lowercase string" do
|
25
|
+
browser.goto files + "onMouseOver.html"
|
26
|
+
browser.elements(:xpath, "//form/*").each { |e| e.fire_event("onmouseover") }
|
27
|
+
end
|
28
|
+
|
29
|
+
|
30
|
+
# onMouseOut
|
31
|
+
it "should fire event onMouseOut with symbol" do
|
32
|
+
browser.goto files + "onMouseOut.html"
|
33
|
+
browser.elements(:xpath, "//form/*").each { |e| e.fire_event(:onMouseOut) }
|
34
|
+
end
|
35
|
+
|
36
|
+
it "should fire event onMouseOut with lowercase symbol" do
|
37
|
+
browser.goto files + "onMouseOut.html"
|
38
|
+
browser.elements(:xpath, "//form/*").each { |e| e.fire_event(:onmouseout) }
|
39
|
+
end
|
40
|
+
|
41
|
+
it "should fire event onMouseOut with string" do
|
42
|
+
browser.goto files + "onMouseOut.html"
|
43
|
+
browser.elements(:xpath, "//form/*").each { |e| e.fire_event("onMouseOut") }
|
44
|
+
end
|
45
|
+
|
46
|
+
it "should fire event onMouseOut with lowercase string" do
|
47
|
+
browser.goto files + "onMouseOut.html"
|
48
|
+
browser.elements(:xpath, "//form/*").each { |e| e.fire_event("onmouseout") }
|
49
|
+
end
|
50
|
+
|
51
|
+
|
52
|
+
# onMouseDown
|
53
|
+
it "should fire event onMouseDown with symbol" do
|
54
|
+
browser.goto files + "onMouseDown.html"
|
55
|
+
browser.elements(:xpath, "//form/*").each { |e| e.fire_event(:onMouseDown) }
|
56
|
+
end
|
57
|
+
|
58
|
+
it "should fire event onMouseDown with lowercase symbol" do
|
59
|
+
browser.goto files + "onMouseDown.html"
|
60
|
+
browser.elements(:xpath, "//form/*").each { |e| e.fire_event(:onmousedown) }
|
61
|
+
end
|
62
|
+
|
63
|
+
it "should fire event onMouseDown with string" do
|
64
|
+
browser.goto files + "onMouseDown.html"
|
65
|
+
browser.elements(:xpath, "//form/*").each { |e| e.fire_event("onMouseDown") }
|
66
|
+
end
|
67
|
+
|
68
|
+
it "should fire event onMouseDown with lowercase string" do
|
69
|
+
browser.goto files + "onMouseDown.html"
|
70
|
+
browser.elements(:xpath, "//form/*").each { |e| e.fire_event("onmousedown") }
|
71
|
+
end
|
72
|
+
|
73
|
+
|
74
|
+
# onMouseUp
|
75
|
+
it "should fire event onMouseUp with symbol" do
|
76
|
+
browser.goto files + "onMouseUp.html"
|
77
|
+
browser.elements(:xpath, "//form/*").each { |e| e.fire_event(:onMouseUp) }
|
78
|
+
end
|
79
|
+
|
80
|
+
it "should fire event onMouseUp with lowercase symbol" do
|
81
|
+
browser.goto files + "onMouseUp.html"
|
82
|
+
browser.elements(:xpath, "//form/*").each { |e| e.fire_event(:onmouseup) }
|
83
|
+
end
|
84
|
+
|
85
|
+
it "should fire event onMouseUp with string" do
|
86
|
+
browser.goto files + "onMouseUp.html"
|
87
|
+
browser.elements(:xpath, "//form/*").each { |e| e.fire_event("onMouseUp") }
|
88
|
+
end
|
89
|
+
|
90
|
+
it "should fire event onMouseUp with lowercase string" do
|
91
|
+
browser.goto files + "onMouseUp.html"
|
92
|
+
browser.elements(:xpath, "//form/*").each { |e| e.fire_event("onmouseup") }
|
93
|
+
end
|
94
|
+
|
95
|
+
|
96
|
+
# onMouseMove
|
97
|
+
it "should fire event onMouseMove with symbol" do
|
98
|
+
browser.goto files + "onMouseMove.html"
|
99
|
+
browser.elements(:xpath, "//form/*").each { |e| e.fire_event(:onMouseMove) }
|
100
|
+
end
|
101
|
+
|
102
|
+
it "should fire event onMouseMove with lowercase symbol" do
|
103
|
+
browser.goto files + "onMouseMove.html"
|
104
|
+
browser.elements(:xpath, "//form/*").each { |e| e.fire_event(:onmousemove) }
|
105
|
+
end
|
106
|
+
|
107
|
+
it "should fire event onMouseMove with string" do
|
108
|
+
browser.goto files + "onMouseMove.html"
|
109
|
+
browser.elements(:xpath, "//form/*").each { |e| e.fire_event("onMouseMove") }
|
110
|
+
end
|
111
|
+
|
112
|
+
it "should fire event onMouseMove with lowercase string" do
|
113
|
+
browser.goto files + "onMouseMove.html"
|
114
|
+
browser.elements(:xpath, "//form/*").each { |e| e.fire_event("onmousemove") }
|
115
|
+
end
|
116
|
+
|
117
|
+
|
118
|
+
# onClick
|
119
|
+
it "should fire event onClick with symbol" do
|
120
|
+
browser.goto files + "onClick.html"
|
121
|
+
browser.elements(:xpath, "//form/*").each { |e| e.fire_event(:onClick) }
|
122
|
+
end
|
123
|
+
|
124
|
+
it "should fire event onClick with lowercase symbol" do
|
125
|
+
browser.goto files + "onClick.html"
|
126
|
+
browser.elements(:xpath, "//form/*").each { |e| e.fire_event(:onclick) }
|
127
|
+
end
|
128
|
+
|
129
|
+
it "should fire event onClick with string" do
|
130
|
+
browser.goto files + "onClick.html"
|
131
|
+
browser.elements(:xpath, "//form/*").each { |e| e.fire_event("onClick") }
|
132
|
+
end
|
133
|
+
|
134
|
+
it "should fire event onClick with lowercase string" do
|
135
|
+
browser.goto files + "onClick.html"
|
136
|
+
browser.elements(:xpath, "//form/*").each { |e| e.fire_event("onclick") }
|
137
|
+
end
|
138
|
+
|
139
|
+
|
140
|
+
# onDblClick
|
141
|
+
it "should fire event onDblClick with symbol" do
|
142
|
+
browser.goto files + "onDblClick.html"
|
143
|
+
browser.elements(:xpath, "//form/*").each { |e| e.fire_event(:onDblClick) }
|
144
|
+
end
|
145
|
+
|
146
|
+
it "should fire event onDblClick with lowercase symbol" do
|
147
|
+
browser.goto files + "onDblClick.html"
|
148
|
+
browser.elements(:xpath, "//form/*").each { |e| e.fire_event(:ondblclick) }
|
149
|
+
end
|
150
|
+
|
151
|
+
it "should fire event onDblClick with string" do
|
152
|
+
browser.goto files + "onDblClick.html"
|
153
|
+
browser.elements(:xpath, "//form/*").each { |e| e.fire_event("onDblClick") }
|
154
|
+
end
|
155
|
+
|
156
|
+
it "should fire event onDblClick with lowercase string" do
|
157
|
+
browser.goto files + "onDblClick.html"
|
158
|
+
browser.elements(:xpath, "//form/*").each { |e| e.fire_event("ondblclick") }
|
159
|
+
end
|
160
|
+
|
161
|
+
|
162
|
+
# onAbort cannot be automated using Watir.
|
163
|
+
|
164
|
+
|
165
|
+
# onBlur
|
166
|
+
it "should fire event onBlur with symbol" do
|
167
|
+
browser.goto files + "onBlur.html"
|
168
|
+
browser.elements(:xpath, "//form/*").each { |e| e.fire_event(:onBlur) }
|
169
|
+
end
|
170
|
+
|
171
|
+
it "should fire event onBlur with lowercase symbol" do
|
172
|
+
browser.goto files + "onBlur.html"
|
173
|
+
browser.elements(:xpath, "//form/*").each { |e| e.fire_event(:onblur) }
|
174
|
+
end
|
175
|
+
|
176
|
+
it "should fire event onBlur with string" do
|
177
|
+
browser.goto files + "onBlur.html"
|
178
|
+
browser.elements(:xpath, "//form/*").each { |e| e.fire_event("onBlur") }
|
179
|
+
end
|
180
|
+
|
181
|
+
it "should fire event onBlur with lowercase string" do
|
182
|
+
browser.goto files + "onBlur.html"
|
183
|
+
browser.elements(:xpath, "//form/*").each { |e| e.fire_event("onblur") }
|
184
|
+
end
|
185
|
+
|
186
|
+
|
187
|
+
# onChange
|
188
|
+
it "should fire event onChange with symbol" do
|
189
|
+
browser.goto files + "onChange.html"
|
190
|
+
browser.elements(:xpath, "//form/*").each { |e| e.fire_event(:onChange) }
|
191
|
+
end
|
192
|
+
|
193
|
+
it "should fire event onChange with lowercase symbol" do
|
194
|
+
browser.goto files + "onChange.html"
|
195
|
+
browser.elements(:xpath, "//form/*").each { |e| e.fire_event(:onchange) }
|
196
|
+
end
|
197
|
+
|
198
|
+
it "should fire event onChange with string" do
|
199
|
+
browser.goto files + "onChange.html"
|
200
|
+
browser.elements(:xpath, "//form/*").each { |e| e.fire_event("onChange") }
|
201
|
+
end
|
202
|
+
|
203
|
+
it "should fire event onChange with lowercase string" do
|
204
|
+
browser.goto files + "onChange.html"
|
205
|
+
browser.elements(:xpath, "//form/*").each { |e| e.fire_event("onchange") }
|
206
|
+
end
|
207
|
+
|
208
|
+
|
209
|
+
# onFocus
|
210
|
+
it "should fire event onFocus with symbol" do
|
211
|
+
browser.goto files + "onFocus.html"
|
212
|
+
browser.elements(:xpath, "//form/*").each { |e| e.fire_event(:onFocus) }
|
213
|
+
end
|
214
|
+
|
215
|
+
it "should fire event onFocus with lowercase symbol" do
|
216
|
+
browser.goto files + "onFocus.html"
|
217
|
+
browser.elements(:xpath, "//form/*").each { |e| e.fire_event(:onfocus) }
|
218
|
+
end
|
219
|
+
|
220
|
+
it "should fire event onFocus with string" do
|
221
|
+
browser.goto files + "onFocus.html"
|
222
|
+
browser.elements(:xpath, "//form/*").each { |e| e.fire_event("onFocus") }
|
223
|
+
end
|
224
|
+
|
225
|
+
it "should fire event onFocus with lowercase string" do
|
226
|
+
browser.goto files + "onFocus.html"
|
227
|
+
browser.elements(:xpath, "//form/*").each { |e| e.fire_event("onfocus") }
|
228
|
+
end
|
229
|
+
|
230
|
+
# FIXME: onLoad
|
231
|
+
|
232
|
+
|
233
|
+
# FIXME: onReset
|
234
|
+
|
235
|
+
|
236
|
+
# FIXME: onResize
|
237
|
+
|
238
|
+
|
239
|
+
it "should fire event onScroll with symbol" do
|
240
|
+
browser.goto files + "onScroll.html"
|
241
|
+
browser.element(:xpath, "//body").fire_event(:onScroll)
|
242
|
+
end
|
243
|
+
|
244
|
+
it "should fire event onScroll with lowercase symbol" do
|
245
|
+
browser.goto files + "onScroll.html"
|
246
|
+
browser.element(:xpath, "//body").fire_event(:onscroll)
|
247
|
+
end
|
248
|
+
|
249
|
+
it "should fire event onScroll with string" do
|
250
|
+
browser.goto files + "onScroll.html"
|
251
|
+
browser.element(:xpath, "//body").fire_event("onScroll")
|
252
|
+
end
|
253
|
+
|
254
|
+
it "should fire event onScroll with lowercase string" do
|
255
|
+
browser.goto files + "onScroll.html"
|
256
|
+
browser.element(:xpath, "//body").fire_event("onscroll")
|
257
|
+
end
|
258
|
+
|
259
|
+
|
260
|
+
# FIXME: onSelect
|
261
|
+
|
262
|
+
|
263
|
+
# FIXME: onSubmit
|
264
|
+
|
265
|
+
|
266
|
+
# FIXME: onUnload
|
267
|
+
end
|
268
|
+
|