druid-ts 1.2.4 → 1.2.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/ChangeLog +21 -2
- data/Gemfile +1 -1
- data/druid.gemspec +3 -3
- data/features/element.feature +0 -5
- data/features/frames.feature +4 -0
- data/features/html/static_elements.html +11 -0
- data/features/populate_page_with.feature +25 -0
- data/features/select_list.feature +1 -0
- data/features/step_definations/audio_steps.rb +1 -1
- data/features/step_definations/element_steps.rb +0 -4
- data/features/step_definations/frame_steps.rb +35 -0
- data/features/step_definations/populate_page_with_steps.rb +3 -0
- data/features/step_definations/select_list_steps.rb +4 -0
- data/features/step_definations/table_steps.rb +19 -0
- data/features/support/page.rb +2 -0
- data/features/table.feature +21 -0
- data/lib/druid.rb +0 -1
- data/lib/druid/assist.rb +8 -5
- data/lib/druid/elements/area.rb +0 -20
- data/lib/druid/elements/check_box.rb +0 -20
- data/lib/druid/elements/element.rb +73 -64
- data/lib/druid/elements/file_field.rb +0 -6
- data/lib/druid/elements/hidden_field.rb +0 -4
- data/lib/druid/elements/image.rb +0 -7
- data/lib/druid/elements/media.rb +0 -34
- data/lib/druid/elements/ordered_list.rb +8 -21
- data/lib/druid/elements/radio_button.rb +0 -13
- data/lib/druid/elements/select_list.rb +2 -11
- data/lib/druid/elements/table.rb +41 -16
- data/lib/druid/elements/table_row.rb +21 -17
- data/lib/druid/elements/text_area.rb +0 -7
- data/lib/druid/elements/text_field.rb +0 -7
- data/lib/druid/elements/unordered_list.rb +9 -22
- data/lib/druid/javascript_framework_facade.rb +1 -1
- data/lib/druid/locator_generator.rb +153 -147
- data/lib/druid/page_populator.rb +44 -37
- data/lib/druid/version.rb +1 -1
- data/spec/druid/accessors_spec.rb +3 -3
- data/spec/druid/elements/check_box_spec.rb +0 -15
- data/spec/druid/elements/element_spec.rb +77 -78
- data/spec/druid/elements/file_field_spec.rb +0 -5
- data/spec/druid/elements/media_spec.rb +0 -49
- data/spec/druid/elements/ordered_list_spec.rb +24 -20
- data/spec/druid/elements/radio_button_spec.rb +0 -10
- data/spec/druid/elements/table_row_spec.rb +12 -12
- data/spec/druid/elements/table_spec.rb +29 -25
- data/spec/druid/elements/text_area_spec.rb +0 -4
- data/spec/druid/elements/text_field_spec.rb +0 -5
- data/spec/druid/elements/unordered_list_spec.rb +25 -20
- data/spec/druid/javascript_framework_facade_spec.rb +1 -1
- data/spec/druid/page_populator_spec.rb +34 -4
- metadata +15 -18
- data/lib/druid/core_ext/string.rb +0 -5
- data/spec/druid/elements/area_spec.rb +0 -25
- data/spec/druid/elements/canvas_spec.rb +0 -19
- data/spec/druid/elements/video_spec.rb +0 -25
data/lib/druid/elements/image.rb
CHANGED
data/lib/druid/elements/media.rb
CHANGED
@@ -2,44 +2,10 @@ module Druid
|
|
2
2
|
module Elements
|
3
3
|
class Media < Element
|
4
4
|
|
5
|
-
def autoplay?
|
6
|
-
attribute(:autoplay)
|
7
|
-
end
|
8
|
-
|
9
5
|
def has_controls?
|
10
6
|
attribute(:controls)
|
11
7
|
end
|
12
8
|
|
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
9
|
end
|
44
10
|
end
|
45
11
|
end
|
@@ -4,35 +4,22 @@ module Druid
|
|
4
4
|
attr_accessor :li_element
|
5
5
|
|
6
6
|
def [](idx)
|
7
|
-
|
7
|
+
list_items[idx]
|
8
8
|
end
|
9
9
|
|
10
10
|
def items
|
11
|
-
|
11
|
+
list_items.size
|
12
12
|
end
|
13
13
|
|
14
|
-
def each
|
15
|
-
|
16
|
-
yield self[index-1]
|
17
|
-
end
|
14
|
+
def each(&block)
|
15
|
+
list_items.each(&block)
|
18
16
|
end
|
19
17
|
|
18
|
+
#
|
19
|
+
# Return Array of ListItem objects that are children of the OrderedList
|
20
|
+
#
|
20
21
|
def list_items
|
21
|
-
children
|
22
|
-
Druid::Elements::ListItem.new(obj)
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
protected
|
27
|
-
|
28
|
-
def child_xpath
|
29
|
-
"./child::li"
|
30
|
-
end
|
31
|
-
|
32
|
-
private
|
33
|
-
|
34
|
-
def children
|
35
|
-
element.ols(:xpath => child_xpath)
|
22
|
+
@list_items ||= children(tag_name: 'li')
|
36
23
|
end
|
37
24
|
|
38
25
|
end
|
@@ -2,19 +2,6 @@ module Druid
|
|
2
2
|
module Elements
|
3
3
|
class RadioButton < Element
|
4
4
|
|
5
|
-
#
|
6
|
-
# Select the RadioButton
|
7
|
-
#
|
8
|
-
def select
|
9
|
-
element.set
|
10
|
-
end
|
11
|
-
|
12
|
-
#
|
13
|
-
# Return if it is selected
|
14
|
-
#
|
15
|
-
def selected?
|
16
|
-
element.set?
|
17
|
-
end
|
18
5
|
end
|
19
6
|
|
20
7
|
Druid::Elements.type_to_class[:radio] = Druid::Elements::RadioButton
|
@@ -14,22 +14,13 @@ module Druid
|
|
14
14
|
# @return [Array<String>] An array of strings representing the text of the currently selected options.
|
15
15
|
#
|
16
16
|
def selected_options
|
17
|
-
element.selected_options.map
|
17
|
+
element.selected_options.map(&:text).compact
|
18
18
|
end
|
19
19
|
|
20
20
|
#
|
21
21
|
# @return [Array<String>] An array of strings representing the value of the currently selected options.
|
22
22
|
def selected_values
|
23
|
-
element.selected_options.map
|
24
|
-
end
|
25
|
-
|
26
|
-
#
|
27
|
-
# Returns true if the select list has one or more options where text or label matches the given value.
|
28
|
-
#
|
29
|
-
# @param [String, Regexp] value A value
|
30
|
-
# @return [Boolean]
|
31
|
-
def include? value
|
32
|
-
element.include? value
|
23
|
+
element.selected_options.map(&:value).compact
|
33
24
|
end
|
34
25
|
|
35
26
|
end
|
data/lib/druid/elements/table.rb
CHANGED
@@ -7,24 +7,27 @@ module Druid
|
|
7
7
|
# will be matched with the text from any column. The text can be
|
8
8
|
# a substring of the full column text.
|
9
9
|
#
|
10
|
-
# @return [Druid::Elements::
|
10
|
+
# @return [Druid::Elements::TableRow]
|
11
11
|
#
|
12
|
-
def [](
|
13
|
-
idx =
|
14
|
-
|
15
|
-
Druid::Elements::TableRow.new(element[idx])
|
12
|
+
def [](what)
|
13
|
+
idx = find_index(what)
|
14
|
+
idx && row_items[idx]
|
16
15
|
end
|
16
|
+
|
17
17
|
#
|
18
18
|
# Returns the number of rows in the table.
|
19
19
|
#
|
20
20
|
def rows
|
21
|
-
|
21
|
+
row_items.size
|
22
22
|
end
|
23
23
|
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
24
|
+
#
|
25
|
+
# iterator that yields with a Druid::Elements::TableRow
|
26
|
+
#
|
27
|
+
# @return [Druid::Elements::TableRow]
|
28
|
+
#
|
29
|
+
def each(&block)
|
30
|
+
row_items.each(&block)
|
28
31
|
end
|
29
32
|
|
30
33
|
#
|
@@ -46,17 +49,39 @@ module Druid
|
|
46
49
|
end
|
47
50
|
|
48
51
|
#
|
49
|
-
#
|
52
|
+
# Returns the Array of values(String) in a column for the index provided. Index
|
53
|
+
# is zero based. If the index provided is a String then it
|
54
|
+
# will be matched with the text from the header. The text can be a substring of the full header text
|
50
55
|
#
|
51
|
-
def
|
52
|
-
|
56
|
+
def column_values(what)
|
57
|
+
idx = find_index_of_header(what)
|
58
|
+
idx && row_items.drop(1).collect{ |row| row.cell(index: idx).text }
|
53
59
|
end
|
54
60
|
|
55
61
|
private
|
56
62
|
|
57
|
-
def
|
58
|
-
|
59
|
-
|
63
|
+
def row_items
|
64
|
+
meth = stragegy == :descendants ? :trs : :rows
|
65
|
+
@row_items ||= element.send(meth).map do |obj|
|
66
|
+
Druid::Elements::TableRow.new(obj)
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
def stragegy
|
71
|
+
:children
|
72
|
+
end
|
73
|
+
|
74
|
+
def find_index_of_header(what)
|
75
|
+
return what if what.is_a? Integer
|
76
|
+
row_items[0].cells.find_index do |cell|
|
77
|
+
cell.text.include? Regexp.escape(what)
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
def find_index(what)
|
82
|
+
return what if what.is_a? Integer
|
83
|
+
row_items.find_index do |row|
|
84
|
+
row.cell(text: /#{Regexp.escape(what)}/).exist?
|
60
85
|
end
|
61
86
|
end
|
62
87
|
|
@@ -8,34 +8,38 @@ module Druid
|
|
8
8
|
# is zero based. If the index provided is a String then it
|
9
9
|
# will be matched with the text from the columns in the first row.
|
10
10
|
#
|
11
|
-
def [](
|
12
|
-
idx =
|
13
|
-
|
14
|
-
Druid::Elements::TableCell.new(element[idx])
|
11
|
+
def [](what)
|
12
|
+
idx = find_index(what)
|
13
|
+
idx && cell_items[idx]
|
15
14
|
end
|
15
|
+
|
16
16
|
#
|
17
|
-
# Returns the number of
|
17
|
+
# Returns the number of colums in the table
|
18
18
|
#
|
19
19
|
def columns
|
20
|
-
|
20
|
+
cell_items.size
|
21
21
|
end
|
22
22
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
23
|
+
#
|
24
|
+
# iterator that yields with a Druid::Elements::TableCell
|
25
|
+
#
|
26
|
+
def each(&block)
|
27
|
+
cell_items.each(&block)
|
27
28
|
end
|
28
29
|
|
29
30
|
private
|
30
31
|
|
31
|
-
def
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
32
|
+
def cell_items
|
33
|
+
@cell_items ||= element.cells.map do |obj|
|
34
|
+
Druid::Elements::TableCell.new(obj)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
def find_index(what)
|
39
|
+
return what if what.is_a? Integer
|
40
|
+
parent(tag_name: 'table').headers.find_index do |header|
|
41
|
+
header.text.include? what
|
36
42
|
end
|
37
|
-
first_row = table[0]
|
38
|
-
first_row.cells.find_index { |column| column.text.include? title}
|
39
43
|
end
|
40
44
|
|
41
45
|
end
|
@@ -2,41 +2,28 @@ module Druid
|
|
2
2
|
module Elements
|
3
3
|
class UnOrderedList < Element
|
4
4
|
|
5
|
+
#
|
6
|
+
# @return [Druid::Elements::ListItem]
|
7
|
+
#
|
5
8
|
def [](idx)
|
6
|
-
|
9
|
+
list_items[idx]
|
7
10
|
end
|
8
11
|
|
9
12
|
def items
|
10
|
-
|
13
|
+
list_items.size
|
11
14
|
end
|
12
15
|
|
13
|
-
def each
|
14
|
-
|
15
|
-
yield self[index-1]
|
16
|
-
end
|
16
|
+
def each(&block)
|
17
|
+
list_items.each(&block)
|
17
18
|
end
|
18
19
|
|
19
20
|
#
|
20
|
-
#
|
21
|
-
# UnOrderedList
|
21
|
+
# Return Array of ListItem objects that are children of the UnorderedList
|
22
22
|
#
|
23
23
|
def list_items
|
24
|
-
children
|
25
|
-
Druid::Elements::ListItem.new(obj)
|
26
|
-
end
|
24
|
+
@list_items ||= children(tag_name: 'li')
|
27
25
|
end
|
28
26
|
|
29
|
-
protected
|
30
|
-
|
31
|
-
def child_xpath
|
32
|
-
"./child::li"
|
33
|
-
end
|
34
|
-
|
35
|
-
private
|
36
|
-
|
37
|
-
def children
|
38
|
-
element.uls(:xpath => child_xpath)
|
39
|
-
end
|
40
27
|
end
|
41
28
|
|
42
29
|
Druid::Elements.tag_to_class[:ul] = Druid::Elements::UnOrderedList
|
@@ -65,7 +65,7 @@ module Druid
|
|
65
65
|
end
|
66
66
|
|
67
67
|
def unknown_framework(framework)
|
68
|
-
"You specified the Javascript framework #{framework} and it is
|
68
|
+
"You specified the Javascript framework #{framework} and it is unknown to the system"
|
69
69
|
end
|
70
70
|
|
71
71
|
def invalid_framework
|
@@ -1,154 +1,160 @@
|
|
1
1
|
module Druid
|
2
2
|
module LocatorGenerator
|
3
3
|
|
4
|
-
BASIC_ELEMENTS =
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
4
|
+
BASIC_ELEMENTS = %i(
|
5
|
+
abbr
|
6
|
+
address
|
7
|
+
animate
|
8
|
+
animate_motion
|
9
|
+
animate_transform
|
10
|
+
article
|
11
|
+
as
|
12
|
+
aside
|
13
|
+
base
|
14
|
+
bdi
|
15
|
+
bdo
|
16
|
+
blockquote
|
17
|
+
body
|
18
|
+
br
|
19
|
+
caption
|
20
|
+
circle
|
21
|
+
cite
|
22
|
+
code
|
23
|
+
col
|
24
|
+
colgroup
|
25
|
+
command
|
26
|
+
cursor
|
27
|
+
data
|
28
|
+
datalist
|
29
|
+
dd
|
30
|
+
defs
|
31
|
+
del
|
32
|
+
desc
|
33
|
+
details
|
34
|
+
dfn
|
35
|
+
dialog
|
36
|
+
discard
|
37
|
+
dl
|
38
|
+
dt
|
39
|
+
ellipse
|
40
|
+
em
|
41
|
+
embed
|
42
|
+
fieldset
|
43
|
+
figcaption
|
44
|
+
figure
|
45
|
+
font
|
46
|
+
footer
|
47
|
+
foreign_object
|
48
|
+
g
|
49
|
+
head
|
50
|
+
header
|
51
|
+
hgroup
|
52
|
+
hr
|
53
|
+
html
|
54
|
+
ins
|
55
|
+
kbd
|
56
|
+
keygen
|
57
|
+
legend
|
58
|
+
line
|
59
|
+
linear_gradient
|
60
|
+
main
|
61
|
+
map
|
62
|
+
mark
|
63
|
+
marker
|
64
|
+
menu
|
65
|
+
menuitem
|
66
|
+
mesh_gradient
|
67
|
+
mesh_patch
|
68
|
+
mesh_row
|
69
|
+
meta
|
70
|
+
metadata
|
71
|
+
meter
|
72
|
+
mpath
|
73
|
+
nav
|
74
|
+
noscript
|
75
|
+
object
|
76
|
+
optgroup
|
77
|
+
output
|
78
|
+
p
|
79
|
+
param
|
80
|
+
path
|
81
|
+
pattern
|
82
|
+
polygon
|
83
|
+
polyline
|
84
|
+
pre
|
85
|
+
progress
|
86
|
+
q
|
87
|
+
radial_gradient
|
88
|
+
rect
|
89
|
+
rp
|
90
|
+
rt
|
91
|
+
ruby
|
92
|
+
s
|
93
|
+
samp
|
94
|
+
script
|
95
|
+
section
|
96
|
+
set
|
97
|
+
small
|
98
|
+
source
|
99
|
+
stop
|
100
|
+
strong
|
101
|
+
style
|
102
|
+
sub
|
103
|
+
summary
|
104
|
+
sup
|
105
|
+
switch
|
106
|
+
symbol
|
107
|
+
template
|
108
|
+
text_path
|
109
|
+
thread
|
110
|
+
time
|
111
|
+
title
|
112
|
+
track
|
113
|
+
tspan
|
114
|
+
u
|
115
|
+
use
|
116
|
+
var
|
117
|
+
view
|
118
|
+
wbr
|
119
|
+
)
|
117
120
|
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
121
|
+
|
122
|
+
ADVANCED_ELEMENTS = %i(
|
123
|
+
text_field
|
124
|
+
hidden_field
|
125
|
+
text_area
|
126
|
+
select_list
|
127
|
+
link
|
128
|
+
checkbox
|
129
|
+
radio_button
|
130
|
+
button
|
131
|
+
div
|
132
|
+
span
|
133
|
+
table
|
134
|
+
cell
|
135
|
+
row
|
136
|
+
image
|
137
|
+
form
|
138
|
+
list_item
|
139
|
+
ordered_list
|
140
|
+
unordered_list
|
141
|
+
h1
|
142
|
+
h2
|
143
|
+
h3
|
144
|
+
h4
|
145
|
+
h5
|
146
|
+
h6
|
147
|
+
paragraph
|
148
|
+
label
|
149
|
+
file_field
|
150
|
+
area
|
151
|
+
canvas
|
152
|
+
audio
|
153
|
+
video
|
154
|
+
b
|
155
|
+
i
|
156
|
+
svg
|
157
|
+
)
|
152
158
|
|
153
159
|
def self.generate_locators(target)
|
154
160
|
ADVANCED_ELEMENTS.each do |tag|
|