insite 0.0.2 → 0.0.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.
Files changed (40) hide show
  1. checksums.yaml +4 -4
  2. data/lib/insite.rb +13 -7
  3. data/lib/insite/component/component.rb +454 -0
  4. data/lib/insite/component/component_collection.rb +112 -0
  5. data/lib/insite/component/component_instance_methods.rb +4 -0
  6. data/lib/insite/component/component_methods.rb +4 -0
  7. data/lib/insite/constants.rb +323 -31
  8. data/lib/insite/element/element.rb +147 -0
  9. data/lib/insite/element/element_collection.rb +102 -0
  10. data/lib/insite/element/generated/class_map.rb +244 -0
  11. data/lib/insite/element/generated/element_classes.rb +721 -0
  12. data/lib/insite/element/generated/element_instance_methods.rb +1594 -0
  13. data/lib/insite/errors.rb +2 -0
  14. data/lib/insite/examples/material_angular_io/components/angular_material_component.rb +13 -0
  15. data/lib/insite/examples/material_angular_io/components/example_viewer.rb +5 -0
  16. data/lib/insite/examples/material_angular_io/components/mat_chip.rb +29 -0
  17. data/lib/insite/examples/material_angular_io/components/mat_chip_list.rb +21 -0
  18. data/lib/insite/examples/material_angular_io/components/mat_form_field.rb +5 -0
  19. data/lib/insite/examples/material_angular_io/components/mat_icon.rb +5 -0
  20. data/lib/insite/examples/material_angular_io/components/mat_input.rb +5 -0
  21. data/lib/insite/examples/material_angular_io/components/mat_option.rb +3 -0
  22. data/lib/insite/examples/material_angular_io/components/mat_select.rb +15 -0
  23. data/lib/insite/examples/material_angular_io/components/mat_select_content.rb +13 -0
  24. data/lib/insite/examples/material_angular_io/components/no_selector.rb +3 -0
  25. data/lib/insite/examples/material_angular_io/pages.rb +20 -0
  26. data/lib/insite/examples/material_angular_io/site.rb +5 -0
  27. data/lib/insite/examples/material_angular_io/utils.rb +6 -0
  28. data/lib/insite/examples/material_angular_io/watir_mods.rb +54 -0
  29. data/lib/insite/examples/material_angular_io_site.rb +54 -0
  30. data/lib/insite/insite.rb +96 -11
  31. data/lib/insite/methods/common_methods.rb +26 -37
  32. data/lib/insite/methods/dom_methods.rb +73 -46
  33. data/lib/insite/page/defined_page.rb +37 -50
  34. data/lib/insite/page/undefined_page.rb +12 -1
  35. data/lib/insite/version.rb +1 -1
  36. metadata +69 -29
  37. data/lib/insite/element_container/element_container.rb +0 -42
  38. data/lib/insite/feature/feature.rb +0 -30
  39. data/lib/insite/widget/widget.rb +0 -346
  40. data/lib/insite/widget/widget_methods.rb +0 -4
