druid-ts 1.1.4 → 1.1.5
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.
- checksums.yaml +4 -4
- data/ChangeLog +27 -0
- data/cucumber.yml +6 -2
- data/features/area.feature +33 -0
- data/features/audio.feature +66 -0
- data/features/canvas.feature +35 -0
- data/features/element.feature +9 -0
- data/features/html/hover.html +11 -0
- data/features/html/planets.gif +0 -0
- data/features/html/static_elements.html +43 -0
- data/features/html/sun.gif +0 -0
- data/features/html/sun.html +7 -0
- data/features/list_item.feature +1 -0
- data/features/page_level_actions.feature +25 -0
- data/features/sample-app/public/04-Death_Becomes_Fur.mp4 +0 -0
- data/features/sample-app/public/04-Death_Becomes_Fur.oga +0 -0
- data/features/sample-app/public/movie.mp4 +0 -0
- data/features/sample-app/public/movie.ogg +0 -0
- data/features/select_list.feature +5 -1
- data/features/step_definations/area_steps.rb +23 -0
- data/features/step_definations/audio_steps.rb +31 -0
- data/features/step_definations/canvas_steps.rb +19 -0
- data/features/step_definations/element_steps.rb +23 -2
- data/features/step_definations/page_level_actions_steps.rb +35 -0
- data/features/step_definations/select_list_steps.rb +4 -0
- data/features/step_definations/table_steps.rb +4 -0
- data/features/step_definations/video_steps.rb +19 -0
- data/features/support/page.rb +38 -2
- data/features/support/persistent_browser.rb +2 -1
- data/features/support/url_helper.rb +4 -0
- data/features/table.feature +8 -0
- data/features/video.feature +59 -0
- data/lib/druid/accessors.rb +162 -26
- data/lib/druid/assist.rb +63 -0
- data/lib/druid/element_locators.rb +126 -0
- data/lib/druid/elements.rb +29 -24
- data/lib/druid/elements/area.rb +29 -0
- data/lib/druid/elements/audio.rb +9 -0
- data/lib/druid/elements/canvas.rb +22 -0
- data/lib/druid/elements/element.rb +15 -1
- data/lib/druid/elements/list_item.rb +4 -0
- data/lib/druid/elements/media.rb +45 -0
- data/lib/druid/elements/select_list.rb +7 -1
- data/lib/druid/elements/table_row.rb +1 -0
- data/lib/druid/elements/video.rb +17 -0
- data/lib/druid/nested_elements.rb +32 -0
- data/lib/druid/version.rb +1 -1
- data/spec/druid/accessors_spec.rb +77 -0
- data/spec/druid/element_locators_spec.rb +89 -0
- data/spec/druid/elements/area_spec.rb +33 -0
- data/spec/druid/elements/canvas_spec.rb +28 -0
- data/spec/druid/elements/list_item_spec.rb +1 -1
- data/spec/druid/elements/select_list_spec.rb +6 -0
- metadata +42 -1
data/lib/druid/assist.rb
CHANGED
@@ -402,6 +402,69 @@ module Druid
|
|
402
402
|
find_elements("labels(identifier)", Elements::Label, identifier, 'p')
|
403
403
|
end
|
404
404
|
|
405
|
+
#
|
406
|
+
# method to click on an area
|
407
|
+
#
|
408
|
+
def click_area_for(identifier)
|
409
|
+
process_call("area(identifier).click", Elements::Area, identifier, nil, 'area')
|
410
|
+
end
|
411
|
+
|
412
|
+
#
|
413
|
+
# method to retrieve an area element
|
414
|
+
#
|
415
|
+
def area_for(identifier)
|
416
|
+
find_element("area(identifier)", Elements::Area, identifier, 'area')
|
417
|
+
end
|
418
|
+
|
419
|
+
#
|
420
|
+
# method to retrieve an array of area elements
|
421
|
+
#
|
422
|
+
def areas_for(identifier)
|
423
|
+
find_elements("areas(identifier)", Elements::Area, identifier, 'area')
|
424
|
+
end
|
425
|
+
|
426
|
+
#
|
427
|
+
# method to retrieve a canvas element
|
428
|
+
#
|
429
|
+
def canvas_for(identifier)
|
430
|
+
find_element("canvas(identifier)", Elements::Canvas, identifier, 'canvas')
|
431
|
+
end
|
432
|
+
|
433
|
+
#
|
434
|
+
# method to retrieve an array of canvas elements
|
435
|
+
#
|
436
|
+
def canvases_for(identifier)
|
437
|
+
find_elements("canvases(identifier)", Elements::Canvas, identifier, 'canvas')
|
438
|
+
end
|
439
|
+
|
440
|
+
#
|
441
|
+
# method to retrieve an audio element
|
442
|
+
#
|
443
|
+
def audio_for(identifier)
|
444
|
+
find_element("audio(identifier)", Elements::Audio, identifier, 'audio')
|
445
|
+
end
|
446
|
+
|
447
|
+
#
|
448
|
+
# method to retrieve an array of audio elements
|
449
|
+
#
|
450
|
+
def audios_for(identifier)
|
451
|
+
find_elements("audios(identifier)", Elements::Audio, identifier, 'audio')
|
452
|
+
end
|
453
|
+
|
454
|
+
#
|
455
|
+
# method to retrieve an video element
|
456
|
+
#
|
457
|
+
def video_for(identifier)
|
458
|
+
find_element("video(identifier)", Elements::Video, identifier, 'video')
|
459
|
+
end
|
460
|
+
|
461
|
+
#
|
462
|
+
# method to retrieve an array of audio elements
|
463
|
+
#
|
464
|
+
def videos_for(identifier)
|
465
|
+
find_elements("videos(identifier)", Elements::Video, identifier, 'video')
|
466
|
+
end
|
467
|
+
|
405
468
|
def element_for(tag, identifier)
|
406
469
|
find_element("#{tag.to_s}(identifier)", Elements::Element, identifier, tag.to_s)
|
407
470
|
end
|
@@ -899,6 +899,132 @@ module Druid
|
|
899
899
|
labels_for identifier.clone
|
900
900
|
end
|
901
901
|
|
902
|
+
#
|
903
|
+
# Finds an area
|
904
|
+
#
|
905
|
+
# @param [Hash] identifier how we find an area. You can use a multiple parameters
|
906
|
+
# by combining of any of the following except xpath. It defaults to {:index => 0}
|
907
|
+
# which will return the first file field. The valid keys are:
|
908
|
+
# * :class
|
909
|
+
# * :id
|
910
|
+
# * :index
|
911
|
+
# * :name
|
912
|
+
# * :xpath
|
913
|
+
#
|
914
|
+
def area_element(identifier={:index => 0})
|
915
|
+
area_for(identifier.clone)
|
916
|
+
end
|
917
|
+
|
918
|
+
#
|
919
|
+
# Finds all areas that matches the provided identifier
|
920
|
+
#
|
921
|
+
# @param [Hash] identifier how we find an area. You can use a multiple parameters
|
922
|
+
# by combining of any of the following except xpath. It defaults to empty hash
|
923
|
+
# which will return all file fields. The valid keys are:
|
924
|
+
# * :class
|
925
|
+
# * :id
|
926
|
+
# * :index
|
927
|
+
# * :name
|
928
|
+
# * :xpath
|
929
|
+
#
|
930
|
+
def area_elements(identifier={})
|
931
|
+
areas_for(identifier.clone)
|
932
|
+
end
|
933
|
+
|
934
|
+
#
|
935
|
+
# Finds an canvas
|
936
|
+
#
|
937
|
+
# @param [Hash] identifier how we find an canvas. You can use a multiple parameters
|
938
|
+
# by combining of any of the following except xpath. It defaults to {:index => 0}
|
939
|
+
# which will return the first file field. The valid keys are:
|
940
|
+
# * :class
|
941
|
+
# * :id
|
942
|
+
# * :index
|
943
|
+
# * :name
|
944
|
+
# * :xpath
|
945
|
+
#
|
946
|
+
def canvas_element(identifier={:index => 0})
|
947
|
+
canvas_for(identifier.clone)
|
948
|
+
end
|
949
|
+
|
950
|
+
#
|
951
|
+
# Finds all canvases that matches the provided identifier
|
952
|
+
#
|
953
|
+
# @param [Hash] identifier how we find an canvas. You can use a multiple parameters
|
954
|
+
# by combining of any of the following except xpath. It defaults to empty hash
|
955
|
+
# which will return all file fields. The valid keys are:
|
956
|
+
# * :class
|
957
|
+
# * :id
|
958
|
+
# * :index
|
959
|
+
# * :name
|
960
|
+
# * :xpath
|
961
|
+
#
|
962
|
+
def canvas_elements(identifier={})
|
963
|
+
canvases_for(identifier.clone)
|
964
|
+
end
|
965
|
+
|
966
|
+
#
|
967
|
+
# Finds an audio element
|
968
|
+
#
|
969
|
+
# @param [Hash] identifier how we find an audio. You can use a multiple parameters
|
970
|
+
# by combining of any of the following except xpath. It defaults to {:index => 0}
|
971
|
+
# which will return the first file field. The valid keys are:
|
972
|
+
# * :class
|
973
|
+
# * :id
|
974
|
+
# * :index
|
975
|
+
# * :name
|
976
|
+
# * :xpath
|
977
|
+
#
|
978
|
+
def audio_element(identifier={:index => 0})
|
979
|
+
audio_for(identifier.clone)
|
980
|
+
end
|
981
|
+
|
982
|
+
#
|
983
|
+
# Finds all audios that matches the provided identifier
|
984
|
+
#
|
985
|
+
# @param [Hash] identifier how we find an audio. You can use a multiple parameters
|
986
|
+
# by combining of any of the following except xpath. It defaults to empty hash
|
987
|
+
# which will return all file fields. The valid keys are:
|
988
|
+
# * :class
|
989
|
+
# * :id
|
990
|
+
# * :index
|
991
|
+
# * :name
|
992
|
+
# * :xpath
|
993
|
+
#
|
994
|
+
def audio_elements(identifier={})
|
995
|
+
audios_for(identifier.clone)
|
996
|
+
end
|
997
|
+
#
|
998
|
+
# Finds an video element
|
999
|
+
#
|
1000
|
+
# @param [Hash] identifier how we find an video. You can use a multiple parameters
|
1001
|
+
# by combining of any of the following except xpath. It defaults to {:index => 0}
|
1002
|
+
# which will return the first file field. The valid keys are:
|
1003
|
+
# * :class
|
1004
|
+
# * :id
|
1005
|
+
# * :index
|
1006
|
+
# * :name
|
1007
|
+
# * :xpath
|
1008
|
+
#
|
1009
|
+
def video_element(identifier={:index => 0})
|
1010
|
+
video_for(identifier.clone)
|
1011
|
+
end
|
1012
|
+
|
1013
|
+
#
|
1014
|
+
# Finds all videos that matches the provided identifier
|
1015
|
+
#
|
1016
|
+
# @param [Hash] identifier how we find an video. You can use a multiple parameters
|
1017
|
+
# by combining of any of the following except xpath. It defaults to empty hash
|
1018
|
+
# which will return all file fields. The valid keys are:
|
1019
|
+
# * :class
|
1020
|
+
# * :id
|
1021
|
+
# * :index
|
1022
|
+
# * :name
|
1023
|
+
# * :xpath
|
1024
|
+
#
|
1025
|
+
def video_elements(identifier={})
|
1026
|
+
videos_for(identifier.clone)
|
1027
|
+
end
|
902
1028
|
#
|
903
1029
|
# Finds an element
|
904
1030
|
#
|
data/lib/druid/elements.rb
CHANGED
@@ -22,27 +22,32 @@ module Druid
|
|
22
22
|
end
|
23
23
|
end
|
24
24
|
|
25
|
-
require 'druid/elements/element
|
26
|
-
require 'druid/elements/ordered_list
|
27
|
-
require 'druid/elements/unordered_list
|
28
|
-
require 'druid/elements/table
|
29
|
-
require 'druid/elements/table_row
|
30
|
-
require 'druid/elements/select_list
|
31
|
-
require 'druid/elements/link
|
32
|
-
require 'druid/elements/button
|
33
|
-
require 'druid/elements/check_box
|
34
|
-
require 'druid/elements/radio_button
|
35
|
-
require 'druid/elements/text_field
|
36
|
-
require 'druid/elements/div
|
37
|
-
require 'druid/elements/table_cell
|
38
|
-
require 'druid/elements/image
|
39
|
-
require 'druid/elements/span
|
40
|
-
require 'druid/elements/hidden_field
|
41
|
-
require 'druid/elements/list_item
|
42
|
-
require 'druid/elements/text_area
|
43
|
-
require 'druid/elements/form
|
44
|
-
require 'druid/elements/option
|
45
|
-
require 'druid/elements/heading
|
46
|
-
require 'druid/elements/paragraph
|
47
|
-
require 'druid/elements/file_field
|
48
|
-
require 'druid/elements/label
|
25
|
+
require 'druid/elements/element'
|
26
|
+
require 'druid/elements/ordered_list'
|
27
|
+
require 'druid/elements/unordered_list'
|
28
|
+
require 'druid/elements/table'
|
29
|
+
require 'druid/elements/table_row'
|
30
|
+
require 'druid/elements/select_list'
|
31
|
+
require 'druid/elements/link'
|
32
|
+
require 'druid/elements/button'
|
33
|
+
require 'druid/elements/check_box'
|
34
|
+
require 'druid/elements/radio_button'
|
35
|
+
require 'druid/elements/text_field'
|
36
|
+
require 'druid/elements/div'
|
37
|
+
require 'druid/elements/table_cell'
|
38
|
+
require 'druid/elements/image'
|
39
|
+
require 'druid/elements/span'
|
40
|
+
require 'druid/elements/hidden_field'
|
41
|
+
require 'druid/elements/list_item'
|
42
|
+
require 'druid/elements/text_area'
|
43
|
+
require 'druid/elements/form'
|
44
|
+
require 'druid/elements/option'
|
45
|
+
require 'druid/elements/heading'
|
46
|
+
require 'druid/elements/paragraph'
|
47
|
+
require 'druid/elements/file_field'
|
48
|
+
require 'druid/elements/label'
|
49
|
+
require 'druid/elements/area'
|
50
|
+
require 'druid/elements/canvas'
|
51
|
+
require 'druid/elements/media'
|
52
|
+
require 'druid/elements/audio'
|
53
|
+
require 'druid/elements/video'
|
@@ -0,0 +1,29 @@
|
|
1
|
+
module Druid
|
2
|
+
module Elements
|
3
|
+
class Area < Element
|
4
|
+
|
5
|
+
#
|
6
|
+
# Return the coordinates of the area
|
7
|
+
#
|
8
|
+
def coords
|
9
|
+
attribute(:coords)
|
10
|
+
end
|
11
|
+
|
12
|
+
#
|
13
|
+
# Return the shape of the area
|
14
|
+
#
|
15
|
+
def shape
|
16
|
+
attribute(:shape)
|
17
|
+
end
|
18
|
+
|
19
|
+
#
|
20
|
+
# Return the href of the area
|
21
|
+
#
|
22
|
+
def href
|
23
|
+
attribute(:href)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
Druid::Elements.type_to_class[:area] = Druid::Elements::Area
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module Druid
|
2
|
+
module Elements
|
3
|
+
class Canvas < Element
|
4
|
+
|
5
|
+
#
|
6
|
+
# return the width of the canvas
|
7
|
+
#
|
8
|
+
def width
|
9
|
+
attribute(:width).to_i
|
10
|
+
end
|
11
|
+
|
12
|
+
#
|
13
|
+
# return the height of the canvas
|
14
|
+
#
|
15
|
+
def height
|
16
|
+
attribute(:height).to_i
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
Druid::Elements.type_to_class[:canvas] = Druid::Elements::Canvas
|
21
|
+
end
|
22
|
+
end
|
@@ -144,6 +144,13 @@ module Druid
|
|
144
144
|
element.focus
|
145
145
|
end
|
146
146
|
|
147
|
+
#
|
148
|
+
# get the id of element
|
149
|
+
#
|
150
|
+
def id
|
151
|
+
attribute(:id)
|
152
|
+
end
|
153
|
+
|
147
154
|
#
|
148
155
|
# Flash the element by temporarily changing the background color
|
149
156
|
#
|
@@ -151,6 +158,13 @@ module Druid
|
|
151
158
|
element.flash
|
152
159
|
end
|
153
160
|
|
161
|
+
#
|
162
|
+
# hover over the element
|
163
|
+
#
|
164
|
+
def hover
|
165
|
+
element.hover
|
166
|
+
end
|
167
|
+
|
154
168
|
#
|
155
169
|
# Returns parent element of current element.
|
156
170
|
def parent
|
@@ -250,7 +264,7 @@ module Druid
|
|
250
264
|
protected
|
251
265
|
|
252
266
|
def self.have_to_build_xpath(identifier)
|
253
|
-
['table', 'span', 'div', 'td', 'li', 'ol', 'ul', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'p', 'label'].include? identifier[:tag_name] and identifier[:name]
|
267
|
+
['table', 'span', 'div', 'td', 'li', 'ol', 'ul', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'p', 'label', 'area', 'canvas', 'audio', 'video'].include? identifier[:tag_name] and identifier[:name]
|
254
268
|
end
|
255
269
|
|
256
270
|
def self.build_xpath_for identifier
|
@@ -0,0 +1,45 @@
|
|
1
|
+
module Druid
|
2
|
+
module Elements
|
3
|
+
class Media < Element
|
4
|
+
|
5
|
+
def autoplay?
|
6
|
+
attribute(:autoplay)
|
7
|
+
end
|
8
|
+
|
9
|
+
def has_controls?
|
10
|
+
attribute(:controls)
|
11
|
+
end
|
12
|
+
|
13
|
+
def paused?
|
14
|
+
attribute(:paused)
|
15
|
+
end
|
16
|
+
|
17
|
+
def duration
|
18
|
+
duration = attribute(:duration)
|
19
|
+
return duration.to_f if duration
|
20
|
+
end
|
21
|
+
|
22
|
+
def volume
|
23
|
+
volume = attribute(:volume)
|
24
|
+
return volume.to_i if volume
|
25
|
+
end
|
26
|
+
|
27
|
+
def ended?
|
28
|
+
attribute(:ended)
|
29
|
+
end
|
30
|
+
|
31
|
+
def seeking?
|
32
|
+
attribute(:seeking)
|
33
|
+
end
|
34
|
+
|
35
|
+
def loop?
|
36
|
+
attribute(:loop)
|
37
|
+
end
|
38
|
+
|
39
|
+
def muted?
|
40
|
+
attribute(:muted)
|
41
|
+
end
|
42
|
+
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
@@ -30,12 +30,18 @@ module Druid
|
|
30
30
|
end
|
31
31
|
|
32
32
|
#
|
33
|
-
# @return [Array<
|
33
|
+
# @return [Array<String>] An array of strings representing the text of the currently selected options.
|
34
34
|
#
|
35
35
|
def selected_options
|
36
36
|
element.selected_options.map { |e| e.text }.compact
|
37
37
|
end
|
38
38
|
|
39
|
+
#
|
40
|
+
# @return [Array<String>] An array of strings representing the value of the currently selected options.
|
41
|
+
def selected_values
|
42
|
+
element.selected_options.map { |e| e.value }.compact
|
43
|
+
end
|
44
|
+
|
39
45
|
#
|
40
46
|
# Returns true if the select list has one or more options where text or label matches the given value.
|
41
47
|
#
|