page_object_wrapper 1.3.7 → 1.4.0
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 +66 -54
- data/bad_pages/bad_page.rb +4 -0
- data/good_pages/google_wrong_uniq_page.rb +1 -1
- data/good_pages/required_missing_page.rb +9 -0
- data/good_pages/some_test_page.rb +29 -0
- data/good_pages/uniq_missing_page.rb +4 -0
- data/lib/page_object_wrapper.rb +4 -0
- data/lib/page_object_wrapper/Element.rb +18 -0
- data/lib/page_object_wrapper/Exceptions.rb +1 -0
- data/lib/page_object_wrapper/PageObject.rb +73 -31
- data/lib/page_object_wrapper/Pagination.rb +2 -1
- data/lib/page_object_wrapper/Table.rb +2 -4
- data/lib/page_object_wrapper/known_elements.rb +2 -2
- data/lib/page_object_wrapper/version.rb +1 -1
- data/spec/define_page_object_spec.rb +47 -3
- data/spec/feed_xxx_spec.rb +99 -4
- data/spec/load_spec.rb +23 -18
- data/spec/press_xxx_spec.rb +61 -0
- data/spec/required_elements_spec.rb +65 -0
- metadata +19 -38
data/README.md
CHANGED
@@ -42,49 +42,87 @@ optional arguments are enclosed with [ ]
|
|
42
42
|
|
43
43
|
### Examples
|
44
44
|
|
45
|
-
#### definition
|
45
|
+
#### definition examples
|
46
|
+
##### define a page object with url and some elements
|
47
|
+
PageObjectWrapper.define_page :some_test_page do
|
48
|
+
locator 'http://www.cs.tut.fi/~jkorpela/www/testel.html' # url
|
49
|
+
|
50
|
+
text_field(:tf) do # defines a text_field
|
51
|
+
locator :id => 'f1' # element locator (can be Hash or String)
|
52
|
+
menu :user_defined, 'some food' # input data with type :user_defined for this element
|
53
|
+
end
|
46
54
|
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
55
|
+
select(:s1) do # select list
|
56
|
+
locator :id => 'f10'
|
57
|
+
menu :fresh_food, 'one'
|
58
|
+
menu :missing_food, 'three'
|
59
|
+
end
|
60
|
+
|
61
|
+
table(:table_with_header) do # table with predifined header
|
62
|
+
locator :summary => 'Each row names a Nordic country and specifies its total area and land area, in square kilometers'
|
63
|
+
header [:country, :total_area, :land_area] # header will be used later inside #select_from_xxx calls
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
##### elements can be included into element\_sets
|
68
|
+
PageObjectWrapper.define_page :some_test_page do
|
69
|
+
locator 'http://www.cs.tut.fi/~jkorpela/www/testel.html'
|
51
70
|
|
52
|
-
elements_set
|
71
|
+
elements_set :test_elements do
|
53
72
|
text_field(:tf) do
|
54
73
|
locator :id => 'f1'
|
55
74
|
menu :user_defined, 'some food'
|
56
75
|
end
|
57
76
|
|
58
|
-
textarea
|
77
|
+
textarea :ta do
|
59
78
|
locator :id => 'f2'
|
60
79
|
end
|
61
80
|
|
62
|
-
select
|
81
|
+
select :s1 do
|
63
82
|
locator :id => 'f10'
|
64
83
|
menu :fresh_food, 'one'
|
65
84
|
menu :missing_food, 'three'
|
66
85
|
end
|
86
|
+
end
|
87
|
+
end
|
67
88
|
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
end
|
89
|
+
##### each element can be marked as required
|
90
|
+
PageObjectWrapper.define_page :some_test_page do
|
91
|
+
locator 'http://www.cs.tut.fi/~jkorpela/www/testel.html'
|
72
92
|
|
73
|
-
|
74
|
-
|
93
|
+
text_field :tf do
|
94
|
+
locator :id => 'f1'
|
95
|
+
menu :user_defined, 'some food'
|
96
|
+
required true # will be checked for presence upon page load
|
75
97
|
end
|
98
|
+
end
|
76
99
|
|
77
|
-
|
78
|
-
|
100
|
+
*if all pages are similar through out the web app, it's possible to additionaly set a number of uniq elements
|
101
|
+
which will be checked for presence as well*
|
102
|
+
|
103
|
+
PageObjectWrapper.define_page :some_test_page_similar_to_previous do
|
104
|
+
locator 'http://www.cs.tut.fi/~jkorpela/www/testel.html'
|
105
|
+
|
106
|
+
text_field :tf do
|
107
|
+
locator :id => 'f1'
|
108
|
+
menu :user_defined, 'some food'
|
109
|
+
required true # will be checked for presence upon page load
|
79
110
|
end
|
111
|
+
end
|
80
112
|
|
81
|
-
|
82
|
-
|
83
|
-
|
113
|
+
##### it's possible to define action and its aliases inside pages
|
114
|
+
*actions are being executed in browser context
|
115
|
+
|
116
|
+
PageObjectWrapper.define_page :some_test_page do
|
117
|
+
locator 'http://www.cs.tut.fi/~jkorpela/www/testel.html'
|
118
|
+
uniq_h1 :text => 'Testing display of HTML elements'
|
119
|
+
|
120
|
+
action(:press_cool_button, :test_page_with_table) do # this action returns :test_page_with_table object after execution
|
121
|
+
button(:name => 'foo').when_present.click
|
84
122
|
end
|
85
123
|
|
86
|
-
action :fill_textarea_with_returned_value do |fill_with|
|
87
|
-
data = (fill_with.nil?)? 'Default data' : fill_with
|
124
|
+
action :fill_textarea_with_returned_value do |fill_with| # this action returns 'data'
|
125
|
+
data = (fill_with.nil?)? 'Default data' : fill_with # (because returned page object is not specified)
|
88
126
|
textarea(:id => 'f2').set data
|
89
127
|
data
|
90
128
|
end
|
@@ -95,21 +133,10 @@ optional arguments are enclosed with [ ]
|
|
95
133
|
table(:table_without_header) do
|
96
134
|
locator :summary => 'Each row names a Nordic country and specifies its total area and land area, in square kilometers'
|
97
135
|
end
|
98
|
-
|
99
|
-
table(:table_with_header) do
|
100
|
-
locator :summary => 'Each row names a Nordic country and specifies its total area and land area, in square kilometers'
|
101
|
-
header [:country, :total_area, :land_area]
|
102
|
-
end
|
103
|
-
|
104
|
-
pagination(:some_pagination) do
|
105
|
-
locator :xpath => ''
|
106
|
-
end
|
107
|
-
|
108
|
-
validator(:textarea_value) do |expected|
|
109
|
-
textarea(:id => 'f2').value == expected
|
110
|
-
end
|
111
136
|
end
|
112
137
|
|
138
|
+
##### other definition examples can be found inside 'good\_pages', 'bad\_pages' folders
|
139
|
+
|
113
140
|
here we have defined a page object with locator (url) = 'http://www.cs.tut.fi/~jkorpela/www/testel.html'
|
114
141
|
- uniq\_xxx is used to define a uniq element on that page, which uniquely identifies the page from other pages
|
115
142
|
- uniq\_xxx is being checked when openning the page with PageObjectWrapper.open\_page and when running an page\_object.action
|
@@ -167,7 +194,7 @@ Defined elements can be accessed with their labels.
|
|
167
194
|
|
168
195
|
#### feed\_xxx
|
169
196
|
*parameters*
|
170
|
-
|
197
|
+
menu type, specified inside page\_object (optional)
|
171
198
|
*returns*
|
172
199
|
current\_page
|
173
200
|
|
@@ -222,10 +249,6 @@ next\_page from xxx action
|
|
222
249
|
*preconditions*
|
223
250
|
**tp** is a :some\_test\_page object opened in the browser
|
224
251
|
|
225
|
-
it "executes fire_block in Watir::Browser context":
|
226
|
-
tp = PageObjectWrapper.open_page(:some_test_page)
|
227
|
-
tp.fire_fill_textarea
|
228
|
-
|
229
252
|
it "can be invoked with parameters":
|
230
253
|
tp = PageObjectWrapper.current_page
|
231
254
|
tp.fire_fill_textarea('User defined data')
|
@@ -236,13 +259,6 @@ next\_page from xxx action
|
|
236
259
|
data = tp.fire_fill_textarea_with_returned_value('data to fill with')
|
237
260
|
tp.validate_textarea_value(data).should be(true)
|
238
261
|
|
239
|
-
context "next_page not nil":
|
240
|
-
it "returns next_page":
|
241
|
-
tp = PageObjectWrapper.current_page
|
242
|
-
np = tp.fire_press_cool_button
|
243
|
-
np.should be_a(PageObject)
|
244
|
-
np.label_value.should eq(:test_page_with_table)
|
245
|
-
|
246
262
|
context "xxx is alias":
|
247
263
|
it "executes corresponding action":
|
248
264
|
tp = PageObjectWrapper.open_page(:some_test_page)
|
@@ -253,18 +269,13 @@ next\_page from xxx action
|
|
253
269
|
optional arguments defined inside action
|
254
270
|
*returns*
|
255
271
|
anything block inside xxx validator returns
|
256
|
-
it's expected that validator returns true | false
|
257
272
|
|
258
273
|
*preconditions*
|
259
274
|
**tp** is a :some\_test\_page object opened in the browser
|
260
275
|
|
261
276
|
tp = PageObjectWrapper.open_page(:some_test_page)
|
262
|
-
tp.fire_fill_textarea
|
263
|
-
tp.validate_textarea_value
|
264
|
-
|
265
|
-
tp = PageObjectWrapper.current_page
|
266
|
-
tp.fire_fill_textarea('User defined data')
|
267
|
-
tp.validate_textarea_value('User defined data').should be(true)
|
277
|
+
tp.fire_fill_textarea data
|
278
|
+
tp.validate_textarea_value.should eq data
|
268
279
|
|
269
280
|
#### select\_from\_xxx
|
270
281
|
*parameters*
|
@@ -274,7 +285,7 @@ Watir::TableCell if next\_page not specified
|
|
274
285
|
next\_page if it is specified
|
275
286
|
|
276
287
|
*preconditions*
|
277
|
-
**tp** is a :some\_test\_page object opened in the browser
|
288
|
+
**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))
|
278
289
|
its syntax is close to SQL *'select column1 from page\_object.some\_table where column2 = string\_or\_regexp'*
|
279
290
|
page\_object.select\_from\_xxx( :column1, :column2 => 'string\_or\_regexp' )
|
280
291
|
correct arguments are:
|
@@ -343,6 +354,7 @@ correct arguments are:
|
|
343
354
|
gp = PageObjectWrapper.open_page(:google_pagination)
|
344
355
|
gp.pagination_open(n).should be_a PageObject
|
345
356
|
gp.validate_current_number?(n).should be_true
|
357
|
+
|
346
358
|
## Contributing
|
347
359
|
|
348
360
|
1. Fork it
|
data/bad_pages/bad_page.rb
CHANGED
@@ -7,6 +7,10 @@ PageObjectWrapper.define_page('some_page_with_lost_of_errors') do
|
|
7
7
|
elements_set('some elements_set label') do
|
8
8
|
end
|
9
9
|
|
10
|
+
text_field :bad_required_flad do
|
11
|
+
required 'a string'
|
12
|
+
end
|
13
|
+
|
10
14
|
elements_set(:bad_elements) do
|
11
15
|
element('') do
|
12
16
|
menu :fresh_food, Array.new
|
@@ -3,7 +3,36 @@ PageObjectWrapper.define_page(:some_test_page) do
|
|
3
3
|
locator 'file://'+Dir.pwd+'/good_pages/some_test_page.html'
|
4
4
|
uniq_h1 :text => 'Testing display of HTML elements'
|
5
5
|
|
6
|
+
text_field(:tf_standalone) do
|
7
|
+
locator :id => 'f1'
|
8
|
+
menu :loud, 'tf food'
|
9
|
+
end
|
10
|
+
|
11
|
+
button(:standalone_cool_button_with_default_press_action) do
|
12
|
+
locator :name => 'foo'
|
13
|
+
menu :loud, 'try to feed me!'
|
14
|
+
end
|
15
|
+
|
16
|
+
button(:standalone_cool_button) do
|
17
|
+
locator :name => 'foo'
|
18
|
+
press_action :click
|
19
|
+
end
|
20
|
+
|
21
|
+
button(:invalid_press_action_button) do
|
22
|
+
locator :name => 'foo'
|
23
|
+
press_action :press
|
24
|
+
end
|
25
|
+
|
26
|
+
button(:invalid_button) do
|
27
|
+
locator :name => 'bar'
|
28
|
+
end
|
29
|
+
|
6
30
|
elements_set(:test_elements) do
|
31
|
+
|
32
|
+
button(:cool_button) do
|
33
|
+
locator :name => 'foo'
|
34
|
+
end
|
35
|
+
|
7
36
|
text_field(:tf) do
|
8
37
|
locator :id => 'f1'
|
9
38
|
menu :loud, 'tf food'
|
data/lib/page_object_wrapper.rb
CHANGED
@@ -6,6 +6,8 @@ class Element < DslElementWithLocator
|
|
6
6
|
super label
|
7
7
|
@type = type
|
8
8
|
@menu = Hash.new
|
9
|
+
@press_action = :click
|
10
|
+
@required = false
|
9
11
|
end
|
10
12
|
|
11
13
|
def menu food_type, value
|
@@ -15,4 +17,20 @@ class Element < DslElementWithLocator
|
|
15
17
|
def menu_value
|
16
18
|
@menu
|
17
19
|
end
|
20
|
+
|
21
|
+
def press_action action
|
22
|
+
@press_action = action
|
23
|
+
end
|
24
|
+
|
25
|
+
def press_action_value
|
26
|
+
@press_action
|
27
|
+
end
|
28
|
+
|
29
|
+
def required flag
|
30
|
+
@required = flag
|
31
|
+
end
|
32
|
+
|
33
|
+
def required_value
|
34
|
+
@required
|
35
|
+
end
|
18
36
|
end
|
@@ -10,6 +10,7 @@ require 'Alias'
|
|
10
10
|
require 'Validator'
|
11
11
|
require 'Table'
|
12
12
|
require 'Pagination'
|
13
|
+
require 'Element'
|
13
14
|
require 'known_elements'
|
14
15
|
|
15
16
|
class PageObject < DslElementWithLocator
|
@@ -18,19 +19,18 @@ class PageObject < DslElementWithLocator
|
|
18
19
|
@@pages = []
|
19
20
|
@@current_page = nil
|
20
21
|
|
21
|
-
|
22
|
+
REQUIRED_ELEMENT_WAIT_PERIOD = 10
|
22
23
|
FEED_ALL = Regexp.new(/^feed_all$/)
|
23
|
-
|
24
|
+
FEED = Regexp.new(/^feed_([\w_]+)$/)
|
24
25
|
FIRE_ACTION = Regexp.new(/^fire_([\w_]+)$/)
|
25
26
|
SELECT_FROM = Regexp.new(/^select_from_([\w_]+)$/)
|
26
27
|
PAGINATION_EACH = Regexp.new(/^([\w_]+)_each$/)
|
27
28
|
PAGINATION_OPEN = Regexp.new(/^([\w_]+)_open$/)
|
28
29
|
VALIDATE = Regexp.new(/^validate_([\w_\?]+)$/)
|
30
|
+
PRESS = Regexp.new(/^press_([\w_\?]+)$/)
|
29
31
|
|
30
32
|
def initialize(label)
|
31
33
|
super label
|
32
|
-
@uniq_element_type = nil
|
33
|
-
@uniq_element_hash = {}
|
34
34
|
@esets = []
|
35
35
|
@elements = []
|
36
36
|
@actions = []
|
@@ -40,28 +40,42 @@ class PageObject < DslElementWithLocator
|
|
40
40
|
@paginations = []
|
41
41
|
end
|
42
42
|
|
43
|
+
KNOWN_ELEMENTS.each{|m|
|
44
|
+
PageObject.send :define_method, m do |l, &b|
|
45
|
+
e = Element.new(l, m.to_sym)
|
46
|
+
e.instance_eval(&b)
|
47
|
+
@elements << e
|
48
|
+
end
|
49
|
+
}
|
50
|
+
|
43
51
|
# lazy evaluated calls of real watir elements are handled by :method_missing
|
44
52
|
def method_missing(method_name, *args, &block)
|
45
53
|
case
|
46
54
|
when KNOWN_ELEMENTS.include?(method_name.to_s.gsub(/^uniq_/,''))
|
47
55
|
# page_object.uniq_xxx(hash)
|
48
|
-
|
49
|
-
|
56
|
+
meth = method_name.to_s.gsub(/^uniq_/,'')
|
57
|
+
e = Element.new(method_name.to_sym, meth)
|
58
|
+
e.instance_eval { locator(args[0]); required(true) }
|
59
|
+
@elements << e
|
50
60
|
when has_eset?(method_name)
|
51
61
|
# page_object.some_elements_set
|
52
62
|
eset = eset_for(method_name)
|
53
|
-
return_array_of_watir_elements(eset)
|
63
|
+
PageObject.return_array_of_watir_elements(eset)
|
54
64
|
when has_element?(method_name)
|
55
65
|
# page_object.some_element
|
56
66
|
element = element_for(method_name)
|
57
|
-
return_watir_element
|
67
|
+
PageObject.return_watir_element element
|
58
68
|
when FEED_ALL.match(method_name)
|
59
69
|
# page_object.feed_all(:fresh_food)
|
60
70
|
feed_elements(@elements, *args)
|
61
|
-
when (
|
71
|
+
when (FEED.match(method_name) and has_eset?($1))
|
62
72
|
# page_object.feed_some_elements_set(:fresh_food)
|
63
73
|
eset = eset_for($1)
|
64
74
|
feed_elements(eset.elements, *args)
|
75
|
+
when (FEED.match(method_name) and has_element?($1))
|
76
|
+
# page_object.feed_some_element(:fresh_food)
|
77
|
+
e = element_for($1)
|
78
|
+
feed_elements([e], *args)
|
65
79
|
when (FIRE_ACTION.match(method_name) and has_action?($1))
|
66
80
|
# page_object.fire_some_action
|
67
81
|
a = action_for($1)
|
@@ -86,6 +100,10 @@ class PageObject < DslElementWithLocator
|
|
86
100
|
# page_object.open_padination(1)
|
87
101
|
pagination = pagination_for($1)
|
88
102
|
open_subpage(pagination, *args)
|
103
|
+
when (PRESS.match(method_name) and has_element?($1))
|
104
|
+
# page_object.press_element
|
105
|
+
element = element_for($1)
|
106
|
+
press(element)
|
89
107
|
else
|
90
108
|
super
|
91
109
|
end
|
@@ -107,9 +125,12 @@ class PageObject < DslElementWithLocator
|
|
107
125
|
when FEED_ALL.match(method_name)
|
108
126
|
# page_object.feed_all(:fresh_food)
|
109
127
|
true
|
110
|
-
when (
|
128
|
+
when (FEED.match(method_name) and has_eset?($1))
|
111
129
|
# page_object.feed_some_elements_set(:fresh_food)
|
112
130
|
true
|
131
|
+
when (FEED.match(method_name) and has_element?($1))
|
132
|
+
# page_object.feed_some_element(:fresh_food)
|
133
|
+
true
|
113
134
|
when (FIRE_ACTION.match(method_name) and has_action?($1))
|
114
135
|
# page_object.fire_some_action
|
115
136
|
true
|
@@ -128,6 +149,9 @@ class PageObject < DslElementWithLocator
|
|
128
149
|
when (PAGINATION_OPEN.match(method_name) and has_pagination?($1))
|
129
150
|
# page_object.open_padination(1)
|
130
151
|
true
|
152
|
+
when (PRESS.match(method_name) and has_element?($1))
|
153
|
+
# page_object.press_element
|
154
|
+
true
|
131
155
|
else
|
132
156
|
super
|
133
157
|
end
|
@@ -155,17 +179,22 @@ class PageObject < DslElementWithLocator
|
|
155
179
|
raise PageObjectWrapper::BrowserNotFound if @@browser.nil?
|
156
180
|
raise PageObjectWrapper::UnknownPageObject, label if not @@pages.collect(&:label_value).include?(label)
|
157
181
|
page_object = PageObject.find_page_object(label)
|
158
|
-
|
182
|
+
page_object.elements.select{ |e| e.required_value == true }.each{ |required_element|
|
159
183
|
begin
|
160
|
-
|
161
|
-
|
184
|
+
watir_element = return_watir_element required_element
|
185
|
+
watir_element.wait_until_present REQUIRED_ELEMENT_WAIT_PERIOD
|
162
186
|
rescue Watir::Wait::TimeoutError => e
|
163
|
-
raise PageObjectWrapper::UnmappedPageObject, "#{label} <=> #{@@browser.url} (#{e.message})" if not
|
187
|
+
raise PageObjectWrapper::UnmappedPageObject, "#{label} <=> #{@@browser.url} (#{e.message})" if not watir_element.present?
|
164
188
|
end
|
165
|
-
|
189
|
+
}
|
166
190
|
@@current_page = page_object
|
167
191
|
end
|
168
192
|
|
193
|
+
def self.current_page? label
|
194
|
+
self.map_current_page label
|
195
|
+
true
|
196
|
+
end
|
197
|
+
|
169
198
|
def self.current_page
|
170
199
|
@@current_page
|
171
200
|
end
|
@@ -242,15 +271,19 @@ class PageObject < DslElementWithLocator
|
|
242
271
|
eset_output << "\tlabel #{eset.label_value.inspect} not a Symbol\n" if not eset.label_value.is_a?(Symbol)
|
243
272
|
eset_output.unshift "elements_set(#{eset.label_value.inspect}):\n" if not eset_output.empty?
|
244
273
|
output += eset_output
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
274
|
+
}
|
275
|
+
@elements.each{|e|
|
276
|
+
element_output = []
|
277
|
+
element_output << "\telement #{e.label_value.inspect} already defined\n" if labeled(@elements).count(e.label_value) > 1
|
278
|
+
element_output << "\tlabel #{e.label_value.inspect} not a Symbol\n" if not e.label_value.is_a?(Symbol)
|
279
|
+
element_output << "\tlocator #{e.locator_value.inspect} not a meaningful Hash or String\n" if (not e.locator_value.is_a?(Hash) and not e.locator_value.is_a?(String)) \
|
280
|
+
or e.locator_value.empty?
|
281
|
+
element_output << "\tmenu #{e.menu_value.inspect} not properly defined (must be { :food_type => 'a string' | true | false })\n" if (not e.menu_value.empty?) and \
|
282
|
+
((e.menu_value.keys.collect(&:class).uniq != [Symbol]) \
|
283
|
+
or not (e.menu_value.values.collect(&:class).uniq - [String, TrueClass, FalseClass]).empty?)
|
284
|
+
element_output << "\trequired flag #{e.required_value.inspect} not a true | false\n" if not [true, false].include? e.required_value
|
285
|
+
element_output.unshift "element(#{e.label_value.inspect}):\n" if not element_output.empty?
|
286
|
+
output += element_output
|
254
287
|
}
|
255
288
|
@actions.each{|a|
|
256
289
|
action_output = []
|
@@ -286,9 +319,6 @@ class PageObject < DslElementWithLocator
|
|
286
319
|
}
|
287
320
|
@tables.each{|t|
|
288
321
|
table_output = []
|
289
|
-
table_output << "\ttable #{t.label_value.inspect} already defined\n" if labeled(@tables).count(t.label_value) > 1
|
290
|
-
table_output << "\tlabel #{t.label_value.inspect} not a Symbol\n" if not t.label_value.is_a?(Symbol)
|
291
|
-
table_output << "\tlocator #{t.locator_value.inspect} not a meaningful Hash or String\n" if (not t.locator_value.is_a?(Hash) and not t.locator_value.is_a?(String)) or t.locator_value.empty?
|
292
322
|
table_output << "\theader #{t.header_value.inspect} not a meaningful Array\n" if not t.header_value.is_a?(Array) or t.header_value.empty?
|
293
323
|
table_output.unshift "table(#{t.label_value.inspect}):\n" if not table_output.empty?
|
294
324
|
output += table_output
|
@@ -314,7 +344,7 @@ private
|
|
314
344
|
p
|
315
345
|
end
|
316
346
|
|
317
|
-
def return_watir_element(e)
|
347
|
+
def self.return_watir_element(e)
|
318
348
|
el = nil
|
319
349
|
if e.locator_value.is_a? Hash
|
320
350
|
el = @@browser.send e.type, e.locator_value
|
@@ -324,7 +354,7 @@ private
|
|
324
354
|
el
|
325
355
|
end
|
326
356
|
|
327
|
-
def return_array_of_watir_elements(eset)
|
357
|
+
def self.return_array_of_watir_elements(eset)
|
328
358
|
eset.elements.collect{|e| return_watir_element(e)}
|
329
359
|
end
|
330
360
|
|
@@ -349,7 +379,7 @@ private
|
|
349
379
|
else
|
350
380
|
food = e.menu_value[menu_name].to_s
|
351
381
|
end
|
352
|
-
watir_element = return_watir_element
|
382
|
+
watir_element = PageObject.return_watir_element e
|
353
383
|
case watir_element
|
354
384
|
when Watir::CheckBox
|
355
385
|
watir_element.when_present.set eval(food) if ["true", "false"].include? food
|
@@ -361,7 +391,9 @@ private
|
|
361
391
|
if watir_element.respond_to?(:set)
|
362
392
|
watir_element.when_present.set food if food!=''
|
363
393
|
else
|
364
|
-
|
394
|
+
# this is an element which does not support input (e.g. button) => skipping it
|
395
|
+
next
|
396
|
+
#raise PageObjectWrapper::UnableToFeedObject, to_tree(@@current_page, e) + ' check element type'
|
365
397
|
end
|
366
398
|
end
|
367
399
|
}
|
@@ -487,6 +519,16 @@ private
|
|
487
519
|
self
|
488
520
|
end
|
489
521
|
|
522
|
+
def press e
|
523
|
+
raise PageObjectWrapper::BrowserNotFound if @@browser.nil? or not @@browser.exist?
|
524
|
+
watir_element = PageObject.return_watir_element e
|
525
|
+
raise PageObjectWrapper::InvalidElement, "Element #{e.locator_value} not found in #{@@current_page}"\
|
526
|
+
if not watir_element.present?
|
527
|
+
raise PageObjectWrapper::InvalidElement, "Element #{e.locator_value} does not respond to #{e.press_action_value}"\
|
528
|
+
if not watir_element.respond_to? e.press_action_value
|
529
|
+
watir_element.when_present.send e.press_action_value
|
530
|
+
watir_element
|
531
|
+
end
|
490
532
|
|
491
533
|
def labeled(ary)
|
492
534
|
ary.collect(&:label_value)
|
@@ -1,5 +1,5 @@
|
|
1
1
|
require 'Dsl'
|
2
|
-
class Table <
|
2
|
+
class Table < Element
|
3
3
|
attr_reader :type
|
4
4
|
dsl_attr_accessor :header
|
5
5
|
DEFAULT_HEADER_COLLUMNS_NUMBER = 100
|
@@ -7,11 +7,9 @@ class Table < DslElementWithLocator
|
|
7
7
|
|
8
8
|
|
9
9
|
def initialize(label)
|
10
|
-
super label
|
10
|
+
super label, 'table'
|
11
11
|
h = []
|
12
12
|
DEFAULT_HEADER_COLLUMNS_NUMBER.times { |i| h << (DEFAULT_HEADER_COLLUMNS_PREFIX+i.to_s).to_sym }
|
13
13
|
@header = h
|
14
|
-
@type = 'table'
|
15
14
|
end
|
16
15
|
end
|
17
|
-
|
@@ -8,7 +8,7 @@ KNOWN_ELEMENTS = [
|
|
8
8
|
'cites', 'code', 'codes', 'col', 'colgroup', 'colgroups',
|
9
9
|
'cols', 'command', 'commands', 'datalist', 'datalists',
|
10
10
|
'dd', 'dds', 'del', 'dels', 'details', 'dfn', 'dfns', 'div',
|
11
|
-
'divs', 'dl', 'dls', 'dt', 'dts', 'element',
|
11
|
+
'divs', 'dl', 'dls', 'dt', 'dts', 'element',
|
12
12
|
'em', 'embed', 'embeds', 'ems', 'fieldset', 'fieldsets', 'figcaption',
|
13
13
|
'figcaptions', 'figure', 'figures', 'file_field', 'file_fields', 'font',
|
14
14
|
'fonts', 'footer', 'footers', 'form', 'forms', 'frame', 'frames',
|
@@ -24,7 +24,7 @@ KNOWN_ELEMENTS = [
|
|
24
24
|
'ps', 'q', 'qs', 'radio', 'radios', 'rp', 'rps', 'rt', 'rts', 'rubies', 'ruby', 's',
|
25
25
|
'samp', 'samps', 'script', 'scripts', 'section', 'sections', 'select', 'selects', 'small',
|
26
26
|
'smalls', 'source', 'sources', 'span', 'spans', 'ss', 'strong', 'strongs', 'style', 'styles',
|
27
|
-
'sub', 'subs', 'summaries', 'summary', 'sup', 'sups', '
|
27
|
+
'sub', 'subs', 'summaries', 'summary', 'sup', 'sups', 'tbody', 'tbodys', 'td',
|
28
28
|
'tds', 'text_field', 'text_fields', 'textarea', 'textareas', 'tfoot', 'tfoots', 'th', 'thead',
|
29
29
|
'theads', 'ths', 'time', 'times', 'title', 'titles', 'tr', 'track', 'tracks', 'trs', 'ul',
|
30
30
|
'uls', 'var', 'vars', 'video', 'videos', 'wbr', 'wbrs'
|
@@ -1,5 +1,6 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
require 'shared_examples'
|
3
|
+
require 'known_elements'
|
3
4
|
|
4
5
|
describe "define_page_object" do
|
5
6
|
let!(:page_object){
|
@@ -21,8 +22,17 @@ describe "define_page_object" do
|
|
21
22
|
end
|
22
23
|
|
23
24
|
describe "page_object uniq_element" do
|
24
|
-
|
25
|
-
|
25
|
+
specify { subject.elements.collect(&:label_value).should include(:uniq_h1) }
|
26
|
+
let(:uniq_element){ subject.elements[subject.elements.collect(&:label_value).index(:uniq_h1)] }
|
27
|
+
specify { uniq_element.required_value.should be_true }
|
28
|
+
end
|
29
|
+
|
30
|
+
describe "page_object element" do
|
31
|
+
it "can contain known elements" do
|
32
|
+
KNOWN_ELEMENTS.each{ |known|
|
33
|
+
subject.should respond_to known
|
34
|
+
}
|
35
|
+
end
|
26
36
|
end
|
27
37
|
|
28
38
|
specify { subject.esets.collect(&:label_value).should include(:test_elements)}
|
@@ -47,8 +57,42 @@ describe "define_page_object" do
|
|
47
57
|
specify { subject.paginations.collect(&:label_value).should include(:some_pagination)}
|
48
58
|
it { should respond_to(:some_pagination_each) }
|
49
59
|
it { should respond_to(:some_pagination_open) }
|
60
|
+
|
61
|
+
specify { subject.elements.collect(&:label_value).should include(:tf_standalone)}
|
62
|
+
it { should respond_to(:feed_tf_standalone) }
|
63
|
+
it { should respond_to(:press_tf_standalone) }
|
64
|
+
|
65
|
+
specify { subject.elements.collect(&:label_value).should include(:standalone_cool_button)}
|
66
|
+
it { should respond_to(:press_standalone_cool_button) }
|
67
|
+
it { should respond_to(:feed_standalone_cool_button) }
|
50
68
|
end
|
51
69
|
|
70
|
+
context "element outside elements_set" do
|
71
|
+
subject { page_object.elements[page_object.elements.collect(&:label_value).index(:tf_standalone)] }
|
72
|
+
|
73
|
+
it { should be_a(Element) }
|
74
|
+
|
75
|
+
describe "element label" do
|
76
|
+
it_should_behave_like "a label"
|
77
|
+
end
|
78
|
+
|
79
|
+
describe "element locator" do
|
80
|
+
it_should_behave_like "a locator"
|
81
|
+
its(:locator_value) { should be_a Hash }
|
82
|
+
end
|
83
|
+
|
84
|
+
describe "element menu" do
|
85
|
+
it { should respond_to(:menu) }
|
86
|
+
it { should respond_to(:menu_value) }
|
87
|
+
|
88
|
+
its(:menu_value) { should be_a Hash}
|
89
|
+
|
90
|
+
describe "user defined menu" do
|
91
|
+
its(:menu_value){ should have_key :loud }
|
92
|
+
its(:menu_value){ should have_value 'tf food'}
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|
52
96
|
|
53
97
|
context "elements_set" do
|
54
98
|
subject { page_object.esets[page_object.esets.collect(&:label_value).index(:test_elements)] }
|
@@ -60,7 +104,7 @@ describe "define_page_object" do
|
|
60
104
|
end
|
61
105
|
end
|
62
106
|
|
63
|
-
context "element" do
|
107
|
+
context "element inside elements_set" do
|
64
108
|
subject { page_object.elements[page_object.elements.collect(&:label_value).index(:tf)] }
|
65
109
|
|
66
110
|
it { should be_a(Element) }
|
data/spec/feed_xxx_spec.rb
CHANGED
@@ -24,12 +24,19 @@ describe "page_object.feed_xxx" do
|
|
24
24
|
end
|
25
25
|
|
26
26
|
it "returns current page object" do
|
27
|
+
@tp.feed_tf_standalone(:quite).should be_a PageObject
|
27
28
|
@tp.feed_test_elements(:quite).should be_a PageObject
|
29
|
+
@tp.feed_all(:quite).should be_a PageObject
|
28
30
|
end
|
29
31
|
|
30
|
-
|
31
|
-
it "does nothing" do
|
32
|
-
@tp.
|
32
|
+
describe "feed_standalone_element" do
|
33
|
+
it "does nothing if menu not spesified" do
|
34
|
+
@tp.feed_tf_standalone
|
35
|
+
@b.text_field(:id => 'f1').value.should eq 'Default text.'
|
36
|
+
end
|
37
|
+
|
38
|
+
it "does nothing if element does not support :select or :set methods" do
|
39
|
+
@tp.feed_standalone_cool_button(:loud)
|
33
40
|
@b.text_field(:id => 'f1').value.should eq 'Default text.'
|
34
41
|
@b.textarea(:id => 'f2').value.should eq "Default text.\n"
|
35
42
|
@b.radio(:id => 'f3').should_not be_set
|
@@ -39,9 +46,46 @@ describe "page_object.feed_xxx" do
|
|
39
46
|
@b.select(:id => 'f10').value.should eq 'two (default)'
|
40
47
|
@b.select(:id => 'f11').value.should eq 'two (default)'
|
41
48
|
end
|
49
|
+
|
50
|
+
it "FEEDS elements which has provided menu" do
|
51
|
+
@tp.feed_tf_standalone(:loud)
|
52
|
+
@b.text_field(:id => 'f1').value.should eq 'tf food'
|
53
|
+
end
|
54
|
+
|
55
|
+
it "feeds ONLY elements which has provided menu" do
|
56
|
+
@tp.feed_tf_standalone(:quite)
|
57
|
+
@b.text_field(:id => 'f1').value.should eq 'Default text.'
|
58
|
+
@b.textarea(:id => 'f2').value.should eq "Default text.\n"
|
59
|
+
@b.radio(:id => 'f4').should be_set
|
60
|
+
@b.checkbox(:id => 'f6').should be_set
|
61
|
+
@b.select(:id => 'f11').value.should eq 'two (default)'
|
62
|
+
end
|
63
|
+
|
64
|
+
it "overrides defined menu when passing arguments" do
|
65
|
+
@tp.feed_tf_standalone(:loud, :tf_standalone => 'cheef menu')
|
66
|
+
@b.text_field(:id => 'f1').value.should eq 'cheef menu'
|
67
|
+
end
|
68
|
+
|
69
|
+
it "can be used without providing a menu" do
|
70
|
+
@tp.feed_tf_standalone(:tf_standalone => 'cheef menu')
|
71
|
+
@b.text_field(:id => 'f1').value.should eq 'cheef menu'
|
72
|
+
end
|
42
73
|
end
|
43
74
|
|
44
|
-
describe "
|
75
|
+
describe "feed_elements_set" do
|
76
|
+
it "does nothing if menu not spesified" do
|
77
|
+
@tp.feed_test_elements
|
78
|
+
@tp.feed_all
|
79
|
+
@b.text_field(:id => 'f1').value.should eq 'Default text.'
|
80
|
+
@b.textarea(:id => 'f2').value.should eq "Default text.\n"
|
81
|
+
@b.radio(:id => 'f3').should_not be_set
|
82
|
+
@b.radio(:id => 'f4').should be_set
|
83
|
+
@b.checkbox(:id => 'f5').should_not be_set
|
84
|
+
@b.checkbox(:id => 'f6').should be_set
|
85
|
+
@b.select(:id => 'f10').value.should eq 'two (default)'
|
86
|
+
@b.select(:id => 'f11').value.should eq 'two (default)'
|
87
|
+
end
|
88
|
+
|
45
89
|
it "FEEDS elements which has provided menu" do
|
46
90
|
@tp.feed_test_elements(:loud)
|
47
91
|
@b.text_field(:id => 'f1').value.should eq 'tf food'
|
@@ -79,5 +123,56 @@ describe "page_object.feed_xxx" do
|
|
79
123
|
@b.select(:id => 'f11').value.should eq 'three'
|
80
124
|
end
|
81
125
|
end
|
126
|
+
|
127
|
+
describe "feed_all" do
|
128
|
+
it "does nothing if menu not spesified" do
|
129
|
+
@tp.feed_all
|
130
|
+
@b.text_field(:id => 'f1').value.should eq 'Default text.'
|
131
|
+
@b.textarea(:id => 'f2').value.should eq "Default text.\n"
|
132
|
+
@b.radio(:id => 'f3').should_not be_set
|
133
|
+
@b.radio(:id => 'f4').should be_set
|
134
|
+
@b.checkbox(:id => 'f5').should_not be_set
|
135
|
+
@b.checkbox(:id => 'f6').should be_set
|
136
|
+
@b.select(:id => 'f10').value.should eq 'two (default)'
|
137
|
+
@b.select(:id => 'f11').value.should eq 'two (default)'
|
138
|
+
end
|
139
|
+
|
140
|
+
it "FEEDS elements which has provided menu" do
|
141
|
+
@tp.feed_all(:loud)
|
142
|
+
@b.text_field(:id => 'f1').value.should eq 'tf food'
|
143
|
+
@b.textarea(:id => 'f2').value.should eq "ta food"
|
144
|
+
@b.radio(:id => 'f3').should be_set
|
145
|
+
@b.radio(:id => 'f4').should_not be_set
|
146
|
+
@b.checkbox(:id => 'f5').should be_set
|
147
|
+
@b.checkbox(:id => 'f6').should_not be_set
|
148
|
+
@b.select(:id => 'f10').value.should eq 'one'
|
149
|
+
@b.select(:id => 'f11').value.should eq 'one'
|
150
|
+
end
|
151
|
+
|
152
|
+
it "feeds ONLY elements which has provided menu" do
|
153
|
+
@tp.feed_all(:quite)
|
154
|
+
@b.text_field(:id => 'f1').value.should eq 'Default text.'
|
155
|
+
@b.textarea(:id => 'f2').value.should eq "Default text.\n"
|
156
|
+
@b.radio(:id => 'f4').should be_set
|
157
|
+
@b.checkbox(:id => 'f6').should be_set
|
158
|
+
@b.select(:id => 'f11').value.should eq 'two (default)'
|
159
|
+
end
|
160
|
+
|
161
|
+
it "overrides defined menu when passing arguments" do
|
162
|
+
@tp.feed_all(:loud, :tf => 'cheef menu', :rb1 => false, :rb2 => true, :cb2 => true, :s2 => 'three')
|
163
|
+
@b.text_field(:id => 'f1').value.should eq 'cheef menu'
|
164
|
+
@b.radio(:id => 'f4').should be_set
|
165
|
+
@b.checkbox(:id => 'f6').should be_set
|
166
|
+
@b.select(:id => 'f11').value.should eq 'three'
|
167
|
+
end
|
168
|
+
|
169
|
+
it "can be used without providing a menu" do
|
170
|
+
@tp.feed_all(:tf => 'cheef menu', :rb2 => true, :cb2 => true, :s2 => 'three')
|
171
|
+
@b.text_field(:id => 'f1').value.should eq 'cheef menu'
|
172
|
+
@b.radio(:id => 'f4').should be_set
|
173
|
+
@b.checkbox(:id => 'f6').should be_set
|
174
|
+
@b.select(:id => 'f11').value.should eq 'three'
|
175
|
+
end
|
176
|
+
end
|
82
177
|
end
|
83
178
|
end
|
data/spec/load_spec.rb
CHANGED
@@ -10,26 +10,35 @@ describe "PageObjectWrapper.load" do
|
|
10
10
|
begin
|
11
11
|
PageObjectWrapper.load(File.dirname(__FILE__)+'/../bad_pages')
|
12
12
|
rescue Exception => e
|
13
|
-
#
|
14
|
-
#
|
15
|
-
#
|
13
|
+
# puts '=============='
|
14
|
+
# puts e.message
|
15
|
+
# puts '=============='
|
16
16
|
e.should be_a(PageObjectWrapper::Load)
|
17
17
|
e.message.should == 'page_object("some_page_with_lost_of_errors"):
|
18
18
|
label "some_page_with_lost_of_errors" not a Symbol
|
19
19
|
locator "" not a meaningful String
|
20
20
|
elements_set("some elements_set label"):
|
21
21
|
label "some elements_set label" not a Symbol
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
element
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
22
|
+
element(:bad_required_flad):
|
23
|
+
locator nil not a meaningful Hash or String
|
24
|
+
required flag "a string" not a true | false
|
25
|
+
element(""):
|
26
|
+
element "" already defined
|
27
|
+
label "" not a Symbol
|
28
|
+
locator nil not a meaningful Hash or String
|
29
|
+
menu {:fresh_food=>[]} not properly defined (must be { :food_type => \'a string\' | true | false })
|
30
|
+
element(:e):
|
31
|
+
element :e already defined
|
32
|
+
menu {"a string"=>"another string"} not properly defined (must be { :food_type => \'a string\' | true | false })
|
33
|
+
element(:e):
|
34
|
+
element :e already defined
|
35
|
+
locator {} not a meaningful Hash or String
|
36
|
+
element(""):
|
37
|
+
element "" already defined
|
38
|
+
label "" not a Symbol
|
39
|
+
locator nil not a meaningful Hash or String
|
40
|
+
element(:some_table):
|
41
|
+
locator nil not a meaningful Hash or String
|
33
42
|
action(""):
|
34
43
|
label "" not a Symbol
|
35
44
|
next_page "a string" not a Symbol
|
@@ -41,11 +50,7 @@ alias(""):
|
|
41
50
|
action "unknown action" not known Action
|
42
51
|
validator(""):
|
43
52
|
label "" not a Symbol
|
44
|
-
table(""):
|
45
|
-
label "" not a Symbol
|
46
|
-
locator nil not a meaningful Hash or String
|
47
53
|
table(:some_table):
|
48
|
-
locator nil not a meaningful Hash or String
|
49
54
|
header [] not a meaningful Array
|
50
55
|
pagination(""):
|
51
56
|
label "" not a Symbol
|
@@ -0,0 +1,61 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe "page_object.press_xxx" do
|
4
|
+
context "browser is closed" do
|
5
|
+
it "raises PageObjectWrapper::BrowserNotFound" do
|
6
|
+
tp = PageObjectWrapper.receive_page(:some_test_page)
|
7
|
+
expect{ tp.press_standalone_cool_button }.to raise_error(PageObjectWrapper::BrowserNotFound)
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
context "browser is opened" do
|
12
|
+
before(:all){
|
13
|
+
@b = Watir::Browser.new
|
14
|
+
PageObjectWrapper.use_browser @b
|
15
|
+
}
|
16
|
+
before(:each){ @tp = PageObjectWrapper.open_page(:some_test_page) }
|
17
|
+
after(:all){ PageObjectWrapper.browser.quit }
|
18
|
+
let(:tp){ PageObjectWrapper.current_page }
|
19
|
+
|
20
|
+
context "xxx not found among current_page elements" do
|
21
|
+
it "raises NoMethodError" do
|
22
|
+
expect{ tp.press_nonexistent_element }.to raise_error(NoMethodError)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
context "element does not respond to user action" do
|
27
|
+
it "raises InvalidElement error" do
|
28
|
+
expect{ tp.press_invalid_press_action_button }.to raise_error(PageObjectWrapper::InvalidElement)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
context "element does not present" do
|
33
|
+
it "raises InvalidElement error" do
|
34
|
+
expect{ tp.press_invalid_button }.to raise_error(PageObjectWrapper::InvalidElement)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
context "basic usage" do
|
39
|
+
|
40
|
+
it "returns pressed watir element" do
|
41
|
+
tp.press_cool_button.should be_a Watir::Button
|
42
|
+
end
|
43
|
+
|
44
|
+
it "really presses the element" do
|
45
|
+
tp.press_standalone_cool_button_with_default_press_action
|
46
|
+
PageObjectWrapper.current_page?(:test_page_with_table).should be_true
|
47
|
+
end
|
48
|
+
|
49
|
+
it "presses with user defined action" do
|
50
|
+
tp.press_standalone_cool_button
|
51
|
+
PageObjectWrapper.current_page?(:test_page_with_table).should be_true
|
52
|
+
end
|
53
|
+
|
54
|
+
it "presses element inside an elements_set" do
|
55
|
+
tp.press_cool_button
|
56
|
+
PageObjectWrapper.current_page?(:test_page_with_table).should be_true
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
@@ -0,0 +1,65 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe "page_object required elements" do
|
4
|
+
describe "required elements are checked during .open_page" do
|
5
|
+
|
6
|
+
context "browser is closed" do
|
7
|
+
it "raises PageObjectWrapper::BrowserNotFound" do
|
8
|
+
tp = PageObjectWrapper.receive_page(:some_test_page)
|
9
|
+
expect{ PageObjectWrapper.open_page :some_test_page }.to raise_error(PageObjectWrapper::BrowserNotFound)
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
context "browser is opened" do
|
14
|
+
before(:all){
|
15
|
+
@b = Watir::Browser.new
|
16
|
+
PageObjectWrapper.use_browser @b
|
17
|
+
}
|
18
|
+
|
19
|
+
after(:all){ PageObjectWrapper.browser.quit }
|
20
|
+
|
21
|
+
context "one of required elements not found" do
|
22
|
+
it "raises UnmappedPageObject error" do
|
23
|
+
expect{ PageObjectWrapper.open_page :required_missing }.to raise_error(PageObjectWrapper::UnmappedPageObject)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
context "one of uniq elements not found" do
|
28
|
+
it "raises UnmappedPageObject error" do
|
29
|
+
expect{ PageObjectWrapper.open_page :uniq_missing }.to raise_error(PageObjectWrapper::UnmappedPageObject)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
describe "required elements are checked during .current_page?" do
|
36
|
+
context "browser is closed" do
|
37
|
+
it "raises PageObjectWrapper::BrowserNotFound" do
|
38
|
+
tp = PageObjectWrapper.receive_page(:some_test_page)
|
39
|
+
expect{ PageObjectWrapper.current_page? :some_test_page }.to raise_error(Watir::Exception::Error)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
context "browser is opened" do
|
44
|
+
before(:all){
|
45
|
+
@b = Watir::Browser.new
|
46
|
+
PageObjectWrapper.use_browser @b
|
47
|
+
}
|
48
|
+
|
49
|
+
after(:all){ PageObjectWrapper.browser.quit }
|
50
|
+
before(:all){ PageObjectWrapper.open_page :some_test_page }
|
51
|
+
|
52
|
+
context "one of required elements not found" do
|
53
|
+
it "raises UnmappedPageObject error" do
|
54
|
+
expect{ PageObjectWrapper.current_page? :required_missing }.to raise_error(PageObjectWrapper::UnmappedPageObject)
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
context "one of uniq elements not found" do
|
59
|
+
it "raises UnmappedPageObject error" do
|
60
|
+
expect{ PageObjectWrapper.current_page? :uniq_missing }.to raise_error(PageObjectWrapper::UnmappedPageObject)
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
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
|
+
version: 1.4.0
|
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-14 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: watir-webdriver
|
16
|
-
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirement: &20221960 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,15 +21,10 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements:
|
25
|
-
none: false
|
26
|
-
requirements:
|
27
|
-
- - ! '>='
|
28
|
-
- !ruby/object:Gem::Version
|
29
|
-
version: '0'
|
24
|
+
version_requirements: *20221960
|
30
25
|
- !ruby/object:Gem::Dependency
|
31
26
|
name: activesupport
|
32
|
-
requirement: !ruby/object:Gem::Requirement
|
27
|
+
requirement: &20221520 !ruby/object:Gem::Requirement
|
33
28
|
none: false
|
34
29
|
requirements:
|
35
30
|
- - ! '>='
|
@@ -37,15 +32,10 @@ dependencies:
|
|
37
32
|
version: '0'
|
38
33
|
type: :runtime
|
39
34
|
prerelease: false
|
40
|
-
version_requirements:
|
41
|
-
none: false
|
42
|
-
requirements:
|
43
|
-
- - ! '>='
|
44
|
-
- !ruby/object:Gem::Version
|
45
|
-
version: '0'
|
35
|
+
version_requirements: *20221520
|
46
36
|
- !ruby/object:Gem::Dependency
|
47
37
|
name: babosa
|
48
|
-
requirement: !ruby/object:Gem::Requirement
|
38
|
+
requirement: &20220960 !ruby/object:Gem::Requirement
|
49
39
|
none: false
|
50
40
|
requirements:
|
51
41
|
- - ! '>='
|
@@ -53,15 +43,10 @@ dependencies:
|
|
53
43
|
version: '0'
|
54
44
|
type: :runtime
|
55
45
|
prerelease: false
|
56
|
-
version_requirements:
|
57
|
-
none: false
|
58
|
-
requirements:
|
59
|
-
- - ! '>='
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
version: '0'
|
46
|
+
version_requirements: *20220960
|
62
47
|
- !ruby/object:Gem::Dependency
|
63
48
|
name: rspec
|
64
|
-
requirement: !ruby/object:Gem::Requirement
|
49
|
+
requirement: &20220180 !ruby/object:Gem::Requirement
|
65
50
|
none: false
|
66
51
|
requirements:
|
67
52
|
- - ! '>='
|
@@ -69,15 +54,10 @@ dependencies:
|
|
69
54
|
version: 2.0.0
|
70
55
|
type: :development
|
71
56
|
prerelease: false
|
72
|
-
version_requirements:
|
73
|
-
none: false
|
74
|
-
requirements:
|
75
|
-
- - ! '>='
|
76
|
-
- !ruby/object:Gem::Version
|
77
|
-
version: 2.0.0
|
57
|
+
version_requirements: *20220180
|
78
58
|
- !ruby/object:Gem::Dependency
|
79
59
|
name: debugger
|
80
|
-
requirement: !ruby/object:Gem::Requirement
|
60
|
+
requirement: &20219440 !ruby/object:Gem::Requirement
|
81
61
|
none: false
|
82
62
|
requirements:
|
83
63
|
- - ! '>='
|
@@ -85,12 +65,7 @@ dependencies:
|
|
85
65
|
version: '0'
|
86
66
|
type: :development
|
87
67
|
prerelease: false
|
88
|
-
version_requirements:
|
89
|
-
none: false
|
90
|
-
requirements:
|
91
|
-
- - ! '>='
|
92
|
-
- !ruby/object:Gem::Version
|
93
|
-
version: '0'
|
68
|
+
version_requirements: *20219440
|
94
69
|
description: Wraps watir-webdriver with convenient testing interface, based on PageObjects
|
95
70
|
automation testing pattern. Simplifies resulting automated test understanding.
|
96
71
|
email:
|
@@ -111,9 +86,11 @@ files:
|
|
111
86
|
- good_pages/google_wrong_uniq_page.rb
|
112
87
|
- good_pages/goole_as_page.rb
|
113
88
|
- good_pages/pagination_example_page.rb
|
89
|
+
- good_pages/required_missing_page.rb
|
114
90
|
- good_pages/some_test_page.html
|
115
91
|
- good_pages/some_test_page.rb
|
116
92
|
- good_pages/test_table_page.rb
|
93
|
+
- good_pages/uniq_missing_page.rb
|
117
94
|
- img/scheme.png
|
118
95
|
- lib/page_object_wrapper.rb
|
119
96
|
- lib/page_object_wrapper/Action.rb
|
@@ -136,6 +113,8 @@ files:
|
|
136
113
|
- spec/load_spec.rb
|
137
114
|
- spec/menu_xxx_spec.rb
|
138
115
|
- spec/open_page_spec.rb
|
116
|
+
- spec/press_xxx_spec.rb
|
117
|
+
- spec/required_elements_spec.rb
|
139
118
|
- spec/select_from_xxx_spec.rb
|
140
119
|
- spec/shared_examples.rb
|
141
120
|
- spec/spec_helper.rb
|
@@ -163,7 +142,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
163
142
|
version: '0'
|
164
143
|
requirements: []
|
165
144
|
rubyforge_project:
|
166
|
-
rubygems_version: 1.8.
|
145
|
+
rubygems_version: 1.8.15
|
167
146
|
signing_key:
|
168
147
|
specification_version: 3
|
169
148
|
summary: Wraps watir-webdriver with convenient testing interface.
|
@@ -175,6 +154,8 @@ test_files:
|
|
175
154
|
- spec/load_spec.rb
|
176
155
|
- spec/menu_xxx_spec.rb
|
177
156
|
- spec/open_page_spec.rb
|
157
|
+
- spec/press_xxx_spec.rb
|
158
|
+
- spec/required_elements_spec.rb
|
178
159
|
- spec/select_from_xxx_spec.rb
|
179
160
|
- spec/shared_examples.rb
|
180
161
|
- spec/spec_helper.rb
|