@@ -0,0 +1,112 @@
1
+ module Insite
2
+ class ComponentCollection
3
+ attr_reader :args, :collection_member_type, :browser, :indentifiers, :site, :target
4
+ class_attribute :selector, default: {}
5
+ self.selector = self.selector.clone
6
+
7
+ include Insite::CommonMethods
8
+ extend Insite::DOMMethods
9
+ include Insite::ElementInstanceMethods
10
+ extend Insite::ComponentMethods
11
+ include Insite::ComponentInstanceMethods
12
+ include Enumerable
13
+
14
+ # Returns true if the class represents a collection, false if not.
15
+ # @return [true, false]
16
+ def self.collection?
17
+ true
18
+ end
19
+
20
+ def ==(other)
21
+ to_a == other.to_a
22
+ end
23
+ alias eql? ==
24
+
25
+ def[](idx)
26
+ to_a[idx]
27
+ end
28
+
29
+ def collection?
30
+ true
31
+ end
32
+
33
+ def first
34
+ to_a[0]
35
+ end
36
+
37
+ def each(&block)
38
+ to_a.each(&block)
39
+ end
40
+
41
+ def empty?
42
+ length == 0
43
+ end
44
+
45
+ def initialize(parent, *args)
46
+ # Figure out the correct query scope.
47
+ parent.respond_to?(:target) ? obj = parent : obj = parent.site
48
+ @parent = obj
49
+
50
+ @site = parent.class.ancestors.include?(Insite) ? parent : parent.site
51
+ @browser = @site.browser
52
+ @collection_member_type = self.class.instance_variable_get(:@collection_member_type)
53
+ @selector = @collection_member_type.selector
54
+
55
+ if args[0].is_a?(Insite::Element) || args[0].is_a?(Insite::ElementCollection)
56
+ @dom_type = nil
57
+ @args = nil
58
+ @target = args[0].target
59
+ elsif args[0].is_a?(Watir::Element) || args[0].is_a?(Watir::ElementCollection)
60
+ @dom_type = nil
61
+ @args = nil
62
+ @target = args[0]
63
+ else
64
+ @args = parse_args(args)
65
+
66
+ if watir_class = Insite::CLASS_MAP.key(self.class)
67
+ if @parent.respond_to?(:target)
68
+ @target = watir_class.new(@parent.target, @args)
69
+ else
70
+ @target = watir_class.new(@browser, @args)
71
+ end
72
+ else
73
+ if @parent.respond_to?(:target)
74
+ @target = Watir::HTMLElementCollection.new(@parent.target, @args)
75
+ else
76
+ @target = Watir::HTMLElementCollection.new(@browser, @args)
77
+ end
78
+ end
79
+ end
80
+ end
81
+
82
+ def inspect
83
+ @selector.empty? ? s = '{element: (selenium element)}' : s = @selector.to_s
84
+ "#<#{self.class}: @parent: #{@parent}; @selector=#{s}>"
85
+ end
86
+
87
+ def last
88
+ to_a[-1]
89
+ end
90
+
91
+ def length
92
+ to_a.length
93
+ end
94
+ alias count length
95
+ alias size length
96
+
97
+ def text
98
+ to_a.map(&:text)
99
+ end
100
+
101
+ def to_a
102
+ out = []
103
+ @target.to_a.each_with_index do |elem, idx|
104
+ out << @collection_member_type.new(
105
+ @parent,
106
+ @args.merge!(index: idx)
107
+ )
108
+ end
109
+ out
110
+ end
111
+ end
112
+ end
@@ -0,0 +1,4 @@
1
+ module Insite
2
+ module ComponentInstanceMethods
3
+ end
4
+ end
@@ -0,0 +1,4 @@
1
+ module Insite
2
+ module ComponentMethods
3
+ end
4
+ end
@@ -1,32 +1,324 @@
1
- # DOM_ELEMENTS
2
- # DOM_COLLECTIONS
3
1
 
