watir_pump 0.3.4 → 0.3.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1c3bcc424954cdcc59cecdb50c0018bc61f28d36
4
- data.tar.gz: b67d48f87edf576d5416a46df0e2c921b692d0d8
3
+ metadata.gz: 55ea2b14189a53f881455afccfcb1d8eae770284
4
+ data.tar.gz: 3c3f9d78ba3a2cd64e303862712d707af8f42484
5
5
  SHA512:
6
- metadata.gz: 5849c0b42c0f198876bc20d3b48a5ac74e4afbce99b7a83c8af9a6ba709d8031fbe8ee7dcabdb6336babec4e1864baf5934851c28c82f568ff7d8f3f90c627da
7
- data.tar.gz: cfb180a53d56cb07e28e4a8a33e5285316f0c7b7a5bd8b1dc75b73d13c798d794d8a2680abcf6feffc00bf24c8baff1b95a77f5113ce664fa9ca6ae0b6971d17
6
+ metadata.gz: d4d027333cd88cce8bcbd38763261f3dd4ee7110141d4db4092e486273a6fe0399427b8358ae156cca17014a92edb9781744d0cfa8acaf4ee29dec887df34da4
7
+ data.tar.gz: a4b8a3405bbbe6623087ddeafa448c71ab15982e14f8fd6f3e47a4bcf587296dd255dc1259a524e45f0c1d02e4fa202c6ffbac1e8efe5ab733046c320fc9354b
@@ -6,6 +6,7 @@ require 'forwardable'
6
6
  require_relative 'component_collection'
7
7
  require_relative 'decorated_element'
8
8
  require_relative 'constants'
9
+ require_relative 'watir_method_mapping'
9
10
  require_relative 'components/radio_group'
10
11
  require_relative 'components/checkbox_group'
11
12
  require_relative 'components/dropdown_list'
@@ -242,17 +243,26 @@ module WatirPump
242
243
 
243
244
  def find_element_raw(watir_method: nil, watir_method_args: nil, code: nil, code_args: nil) # rubocop:disable Metrics/LineLength
244
245
  if code.is_a? Proc
245
- instance_exec(*code_args, &code)
246
+ evaluated = instance_exec(*code_args, &code)
247
+ check_watir_method_mapping(watir_method, evaluated)
246
248
  elsif watir_method
247
249
  root.send(watir_method, *watir_method_args)
248
250
  end
249
251
  end
250
252
 
251
- def method_missing(name, *args)
253
+ # Raise error if watir_method (e.g. :image)
254
+ # does not correspond to returned element (e.g. Watir::Table)
255
+ def check_watir_method_mapping(watir_method, evaluated)
256
+ return evaluated unless watir_method.is_a?(Symbol)
257
+ return evaluated if evaluated.class == WATIR_METHOD_MAPPING[watir_method]
258
+ raise "#{evaluated.class} class does not match expected: #{watir_method}"
259
+ end
260
+
261
+ def method_missing(name, *args, &blk)
252
262
  # delegate missing methods to current RSpec example if set
253
263
  example = WatirPump.config.current_example
254
264
  if example&.instance_exec { respond_to? name }
255
- return example.instance_exec { send(name, *args) }
265
+ return example.instance_exec { send(name, *args, &blk) }
256
266
  end
257
267
  super
258
268
  end
