safariwatir 0.3.1 → 0.3.2
Sign up to get free protection for your applications and to get access to all the features.
- data/safariwatir.rb +8 -14
- data/safariwatir/scripter.rb +14 -4
- metadata +2 -2
data/safariwatir.rb
CHANGED
@@ -107,6 +107,9 @@ module Watir
|
|
107
107
|
|
108
108
|
def operate(&block)
|
109
109
|
scripter_suffix = OPERATIONS[how]
|
110
|
+
if scripter_suffix.kind_of? Hash
|
111
|
+
scripter_suffix = scripter_suffix[name]
|
112
|
+
end
|
110
113
|
if scripter_suffix.nil?
|
111
114
|
raise "SafariWatir does not currently support finding by #{how}"
|
112
115
|
end
|
@@ -118,10 +121,11 @@ module Watir
|
|
118
121
|
:index => "by_index",
|
119
122
|
:class => "by_class",
|
120
123
|
:name => "by_name",
|
121
|
-
:text => "on_link",
|
124
|
+
:text => { "Link" => "on_link", "Label" => "by_text" },
|
122
125
|
:url => "on_link",
|
123
126
|
:value => "by_input_value",
|
124
|
-
:caption => "by_input_value"
|
127
|
+
:caption => "by_input_value",
|
128
|
+
:src => "by_src",
|
125
129
|
}
|
126
130
|
end
|
127
131
|
|
@@ -166,13 +170,9 @@ module Watir
|
|
166
170
|
end
|
167
171
|
|
168
172
|
class Image < HtmlElement
|
169
|
-
|
170
|
-
|
171
|
-
protected
|
173
|
+
include Clickable
|
172
174
|
|
173
|
-
def
|
174
|
-
@scripter.operate_by(self, 'src', &block)
|
175
|
-
end
|
175
|
+
def tag; "IMG"; end
|
176
176
|
end
|
177
177
|
|
178
178
|
class Button < InputElement
|
@@ -203,12 +203,6 @@ module Watir
|
|
203
203
|
|
204
204
|
class Label < ContentElement
|
205
205
|
def tag; "LABEL"; end
|
206
|
-
|
207
|
-
protected
|
208
|
-
|
209
|
-
def operate_by_text(&block)
|
210
|
-
@scripter.operate_by(self, 'innerText', &block)
|
211
|
-
end
|
212
206
|
end
|
213
207
|
|
214
208
|
class Link < ContentElement
|
data/safariwatir/scripter.rb
CHANGED
@@ -247,19 +247,21 @@ element.setSelectionRange(element.value.length, element.value.length);|
|
|
247
247
|
|
248
248
|
def click_element(element = @element)
|
249
249
|
page_load do
|
250
|
+
# Not sure if these events should be either/or. But if you have an image with an onclick, it fires twice without the else clause.
|
250
251
|
execute(element.operate { %|
|
251
252
|
if (element.click) {
|
252
253
|
element.click();
|
253
254
|
} else {
|
254
|
-
var event = DOCUMENT.createEvent('MouseEvents');
|
255
|
-
event.initEvent('click', true, true);
|
256
|
-
element.dispatchEvent(event);
|
257
|
-
|
258
255
|
if (element.onclick) {
|
259
256
|
var event = DOCUMENT.createEvent('HTMLEvents');
|
260
257
|
event.initEvent('click', true, true);
|
261
258
|
element.onclick(event);
|
259
|
+
} else {
|
260
|
+
var event = DOCUMENT.createEvent('MouseEvents');
|
261
|
+
event.initEvent('click', true, true);
|
262
|
+
element.dispatchEvent(event);
|
262
263
|
}
|
264
|
+
|
263
265
|
}| })
|
264
266
|
end
|
265
267
|
end
|
@@ -392,6 +394,14 @@ var element = elements[0];|, yield)
|
|
392
394
|
js.operate(%|var element = document.getElementsByTagName('#{element.tag}')[#{element.what-1}];|, yield)
|
393
395
|
end
|
394
396
|
|
397
|
+
def operate_by_src(element, &block)
|
398
|
+
operate_by(element, 'src', &block)
|
399
|
+
end
|
400
|
+
|
401
|
+
def operate_by_text(element, &block)
|
402
|
+
operate_by(element, 'innerText', &block)
|
403
|
+
end
|
404
|
+
|
395
405
|
def operate_by(element, attribute)
|
396
406
|
js.operate(%|var elements = document.getElementsByTagName('#{element.tag}');
|
397
407
|
var element = undefined;
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: safariwatir
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dave Hoover
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2008-10-
|
12
|
+
date: 2008-10-28 00:00:00 -05:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|