page_object_wrapper 1.4.0 → 1.4.1
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.
- data/README.md +18 -23
- data/good_pages/some_test_page.html +1 -0
- data/lib/page_object_wrapper/PageObject.rb +23 -2
- data/lib/page_object_wrapper/version.rb +1 -1
- data/spec/feed_xxx_spec.rb +22 -0
- metadata +12 -12
data/README.md
CHANGED
|
@@ -103,6 +103,8 @@ which will be checked for presence as well*
|
|
|
103
103
|
PageObjectWrapper.define_page :some_test_page_similar_to_previous do
|
|
104
104
|
locator 'http://www.cs.tut.fi/~jkorpela/www/testel.html'
|
|
105
105
|
|
|
106
|
+
uniq_h1 :text => 'Testing display of HTML elements'
|
|
107
|
+
|
|
106
108
|
text_field :tf do
|
|
107
109
|
locator :id => 'f1'
|
|
108
110
|
menu :user_defined, 'some food'
|
|
@@ -111,7 +113,7 @@ which will be checked for presence as well*
|
|
|
111
113
|
end
|
|
112
114
|
|
|
113
115
|
##### it's possible to define action and its aliases inside pages
|
|
114
|
-
*actions are being executed in browser context
|
|
116
|
+
*actions are being executed in browser context*
|
|
115
117
|
|
|
116
118
|
PageObjectWrapper.define_page :some_test_page do
|
|
117
119
|
locator 'http://www.cs.tut.fi/~jkorpela/www/testel.html'
|
|
@@ -135,16 +137,9 @@ which will be checked for presence as well*
|
|
|
135
137
|
end
|
|
136
138
|
end
|
|
137
139
|
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
here we have defined a page object with locator (url) = 'http://www.cs.tut.fi/~jkorpela/www/testel.html'
|
|
141
|
-
- uniq\_xxx is used to define a uniq element on that page, which uniquely identifies the page from other pages
|
|
142
|
-
- uniq\_xxx is being checked when openning the page with PageObjectWrapper.open\_page and when running an page\_object.action
|
|
143
|
-
- all defined elements have labels
|
|
144
|
-
- action and action\_alias defined with labels and next\_pages
|
|
145
|
-
- validator defined with label
|
|
140
|
+
### other definition examples can be found inside 'good\_pages', 'bad\_pages' folders
|
|
146
141
|
|
|
147
|
-
####
|
|
142
|
+
#### PageObjectWrapper.open\_page - opens page with specified label
|
|
148
143
|
*preconditions*
|
|
149
144
|
There is a directory, where we've defined a page\_object inside a \*\_page.rb file
|
|
150
145
|
|
|
@@ -172,7 +167,7 @@ There is a directory, where we've defined a page\_object inside a \*\_page.rb fi
|
|
|
172
167
|
PageObjectWrapper.define_page(:google){ locator 'www.google.com/:some_param' }
|
|
173
168
|
PageObjectWrapper.open_page(:google, :some_param => 'advanced_search') # => 'http://google.com/advanced_search'
|
|
174
169
|
|
|
175
|
-
#### page\_object.xxx
|
|
170
|
+
#### page\_object.xxx - returns corresponding Watir element defined inside page\_object
|
|
176
171
|
*parameters*
|
|
177
172
|
no
|
|
178
173
|
*returns*
|
|
@@ -192,7 +187,7 @@ Defined elements can be accessed with their labels.
|
|
|
192
187
|
|
|
193
188
|
|
|
194
189
|
|
|
195
|
-
#### feed\_xxx
|
|
190
|
+
#### feed\_xxx - inserts data inside an element, an elements\_set or all elements of the page
|
|
196
191
|
*parameters*
|
|
197
192
|
menu type, specified inside page\_object (optional)
|
|
198
193
|
*returns*
|
|
@@ -228,7 +223,7 @@ current\_page
|
|
|
228
223
|
browser.text_field(:id => 'f1').value.should eq 'cheef menu'
|
|
229
224
|
....
|
|
230
225
|
|
|
231
|
-
#### xxx\_menu
|
|
226
|
+
#### xxx\_menu - returns corresponding data, defined inside xxx element
|
|
232
227
|
*parameters*
|
|
233
228
|
:food\_type
|
|
234
229
|
*returns*
|
|
@@ -240,7 +235,7 @@ food value for this type which is defined in page\_object
|
|
|
240
235
|
tp.tf_menu(:loud) # => 'tf food'
|
|
241
236
|
tp.rb1_menu(:loud) # => 'true' # pay attention that String is being returned (not true, TrueClass)
|
|
242
237
|
|
|
243
|
-
#### fire\_xxx
|
|
238
|
+
#### fire\_xxx - executes action with label xxx
|
|
244
239
|
*parameters*
|
|
245
240
|
optional arguments defined inside action
|
|
246
241
|
*returns*
|
|
@@ -264,7 +259,7 @@ next\_page from xxx action
|
|
|
264
259
|
tp = PageObjectWrapper.open_page(:some_test_page)
|
|
265
260
|
tp.fire_fill_textarea_alias
|
|
266
261
|
|
|
267
|
-
#### validate\_xxx
|
|
262
|
+
#### validate\_xxx - executes validator with label xxx
|
|
268
263
|
*parameters*
|
|
269
264
|
optional arguments defined inside action
|
|
270
265
|
*returns*
|
|
@@ -277,7 +272,7 @@ anything block inside xxx validator returns
|
|
|
277
272
|
tp.fire_fill_textarea data
|
|
278
273
|
tp.validate_textarea_value.should eq data
|
|
279
274
|
|
|
280
|
-
#### select\_from\_xxx
|
|
275
|
+
#### select\_from\_xxx - tries to select data from table with label xxx
|
|
281
276
|
*parameters*
|
|
282
277
|
:column\_1, :column\_2 => search\_value, :optional\_next\_page
|
|
283
278
|
*returns*
|
|
@@ -285,12 +280,12 @@ Watir::TableCell if next\_page not specified
|
|
|
285
280
|
next\_page if it is specified
|
|
286
281
|
|
|
287
282
|
*preconditions*
|
|
288
|
-
**tp** is a :some\_test\_page object opened in the browser (url =
|
|
289
|
-
|
|
283
|
+
**tp** is a :some\_test\_page object opened in the browser (url = https://raw.github.com/evgeniy-khatko/page_object_wrapper/master/img/scheme.png)
|
|
284
|
+
*Method's syntax is close to SQL:*
|
|
290
285
|
page\_object.select\_from\_xxx( :column1, :column2 => 'string\_or\_regexp' )
|
|
291
|
-
correct arguments are
|
|
292
|
-
:column1 is a column value from which you want to receive
|
|
293
|
-
:column2 is a column which is used to get specific row
|
|
286
|
+
*correct arguments are:*
|
|
287
|
+
:column1 *is a column value from which you want to receive
|
|
288
|
+
:column2 *is a column which is used to get specific row
|
|
294
289
|
|
|
295
290
|
context "where == nil":
|
|
296
291
|
it "returns last row value from provided column":
|
|
@@ -334,7 +329,7 @@ correct arguments are:
|
|
|
334
329
|
it "returns nil":
|
|
335
330
|
tp.select_from_table_with_header(:country, {:row => 123}, :some_test_page).should eq nil
|
|
336
331
|
|
|
337
|
-
#### each\_xxx
|
|
332
|
+
#### each\_xxx - alternately opens each pagination subpage
|
|
338
333
|
context "correct parameters ( limit = 3 )":
|
|
339
334
|
it "opens browser on subeach page and yields corresponding page_object":
|
|
340
335
|
gp = PageObjectWrapper.open_page(:google_pagination)
|
|
@@ -344,7 +339,7 @@ correct arguments are:
|
|
|
344
339
|
subpage.should be_a PageObject
|
|
345
340
|
subpage.validate_current_number?(counter).should be_true
|
|
346
341
|
}
|
|
347
|
-
#### open\_xxx
|
|
342
|
+
#### open\_xxx - opens pagination subpage number N
|
|
348
343
|
context "correct parameters":
|
|
349
344
|
it "opens browser on provided subpage returns corresponding page_object":
|
|
350
345
|
n = 10
|
|
@@ -75,7 +75,11 @@ class PageObject < DslElementWithLocator
|
|
|
75
75
|
when (FEED.match(method_name) and has_element?($1))
|
|
76
76
|
# page_object.feed_some_element(:fresh_food)
|
|
77
77
|
e = element_for($1)
|
|
78
|
-
|
|
78
|
+
if [true, false].include? args[0] or args[0].is_a? String
|
|
79
|
+
feed_field(e, args[0])
|
|
80
|
+
else
|
|
81
|
+
feed_elements([e], *args)
|
|
82
|
+
end
|
|
79
83
|
when (FIRE_ACTION.match(method_name) and has_action?($1))
|
|
80
84
|
# page_object.fire_some_action
|
|
81
85
|
a = action_for($1)
|
|
@@ -359,6 +363,7 @@ private
|
|
|
359
363
|
end
|
|
360
364
|
|
|
361
365
|
def feed_elements(elements, *args)
|
|
366
|
+
raise PageObjectWrapper::BrowserNotFound if @@browser.nil? or not @@browser.exist?
|
|
362
367
|
menu_name, cheef_menu = nil, nil
|
|
363
368
|
|
|
364
369
|
if args[0].is_a? Symbol
|
|
@@ -367,7 +372,6 @@ private
|
|
|
367
372
|
elsif args[0].is_a? Hash
|
|
368
373
|
cheef_menu = args[0]
|
|
369
374
|
end
|
|
370
|
-
raise PageObjectWrapper::BrowserNotFound if @@browser.nil? or not @@browser.exist?
|
|
371
375
|
if not cheef_menu.nil?
|
|
372
376
|
raise ArgumentError, "#{cheef_menu.inspect} not meaningful Hash" if not cheef_menu.is_a? Hash or cheef_menu.empty?
|
|
373
377
|
end
|
|
@@ -400,6 +404,23 @@ private
|
|
|
400
404
|
self
|
|
401
405
|
end
|
|
402
406
|
|
|
407
|
+
def feed_field(e, value)
|
|
408
|
+
watir_element = PageObject.return_watir_element e
|
|
409
|
+
case watir_element
|
|
410
|
+
when Watir::CheckBox
|
|
411
|
+
watir_element.when_present.set value if [true, false].include? value
|
|
412
|
+
when Watir::Radio
|
|
413
|
+
watir_element.when_present.set if value==true
|
|
414
|
+
when Watir::Select
|
|
415
|
+
watir_element.select value if watir_element.include? value
|
|
416
|
+
else
|
|
417
|
+
if watir_element.respond_to?(:set)
|
|
418
|
+
watir_element.when_present.set value
|
|
419
|
+
end
|
|
420
|
+
end
|
|
421
|
+
end
|
|
422
|
+
|
|
423
|
+
|
|
403
424
|
def fire_action(a, *args)
|
|
404
425
|
raise PageObjectWrapper::BrowserNotFound if @@browser.nil? or not @@browser.exist?
|
|
405
426
|
block = (a.is_a? Action)? a.fire_block_value : action_for(a.action_value).fire_block_value
|
data/spec/feed_xxx_spec.rb
CHANGED
|
@@ -52,6 +52,28 @@ describe "page_object.feed_xxx" do
|
|
|
52
52
|
@b.text_field(:id => 'f1').value.should eq 'tf food'
|
|
53
53
|
end
|
|
54
54
|
|
|
55
|
+
it "FEEDS text_field with String value" do
|
|
56
|
+
@tp.feed_tf_standalone("whible")
|
|
57
|
+
@b.text_field(:id => 'f1').value.should eq 'whible'
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
it "FEEDS checkbox with true value" do
|
|
61
|
+
@tp.feed_cb1(true)
|
|
62
|
+
@b.checkbox(:id => 'f5').should be_set
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
it "FEEDS radio with true" do
|
|
66
|
+
@tp.feed_rb1(true)
|
|
67
|
+
@b.radio(:id => 'f3').should be_set
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
it "FEEDS select list if provided value exists in it" do
|
|
71
|
+
@tp.feed_s1("whible")
|
|
72
|
+
@b.select(:id => 'f10').value.should eq "two (default)"
|
|
73
|
+
@tp.feed_s1("one")
|
|
74
|
+
@b.select(:id => 'f10').value.should eq "one"
|
|
75
|
+
end
|
|
76
|
+
|
|
55
77
|
it "feeds ONLY elements which has provided menu" do
|
|
56
78
|
@tp.feed_tf_standalone(:quite)
|
|
57
79
|
@b.text_field(:id => 'f1').value.should eq 'Default text.'
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: page_object_wrapper
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.4.
|
|
4
|
+
version: 1.4.1
|
|
5
5
|
prerelease:
|
|
6
6
|
platform: ruby
|
|
7
7
|
authors:
|
|
@@ -9,11 +9,11 @@ authors:
|
|
|
9
9
|
autorequire:
|
|
10
10
|
bindir: bin
|
|
11
11
|
cert_chain: []
|
|
12
|
-
date: 2013-03-
|
|
12
|
+
date: 2013-03-15 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
|
14
14
|
- !ruby/object:Gem::Dependency
|
|
15
15
|
name: watir-webdriver
|
|
16
|
-
requirement: &
|
|
16
|
+
requirement: &11441860 !ruby/object:Gem::Requirement
|
|
17
17
|
none: false
|
|
18
18
|
requirements:
|
|
19
19
|
- - ! '>='
|
|
@@ -21,10 +21,10 @@ dependencies:
|
|
|
21
21
|
version: '0'
|
|
22
22
|
type: :runtime
|
|
23
23
|
prerelease: false
|
|
24
|
-
version_requirements: *
|
|
24
|
+
version_requirements: *11441860
|
|
25
25
|
- !ruby/object:Gem::Dependency
|
|
26
26
|
name: activesupport
|
|
27
|
-
requirement: &
|
|
27
|
+
requirement: &11441080 !ruby/object:Gem::Requirement
|
|
28
28
|
none: false
|
|
29
29
|
requirements:
|
|
30
30
|
- - ! '>='
|
|
@@ -32,10 +32,10 @@ dependencies:
|
|
|
32
32
|
version: '0'
|
|
33
33
|
type: :runtime
|
|
34
34
|
prerelease: false
|
|
35
|
-
version_requirements: *
|
|
35
|
+
version_requirements: *11441080
|
|
36
36
|
- !ruby/object:Gem::Dependency
|
|
37
37
|
name: babosa
|
|
38
|
-
requirement: &
|
|
38
|
+
requirement: &11440240 !ruby/object:Gem::Requirement
|
|
39
39
|
none: false
|
|
40
40
|
requirements:
|
|
41
41
|
- - ! '>='
|
|
@@ -43,10 +43,10 @@ dependencies:
|
|
|
43
43
|
version: '0'
|
|
44
44
|
type: :runtime
|
|
45
45
|
prerelease: false
|
|
46
|
-
version_requirements: *
|
|
46
|
+
version_requirements: *11440240
|
|
47
47
|
- !ruby/object:Gem::Dependency
|
|
48
48
|
name: rspec
|
|
49
|
-
requirement: &
|
|
49
|
+
requirement: &11439500 !ruby/object:Gem::Requirement
|
|
50
50
|
none: false
|
|
51
51
|
requirements:
|
|
52
52
|
- - ! '>='
|
|
@@ -54,10 +54,10 @@ dependencies:
|
|
|
54
54
|
version: 2.0.0
|
|
55
55
|
type: :development
|
|
56
56
|
prerelease: false
|
|
57
|
-
version_requirements: *
|
|
57
|
+
version_requirements: *11439500
|
|
58
58
|
- !ruby/object:Gem::Dependency
|
|
59
59
|
name: debugger
|
|
60
|
-
requirement: &
|
|
60
|
+
requirement: &11438680 !ruby/object:Gem::Requirement
|
|
61
61
|
none: false
|
|
62
62
|
requirements:
|
|
63
63
|
- - ! '>='
|
|
@@ -65,7 +65,7 @@ dependencies:
|
|
|
65
65
|
version: '0'
|
|
66
66
|
type: :development
|
|
67
67
|
prerelease: false
|
|
68
|
-
version_requirements: *
|
|
68
|
+
version_requirements: *11438680
|
|
69
69
|
description: Wraps watir-webdriver with convenient testing interface, based on PageObjects
|
|
70
70
|
automation testing pattern. Simplifies resulting automated test understanding.
|
|
71
71
|
email:
|