@@ -0,0 +1,324 @@
1
+ # frozen_string_literal: true
2
+
3
+ # rubocop:disable Metrics/ModuleLength
4
+
5
+ module WatirPump
6
+ WATIR_METHOD_MAPPING = {
7
+ a: Watir::Anchor,
8
+ as: Watir::AnchorCollection,
9
+ abbr: Watir::HTMLElement,
10
+ abbrs: Watir::HTMLElementCollection,
11
+ address: Watir::HTMLElement,
12
+ addresses: Watir::HTMLElementCollection,
13
+ area: Watir::Area,
14
+ areas: Watir::AreaCollection,
15
+ article: Watir::HTMLElement,
16
+ articles: Watir::HTMLElementCollection,
17
+ aside: Watir::HTMLElement,
18
+ asides: Watir::HTMLElementCollection,
19
+ audio: Watir::Audio,
20
+ audios: Watir::AudioCollection,
21
+ b: Watir::HTMLElement,
22
+ bs: Watir::HTMLElementCollection,
23
+ base: Watir::Base,
24
+ bases: Watir::BaseCollection,
25
+ bdi: Watir::HTMLElement,
26
+ bdis: Watir::HTMLElementCollection,
27
+ bdo: Watir::HTMLElement,
28
+ bdos: Watir::HTMLElementCollection,
29
+ blockquote: Watir::Quote,
30
+ blockquotes: Watir::QuoteCollection,
31
+ body: Watir::Body,
32
+ bodys: Watir::BodyCollection,
33
+ br: Watir::BR,
34
+ brs: Watir::BRCollection,
35
+ button: Watir::Button,
36
+ buttons: Watir::ButtonCollection,
37
+ canvas: Watir::Canvas,
38
+ canvases: Watir::CanvasCollection,
39
+ caption: Watir::TableCaption,
40
+ captions: Watir::TableCaptionCollection,
41
+ cite: Watir::HTMLElement,
42
+ cites: Watir::HTMLElementCollection,
43
+ code: Watir::HTMLElement,
44
+ codes: Watir::HTMLElementCollection,
45
+ col: Watir::TableCol,
46
+ cols: Watir::TableColCollection,
47
+ colgroup: Watir::TableCol,
48
+ colgroups: Watir::TableColCollection,
49
+ data: Watir::Data,
50
+ datas: Watir::DataCollection,
51
+ datalist: Watir::DataList,
52
+ datalists: Watir::DataListCollection,
53
+ dd: Watir::HTMLElement,
54
+ dds: Watir::HTMLElementCollection,
55
+ del: Watir::Mod,
56
+ dels: Watir::ModCollection,
57
+ details: Watir::Details,
58
+ detailses: Watir::DetailsCollection,
59
+ dfn: Watir::HTMLElement,
60
+ dfns: Watir::HTMLElementCollection,
61
+ div: Watir::Div,
62
+ divs: Watir::DivCollection,
63
+ dl: Watir::DList,
64
+ dls: Watir::DListCollection,
65
+ dt: Watir::HTMLElement,
66
+ dts: Watir::HTMLElementCollection,
67
+ em: Watir::HTMLElement,
68
+ ems: Watir::HTMLElementCollection,
69
+ embed: Watir::Embed,
70
+ embeds: Watir::EmbedCollection,
71
+ fieldset: Watir::FieldSet,
72
+ fieldsets: Watir::FieldSetCollection,
73
+ figcaption: Watir::HTMLElement,
74
+ figcaptions: Watir::HTMLElementCollection,
75
+ figure: Watir::HTMLElement,
76
+ figures: Watir::HTMLElementCollection,
77
+ footer: Watir::HTMLElement,
78
+ footers: Watir::HTMLElementCollection,
79
+ form: Watir::Form,
80
+ forms: Watir::FormCollection,
81
+ frameset: Watir::FrameSet,
82
+ framesets: Watir::FrameSetCollection,
83
+ h1: Watir::Heading,
84
+ h1s: Watir::HeadingCollection,
85
+ h2: Watir::Heading,
86
+ h2s: Watir::HeadingCollection,
87
+ h3: Watir::Heading,
88
+ h3s: Watir::HeadingCollection,
89
+ h4: Watir::Heading,
90
+ h4s: Watir::HeadingCollection,
91
+ h5: Watir::Heading,
92
+ h5s: Watir::HeadingCollection,
93
+ h6: Watir::Heading,
94
+ h6s: Watir::HeadingCollection,
95
+ head: Watir::Head,
96
+ heads: Watir::HeadCollection,
97
+ header: Watir::HTMLElement,
98
+ headers: Watir::HTMLElementCollection,
99
+ hr: Watir::HR,
100
+ hrs: Watir::HRCollection,
101
+ html: Watir::Html,
102
+ htmls: Watir::HtmlCollection,
103
+ i: Watir::HTMLElement,
104
+ is: Watir::HTMLElementCollection,
105
+ iframe: Watir::IFrame,
106
+ iframes: Watir::IFrameCollection,
107
+ image: Watir::Image,
108
+ images: Watir::ImageCollection,
109
+ img: Watir::Image,
110
+ imgs: Watir::ImageCollection,
111
+ input: Watir::Input,
112
+ inputs: Watir::InputCollection,
113
+ ins: Watir::Mod,
114
+ inses: Watir::ModCollection,
115
+ kbd: Watir::HTMLElement,
116
+ kbds: Watir::HTMLElementCollection,
117
+ keygen: Watir::Keygen,
118
+ keygens: Watir::KeygenCollection,
119
+ label: Watir::Label,
120
+ labels: Watir::LabelCollection,
121
+ legend: Watir::Legend,
122
+ legends: Watir::LegendCollection,
123
+ li: Watir::LI,
124
+ lis: Watir::LICollection,
125
+ link: Watir::Anchor,
126
+ links: Watir::AnchorCollection,
127
+ main: Watir::HTMLElement,
128
+ mains: Watir::HTMLElementCollection,
129
+ map: Watir::Map,
130
+ maps: Watir::MapCollection,
131
+ mark: Watir::HTMLElement,
132
+ marks: Watir::HTMLElementCollection,
133
+ menu: Watir::Menu,
134
+ menus: Watir::MenuCollection,
135
+ menuitem: Watir::MenuItem,
136
+ menuitems: Watir::MenuItemCollection,
137
+ meta: Watir::Meta,
138
+ metas: Watir::MetaCollection,
139
+ meter: Watir::Meter,
140
+ meters: Watir::MeterCollection,
141
+ nav: Watir::HTMLElement,
142
+ navs: Watir::HTMLElementCollection,
143
+ noscript: Watir::HTMLElement,
144
+ noscripts: Watir::HTMLElementCollection,
145
+ object: Watir::Object,
146
+ objects: Watir::ObjectCollection,
147
+ ol: Watir::OList,
148
+ ols: Watir::OListCollection,
149
+ optgroup: Watir::OptGroup,
150
+ optgroups: Watir::OptGroupCollection,
151
+ option: Watir::Option,
152
+ options: Watir::OptionCollection,
153
+ output: Watir::Output,
154
+ outputs: Watir::OutputCollection,
155
+ p: Watir::Paragraph,
156
+ ps: Watir::ParagraphCollection,
157
+ param: Watir::Param,
158
+ params: Watir::ParamCollection,
159
+ picture: Watir::Picture,
160
+ pictures: Watir::PictureCollection,
161
+ pre: Watir::Pre,
162
+ pres: Watir::PreCollection,
163
+ progress: Watir::Progress,
164
+ progresses: Watir::ProgressCollection,
165
+ q: Watir::Quote,
166
+ qs: Watir::QuoteCollection,
167
+ rb: Watir::HTMLElement,
168
+ rbs: Watir::HTMLElementCollection,
169
+ rp: Watir::HTMLElement,
170
+ rps: Watir::HTMLElementCollection,
171
+ rt: Watir::HTMLElement,
172
+ rts: Watir::HTMLElementCollection,
173
+ rtc: Watir::HTMLElement,
174
+ rtcs: Watir::HTMLElementCollection,
175
+ ruby: Watir::HTMLElement,
176
+ rubies: Watir::HTMLElementCollection,
177
+ s: Watir::HTMLElement,
178
+ ss: Watir::HTMLElementCollection,
179
+ samp: Watir::HTMLElement,
180
+ samps: Watir::HTMLElementCollection,
181
+ script: Watir::Script,
182
+ scripts: Watir::ScriptCollection,
183
+ section: Watir::HTMLElement,
184
+ sections: Watir::HTMLElementCollection,
185
+ select: Watir::Select,
186
+ selects: Watir::SelectCollection,
187
+ small: Watir::HTMLElement,
188
+ smalls: Watir::HTMLElementCollection,
189
+ source: Watir::Source,
190
+ sources: Watir::SourceCollection,
191
+ span: Watir::Span,
192
+ spans: Watir::SpanCollection,
193
+ strong: Watir::HTMLElement,
194
+ strongs: Watir::HTMLElementCollection,
195
+ style: Watir::Style,
196
+ styles: Watir::StyleCollection,
197
+ sub: Watir::HTMLElement,
198
+ subs: Watir::HTMLElementCollection,
199
+ summary: Watir::HTMLElement,
200
+ summaries: Watir::HTMLElementCollection,
201
+ sup: Watir::HTMLElement,
202
+ sups: Watir::HTMLElementCollection,
203
+ table: Watir::Table,
204
+ tables: Watir::TableCollection,
205
+ tbody: Watir::TableSection,
206
+ tbodys: Watir::TableSectionCollection,
207
+ td: Watir::TableDataCell,
208
+ tds: Watir::TableDataCellCollection,
209
+ template: Watir::Template,
210
+ templates: Watir::TemplateCollection,
211
+ textarea: Watir::TextArea,
212
+ textareas: Watir::TextAreaCollection,
213
+ tfoot: Watir::TableSection,
214
+ tfoots: Watir::TableSectionCollection,
215
+ th: Watir::TableHeaderCell,
216
+ ths: Watir::TableHeaderCellCollection,
217
+ thead: Watir::TableSection,
218
+ theads: Watir::TableSectionCollection,
219
+ time: Watir::Time,
220
+ times: Watir::TimeCollection,
221
+ title: Watir::Title,
222
+ titles: Watir::TitleCollection,
223
+ tr: Watir::TableRow,
224
+ trs: Watir::TableRowCollection,
225
+ track: Watir::Track,
226
+ tracks: Watir::TrackCollection,
227
+ u: Watir::HTMLElement,
228
+ us: Watir::HTMLElementCollection,
229
+ ul: Watir::UList,
230
+ uls: Watir::UListCollection,
231
+ var: Watir::HTMLElement,
232
+ vars: Watir::HTMLElementCollection,
233
+ video: Watir::Video,
234
+ videos: Watir::VideoCollection,
235
+ wbr: Watir::HTMLElement,
236
+ wbrs: Watir::HTMLElementCollection,
237
+
238
+ # SVG
239
+ circle: Watir::Circle,
240
+ circles: Watir::CircleCollection,
241
+ cursor: Watir::Cursor,
242
+ cursors: Watir::CursorCollection,
243
+ defs: Watir::Defs,
244
+ defss: Watir::DefsCollection,
245
+ desc: Watir::Desc,
246
+ descs: Watir::DescCollection,
247
+ ellipse: Watir::Ellipse,
248
+ ellipses: Watir::EllipseCollection,
249
+ foreign_object: Watir::ForeignObject,
250
+ foreign_objects: Watir::ForeignObjectCollection,
251
+ g: Watir::G,
252
+ gs: Watir::GCollection,
253
+ hatchpath: Watir::Hatchpath,
254
+ hatchpaths: Watir::HatchpathCollection,
255
+ line: Watir::Line,
256
+ lines: Watir::LineCollection,
257
+ linear_gradient: Watir::LinearGradient,
258
+ linear_gradients: Watir::LinearGradientCollection,
259
+ marker: Watir::Marker,
260
+ markers: Watir::MarkerCollection,
261
+ mesh: Watir::Mesh,
262
+ meshes: Watir::MeshCollection,
263
+ meshgradient: Watir::MeshGradient,
264
+ meshgradients: Watir::MeshGradientCollection,
265
+ meshpatch: Watir::Meshpatch,
266
+ meshpatches: Watir::MeshpatchCollection,
267
+ meshrow: Watir::Meshrow,
268
+ meshrows: Watir::MeshrowCollection,
269
+ metadata: Watir::Metadata,
270
+ metadatas: Watir::MetadataCollection,
271
+ path: Watir::Path,
272
+ paths: Watir::PathCollection,
273
+ pattern: Watir::Pattern,
274
+ patterns: Watir::PatternCollection,
275
+ polygon: Watir::Polygon,
276
+ polygons: Watir::PolygonCollection,
277
+ polyline: Watir::Polyline,
278
+ polylines: Watir::PolylineCollection,
279
+ radial_gradient: Watir::RadialGradient,
280
+ radial_gradients: Watir::RadialGradientCollection,
281
+ rect: Watir::Rect,
282
+ rects: Watir::RectCollection,
283
+ solidcolor: Watir::Solidcolor,
284
+ solidcolors: Watir::SolidcolorCollection,
285
+ stop: Watir::Stop,
286
+ stops: Watir::StopCollection,
287
+ svg: Watir::SVG,
288
+ svgs: Watir::SVGCollection,
289
+ switch: Watir::Switch,
290
+ switches: Watir::SwitchCollection,
291
+ symbol: Watir::Symbol,
292
+ symbols: Watir::SymbolCollection,
293
+ text_path: Watir::TextPath,
294
+ text_paths: Watir::TextPathCollection,
295
+ tspan: Watir::TSpan,
296
+ tspans: Watir::TSpanCollection,
297
+ use: Watir::Use,
298
+ uses: Watir::UseCollection,
299
+ view: Watir::View,
300
+ views: Watir::ViewCollection,
301
+
302
+ # others
303
+ radio: Watir::Radio,
304
+ radios: Watir::RadioCollection,
305
+ date_time_field: Watir::DateTimeField,
306
+ date_time_fields: Watir::DateTimeFieldCollection,
307
+ date_field: Watir::DateField,
308
+ date_fields: Watir::DateFieldCollection,
309
+ frame: Watir::Frame,
310
+ frames: Watir::FrameCollection,
311
+ file_field: Watir::FileField,
312
+ file_fields: Watir::FileFieldCollection,
313
+ hidden: Watir::Hidden,
314
+ hiddens: Watir::HiddenCollection,
315
+ checkbox: Watir::CheckBox,
316
+ checkboxes: Watir::CheckBoxCollection,
317
+ font: Watir::Font,
318
+ fonts: Watir::FontCollection,
319
+ text_field: Watir::TextField,
320
+ text_fields: Watir::TextFieldCollection
321
+ }.freeze
322
+ end
323
+
324
+ # rubocop:enable Metrics/ModuleLength
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: watir_pump
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.4
4
+ version: 0.3.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bartek Wilczek
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-07-09 00:00:00.000000000 Z
11
+ date: 2018-07-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -143,6 +143,7 @@ files:
143
143
  - lib/watir_pump/constants.rb
144
144
  - lib/watir_pump/decorated_element.rb
145
145
  - lib/watir_pump/page.rb
146
+ - lib/watir_pump/watir_method_mapping.rb
146
147
  homepage: https://github.com/bwilczek/watir_pump
147
148
  licenses:
148
149
  - MIT
@@ -163,7 +164,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
163
164
  version: '0'
164
165
  requirements: []
165
166
  rubyforge_project:
166
- rubygems_version: 2.6.14
167
+ rubygems_version: 2.6.14.1
167
168
  signing_key:
168
169
  specification_version: 4
169
170
  summary: Page Object pattern for Watir. Hacker friendly and enterprise ready.