4
- # Watir DOM methods. This data is used to create class-level element accessors
5
- # for page objects.
6
- DOM_METHODS = %i(
7
- a br datalists elements forms hidden li meshpatches params rect source tbody tspan
8
- abbr brs datas ellipse frame hiddens line meshrow path rects sources tbodys tspans
9
- abbrs bs date_field ellipses frames hr linear_gradient meshrows paths rp span td u
10
- address button date_fields em frameset hrs linear_gradients meta pattern rps spans tds ul
11
- addresses buttons date_time_field embed framesets htmls lines metadata patterns rt ss template uls
12
- area canvas date_time_fields embeds g i link metadatas picture rtc stop templates us
13
- areas canvases dd ems gs iframe links metas pictures rtcs stops text_field use
14
- article caption dds extract_selector h1 iframes lis meter polygon rts strong text_fields uses
15
- articles captions defs field_set h1s image main meters polygons rubies strongs text_path var
16
- as checkbox defss field_sets h2 images mains nav polyline ruby style text_paths vars
17
- aside checkboxes del fieldset h2s img map navs polylines s styles textarea video
18
- asides circle dels fieldsets h3 imgs maps noscript pre samp sub textareas videos
19
- audio circles desc figcaption h3s input mark noscripts pres samps subs tfoot view
20
- audios cite descs figcaptions h4 inputs marker object progress script summaries tfoots views
21
- b cites details figure h4s ins markers objects progresses scripts summary th wbr
22
- base code detailses figures h5 inses marks ol ps section sup thead wbrs
23
- bases codes dfn file_field h5s is menu ols q sections sups theads
24
- bdi col dfns file_fields h6 kbd menuitem optgroup qs select svg ths
25
- bdis colgroup div font h6s kbds menuitems optgroups radial_gradient select_list svgs time
26
- bdo colgroups divs fonts hatchpath keygen menus option radial_gradients select_lists switch times
27
- bdos cols dl footer hatchpaths keygens mesh options radio selects switches titles
28
- blockquote cursor dls footers head label meshes output radio_set small symbol tr
29
- blockquotes cursors dt foreign_object header labels meshgradient outputs radios smalls symbols track
30
- body data dts foreign_objects headers legend meshgradients p rb solidcolor table tracks
31
- bodys datalist element form heads legends meshpatch param rbs solidcolors tables trs
32
- ).freeze
2
+ module Insite
3
+ METHOD_MAP = {Watir::Rect=>[:rect],
4
+ Watir::Menu=>[:menu],
5
+ Watir::HTMLElement=>
6
+ [:var,
7
+ :i,
8
+ :abbr,
9
+ :summary,
10
+ :cite,
11
+ :code,
12
+ :address,
13
+ :article,
14
+ :aside,
15
+ :bdi,
16
+ :bdo,
17
+ :dfn,
18
+ :dt,
19
+ :em,
20
+ :figcaption,
21
+ :figure,
22
+ :footer,
23
+ :kbd,
24
+ :header,
25
+ :mark,
26
+ :noscript,
27
+ :main,
28
+ :nav,
29
+ :dd,
30
+ :rb,
31
+ :rp,
32
+ :rtc,
33
+ :s,
34
+ :rt,
35
+ :small,
36
+ :samp,
37
+ :sub,
38
+ :section,
39
+ :strong,
40
+ :sup,
41
+ :element,
42
+ :u,
43
+ :b,
44
+ :ruby,
45
+ :wbr],
46
+ Watir::Anchor=>[:a, :link],
47
+ Watir::HTMLElementCollection=>
48
+ [:headers,
49
+ :is,
50
+ :vars,
51
+ :elements,
52
+ :abbrs,
53
+ :addresses,
54
+ :articles,
55
+ :asides,
56
+ :bs,
57
+ :bdis,
58
+ :bdos,
59
+ :cites,
60
+ :codes,
61
+ :dds,
62
+ :dfns,
63
+ :dts,
64
+ :ems,
65
+ :figures,
66
+ :figcaptions,
67
+ :footers,
68
+ :mains,
69
+ :marks,
70
+ :kbds,
71
+ :noscripts,
72
+ :navs,
73
+ :rps,
74
+ :rubies,
75
+ :rbs,
76
+ :ss,
77
+ :rtcs,
78
+ :smalls,
79
+ :samps,
80
+ :rts,
81
+ :sections,
82
+ :subs,
83
+ :summaries,
84
+ :sups,
85
+ :strongs,
86
+ :us,
87
+ :wbrs],
88
+ Watir::TimeCollection=>[:times],
89
+ Watir::Circle=>[:circle],
90
+ Watir::CircleCollection=>[:circles],
91
+ Watir::Cursor=>[:cursor],
92
+ Watir::CursorCollection=>[:cursors],
93
+ Watir::Defs=>[:defs],
94
+ Watir::DefsCollection=>[:defss],
95
+ Watir::Desc=>[:desc],
96
+ Watir::DescCollection=>[:descs],
97
+ Watir::Ellipse=>[:ellipse],
98
+ Watir::EllipseCollection=>[:ellipses],
99
+ Watir::ForeignObject=>[:foreign_object],
100
+ Watir::ForeignObjectCollection=>[:foreign_objects],
101
+ Watir::GCollection=>[:gs],
102
+ Watir::Button=>[:button],
103
+ Watir::Hatchpath=>[:hatchpath],
104
+ Watir::HatchpathCollection=>[:hatchpaths],
105
+ Watir::LinearGradient=>[:linear_gradient],
106
+ Watir::LinearGradientCollection=>[:linear_gradients],
107
+ Watir::Marker=>[:marker],
108
+ Watir::MarkerCollection=>[:markers],
109
+ Watir::Mesh=>[:mesh],
110
+ Watir::MeshCollection=>[:meshes],
111
+ Watir::MeshGradient=>[:meshgradient],
112
+ Watir::MeshGradientCollection=>[:meshgradients],
113
+ Watir::Meshpatch=>[:meshpatch],
114
+ Watir::MeshpatchCollection=>[:meshpatches],
115
+ Watir::Meshrow=>[:meshrow],
116
+ Watir::MeshrowCollection=>[:meshrows],
117
+ Watir::MetadataCollection=>[:metadatas],
118
+ Watir::PatternCollection=>[:patterns],
119
+ Watir::Polygon=>[:polygon],
120
+ Watir::Pre=>[:pre],
121
+ Watir::PolygonCollection=>[:polygons],
122
+ Watir::Polyline=>[:polyline],
123
+ Watir::AreaCollection=>[:areas],
124
+ Watir::PolylineCollection=>[:polylines],
125
+ Watir::Script=>[:script],
126
+ Watir::Solidcolor=>[:solidcolor],
127
+ Watir::RadialGradient=>[:radial_gradient],
128
+ Watir::RadialGradientCollection=>[:radial_gradients],
129
+ Watir::SolidcolorCollection=>[:solidcolors],
130
+ Watir::RectCollection=>[:rects],
131
+ Watir::SVG=>[:svg],
132
+ Watir::SVGCollection=>[:svgs],
133
+ Watir::StopCollection=>[:stops],
134
+ Watir::SwitchCollection=>[:switches],
135
+ Watir::Body=>[:body],
136
+ Watir::LI=>[:li],
137
+ Watir::TextPathCollection=>[:text_paths],
138
+ Watir::Metadata=>[:metadata],
139
+ Watir::TSpan=>[:tspan],
140
+ Watir::TextPath=>[:text_path],
141
+ Watir::UseCollection=>[:uses],
142
+ Watir::View=>[:view],
143
+ Watir::ViewCollection=>[:views],
144
+ Watir::TSpanCollection=>[:tspans],
145
+ Watir::DateField=>[:date_field],
146
+ Watir::CheckBox=>[:checkbox],
147
+ Watir::CheckBoxCollection=>[:checkboxes],
148
+ Watir::Style=>[:style],
149
+ Watir::DateTimeField=>[:date_time_field],
150
+ Watir::DateTimeFieldCollection=>[:date_time_fields],
151
+ Watir::DateFieldCollection=>[:date_fields],
152
+ Watir::FileField=>[:file_field],
153
+ Watir::FileFieldCollection=>[:file_fields],
154
+ Watir::Font=>[:font],
155
+ Watir::FontCollection=>[:fonts],
156
+ Watir::ImageCollection=>[:imgs, :images],
157
+ Watir::FrameCollection=>[:frames],
158
+ Watir::HiddenCollection=>[:hiddens],
159
+ Watir::Image=>[:img, :image],
160
+ Watir::AnchorCollection=>[:as, :links],
161
+ Watir::Radio=>[:radio],
162
+ Watir::Track=>[:track],
163
+ Watir::RadioCollection=>[:radios],
164
+ Watir::Select=>[:select, :select_list],
165
+ Watir::SelectCollection=>[:selects, :select_lists],
166
+ Watir::Pattern=>[:pattern],
167
+ Watir::TextField=>[:text_field],
168
+ Watir::TextFieldCollection=>[:text_fields],
169
+ Watir::Use=>[:use],
170
+ Watir::TableCaption=>[:caption],
171
+ Watir::FieldSet=>[:fieldset, :field_set],
172
+ Watir::RadioSet=>[:radio_set],
173
+ Watir::FieldSetCollection=>[:fieldsets, :field_sets],
174
+ Watir::Input=>[:input],
175
+ Watir::Output=>[:output],
176
+ Watir::Area=>[:area],
177
+ Watir::Audio=>[:audio],
178
+ Watir::AudioCollection=>[:audios],
179
+ Watir::BaseCollection=>[:bases],
180
+ Watir::Quote=>[:blockquote, :q],
181
+ Watir::QuoteCollection=>[:blockquotes, :qs],
182
+ Watir::BodyCollection=>[:bodys],
183
+ Watir::BR=>[:br],
184
+ Watir::BRCollection=>[:brs],
185
+ Watir::ButtonCollection=>[:buttons],
186
+ Watir::Canvas=>[:canvas],
187
+ Watir::CanvasCollection=>[:canvases],
188
+ Watir::TableCaptionCollection=>[:captions],
189
+ Watir::TableCol=>[:colgroup, :col],
190
+ Watir::TableColCollection=>[:colgroups, :cols],
191
+ Watir::DataCollection=>[:datas],
192
+ Watir::DataList=>[:datalist],
193
+ Watir::DataListCollection=>[:datalists],
194
+ Watir::Mod=>[:del, :ins],
195
+ Watir::ModCollection=>[:dels, :inses],
196
+ Watir::DetailsCollection=>[:detailses],
197
+ Watir::DivCollection=>[:divs],
198
+ Watir::DList=>[:dl],
199
+ Watir::DListCollection=>[:dls],
200
+ Watir::Embed=>[:embed],
201
+ Watir::EmbedCollection=>[:embeds],
202
+ Watir::FormCollection=>[:forms],
203
+ Watir::FrameSet=>[:frameset],
204
+ Watir::FrameSetCollection=>[:framesets],
205
+ Watir::Heading=>[:h1, :h2, :h4, :h5, :h6, :h3],
206
+ Watir::HeadingCollection=>[:h1s, :h2s, :h3s, :h4s, :h5s, :h6s],
207
+ Watir::Form=>[:form],
208
+ Watir::Head=>[:head],
209
+ Watir::HeadCollection=>[:heads],
210
+ Watir::HRCollection=>[:hrs],
211
+ Watir::HtmlCollection=>[:htmls],
212
+ Watir::HR=>[:hr],
213
+ Watir::IFrame=>[:iframe],
214
+ Watir::Keygen=>[:keygen],
215
+ Watir::InputCollection=>[:inputs],
216
+ Watir::KeygenCollection=>[:keygens],
217
+ Watir::LegendCollection=>[:legends],
218
+ Watir::LICollection=>[:lis],
219
+ Watir::IFrameCollection=>[:iframes],
220
+ Watir::MenuItem=>[:menuitem],
221
+ Watir::MenuCollection=>[:menus],
222
+ Watir::Legend=>[:legend],
223
+ Watir::Meter=>[:meter],
224
+ Watir::Label=>[:label],
225
+ Watir::Div=>[:div],
226
+ Watir::MapCollection=>[:maps],
227
+ Watir::MeterCollection=>[:meters],
228
+ Watir::MetaCollection=>[:metas],
229
+ Watir::Param=>[:param],
230
+ Watir::MenuItemCollection=>[:menuitems],
231
+ Watir::Data=>[:data],
232
+ Watir::OptGroupCollection=>[:optgroups],
233
+ Watir::OList=>[:ol],
234
+ Watir::OptGroup=>[:optgroup],
235
+ Watir::ParamCollection=>[:params],
236
+ Watir::PreCollection=>[:pres],
237
+ Watir::Object=>[:object],
238
+ Watir::OListCollection=>[:ols],
239
+ Watir::ParagraphCollection=>[:ps],
240
+ Watir::ObjectCollection=>[:objects],
241
+ Watir::Picture=>[:picture],
242
+ Watir::PictureCollection=>[:pictures],
243
+ Watir::Progress=>[:progress],
244
+ Watir::Map=>[:map],
245
+ Watir::OutputCollection=>[:outputs],
246
+ Watir::OptionCollection=>[:options],
247
+ Watir::ScriptCollection=>[:scripts],
248
+ Watir::ProgressCollection=>[:progresses],
249
+ Watir::SpanCollection=>[:spans],
250
+ Watir::Source=>[:source],
251
+ Watir::StyleCollection=>[:styles],
252
+ Watir::Paragraph=>[:p],
253
+ Watir::TableSectionCollection=>[:tbodys, :tfoots, :theads],
254
+ Watir::TableDataCell=>[:td],
255
+ Watir::TableDataCellCollection=>[:tds],
256
+ Watir::Span=>[:span],
257
+ Watir::TableCollection=>[:tables],
258
+ Watir::TableSection=>[:tbody, :tfoot, :thead],
259
+ Watir::Meta=>[:meta],
260
+ Watir::TableHeaderCell=>[:th],
261
+ Watir::TableHeaderCellCollection=>[:ths],
262
+ Watir::Template=>[:template],
263
+ Watir::TextArea=>[:textarea],
264
+ Watir::TemplateCollection=>[:templates],
265
+ Watir::TitleCollection=>[:titles],
266
+ Watir::TextAreaCollection=>[:textareas],
267
+ Watir::TrackCollection=>[:tracks],
268
+ Watir::UList=>[:ul],
269
+ Watir::Table=>[:table],
270
+ Watir::Base=>[:base],
271
+ Watir::TableRowCollection=>[:trs],
272
+ Watir::Line=>[:line],
273
+ Watir::Symbol=>[:symbol],
274
+ Watir::UListCollection=>[:uls],
275
+ Watir::Video=>[:video],
276
+ Watir::VideoCollection=>[:videos],
277
+ Watir::G=>[:g],
278
+ Watir::Frame=>[:frame],
279
+ Watir::SourceCollection=>[:sources],
280
+ Watir::Option=>[:option],
281
+ Watir::PathCollection=>[:paths],
282
+ Watir::TableRow=>[:tr],
283
+ Watir::Path=>[:path],
284
+ Watir::LineCollection=>[:lines],
285
+ Watir::LabelCollection=>[:labels],
286
+ Watir::Time=>[:time],
287
+ Watir::SymbolCollection=>[:symbols],
288
+ Watir::Details=>[:details],
289
+ Watir::Stop=>[:stop],
290
+ Watir::Switch=>[:switch],
291
+ Watir::Hidden=>[:hidden]
292
+ }.freeze
293
+
294
+
295
+ # Watir DOM methods. This data is used to create class-level element accessors
296
+ # for page objects.
297
+ DOM_METHODS = %i(
298
+ a br datalists elements forms hidden li meshpatches params rect source tbody tspan
299
+ abbr brs datas ellipse frame hiddens line meshrow path rects sources tbodys tspans
300
+ abbrs bs date_field ellipses frames hr linear_gradient meshrows paths rp span td u
301
+ address button date_fields em frameset hrs linear_gradients meta pattern rps spans tds ul
302
+ addresses buttons date_time_field embed framesets htmls lines metadata patterns rt ss template uls
303
+ area canvas date_time_fields embeds g i link metadatas picture rtc stop templates us
304
+ areas canvases dd ems gs iframe links metas pictures rtcs stops text_field use
305
+ article caption dds extract_selector h1 iframes lis meter polygon rts strong text_fields uses
306
+ articles captions defs field_set h1s image main meters polygons rubies strongs text_path var
307
+ as checkbox defss field_sets h2 images mains nav polyline ruby style text_paths vars
308
+ aside checkboxes del fieldset h2s img map navs polylines s styles textarea video
309
+ asides circle dels fieldsets h3 imgs maps noscript pre samp sub textareas videos
310
+ audio circles desc figcaption h3s input mark noscripts pres samps subs tfoot view
311
+ audios cite descs figcaptions h4 inputs marker object progress script summaries tfoots views
312
+ b cites details figure h4s ins markers objects progresses scripts summary th wbr
313
+ base code detailses figures h5 inses marks ol ps section sup thead wbrs
314
+ bases codes dfn file_field h5s is menu ols q sections sups theads
315
+ bdi col dfns file_fields h6 kbd menuitem optgroup qs select svg ths
316
+ bdis colgroup div font h6s kbds menuitems optgroups radial_gradient select_list svgs time
317
+ bdo colgroups divs fonts hatchpath keygen menus option radial_gradients select_lists switch times
318
+ bdos cols dl footer hatchpaths keygens mesh options radio selects switches titles
319
+ blockquote cursor dls footers head label meshes output radio_set small symbol tr
320
+ blockquotes cursors dt foreign_object header labels meshgradient outputs radios smalls symbols track
321
+ body data dts foreign_objects headers legend meshgradients p rb solidcolor table tracks
322
+ bodys datalist element form heads legends meshpatch param rbs solidcolors tables trs
323
+ ).freeze
324
+ end