watir-webdriver 0.6.9 → 0.6.10
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGES.md +5 -0
- data/Gemfile +4 -0
- data/lib/watir-webdriver/attribute_helper.rb +28 -73
- data/lib/watir-webdriver/elements/area.rb +1 -1
- data/lib/watir-webdriver/elements/button.rb +1 -2
- data/lib/watir-webdriver/elements/element.rb +6 -2
- data/lib/watir-webdriver/elements/generated.rb +3002 -2610
- data/lib/watir-webdriver/elements/link.rb +1 -1
- data/lib/watir-webdriver/elements/table_cell.rb +3 -5
- data/lib/watir-webdriver/elements/text_field.rb +1 -1
- data/lib/watir-webdriver/html/generator.rb +15 -2
- data/lib/watir-webdriver/html/idl_sorter.rb +1 -1
- data/lib/watir-webdriver/html/spec_extractor.rb +17 -3
- data/lib/watir-webdriver/html/visitor.rb +27 -55
- data/lib/watir-webdriver/locators/element_locator.rb +0 -3
- data/lib/watir-webdriver/version.rb +1 -1
- metadata +3 -4
- data/.yardopts +0 -1
- data/lib/yard/handlers/watir.rb +0 -55
@@ -3,14 +3,12 @@ module Watir
|
|
3
3
|
# @private
|
4
4
|
attr_writer :locator_class
|
5
5
|
|
6
|
+
alias_method :colspan, :col_span
|
7
|
+
alias_method :rowspan, :row_span
|
8
|
+
|
6
9
|
def locator_class
|
7
10
|
@locator_class || super
|
8
11
|
end
|
9
|
-
|
10
|
-
def colspan
|
11
|
-
value = attribute_value :colspan
|
12
|
-
value ? Integer(value) : 1
|
13
|
-
end
|
14
12
|
end # TableCell
|
15
13
|
|
16
14
|
class TableCellCollection < ElementCollection
|
@@ -4,6 +4,8 @@ module Watir
|
|
4
4
|
module HTML
|
5
5
|
class Generator
|
6
6
|
|
7
|
+
IGNORED_ATTRIBUTES = %w(cells elements hash rows span text)
|
8
|
+
|
7
9
|
def generate(spec_url, io = StringIO.new)
|
8
10
|
@spec_url, @io = spec_url, io
|
9
11
|
|
@@ -47,6 +49,11 @@ module Watir
|
|
47
49
|
@sorted_interfaces.reject! { |intf| intf.name == "HTMLLinkElement" }
|
48
50
|
# frame is implemented manually, see https://github.com/watir/watir-webdriver/issues/204
|
49
51
|
@sorted_interfaces.reject! { |intf| intf.name == "HTMLFrameElement" }
|
52
|
+
|
53
|
+
# cleanup attributes
|
54
|
+
@sorted_interfaces.each do |intf|
|
55
|
+
intf.members.delete_if { |member| IGNORED_ATTRIBUTES.include?(member.name) }
|
56
|
+
end
|
50
57
|
end
|
51
58
|
|
52
59
|
def write_header
|
@@ -56,11 +63,16 @@ module Watir
|
|
56
63
|
|
57
64
|
def write_class_defs
|
58
65
|
@sorted_interfaces.each do |interface|
|
59
|
-
|
66
|
+
interface = generator.generate(interface)
|
67
|
+
unless interface.empty?
|
68
|
+
interface.gsub!(/^\s+\n/, '') # remove empty lines
|
69
|
+
@io.puts indent(interface)
|
70
|
+
end
|
60
71
|
end
|
61
72
|
end
|
62
73
|
|
63
74
|
def write_container_methods
|
75
|
+
@io.puts "\n\n"
|
64
76
|
@io.puts indent("module Container")
|
65
77
|
|
66
78
|
@tag2interfaces.sort.each do |tag, interfaces|
|
@@ -74,6 +86,7 @@ module Watir
|
|
74
86
|
|
75
87
|
# visitor.visit_tag(tag, interfaces.first.name) !?
|
76
88
|
@io.puts indent(<<-CODE, 3)
|
89
|
+
|
77
90
|
#
|
78
91
|
# @return [#{element_class}]
|
79
92
|
#
|
@@ -103,7 +116,7 @@ CODE
|
|
103
116
|
end
|
104
117
|
|
105
118
|
def indent(code, indent = 1)
|
106
|
-
indent_string = "
|
119
|
+
indent_string = " " * indent
|
107
120
|
code.split("\n").map { |line| line.empty? ? line : indent_string + line }.join("\n")
|
108
121
|
end
|
109
122
|
|
@@ -33,8 +33,8 @@ module Watir
|
|
33
33
|
process if @interfaces.nil?
|
34
34
|
|
35
35
|
sorter.sort.map { |name|
|
36
|
-
@
|
37
|
-
}.
|
36
|
+
@interfaces.find { |i| i.name == name } or puts "ignoring interface: #{name}"
|
37
|
+
}.compact
|
38
38
|
end
|
39
39
|
|
40
40
|
def print_hierarchy
|
@@ -67,8 +67,9 @@ module Watir
|
|
67
67
|
end
|
68
68
|
end
|
69
69
|
|
70
|
-
@interfaces_by_name = @interfaces.group_by
|
70
|
+
@interfaces_by_name = @interfaces.group_by(&:name)
|
71
71
|
apply_implements(implements)
|
72
|
+
merge_interfaces
|
72
73
|
end
|
73
74
|
|
74
75
|
def extract_interface_map
|
@@ -136,6 +137,19 @@ module Watir
|
|
136
137
|
end
|
137
138
|
end
|
138
139
|
|
140
|
+
def merge_interfaces
|
141
|
+
non_duplicates = @interfaces.uniq(&:name)
|
142
|
+
duplicates = @interfaces - non_duplicates
|
143
|
+
|
144
|
+
duplicates.each do |intf|
|
145
|
+
final = non_duplicates.find { |i| i.name == intf.name }
|
146
|
+
final.members += intf.members
|
147
|
+
final.extended_attributes += intf.extended_attributes
|
148
|
+
end
|
149
|
+
|
150
|
+
@interfaces = non_duplicates
|
151
|
+
end
|
152
|
+
|
139
153
|
def idl_parser
|
140
154
|
@idl_parser ||= WebIDL::Parser::IDLParser.new
|
141
155
|
end
|
@@ -83,9 +83,7 @@ module Watir
|
|
83
83
|
|
84
84
|
def element_class(name, attributes, parent)
|
85
85
|
[:class, Util.classify(name), [:const, Util.classify(parent)],
|
86
|
-
|
87
|
-
[:block, attributes_call(attributes)]
|
88
|
-
]
|
86
|
+
*attribute_calls(attributes)
|
89
87
|
]
|
90
88
|
end
|
91
89
|
|
@@ -113,77 +111,51 @@ module Watir
|
|
113
111
|
]
|
114
112
|
end
|
115
113
|
|
116
|
-
def
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
114
|
+
def attribute_calls(attributes)
|
115
|
+
attributes.map do |attribute|
|
116
|
+
call(:attribute, [
|
117
|
+
[:lit, ruby_type_for(attribute.type)],
|
118
|
+
[:lit, ruby_method_name_for(attribute)],
|
119
|
+
[:lit, attribute.name.to_sym]
|
120
|
+
])
|
123
121
|
end
|
122
|
+
end
|
124
123
|
|
125
|
-
|
124
|
+
def call(name, args)
|
125
|
+
[:call, nil, name.to_sym, [:arglist] + args]
|
126
126
|
end
|
127
127
|
|
128
|
-
def
|
129
|
-
str =
|
128
|
+
def ruby_method_name_for(attribute)
|
129
|
+
str = attribute.name.snake_case
|
130
130
|
|
131
|
-
if
|
132
|
-
str = $1
|
131
|
+
if attribute.type.name == :Boolean
|
132
|
+
str = $1 if str =~ /^is_(.+)/
|
133
|
+
str << '?'
|
133
134
|
end
|
134
135
|
|
135
|
-
str
|
136
|
-
end
|
136
|
+
str = 'for' if str == 'html_for'
|
137
137
|
|
138
|
-
|
139
|
-
[:hash] + hash.map { |k, v| [[:lit, k.to_sym], [:lit, v]] }.flatten(1)
|
140
|
-
end
|
141
|
-
|
142
|
-
def literal_array(arr)
|
143
|
-
[:array] + arr.map { |e| [:lit, e.to_sym] }
|
144
|
-
end
|
145
|
-
|
146
|
-
def call(name, args)
|
147
|
-
[:call, nil, name.to_sym, [:arglist] + args]
|
138
|
+
str.to_sym
|
148
139
|
end
|
149
140
|
|
150
141
|
def ruby_type_for(type)
|
151
142
|
case type.name.to_s
|
152
143
|
when 'DOMString', 'any'
|
153
|
-
|
144
|
+
String
|
154
145
|
when 'UnsignedLong', 'Long', 'Integer', 'Short', 'UnsignedShort'
|
155
|
-
|
146
|
+
Fixnum
|
156
147
|
when 'Float', /.*Double$/
|
157
|
-
|
158
|
-
when 'Function', /.*EventHandler$/
|
159
|
-
:function
|
148
|
+
Float
|
160
149
|
when 'Boolean'
|
161
|
-
|
162
|
-
when 'Document', 'DocumentFragment'
|
163
|
-
:document
|
164
|
-
when 'DOMTokenList', 'DOMSettableTokenList'
|
165
|
-
:token_list
|
166
|
-
when 'DOMStringMap'
|
167
|
-
:string_map
|
168
|
-
when 'HTMLPropertiesCollection'
|
169
|
-
:properties_collection
|
170
|
-
when /HTML(.*)Element/
|
171
|
-
:html_element
|
172
|
-
when /HTML(.*)Collection/
|
173
|
-
:html_collection
|
174
|
-
when 'CSSStyleDeclaration'
|
175
|
-
:style
|
176
|
-
when /.+List$/
|
177
|
-
:list
|
178
|
-
when 'Date'
|
179
|
-
:date
|
180
|
-
when 'Element'
|
181
|
-
:element
|
150
|
+
'Boolean'
|
182
151
|
when 'WindowProxy', 'ValidityState', 'MediaError', 'TimeRanges', 'Location',
|
183
152
|
'Any', 'TimedTrackArray', 'TimedTrack', 'TextTrackArray', 'TextTrack',
|
184
|
-
'MediaController', 'TextTrackKind'
|
153
|
+
'MediaController', 'TextTrackKind', 'Function', /.*EventHandler$/,
|
154
|
+
'Document', 'DocumentFragment', 'DOMTokenList', 'DOMSettableTokenList',
|
155
|
+
'DOMStringMap', 'HTMLPropertiesCollection', /HTML(.*)Element/, /HTML(.*)Collection/,
|
156
|
+
'CSSStyleDeclaration', /.+List$/, 'Date', 'Element'
|
185
157
|
# probably completely wrong.
|
186
|
-
|
158
|
+
String
|
187
159
|
else
|
188
160
|
raise "unknown type: #{type.name}"
|
189
161
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: watir-webdriver
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.6.
|
4
|
+
version: 0.6.10
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jari Bakken
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-06-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: selenium-webdriver
|
@@ -175,7 +175,6 @@ files:
|
|
175
175
|
- .gitignore
|
176
176
|
- .gitmodules
|
177
177
|
- .travis.yml
|
178
|
-
- .yardopts
|
179
178
|
- CHANGES.md
|
180
179
|
- Gemfile
|
181
180
|
- LICENSE
|
@@ -246,7 +245,6 @@ files:
|
|
246
245
|
- lib/watir-webdriver/wait/timer.rb
|
247
246
|
- lib/watir-webdriver/window.rb
|
248
247
|
- lib/watir-webdriver/xpath_support.rb
|
249
|
-
- lib/yard/handlers/watir.rb
|
250
248
|
- spec/browser_spec.rb
|
251
249
|
- spec/click_spec.rb
|
252
250
|
- spec/container_spec.rb
|
@@ -305,3 +303,4 @@ test_files:
|
|
305
303
|
- spec/locator_spec_helper.rb
|
306
304
|
- spec/spec_helper.rb
|
307
305
|
- spec/special_chars_spec.rb
|
306
|
+
has_rdoc:
|
data/.yardopts
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
--load ./lib/yard/handlers/watir.rb
|
data/lib/yard/handlers/watir.rb
DELETED
@@ -1,55 +0,0 @@
|
|
1
|
-
module YARD
|
2
|
-
module Handlers
|
3
|
-
module Watir
|
4
|
-
#
|
5
|
-
# @private
|
6
|
-
#
|
7
|
-
|
8
|
-
class AttributesHandler < YARD::Handlers::Ruby::Base
|
9
|
-
handles method_call(:attributes)
|
10
|
-
|
11
|
-
TYPES = {
|
12
|
-
:string => "String",
|
13
|
-
:bool => "Boolean",
|
14
|
-
:int => "Integer"
|
15
|
-
}
|
16
|
-
|
17
|
-
def process
|
18
|
-
attributes = try_eval
|
19
|
-
|
20
|
-
if attributes.nil?
|
21
|
-
p :ignoring => statement.source, :in => namespace.to_s if $DEBUG
|
22
|
-
return
|
23
|
-
end
|
24
|
-
|
25
|
-
TYPES.each do |type, return_type|
|
26
|
-
if attributes.member? type
|
27
|
-
create_attributes attributes[type], return_type
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
private
|
33
|
-
|
34
|
-
def create_attributes(names, return_type)
|
35
|
-
names.each do |attribute_name|
|
36
|
-
p :adding => "#{namespace}##{attribute_name}" if $DEBUG
|
37
|
-
attribute_name = "#{attribute_name}?".to_sym if return_type == "Boolean"
|
38
|
-
register MethodObject.new(namespace, attribute_name, scope) do |o|
|
39
|
-
o.visibility = :public
|
40
|
-
o.explicit = false
|
41
|
-
o.docstring.add_tag YARD::Tags::Tag.new(:return, "", return_type)
|
42
|
-
end
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
46
|
-
def try_eval
|
47
|
-
eval "{#{statement.parameters.source}}"
|
48
|
-
rescue SyntaxError, StandardError
|
49
|
-
nil
|
50
|
-
end
|
51
|
-
|
52
|
-
end # AttributesHandler
|
53
|
-
end # Watir
|
54
|
-
end # Handlers
|
55
|
-
end # YARD
|