watir-webdriver 0.0.6 → 0.0.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (129) hide show
  1. data/Rakefile +53 -31
  2. data/VERSION +1 -1
  3. data/lib/watir-webdriver.rb +6 -8
  4. data/lib/watir-webdriver/attribute_helper.rb +121 -0
  5. data/lib/watir-webdriver/browser.rb +13 -6
  6. data/lib/watir-webdriver/collections/element_collection.rb +21 -15
  7. data/lib/watir-webdriver/collections/table_row_collection.rb +11 -0
  8. data/lib/watir-webdriver/container.rb +17 -11
  9. data/lib/watir-webdriver/element.rb +201 -0
  10. data/lib/watir-webdriver/elements/button.rb +19 -2
  11. data/lib/watir-webdriver/elements/checkbox.rb +24 -4
  12. data/lib/watir-webdriver/elements/file_field.rb +24 -4
  13. data/lib/watir-webdriver/elements/font.rb +10 -11
  14. data/lib/watir-webdriver/elements/frame.rb +11 -3
  15. data/lib/watir-webdriver/elements/generated.rb +2491 -1313
  16. data/lib/watir-webdriver/elements/hidden.rb +16 -5
  17. data/lib/watir-webdriver/elements/input.rb +44 -5
  18. data/lib/watir-webdriver/elements/link.rb +6 -8
  19. data/lib/watir-webdriver/elements/radio.rb +25 -6
  20. data/lib/watir-webdriver/elements/{select_list.rb → select.rb} +8 -9
  21. data/lib/watir-webdriver/elements/text_field.rb +32 -3
  22. data/lib/watir-webdriver/html.rb +18 -0
  23. data/lib/watir-webdriver/html/generator.rb +112 -0
  24. data/lib/watir-webdriver/html/idl_sorter.rb +49 -0
  25. data/lib/watir-webdriver/html/spec_extractor.rb +111 -0
  26. data/lib/watir-webdriver/html/util.rb +31 -0
  27. data/lib/watir-webdriver/html/visitor.rb +186 -0
  28. data/lib/watir-webdriver/locators/element_locator.rb +4 -0
  29. data/lib/watir-webdriver/locators/text_field_locator.rb +2 -2
  30. data/lib/watir-webdriver/xpath_support.rb +3 -5
  31. data/lib/yard/handlers/watir.rb +57 -0
  32. data/spec/{base_element_spec.rb → element_spec.rb} +3 -2
  33. data/spec/input_spec.rb +65 -0
  34. data/spec/spec_helper.rb +9 -2
  35. data/spec/watirspec/area_spec.rb +9 -13
  36. data/spec/watirspec/areas_spec.rb +7 -1
  37. data/spec/watirspec/browser_spec.rb +68 -72
  38. data/spec/watirspec/button_spec.rb +16 -9
  39. data/spec/watirspec/buttons_spec.rb +11 -9
  40. data/spec/watirspec/checkbox_spec.rb +1 -1
  41. data/spec/watirspec/checkboxes_spec.rb +7 -1
  42. data/spec/watirspec/collections_spec.rb +18 -0
  43. data/spec/watirspec/dd_spec.rb +1 -1
  44. data/spec/watirspec/dds_spec.rb +7 -1
  45. data/spec/watirspec/del_spec.rb +141 -0
  46. data/spec/watirspec/dels_spec.rb +37 -0
  47. data/spec/watirspec/div_spec.rb +6 -22
  48. data/spec/watirspec/divs_spec.rb +8 -2
  49. data/spec/watirspec/dl_spec.rb +1 -1
  50. data/spec/watirspec/dls_spec.rb +7 -1
  51. data/spec/watirspec/dt_spec.rb +1 -1
  52. data/spec/watirspec/dts_spec.rb +7 -1
  53. data/spec/watirspec/element_spec.rb +11 -20
  54. data/spec/watirspec/em_spec.rb +1 -1
  55. data/spec/watirspec/ems_spec.rb +7 -1
  56. data/spec/watirspec/filefield_spec.rb +8 -11
  57. data/spec/watirspec/filefields_spec.rb +7 -1
  58. data/spec/watirspec/font_spec.rb +2 -2
  59. data/spec/watirspec/form_spec.rb +10 -18
  60. data/spec/watirspec/forms_spec.rb +7 -1
  61. data/spec/watirspec/frame_spec.rb +69 -73
  62. data/spec/watirspec/frames_spec.rb +15 -2
  63. data/spec/watirspec/hidden_spec.rb +1 -1
  64. data/spec/watirspec/hiddens_spec.rb +7 -1
  65. data/spec/watirspec/hn_spec.rb +1 -1
  66. data/spec/watirspec/hns_spec.rb +23 -27
  67. data/spec/watirspec/image_spec.rb +9 -15
  68. data/spec/watirspec/images_spec.rb +7 -1
  69. data/spec/watirspec/ins_spec.rb +142 -0
  70. data/spec/watirspec/inses_spec.rb +37 -0
  71. data/spec/watirspec/label_spec.rb +1 -1
  72. data/spec/watirspec/labels_spec.rb +7 -1
  73. data/spec/watirspec/li_spec.rb +1 -1
  74. data/spec/watirspec/lib/guards.rb +12 -12
  75. data/spec/watirspec/lib/implementation.rb +48 -0
  76. data/spec/watirspec/lib/watirspec.rb +17 -12
  77. data/spec/watirspec/link_spec.rb +6 -11
  78. data/spec/watirspec/links_spec.rb +1 -1
  79. data/spec/watirspec/lis_spec.rb +7 -1
  80. data/spec/watirspec/map_spec.rb +1 -1
  81. data/spec/watirspec/maps_spec.rb +7 -1
  82. data/spec/watirspec/meta_spec.rb +13 -15
  83. data/spec/watirspec/metas_spec.rb +6 -1
  84. data/spec/watirspec/ol_spec.rb +57 -59
  85. data/spec/watirspec/ols_spec.rb +10 -4
  86. data/spec/watirspec/option_spec.rb +50 -83
  87. data/spec/watirspec/p_spec.rb +1 -1
  88. data/spec/watirspec/pre_spec.rb +1 -1
  89. data/spec/watirspec/pres_spec.rb +7 -1
  90. data/spec/watirspec/ps_spec.rb +7 -1
  91. data/spec/watirspec/radio_spec.rb +9 -11
  92. data/spec/watirspec/radios_spec.rb +1 -1
  93. data/spec/watirspec/select_list_spec.rb +27 -40
  94. data/spec/watirspec/select_lists_spec.rb +1 -1
  95. data/spec/watirspec/span_spec.rb +1 -1
  96. data/spec/watirspec/spans_spec.rb +7 -1
  97. data/spec/watirspec/spec_helper.rb +1 -0
  98. data/spec/watirspec/strong_spec.rb +1 -1
  99. data/spec/watirspec/strongs_spec.rb +7 -1
  100. data/spec/watirspec/table_bodies_spec.rb +22 -10
  101. data/spec/watirspec/table_body_spec.rb +33 -40
  102. data/spec/watirspec/table_cell_spec.rb +1 -1
  103. data/spec/watirspec/table_cells_spec.rb +36 -15
  104. data/spec/watirspec/table_footer_spec.rb +43 -40
  105. data/spec/watirspec/table_footers_spec.rb +35 -19
  106. data/spec/watirspec/table_header_spec.rb +44 -39
  107. data/spec/watirspec/table_headers_spec.rb +37 -19
  108. data/spec/watirspec/table_row_spec.rb +13 -9
  109. data/spec/watirspec/table_rows_spec.rb +16 -6
  110. data/spec/watirspec/table_spec.rb +83 -62
  111. data/spec/watirspec/tables_spec.rb +7 -1
  112. data/spec/watirspec/text_field_spec.rb +4 -6
  113. data/spec/watirspec/text_fields_spec.rb +1 -1
  114. data/spec/watirspec/ul_spec.rb +1 -1
  115. data/spec/watirspec/uls_spec.rb +25 -22
  116. data/support/html5.html +89235 -0
  117. data/watir-webdriver.gemspec +31 -21
  118. metadata +52 -23
  119. data/TODO +0 -15
  120. data/lib/watir-webdriver/base_element.rb +0 -361
  121. data/lib/watir-webdriver/collections/buttons_collection.rb +0 -15
  122. data/lib/watir-webdriver/collections/table_rows_collection.rb +0 -16
  123. data/lib/watir-webdriver/collections/text_fields_collection.rb +0 -15
  124. data/lib/watir-webdriver/elements/headings.rb +0 -48
  125. data/support/html5/html5.idl +0 -1274
  126. data/support/html5/old/html5.idl +0 -962
  127. data/support/html5/old/html5_extras.idl +0 -145
  128. data/support/html5/watir_visitor.rb +0 -173
  129. data/support/yard_handlers.rb +0 -87
