page_object_wrapper 0.0.6 → 1.0.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 +180 -340
- data/bad_pages/bad_page.rb +34 -0
- data/good_pages/another_test_page.rb +14 -0
- data/good_pages/some_test_page.rb +53 -0
- data/good_pages/test_table_page.rb +12 -0
- data/img/scheme.png +0 -0
- data/lib/page_object_wrapper.rb +57 -92
- data/lib/page_object_wrapper/Action.rb +11 -0
- data/lib/page_object_wrapper/Dsl.rb +35 -0
- data/lib/page_object_wrapper/Element.rb +15 -0
- data/lib/page_object_wrapper/ElementsSet.rb +22 -0
- data/lib/page_object_wrapper/Exceptions.rb +7 -21
- data/lib/page_object_wrapper/PageObject.rb +371 -0
- data/lib/page_object_wrapper/Pagination.rb +6 -57
- data/lib/page_object_wrapper/Table.rb +13 -48
- data/lib/page_object_wrapper/known_elements.rb +31 -0
- data/lib/page_object_wrapper/version.rb +1 -1
- data/spec/define_page_object_spec.rb +162 -0
- data/spec/defined_elements_spec.rb +77 -0
- data/spec/feed_elements_spec.rb +95 -0
- data/spec/fire_event_spec.rb +53 -0
- data/spec/generate_spec.rb +20 -0
- data/spec/load_spec.rb +46 -0
- data/spec/open_spec.rb +70 -0
- data/spec/select_from_spec.rb +84 -0
- data/spec/shared_examples.rb +12 -0
- data/spec/spec_helper.rb +2 -15
- metadata +35 -27
- data/Gemfile +0 -4
- data/LICENSE.txt +0 -22
- data/Rakefile +0 -1
- data/lib/page_object_wrapper/Distribution.rb +0 -43
- data/lib/page_object_wrapper/DynamicClass.rb +0 -31
- data/lib/page_object_wrapper/Editable.rb +0 -13
- data/lib/page_object_wrapper/Form.rb +0 -116
- data/lib/page_object_wrapper/Submitter.rb +0 -8
- data/page_object_wrapper.gemspec +0 -22
- data/spec/example_spec.rb +0 -42
- data/spec/form_spec.rb +0 -176
- data/spec/page_object_spec.rb +0 -173
- data/spec/pagination_spec.rb +0 -14
- data/spec/table_spec.rb +0 -52
- data/spec/test_data_spec.rb +0 -38
data/README.md
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
# PageObjectWrapper
|
2
2
|
|
3
|
-
Wraps watir-webdriver with convenient testing interface, based on PageObjects automation testing pattern. Simplifies resulting automated test understanding.
|
3
|
+
Wraps watir-webdriver with convenient testing interface, based on PageObjects automation testing pattern. Simplifies resulting automated test understanding.
|
4
|
+
*Warning:* version 1.0 and higher are not compatible with older versions
|
4
5
|
|
5
6
|
## Installation
|
6
7
|
|
@@ -19,354 +20,193 @@ Or install it yourself as:
|
|
19
20
|
$ gem install page_object_wrapper
|
20
21
|
|
21
22
|
## Usage
|
23
|
+
#####please look into specs for more detailed usage examples
|
22
24
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
def initialize visit=false
|
51
|
-
super visit
|
52
|
-
end
|
53
|
-
end
|
54
|
-
GoogleSearchPage
|
55
|
-
}
|
56
|
-
###PageObject class has @url class variable which can be treated as Page specific path inside current domain
|
57
|
-
page_object.url.should eq('/')
|
58
|
-
###init with 'true' is similar to openning page in browser
|
59
|
-
google_search_page = page_object.new(true)
|
60
|
-
page_object.accessor.title.should eq('Google')
|
61
|
-
###init with 'false' just returns new instanse, but does not opens browser on that page
|
62
|
-
google_search_page = page_object.new(false)
|
63
|
-
page_object.accessor.title.should_not eq('Google')
|
64
|
-
##expected element
|
65
|
-
let(:google_search_with_wrong_expected_element_page_class){
|
66
|
-
class NotGoogleSearchPage < PageObjectWrapper::Page
|
67
|
-
attr_accessor :find_form
|
68
|
-
@url="/"
|
69
|
-
expected_element :text_field, :name => 'some element that does not exist on the page'
|
70
|
-
|
71
|
-
def initialize visit=false
|
72
|
-
super visit
|
73
|
-
end
|
74
|
-
end
|
75
|
-
NotGoogleSearchPage
|
76
|
-
}
|
77
|
-
let(:google_search_with_correct_expected_element_page_class){
|
78
|
-
class GoogleSearchPage < PageObjectWrapper::Page
|
79
|
-
attr_accessor :find_form
|
80
|
-
@url="/"
|
81
|
-
expected_element :text_field, :name => 'q'
|
82
|
-
|
83
|
-
def initialize visit=false
|
84
|
-
super visit
|
85
|
-
end
|
86
|
-
end
|
87
|
-
GoogleSearchPage
|
88
|
-
}
|
89
|
-
###should raise error when trying to init google_search_with_wrong_expected_element_page_class
|
90
|
-
begin
|
91
|
-
gsearch_page = google_search_with_wrong_expected_element_page_class.new(true)
|
92
|
-
rescue PageError => e
|
93
|
-
e.should be_a(PageError)
|
94
|
-
e.message.should =~ /PROBLEM:/
|
95
|
-
e.message.should =~ /PAGE:/
|
96
|
-
e.message.should =~ /URL:/
|
97
|
-
end
|
98
|
-
###should init google_search_with_correct_expected_element_page_class successfully
|
99
|
-
gsearch_page = google_search_with_correct_expected_element_page_class.new(true)
|
100
|
-
gsearch_page.should be_a(google_search_with_correct_expected_element_page_class)
|
101
|
-
##creation of a PageObject method
|
102
|
-
let(:pages_definition){
|
103
|
-
class GoogleAdvancedSearchPage < PageObjectWrapper::Page
|
104
|
-
attr_accessor :as_form
|
105
|
-
@url="/advanced_search"
|
106
|
-
expected_element :text_field, :name => 'as_q'
|
107
|
-
def initialize visit=false
|
108
|
-
super visit
|
109
|
-
@as_form = form(GoogleResultsPage, {:name => 'f'})
|
110
|
-
@as_form.editable(:text_field, {:name => 'as_q'}, :with_words, 'with_words default value', true)
|
111
|
-
@as_form.editable(:text_field, {:name => 'as_epq'}, :with_phrase, 'with_phrase default value', true)
|
112
|
-
@as_form.editable(:text_field, {:name => 'as_oq'}, :with_any_word, 'with_any_word default value', false)
|
113
|
-
@as_form.submitter(:input, {:type => 'submit'})
|
114
|
-
end
|
115
|
-
end
|
116
|
-
|
117
|
-
class GoogleResultsPage < PageObjectWrapper::Page
|
118
|
-
@url="/"
|
119
|
-
expected_element :button, :name => 'btnG'
|
120
|
-
def initialize visit=false
|
121
|
-
super visit
|
122
|
-
end
|
123
|
-
|
124
|
-
def open_advanced_search
|
125
|
-
@@accessor.span(:id => 'ab_opt_icon').when_present.click
|
126
|
-
@@accessor.a(:id => 'ab_as').when_present.click
|
127
|
-
GoogleAdvancedSearchPage.new
|
128
|
-
end
|
129
|
-
end
|
130
|
-
|
131
|
-
class GoogleSearchPage < PageObjectWrapper::Page
|
132
|
-
attr_accessor :find_form
|
133
|
-
@url="/"
|
134
|
-
expected_element :text_field, :name => 'q'
|
135
|
-
def initialize visit=false
|
136
|
-
super visit
|
137
|
-
@find_form = form(GoogleResultsPage, {:action => '/search'})
|
138
|
-
@find_form.editable(:text_field, {:name => 'q'}, :seach_what, '@find_form default value', true)
|
139
|
-
end
|
140
|
-
end
|
141
|
-
{:gsearch_page_class => GoogleSearchPage, :gresults_page => GoogleResultsPage, :gadv_page => GoogleAdvancedSearchPage}
|
142
|
-
}
|
143
|
-
###return value should be another PageObject instance
|
144
|
-
gsearch_page = pages_definition[:gsearch_page_class].new(true)
|
145
|
-
gsearch_page.find_form.fill_required
|
146
|
-
gresults_page = gsearch_page.find_form.submit(true)
|
147
|
-
gadv_page = gresults_page.open_advanced_search
|
148
|
-
gadv_page.should be_a(pages_definition[:gadv_page])
|
149
|
-
|
150
|
-
#Form wrapper
|
151
|
-
|
152
|
-
##form definition
|
153
|
-
let(:page_objects){
|
154
|
-
class GoogleAdvancedSearchPage < PageObjectWrapper::Page
|
155
|
-
attr_accessor :as_form
|
156
|
-
@url="/advanced_search"
|
157
|
-
expected_element :text_field, :name => 'as_q'
|
158
|
-
def initialize visit=false
|
159
|
-
super visit
|
160
|
-
@as_form = form(GoogleResultsPage, {:name => 'f'})
|
161
|
-
@as_form.editable(:text_field, {:name => 'as_q'}, :with_words, 'with_words default value', true)
|
162
|
-
@as_form.editable(:text_field, {:name => 'as_epq'}, :with_phrase, 'with_phrase default value', true)
|
163
|
-
@as_form.editable(:text_field, {:name => 'as_oq'}, :with_any_word, 'with_any_word default value', false)
|
164
|
-
@as_form.submitter(:input, {:type => 'submit'})
|
165
|
-
end
|
25
|
+
### Basic usecase is following
|
26
|
+
1. Define page object with PageObjectWrapper.define\_page
|
27
|
+
2. Use defined page object inside your tests with usefull page\_object #methods
|
28
|
+
|
29
|
+
### Basic principles of a PageObjectWrapper
|
30
|
+
- there are following objects: page\_object, elements\_set with elements, table, action, pagination
|
31
|
+
- a page_object contains elements\_sets, tables, actions, paginations
|
32
|
+
- an elements\_set contains elements
|
33
|
+
- every object has a :label
|
34
|
+
- a label identifies the object
|
35
|
+
|
36
|
+
Here in the structure of PageObjectWrapper:
|
37
|
+

|
38
|
+
|
39
|
+
### Examples
|
40
|
+
|
41
|
+
#### definition example
|
42
|
+
|
43
|
+
PageObjectWrapper.define_page(:some_test_page) do
|
44
|
+
locator 'http://www.cs.tut.fi/~jkorpela/www/testel.html'
|
45
|
+
uniq_h1 :text => 'Testing display of HTML elements'
|
46
|
+
|
47
|
+
elements_set(:test_elements) do
|
48
|
+
text_field(:tf) do
|
49
|
+
locator :id => 'f1'
|
50
|
+
missing_food 'some missing food'
|
51
|
+
fresh_food 'some fresh food'
|
166
52
|
end
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
def initialize visit=false
|
171
|
-
super visit
|
172
|
-
@find_form = form(GoogleResultsPage, {:action => '/search'})
|
173
|
-
@find_form.editable(:text_field, {:name => 'q'}, :seach_what, '@find_form default value', true)
|
174
|
-
end
|
53
|
+
|
54
|
+
textarea(:ta) do
|
55
|
+
locator :id => 'f2'
|
175
56
|
end
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
###has #editable(:field_type, how_find_hash, :label, default_value, required?) method to set form's fields
|
182
|
-
### :field_type sets corresponding watir element type
|
183
|
-
### how_find_hash is used to locate corresponding watir element on the page
|
184
|
-
### :label is used to reffer to the form field after definition
|
185
|
-
### default_value is used to populate fields with default test data
|
186
|
-
### required = true | false and indicates if the field is required
|
187
|
-
###
|
188
|
-
@as_form.editable(:text_field, {:name => 'as_q'}, :with_words, 'with_words default value', true)
|
189
|
-
@as_form.editable(:text_field, {:name => 'as_epq'}, :with_phrase, 'with_phrase default value', true)
|
190
|
-
@as_form.editable(:text_field, {:name => 'as_oq'}, :with_any_word, 'with_any_word default value', false)
|
191
|
-
###has #submitter(:field_type, how_find_hash, how_click_mehtod, click_params) method to set form's submitter
|
192
|
-
### :field_type sets corresponding watir element type
|
193
|
-
### how_find_hash is used to locate corresponding watir element on the page
|
194
|
-
### how_click_mehtod is used to tell Waitr the method which should be applied to click the submitter
|
195
|
-
### click_params set parameters for the how_click_mehtod
|
196
|
-
###
|
197
|
-
@as_form.submitter(:input, {:type => 'submit'})
|
198
|
-
##form usage
|
199
|
-
let(:page_objects){
|
200
|
-
class GoogleAdvancedSearchPage < PageObjectWrapper::Page
|
201
|
-
attr_accessor :as_form
|
202
|
-
@url="/advanced_search"
|
203
|
-
expected_element :text_field, :name => 'as_q'
|
204
|
-
def initialize visit=false
|
205
|
-
super visit
|
206
|
-
@as_form = form(GoogleSearchPage, {:name => 'f'})
|
207
|
-
@as_form.editable(:text_field, {:name => 'as_q'}, :with_words, 'with_words default value', true)
|
208
|
-
@as_form.editable(:text_field, {:name => 'as_epq'}, :with_phrase, 'with_phrase default value', true)
|
209
|
-
@as_form.editable(:text_field, {:name => 'as_oq'}, :with_any_word, 'with_any_word default value', false)
|
210
|
-
@as_form.submitter(:input, {:type => 'submit'})
|
211
|
-
end
|
57
|
+
|
58
|
+
select(:s1) do
|
59
|
+
locator :id => 'f10'
|
60
|
+
fresh_food 'one'
|
61
|
+
missing_food 'three'
|
212
62
|
end
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
def initialize visit=false
|
218
|
-
super visit
|
219
|
-
@find_form = form(GoogleSearchPage, {:action => '/search'})
|
220
|
-
@find_form.editable(:text_field, {:name => 'q'}, :search_what, '@find_form default value', true)
|
221
|
-
end
|
63
|
+
|
64
|
+
select(:s2) do
|
65
|
+
locator :id => 'f11'
|
66
|
+
fresh_food 'one'
|
222
67
|
end
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
}
|
251
|
-
###has #fill_only(:label => value) method which populated form's :label field with 'value'
|
252
|
-
### method returns form object
|
253
|
-
###
|
254
|
-
form = gadv_page.as_form.fill_only(:with_words => 'some value')
|
255
|
-
gadv_page.as_form.with_words.value.should eq('some value')
|
256
|
-
###has #fill_all(:except => labels_array | label) method which populated all form's fields with default values
|
257
|
-
### if except_hash is not nil than provided fields are not populated
|
258
|
-
### method returns form object
|
259
|
-
###
|
260
|
-
form = gadv_page.as_form.fill_all
|
261
|
-
gadv_page.as_form.each{|field|
|
262
|
-
field.watir_element.value.should eq(gadv_page.as_form.default(field.label))
|
263
|
-
}
|
264
|
-
###has #fill_required(:except => labels_array | label) method which populated all required form's fields with default values
|
265
|
-
### if except_hash is not nil than provided fields are not populated
|
266
|
-
### method returns form object
|
267
|
-
###
|
268
|
-
gadv_page.as_form.fill_required(:except => :with_words)
|
269
|
-
gadv_page.as_form.each_required{|field|
|
270
|
-
if field.label==:with_words
|
271
|
-
field.watir_element.value.should eq ''
|
272
|
-
else
|
273
|
-
field.watir_element.value.should eq(gadv_page.as_form.default(field.label))
|
274
|
-
end
|
275
|
-
}
|
276
|
-
|
277
|
-
#Table wrapper
|
278
|
-
before :all do
|
279
|
-
PageObjectWrapper.domain = 'http://wiki.openqa.org'
|
68
|
+
|
69
|
+
checkbox(:cb){ locator :id => 'f5' }
|
70
|
+
radio(:rb){ locator :id => 'f3' }
|
71
|
+
|
72
|
+
end
|
73
|
+
|
74
|
+
action(:press_cool_button, :test_page_with_table) do
|
75
|
+
button(:name => 'foo').when_present.click
|
76
|
+
end
|
77
|
+
|
78
|
+
action(:fill_textarea, :some_test_page) do |fill_with|
|
79
|
+
data = (fill_with.empty?)? 'Default data' : fill_with
|
80
|
+
textarea(:id => 'f2').set data
|
81
|
+
end
|
82
|
+
|
83
|
+
table(:table_without_header) do
|
84
|
+
locator :summary => 'Each row names a Nordic country and specifies its total area and land area, in square kilometers'
|
85
|
+
end
|
86
|
+
|
87
|
+
table(:table_with_header) do
|
88
|
+
locator :summary => 'Each row names a Nordic country and specifies its total area and land area, in square kilometers'
|
89
|
+
header [:country, :total_area, :land_area]
|
90
|
+
end
|
91
|
+
|
92
|
+
pagination(:some_pagination) do
|
93
|
+
locator :xpath => ''
|
94
|
+
end
|
280
95
|
end
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
96
|
+
|
97
|
+
here we have defined a page object with locator (url) = 'http://www.cs.tut.fi/~jkorpela/www/testel.html'
|
98
|
+
uniq\_xxx is used to define a uniq element on that page, which uniquely identifies the page from other pages
|
99
|
+
uniq\_xxx is being checked when openning the page with PageObjectWrapper.open\_page and when running an page\_object.action
|
100
|
+
|
101
|
+
#### openning the page
|
102
|
+
*preconditions*
|
103
|
+
There is a directory, where we've defined a page\_object inside a \*\_page.rb file
|
104
|
+
|
105
|
+
1. specify browser to be used by PageObjectWrapper
|
106
|
+
@b = Watir::Browser.new
|
107
|
+
PageObjectWrapper.use_browser @b
|
108
|
+
2. load defined pages
|
109
|
+
PageObjectWrapper.load("path/to/pages/directory")
|
110
|
+
3. open page in browser
|
111
|
+
test_page = PageObjectWrapper.open_page(:some_test_page)
|
112
|
+
|
113
|
+
*comments*
|
114
|
+
- it's possible to use any Watir::Browser with any profile
|
115
|
+
- it's possible to use any Webdriver, which behaves like Watir::Browser (meaning that Webdriver uses similar methods for locating elements and working with them)
|
116
|
+
- .load method validates all pages, defined in specified directory inside any \*\_page.rb file
|
117
|
+
- it's possible to define several page objects in one file
|
118
|
+
- .open\_page method takes page label, directs browser to that page and returns corresponding page\_object
|
119
|
+
- PageObjectWrapper.current\_page points to the opened page\_object
|
120
|
+
|
121
|
+
#### feed\_xxx
|
122
|
+
*preconditions*
|
123
|
+
tp is a :some\_test\_page object opened in the browser
|
124
|
+
|
125
|
+
context "argument = :fresh_food" do
|
126
|
+
it "populates all xxx elements with :fresh_food" do
|
127
|
+
tp = PageObjectWrapper.current_page
|
128
|
+
tp.feed_test_elements(:fresh_food)
|
129
|
+
end
|
130
|
+
end
|
131
|
+
|
132
|
+
context "argument = nil" do
|
133
|
+
it "populates all xxx elements with :fresh_food" do
|
134
|
+
tp = PageObjectWrapper.current_page
|
135
|
+
tp.feed_test_elements
|
136
|
+
end
|
137
|
+
end
|
138
|
+
|
139
|
+
context "argument = :missing_food" do
|
140
|
+
it "populates all xxx elements with :missing_food" do
|
141
|
+
tp = PageObjectWrapper.open_page(:some_test_page)
|
142
|
+
tp.feed_test_elements(:missing_food)
|
143
|
+
end
|
144
|
+
end
|
145
|
+
|
146
|
+
|
147
|
+
#### fire\_xxx
|
148
|
+
*preconditions*
|
149
|
+
tp is a :some\_test\_page object opened in the browser
|
150
|
+
|
151
|
+
it "executes fire_block in Watir::Browser context" do
|
152
|
+
tp = PageObjectWrapper.open_page(:some_test_page)
|
153
|
+
tp.fire_fill_textarea
|
154
|
+
end
|
155
|
+
|
156
|
+
it "can be invoked with parameters" do
|
157
|
+
tp = PageObjectWrapper.current_page
|
158
|
+
tp.fire_fill_textarea('User defined data')
|
159
|
+
end
|
160
|
+
|
161
|
+
it "returns next_page" do
|
162
|
+
tp = PageObjectWrapper.current_page
|
163
|
+
np = tp.fire_press_cool_button
|
164
|
+
end
|
165
|
+
|
166
|
+
#### select\_from\_xxx
|
167
|
+
*preconditions*
|
168
|
+
tp is a :some\_test\_page object opened in the browser
|
169
|
+
its syntax is close to SQL *'select column1 from page\_object.some\_table where column2 = string\_or\_regexp'*
|
170
|
+
page\_object.select\_from\_xxx( :column1, :column2 => 'string\_or\_regexp' )
|
171
|
+
correct arguments are:
|
172
|
+
:column1 is a column value from which you want to receive
|
173
|
+
:column2 is a column which is used to get specific row
|
174
|
+
|
175
|
+
context "where == nil" do
|
176
|
+
it "returns last row value from provided column" do
|
177
|
+
tp.select_from_table_without_header(:column_0).text.should eq 'Sweden'
|
178
|
+
tp.select_from_table_without_header(:column_1).text.should eq '449,964'
|
179
|
+
tp.select_from_table_without_header(:column_2).text.should eq '410,928'
|
180
|
+
end
|
181
|
+
end
|
182
|
+
|
183
|
+
context "where not nil" do
|
184
|
+
context "found by String" do
|
185
|
+
it "returns found cells" do
|
186
|
+
tp.select_from_table_without_header(:column_0, :column_1 => '103,000').text.should eq 'Iceland'
|
187
|
+
tp.select_from_table_with_header(:country, :total_area => '337,030').text.should eq 'Finland'
|
188
|
+
end
|
189
|
+
it "returns nil" do
|
190
|
+
tp.select_from_table_without_header(:column_0, :column_1 => '123').should eq nil
|
191
|
+
tp.select_from_table_with_header(:country, :total_area => '123').should eq nil
|
290
192
|
end
|
291
|
-
WatirPage
|
292
|
-
}
|
293
|
-
##table definition
|
294
|
-
|
295
|
-
###has #table(how_find_hash) method to define a table on the page
|
296
|
-
@some_table = table(:class => 'confluenceTable')
|
297
|
-
##table usage
|
298
|
-
before :all do
|
299
|
-
PageObjectWrapper.domain = 'http://wiki.openqa.org'
|
300
193
|
end
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
expected_element :a, :text => 'HTML Elements Supported by Watir'
|
306
|
-
def initialize visit=false
|
307
|
-
super visit
|
308
|
-
@some_table = table(:class => 'confluenceTable')
|
309
|
-
end
|
194
|
+
context "found by Regexp" do
|
195
|
+
it "returns found cells" do
|
196
|
+
tp.select_from_table_without_header(:column_0, :column_1 => /103/).text.should eq 'Iceland'
|
197
|
+
tp.select_from_table_with_header(:country, :total_area => /337/).text.should eq 'Finland'
|
310
198
|
end
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
page = page_object.new(true)
|
318
|
-
page.some_table.should have_cell('<td>')
|
319
|
-
###has #select(column_name, where_hash) method wich returns cell inside specified column wich corresponds to a specified where_hash
|
320
|
-
page = page_object.new(true)
|
321
|
-
cell = page.some_table.select('HTML tag', :where => {'Watir method' => 'cell'})
|
322
|
-
cell.should be_a(Watir::TableCell)
|
323
|
-
cell.text.should eq '<td>'
|
324
|
-
###is possible to specify just parts of column names in #select method
|
325
|
-
cell = page.some_table.select('HTML', :where => {'Watir met' => 'cell'})
|
326
|
-
|
327
|
-
#Pagination wrapper
|
328
|
-
|
329
|
-
##pagination definition
|
330
|
-
|
331
|
-
###TODO
|
332
|
-
Needs to be reimplemented. Current realization is fo rails apps only
|
333
|
-
##pagination usage
|
334
|
-
|
335
|
-
###TODO
|
336
|
-
Needs to be reimplemented. Current realization is fo rails apps only
|
337
|
-
|
338
|
-
#TestData class
|
339
|
-
let(:user1){
|
340
|
-
"login: user1
|
341
|
-
email: user1@example.com
|
342
|
-
password: secret1
|
343
|
-
etc: other data"
|
344
|
-
}
|
345
|
-
let(:user2){
|
346
|
-
"login: user2
|
347
|
-
email: user2@example.com
|
348
|
-
password: secret2
|
349
|
-
etc: other data"
|
350
|
-
}
|
351
|
-
##is initialized with hash and generates dynamic attributes for an instance
|
352
|
-
dynamically_defined_user = PageObjectWrapper::TestData.new(YAML.load(user1))
|
353
|
-
dynamically_defined_user.login.should eq 'user1'
|
354
|
-
dynamically_defined_user.email.should eq 'user1@example.com'
|
355
|
-
dynamically_defined_user.password.should eq 'secret1'
|
356
|
-
dynamically_defined_user.etc.should eq 'other data'
|
357
|
-
##has .find method which allows finding dynamically defined objects
|
358
|
-
dynamically_defined_user1 = PageObjectWrapper::TestData.new(YAML.load(user1))
|
359
|
-
dynamically_defined_user2 = PageObjectWrapper::TestData.new(YAML.load(user2))
|
360
|
-
user1 = PageObjectWrapper::TestData.find(:login,'user1')
|
361
|
-
user1.email.should eq 'user1@example.com'
|
362
|
-
##has .each method which allows navigating between objects
|
363
|
-
dynamically_defined_user1 = PageObjectWrapper::TestData.new(YAML.load(user1))
|
364
|
-
dynamically_defined_user2 = PageObjectWrapper::TestData.new(YAML.load(user2))
|
365
|
-
PageObjectWrapper::TestData.each{|user|
|
366
|
-
user.etc.should eq 'other data'
|
367
|
-
}
|
368
|
-
|
199
|
+
it "returns nil" do
|
200
|
+
tp.select_from_table_without_header(:column_0, :column_1 => /123/).should eq nil
|
201
|
+
tp.select_from_table_with_header(:country, :total_area => /123/).should eq nil
|
202
|
+
end
|
203
|
+
end
|
204
|
+
end
|
369
205
|
|
206
|
+
#### each\_xxx
|
207
|
+
TODO
|
208
|
+
#### open\_xxx
|
209
|
+
TODO
|
370
210
|
## Contributing
|
371
211
|
|
372
212
|
1. Fork it
|
@@ -374,7 +214,7 @@ Or install it yourself as:
|
|
374
214
|
3. Commit your changes (`git commit -am 'Add some feature'`)
|
375
215
|
4. Push to the branch (`git push origin my-new-feature`)
|
376
216
|
5. Create new Pull Request
|
377
|
-
|
217
|
+
page\_object\_wrapper
|
378
218
|
===================
|
379
219
|
|
380
220
|
Wraps watir-webdriver with convenient testing interface, based on PageObjects automation testing pattern. Simplifies resulting automated test understanding.
|