druid-ts 1.2.2 → 1.2.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/ChangeLog +6 -7
- data/Gemfile +0 -5
- data/druid.gemspec +2 -1
- data/features/area.feature +0 -1
- data/features/audio.feature +0 -2
- data/features/bold.feature +0 -1
- data/features/canvas.feature +0 -2
- data/features/div.feature +0 -2
- data/features/heading.feature +0 -10
- data/features/italic.feature +0 -1
- data/features/label.feature +0 -2
- data/features/link.feature +0 -2
- data/features/list_item.feature +0 -2
- data/features/ordered_list.feature +0 -2
- data/features/paragraph.feature +0 -2
- data/features/span.feature +0 -2
- data/features/step_definations/element_steps.rb +2 -2
- data/features/step_definations/section_steps.rb +1 -1
- data/features/table.feature +0 -2
- data/features/table_cell.feature +0 -2
- data/features/unordered_list.feature +0 -3
- data/features/video.feature +0 -11
- data/lib/druid.rb +1 -5
- data/lib/druid/accessors.rb +2 -296
- data/lib/druid/assist.rb +1 -9
- data/lib/druid/elements/button.rb +0 -4
- data/lib/druid/elements/check_box.rb +0 -4
- data/lib/druid/elements/div.rb +0 -3
- data/lib/druid/elements/element.rb +3 -266
- data/lib/druid/elements/file_field.rb +0 -3
- data/lib/druid/elements/form.rb +0 -9
- data/lib/druid/elements/hidden_field.rb +0 -4
- data/lib/druid/elements/image.rb +0 -4
- data/lib/druid/elements/label.rb +0 -3
- data/lib/druid/elements/link.rb +0 -16
- data/lib/druid/elements/list_item.rb +0 -4
- data/lib/druid/elements/option.rb +0 -6
- data/lib/druid/elements/ordered_list.rb +0 -4
- data/lib/druid/elements/radio_button.rb +0 -3
- data/lib/druid/elements/select_list.rb +0 -26
- data/lib/druid/elements/span.rb +0 -4
- data/lib/druid/elements/table_cell.rb +0 -3
- data/lib/druid/elements/table_row.rb +4 -0
- data/lib/druid/elements/text_area.rb +0 -17
- data/lib/druid/elements/text_field.rb +0 -7
- data/lib/druid/elements/unordered_list.rb +0 -4
- data/lib/druid/page_populator.rb +15 -0
- data/lib/druid/version.rb +1 -1
- data/spec/druid/druid_spec.rb +1 -21
- data/spec/druid/elements/area_spec.rb +0 -8
- data/spec/druid/elements/bold_spec.rb +0 -9
- data/spec/druid/elements/button_spec.rb +0 -8
- data/spec/druid/elements/canvas_spec.rb +0 -9
- data/spec/druid/elements/check_box_spec.rb +0 -9
- data/spec/druid/elements/div_spec.rb +0 -9
- data/spec/druid/elements/element_spec.rb +6 -18
- data/spec/druid/elements/file_field_spec.rb +0 -9
- data/spec/druid/elements/form_spec.rb +0 -9
- data/spec/druid/elements/heading_spec.rb +0 -9
- data/spec/druid/elements/hidden_field_spec.rb +0 -9
- data/spec/druid/elements/image_spec.rb +0 -9
- data/spec/druid/elements/itatic_spec.rb +1 -10
- data/spec/druid/elements/label_spec.rb +0 -9
- data/spec/druid/elements/link_spec.rb +0 -16
- data/spec/druid/elements/list_item_spec.rb +0 -9
- data/spec/druid/elements/ordered_list_spec.rb +0 -9
- data/spec/druid/elements/paragraph_spec.rb +0 -9
- data/spec/druid/elements/radio_button_spec.rb +0 -9
- data/spec/druid/elements/select_list_spec.rb +0 -9
- data/spec/druid/elements/span_spec.rb +0 -9
- data/spec/druid/elements/table_cell_spec.rb +0 -9
- data/spec/druid/elements/table_row_spec.rb +0 -8
- data/spec/druid/elements/table_spec.rb +0 -9
- data/spec/druid/elements/text_area_spec.rb +0 -9
- data/spec/druid/elements/text_field_spec.rb +0 -9
- data/spec/druid/elements/unordered_list_spec.rb +0 -9
- data/spec/druid/page_populator_spec.rb +5 -3
- metadata +15 -15
data/lib/druid/assist.rb
CHANGED
@@ -188,7 +188,7 @@ module Druid
|
|
188
188
|
# method to retrieve load status of an image element
|
189
189
|
#
|
190
190
|
def image_loaded_for(identifier)
|
191
|
-
process_call("image(identifier).loaded?", Elements::Image, identifier)
|
191
|
+
process_call("image(identifier).loaded?", Elements::Image, identifier)
|
192
192
|
end
|
193
193
|
|
194
194
|
def form_for identifier
|
@@ -619,16 +619,8 @@ module Druid
|
|
619
619
|
value
|
620
620
|
end
|
621
621
|
|
622
|
-
def add_tagname_if_needed identifier, tag
|
623
|
-
return identifier if identifier.length < 2 and not identifier[:name]
|
624
|
-
identifier[:tag_name] = tag if identifier[:name]
|
625
|
-
identifier
|
626
|
-
end
|
627
|
-
|
628
622
|
def parse_identifiers(identifier, element, tag_name=nil)
|
629
623
|
frame_identifiers = identifier.delete(:frame)
|
630
|
-
identifier = add_tagname_if_needed identifier, tag_name if tag_name
|
631
|
-
identifier = element.identifier_for identifier
|
632
624
|
return identifier, frame_identifiers
|
633
625
|
end
|
634
626
|
|
data/lib/druid/elements/div.rb
CHANGED
@@ -18,72 +18,12 @@ module Druid
|
|
18
18
|
@driver = @element
|
19
19
|
end
|
20
20
|
|
21
|
-
#
|
22
|
-
# Get the text for the element
|
23
|
-
#
|
24
|
-
# @return [String]
|
25
|
-
#
|
26
|
-
def text
|
27
|
-
element.text
|
28
|
-
end
|
29
|
-
|
30
|
-
def exist?
|
31
|
-
element.exist?
|
32
|
-
end
|
33
|
-
|
34
|
-
def enabled?
|
35
|
-
element.enabled?
|
36
|
-
end
|
37
|
-
|
38
21
|
#
|
39
22
|
# return true if the element is not enabled
|
40
23
|
def disabled?
|
41
24
|
not enabled?
|
42
25
|
end
|
43
26
|
|
44
|
-
def visible?
|
45
|
-
element.visible?
|
46
|
-
end
|
47
|
-
|
48
|
-
#
|
49
|
-
# return true if the element is stale(no longer attached to the DOM)
|
50
|
-
#
|
51
|
-
def stale?
|
52
|
-
element.stale?
|
53
|
-
end
|
54
|
-
|
55
|
-
#
|
56
|
-
# Returns the html for the element
|
57
|
-
#
|
58
|
-
# @return [String]
|
59
|
-
#
|
60
|
-
def html
|
61
|
-
element.html
|
62
|
-
end
|
63
|
-
|
64
|
-
#
|
65
|
-
# Returns the inner html for the element
|
66
|
-
#
|
67
|
-
def outer_html
|
68
|
-
element.outer_html
|
69
|
-
end
|
70
|
-
|
71
|
-
#
|
72
|
-
# Returns the inner html for the element
|
73
|
-
#
|
74
|
-
def inner_html
|
75
|
-
element.inner_html
|
76
|
-
end
|
77
|
-
|
78
|
-
#
|
79
|
-
# Get the value of this element
|
80
|
-
#
|
81
|
-
# @return [String]
|
82
|
-
#
|
83
|
-
def value
|
84
|
-
element.value
|
85
|
-
end
|
86
|
-
|
87
27
|
#
|
88
28
|
# compare this element to another to determine if they are equal
|
89
29
|
# @return [Boolean]
|
@@ -92,15 +32,6 @@ module Druid
|
|
92
32
|
other.is_a? self.class and element == other.element
|
93
33
|
end
|
94
34
|
|
95
|
-
#
|
96
|
-
# Get the tag name of this element
|
97
|
-
#
|
98
|
-
# @return [String]
|
99
|
-
#
|
100
|
-
def tag_name
|
101
|
-
element.tag_name
|
102
|
-
end
|
103
|
-
|
104
35
|
#
|
105
36
|
# Get the value of the given attribute of the element
|
106
37
|
# @param [String]
|
@@ -117,92 +48,10 @@ module Druid
|
|
117
48
|
element.class_name
|
118
49
|
end
|
119
50
|
|
120
|
-
#
|
121
|
-
# Click this element
|
122
|
-
#
|
123
|
-
def click
|
124
|
-
element.click
|
125
|
-
end
|
126
|
-
|
127
|
-
#
|
128
|
-
# get the value of the given CSS property
|
129
|
-
#
|
130
|
-
def style(property = nil)
|
131
|
-
element.style property
|
132
|
-
end
|
133
|
-
|
134
51
|
def inspect
|
135
52
|
element.inspect
|
136
53
|
end
|
137
54
|
|
138
|
-
#
|
139
|
-
# Send keystrokes to this element
|
140
|
-
#
|
141
|
-
# @param [String, Symbol, Array]
|
142
|
-
#
|
143
|
-
# Examples:
|
144
|
-
#
|
145
|
-
# element.send_keys "foo" #=> value: 'foo'
|
146
|
-
# element.send_keys "tet", :arrow_left, "s" #=> value: 'test'
|
147
|
-
# element.send_keys [:control, 'a'], :space #=> value: ' '
|
148
|
-
#
|
149
|
-
def send_keys(*args)
|
150
|
-
element.send_keys(*args)
|
151
|
-
end
|
152
|
-
|
153
|
-
#
|
154
|
-
# clear the contents of the element
|
155
|
-
#
|
156
|
-
def clear
|
157
|
-
element.clear
|
158
|
-
end
|
159
|
-
|
160
|
-
#
|
161
|
-
# double click this element
|
162
|
-
#
|
163
|
-
def double_click
|
164
|
-
element.double_click
|
165
|
-
end
|
166
|
-
|
167
|
-
#
|
168
|
-
# right click this element
|
169
|
-
#
|
170
|
-
def right_click
|
171
|
-
element.right_click
|
172
|
-
end
|
173
|
-
|
174
|
-
#
|
175
|
-
# Fire the provided event on the current element
|
176
|
-
#
|
177
|
-
def fire_event(event_name)
|
178
|
-
element.fire_event(event_name)
|
179
|
-
end
|
180
|
-
|
181
|
-
def focus
|
182
|
-
element.focus
|
183
|
-
end
|
184
|
-
|
185
|
-
#
|
186
|
-
# return true if an element is focused
|
187
|
-
#
|
188
|
-
def focused?
|
189
|
-
element.focused?
|
190
|
-
end
|
191
|
-
|
192
|
-
#
|
193
|
-
# Select the provided text
|
194
|
-
#
|
195
|
-
def select_text text
|
196
|
-
element.select_text text
|
197
|
-
end
|
198
|
-
|
199
|
-
#
|
200
|
-
# get the id of element
|
201
|
-
#
|
202
|
-
def id
|
203
|
-
attribute(:id)
|
204
|
-
end
|
205
|
-
|
206
55
|
#
|
207
56
|
# Scroll until the element is viewable
|
208
57
|
#
|
@@ -244,19 +93,6 @@ module Druid
|
|
244
93
|
def centre
|
245
94
|
{ 'y' => (location['y'] + (size['height']/2)), 'x' => (location['x'] + (size['width']/2)) }
|
246
95
|
end
|
247
|
-
#
|
248
|
-
# Flash the element by temporarily changing the background color
|
249
|
-
#
|
250
|
-
def flash
|
251
|
-
element.flash
|
252
|
-
end
|
253
|
-
|
254
|
-
#
|
255
|
-
# hover over the element
|
256
|
-
#
|
257
|
-
def hover
|
258
|
-
element.hover
|
259
|
-
end
|
260
96
|
|
261
97
|
def check_visible(timeout=Druid.default_element_wait)
|
262
98
|
timed_loop(timeout) do |element|
|
@@ -306,6 +142,7 @@ module Druid
|
|
306
142
|
# @param [Interger] (default to:5) seconds to wait before timing out
|
307
143
|
#
|
308
144
|
def when_visible(timeout=Druid.default_element_wait)
|
145
|
+
when_present(timeout)
|
309
146
|
element.wait_until(timeout: timeout, message: "Element not visible in #{timeout} seconds", &:visible?)
|
310
147
|
self
|
311
148
|
end
|
@@ -316,6 +153,7 @@ module Druid
|
|
316
153
|
# @param [Integer] (default to:5) seconds to wait before timing out
|
317
154
|
#
|
318
155
|
def when_not_visible(timeout=Druid.default_element_wait)
|
156
|
+
when_present(timeout)
|
319
157
|
element.wait_while(timeout: timeout, message: "Element still visible after #{timeout} seconds", &:visible?)
|
320
158
|
self
|
321
159
|
end
|
@@ -326,25 +164,7 @@ module Druid
|
|
326
164
|
# @param [Integer] (default to:5) seconds to wait before timing out
|
327
165
|
#
|
328
166
|
def wait_until(timeout=Druid.default_element_wait, message=nil, &block)
|
329
|
-
|
330
|
-
end
|
331
|
-
|
332
|
-
|
333
|
-
# @private
|
334
|
-
def self.identifier_for identifier
|
335
|
-
if have_to_build_xpath(identifier)
|
336
|
-
how = :xpath
|
337
|
-
what = build_xpath_for(identifier)
|
338
|
-
return how => what
|
339
|
-
end
|
340
|
-
all_identities = {}
|
341
|
-
identifier.each do |key, value|
|
342
|
-
each = {key => value}
|
343
|
-
ident = identifier_for_element each, finders, mapping
|
344
|
-
all_identities[ident.keys.first] = ident.values.first
|
345
|
-
end
|
346
|
-
all_identities
|
347
|
-
# end
|
167
|
+
element.wait_until(timeout: timeout, message: message, &block)
|
348
168
|
end
|
349
169
|
|
350
170
|
# @private
|
@@ -354,89 +174,6 @@ module Druid
|
|
354
174
|
element.send m, *args, &block
|
355
175
|
end
|
356
176
|
|
357
|
-
protected
|
358
|
-
|
359
|
-
def self.have_to_build_xpath(identifier)
|
360
|
-
['table', 'span', 'div', 'td', 'li', 'ol', 'ul', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'p', 'label', 'area', 'canvas', 'audio', 'video', 'b', 'i'].include? identifier[:tag_name] and identifier[:name]
|
361
|
-
end
|
362
|
-
|
363
|
-
def self.build_xpath_for identifier
|
364
|
-
tag_locator = identifier.delete(:tag_name)
|
365
|
-
idx = identifier.delete(:index)
|
366
|
-
if tag_locator == 'input' and identifier[:type] == 'submit'
|
367
|
-
identifier.delete(:type)
|
368
|
-
btn_ident = identifier.clone
|
369
|
-
if btn_ident[:value]
|
370
|
-
btn_ident[:text] = btn_ident[:value]
|
371
|
-
btn_ident.delete(:value)
|
372
|
-
end
|
373
|
-
xpath = ".//button"
|
374
|
-
xpath << "[#{attribute_expression(btn_ident)}]" unless btn_ident.empty?
|
375
|
-
xpath = "(#{xpath})[#{idx+1}]" if idx
|
376
|
-
identifier[:type] = %w[button reset submit image]
|
377
|
-
xpath << " | .//input"
|
378
|
-
else
|
379
|
-
xpath = ".//#{tag_locator}"
|
380
|
-
end
|
381
|
-
xpath << "[#{attribute_expression(identifier)}]" unless identifier.empty?
|
382
|
-
xpath = "(#{xpath})[#{idx+1}]" if idx
|
383
|
-
xpath
|
384
|
-
end
|
385
|
-
|
386
|
-
def self.attribute_expression(identifier)
|
387
|
-
identifier.map do |key, value|
|
388
|
-
if value.kind_of?(Array)
|
389
|
-
"(" + value.map { |v| equal_pair(key, v) }.join(" or ") + ")"
|
390
|
-
else
|
391
|
-
equal_pair(key, value)
|
392
|
-
end
|
393
|
-
end.join(" and ")
|
394
|
-
end
|
395
|
-
|
396
|
-
def self.equal_pair(key, value)
|
397
|
-
if key == :label
|
398
|
-
"@id=//label[normalize-space()=#{xpath_string(value)}]/@for"
|
399
|
-
else
|
400
|
-
"#{lhs_for(key)}=#{xpath_string(value)}"
|
401
|
-
end
|
402
|
-
end
|
403
|
-
|
404
|
-
def self.lhs_for(key)
|
405
|
-
case key
|
406
|
-
when :text, 'text'
|
407
|
-
'normalize-space()'
|
408
|
-
when :href
|
409
|
-
'normalize-space(@href)'
|
410
|
-
else
|
411
|
-
"@#{key.to_s.gsub("_", "-")}"
|
412
|
-
end
|
413
|
-
end
|
414
|
-
|
415
|
-
def self.xpath_string(value)
|
416
|
-
if value.include? "'"
|
417
|
-
parts = value.split("'", -1).map { |part| "'#{part}'" }
|
418
|
-
string = parts.join(%{,"'",})
|
419
|
-
"concat(#{string})"
|
420
|
-
else
|
421
|
-
"'#{value}'"
|
422
|
-
end
|
423
|
-
end
|
424
|
-
|
425
|
-
def self.identifier_for_element identifier, find_by, find_by_mapping
|
426
|
-
how, what = identifier.keys.first, identifier.values.first
|
427
|
-
return how => what if find_by.include? how
|
428
|
-
return find_by_mapping[how] => what if find_by_mapping[how]
|
429
|
-
identifier
|
430
|
-
end
|
431
|
-
|
432
|
-
def self.finders
|
433
|
-
[:class, :id, :index, :name, :xpath]
|
434
|
-
end
|
435
|
-
|
436
|
-
def self.mapping
|
437
|
-
{}
|
438
|
-
end
|
439
|
-
|
440
177
|
private
|
441
178
|
|
442
179
|
def timed_loop(timeout)
|
data/lib/druid/elements/form.rb
CHANGED
data/lib/druid/elements/image.rb
CHANGED