@@ -1,145 +0,0 @@
1
- // the-thead-element
2
- [TagName=thead]
3
- interface HTMLTheadElement : HTMLTableSectionElement {};
4
-
5
- // the-dd-element
6
- [TagName=dd]
7
- interface HTMLDdElement : HTMLElement {};
8
-
9
- // the-address-element
10
- [TagName=address]
11
- interface HTMLAddressElement : HTMLElement {};
12
-
13
- // the-nav-element
14
- [TagName=nav]
15
- interface HTMLNavElement : HTMLElement {};
16
-
17
- // the-tfoot-element
18
- [TagName=tfoot]
19
- interface HTMLTFootElement : HTMLTableSectionElement {};
20
-
21
- // the-sub-and-sup-elements
22
- [TagName=sub]
23
- interface HTMLSubElement : HTMLElement {};
24
- [TagName=sup]
25
- interface HTMLSupElement : HTMLElement {};
26
-
27
- // the-bdo-element
28
- [TagName=bdo]
29
- interface HTMLBdoElement : HTMLElement {};
30
-
31
- // the-rp-element
32
- [TagName=rp]
33
- interface HTMLRpElement : HTMLElement {};
34
-
35
- // the-rt-element
36
- [TagName=rt]
37
- interface HTMLRtElement : HTMLElement {};
38
-
39
- // the-mark-element
40
- [TagName=mark]
41
- interface HTMLMarkElement : HTMLElement {};
42
-
43
- // the-kbd-element
44
- [TagName=kbd]
45
- interface HTMLKbdElement : HTMLElement {};
46
-
47
- // the-dfn-element
48
- [TagName=dfn]
49
- interface HTMLDfnElement : HTMLElement {};
50
-
51
- // the-cite-element
52
- [TagName=cite]
53
- interface HTMLCiteElement : HTMLElement {};
54
-
55
- // the-ins-element
56
- [TagName=ins]
57
- interface HTMLInsElement : HTMLModElement {};
58
-
59
- // the-b-element
60
- [TagName=b]
61
- interface HTMLBElement : HTMLElement {};
62
-
63
- // the-noscript-element
64
- [TagName=noscript]
65
- interface HTMLNoscriptElement : HTMLElement {};
66
-
67
- // the-figure-element
68
- [TagName=figure]
69
- interface HTMLFigureElement : HTMLElement {};
70
-
71
- // the-code-element
72
- [TagName=code]
73
- interface HTMLCodeElement : HTMLElement {};
74
-
75
- // the-q-element
76
- [TagName=q]
77
- interface HTMLQElement : HTMLQuoteElement {};
78
-
79
- // the-strong-element
80
- [TagName=strong]
81
- interface HTMLStrongElement : HTMLElement {};
82
-
83
- // the-header-element
84
- [TagName=header]
85
- interface HTMLHeaderElement : HTMLElement {};
86
-
87
- // the-hgroup-element
88
- [TagName=hgroup]
89
- interface HTMLHgroupElement : HTMLElement {};
90
-
91
- // the-aside-element
92
- [TagName=aside]
93
- interface HTMLAsideElement : HTMLElement {};
94
-
95
- // the-samp-element
96
- [TagName=samp]
97
- interface HTMLSampElement : HTMLElement {};
98
-
99
- // the-section-element
100
- [TagName=section]
101
- interface HTMLSectionElement : HTMLElement {};
102
-
103
- // the-dt-element
104
- [TagName=dt]
105
- interface HTMLDtElement : HTMLElement {};
106
-
107
- // the-col-element
108
- [TagName=col]
109
- interface HTMLColElement : HTMLTableColElement {};
110
-
111
- // the-i-element
112
- [TagName=i]
113
- interface HTMLIElement : HTMLElement {};
114
-
115
- // the-var-element
116
- [TagName=var]
117
- interface HTMLVarElement : HTMLElement {};
118
-
119
- // the-abbr-element
120
- [TagName=abbr]
121
- interface HTMLAbbrElement : HTMLElement {};
122
-
123
- // the-small-element
124
- [TagName=small]
125
- interface HTMLSmallElement : HTMLElement {};
126
-
127
- // the-footer-element
128
- [TagName=footer]
129
- interface HTMLFooterElement : HTMLElement {};
130
-
131
- // the-ruby-element
132
- [TagName=ruby]
133
- interface HTMLRubyElement : HTMLElement {};
134
-
135
- // the-article-element
136
- [TagName=article]
137
- interface HTMLArticleElement : HTMLElement {};
138
-
139
- // the-del-element
140
- [TagName=del]
141
- interface HTMLDelElement : HTMLModElement {};
142
-
143
- // the-em-element
144
- [TagName=em]
145
- interface HTMLEmElement : HTMLElement {};
@@ -1,173 +0,0 @@
1
- # encoding: utf-8
2
- require "rubygems"
3
- require "webidl"
4
- require "pp"
5
-
6
- require "active_support"
7
- ActiveSupport::Inflector.inflections do |inflect|
8
- inflect.irregular 'body', 'bodys'
9
- inflect.irregular 'tbody', 'tbodys'
10
- inflect.irregular 'canvas', 'canvases'
11
- inflect.irregular 'ins', 'inses' # made up.
12
- end
13
-
14
- class WatirVisitor < WebIDL::RubySexpVisitor
15
-
16
- SPECIALS = {
17
- 'img' => 'image'
18
- }
19
-
20
- def self.generate_from(file)
21
- result = []
22
- result << "# Autogenerated from the HTML5 specification. Edits may be lost."
23
- result << "module Watir"
24
-
25
- gen = WebIDL::Generator.new(new)
26
- code = gen.generate(File.read(file))
27
- code = " " + code.split("\n").join("\n ")
28
-
29
- result << code
30
- result << "end"
31
-
32
- result.join("\n")
33
- end
34
-
35
- def visit_interface(interface)
36
- name = interface.name
37
- parent = interface.inherits.first
38
-
39
- $stderr.puts name
40
- return unless name =~ /^HTML/
41
-
42
- if name == "HTMLElement"
43
- parent = 'BaseElement'
44
- # elsif !(parent && parent.name =~ /^HTMLElement/)
45
- # return
46
- else
47
- parent = parent ? parent.name : 'HTMLElement'
48
- end
49
-
50
- element_class interface.name,
51
- tag_name_from(interface),
52
- interface.members.select { |e| e.kind_of?(WebIDL::Ast::Attribute) },
53
- parent
54
- end
55
-
56
- def visit_module(mod)
57
- # ignored
58
- end
59
-
60
- def visit_implements_statement(stmt)
61
- # ignored
62
- end
63
-
64
- private
65
-
66
- def tag_name_from(interface)
67
- _, tag_name = interface.extended_attributes.find { |k,v| k == "TagName" }
68
- tag_name
69
- end
70
-
71
- def element_class(name, tag_name, attributes, parent)
72
- sexp = [:class, classify(name), [:const, classify(parent)]]
73
-
74
- if tag_name
75
- sexp << [:scope, [:block] + [identifier_call(tag_name)]]
76
- sexp << [:scope, [:block] + [container_call(tag_name)]]
77
- sexp << [:scope, [:block] + [collection_call(tag_name)]]
78
- end
79
-
80
- sexp << [:scope, [:block] + [attributes_call(attributes)]]
81
-
82
- sexp
83
- end
84
-
85
- def classify(name)
86
- if name =~ /^HTML(.+)Element$/
87
- $1
88
- else
89
- name
90
- end
91
- end
92
-
93
- def paramify(str)
94
- if SPECIALS.has_key?(str)
95
- SPECIALS[str]
96
- else
97
- classify(str).snake_case
98
- end
99
- end
100
-
101
- def attributes_call(attributes)
102
- return if attributes.empty?
103
-
104
- attrs = Hash.new { |hash, key| hash[key] = [] }
105
- attributes.each do |a|
106
- attrs[ruby_type_for(a.type)] << a.name.snake_case
107
- end
108
-
109
- call :attributes, [[:hash] + attrs.map { |type, names| [[:lit, type], literal_array(names)] }.flatten(1)]
110
- end
111
-
112
- def identifier_call(tag_name)
113
- call :identifier, [literal_hash(:tag_name => tag_name)]
114
- end
115
-
116
- def container_call(name)
117
- call :container_method, [[:lit, paramify(name).to_sym]]
118
- end
119
-
120
- def collection_call(name)
121
- call :collection_method, [[:lit, paramify(name).pluralize.to_sym]]
122
- end
123
-
124
- def literal_hash(hash)
125
- [:hash] + hash.map { |k, v| [[:lit, k.to_sym], [:lit, v]] }.flatten(1)
126
- end
127
-
128
- def literal_array(arr)
129
- [:array] + arr.map { |e| [:lit, e.to_sym] }
130
- end
131
-
132
- def call(name, args)
133
- [:call, nil, name.to_sym, [:arglist] + args]
134
- end
135
-
136
- def ruby_type_for(type)
137
- case type.name.to_s
138
- when 'DOMString', 'any'
139
- :string
140
- when 'unsigned long', 'long', 'integer', 'short', 'unsigned short'
141
- :int
142
- when 'float', 'double'
143
- :float
144
- when 'Function'
145
- :function
146
- when 'boolean'
147
- :bool
148
- when 'Document'
149
- :document
150
- when 'DOMTokenList', 'DOMSettableTokenList'
151
- :token_list
152
- when 'DOMStringMap'
153
- :string_map
154
- when 'HTMLPropertiesCollection'
155
- :properties_collection
156
- when /HTML(.*)Element/
157
- :html_element
158
- when /HTML(.*)Collection/
159
- :html_collection
160
- when 'CSSStyleDeclaration'
161
- :style
162
- when /.+List$/
163
- :list
164
- when 'Date'
165
- :date
166
- when 'WindowProxy', 'ValidityState', 'MediaError', 'TimeRanges'
167
- :string
168
- else
169
- raise "unknown type: #{type.name}"
170
- end
171
- end
172
-
173
- end
@@ -1,87 +0,0 @@
1
- # require "ruby-debug"
2
- require "#{File.dirname(__FILE__)}/../lib/watir-webdriver/core_ext/string"
3
-
4
- module YARD
5
- module Watir
6
- class AttributesHandler < YARD::Handlers::Ruby::Base
7
- handles method_call(:attributes)
8
-
9
- TYPES = {
10
- :string => "String",
11
- :bool => "Boolean",
12
- :int => "Integer"
13
- }
14
-
15
- def process
16
- attributes = try_eval
17
-
18
- if attributes.nil?
19
- p :ignoring => statement.source, :in => namespace.to_s
20
- return
21
- end
22
-
23
- TYPES.each do |type, return_type|
24
- if attributes.member? type
25
- create_attributes attributes[type], return_type
26
- end
27
- end
28
- end
29
-
30
- private
31
-
32
- def create_attributes(names, return_type)
33
- names.each do |attribute_name|
34
- p :adding => "#{namespace}##{attribute_name}"
35
- attribute_name = "#{attribute_name}?".to_sym if return_type == "Boolean"
36
- register MethodObject.new(namespace, attribute_name, scope) do |o|
37
- o.visibility = :public
38
- o.explicit = false
39
- o.docstring.add_tag YARD::Tags::Tag.new(:return, "", return_type)
40
- end
41
- end
42
- end
43
-
44
- def try_eval
45
- eval "{#{statement.parameters.source}}"
46
- rescue SyntaxError, StandardError
47
- nil
48
- end
49
-
50
- end # AttributesHandler
51
-
52
- class ContainerMethodHandler < YARD::Handlers::Ruby::Base
53
- handles method_call(:container_method)
54
-
55
- def process
56
- name = statement.parameters.flatten.first
57
- return_type = namespace.to_s
58
- p :adding => "Watir::Container##{name}"
59
-
60
- register MethodObject.new(P("Watir::Container"), name, :instance) do |o|
61
- o.docstring.add_tag(YARD::Tags::Tag.new(:return, "", return_type))
62
- end
63
- end
64
- end # ContainerMethodHandler
65
-
66
- class CollectionMethodHandler < YARD::Handlers::Ruby::Base
67
- handles method_call(:collection_method)
68
-
69
- def process
70
- name = statement.parameters.flatten.first
71
- p :adding => "Watir::Container##{name}"
72
-
73
- class_name = "#{name.to_s.camel_case}Collection"
74
- return_type = "Watir::#{class_name}"
75
-
76
- register MethodObject.new(P("Watir::Container"), name, :instance) do |o|
77
- o.docstring.add_tag(YARD::Tags::Tag.new(:return, "", return_type))
78
- end
79
-
80
- register ClassObject.new(P("Watir"), class_name) do |o|
81
- o.superclass = "Watir::ElementCollection"
82
- end
83
- end
84
- end # CollectionMethodHandler
85
-
86
- end # Watir
87
- end # YARD