page_object_wrapper 0.0.1 → 0.0.2
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/.gitignore +6 -0
- data/README.md +352 -1
- data/lib/page_object_wrapper.rb +96 -3
- data/lib/page_object_wrapper/Distribution.rb +43 -0
- data/lib/page_object_wrapper/DynamicClass.rb +31 -0
- data/lib/page_object_wrapper/Editable.rb +13 -0
- data/lib/page_object_wrapper/Exceptions.rb +22 -0
- data/lib/page_object_wrapper/Form.rb +116 -0
- data/lib/page_object_wrapper/Pagination.rb +59 -0
- data/lib/page_object_wrapper/Submitter.rb +8 -0
- data/lib/page_object_wrapper/Table.rb +50 -0
- data/lib/page_object_wrapper/version.rb +1 -1
- data/page_object_wrapper.gemspec +2 -1
- data/spec/example_spec.rb +42 -0
- data/spec/form_spec.rb +176 -0
- data/spec/page_object_spec.rb +173 -0
- data/spec/pagination_spec.rb +14 -0
- data/spec/spec_helper.rb +15 -0
- data/spec/table_spec.rb +52 -0
- data/spec/test_data_spec.rb +38 -0
- metadata +39 -5
@@ -0,0 +1,173 @@
|
|
1
|
+
# -*- encoding : utf-8 -*-
|
2
|
+
require 'spec_helper'
|
3
|
+
|
4
|
+
describe "Page object" do
|
5
|
+
describe "PageObjectWrapper" do
|
6
|
+
let(:google_search_page_class){
|
7
|
+
class GoogleSearchPage < PageObjectWrapper::Page
|
8
|
+
attr_accessor :find_form
|
9
|
+
@url="/"
|
10
|
+
def initialize visit=false
|
11
|
+
super visit
|
12
|
+
end
|
13
|
+
end
|
14
|
+
GoogleSearchPage
|
15
|
+
}
|
16
|
+
|
17
|
+
it "has .start_browser method which puts Watir::Browser.new to Page.accessor by default", :code => 19..20 do
|
18
|
+
PageObjectWrapper.stop_browser # stoping browser of (before :suite) hook
|
19
|
+
PageObjectWrapper.start_browser
|
20
|
+
PageObjectWrapper::Page.accessor.should be_a(Watir::Browser)
|
21
|
+
PageObjectWrapper.stop_browser
|
22
|
+
end
|
23
|
+
|
24
|
+
it "has .stop_browser method which closes browser", :code => 26..27 do
|
25
|
+
PageObjectWrapper.start_browser
|
26
|
+
PageObjectWrapper.stop_browser
|
27
|
+
PageObjectWrapper::Page.accessor.should_not exist
|
28
|
+
end
|
29
|
+
|
30
|
+
it "has .restart_browser method which restart current browser", :code => 31..33 do
|
31
|
+
PageObjectWrapper.start_browser
|
32
|
+
PageObjectWrapper.restart_browser
|
33
|
+
PageObjectWrapper::Page.accessor.should be_a(Watir::Browser)
|
34
|
+
PageObjectWrapper.stop_browser
|
35
|
+
end
|
36
|
+
|
37
|
+
it "has .domain= method which reprsents the domain of DUT", :code => 39..41 do
|
38
|
+
PageObjectWrapper.start_browser
|
39
|
+
PageObjectWrapper.domain = 'www.google.com'
|
40
|
+
google_search_page_class.new(true)
|
41
|
+
PageObjectWrapper::Page.accessor.title.should eq('Google')
|
42
|
+
PageObjectWrapper.stop_browser
|
43
|
+
end
|
44
|
+
|
45
|
+
it "has .timeout= method which sets implicit timeout for webdriver (default is 5 sec)" do
|
46
|
+
pending "not working yet"
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
describe "PageObject class and instance in general", :code => 51..60 do
|
51
|
+
let(:page_object){
|
52
|
+
class GoogleSearchPage < PageObjectWrapper::Page
|
53
|
+
attr_accessor :find_form
|
54
|
+
@url="/"
|
55
|
+
def initialize visit=false
|
56
|
+
super visit
|
57
|
+
end
|
58
|
+
end
|
59
|
+
GoogleSearchPage
|
60
|
+
}
|
61
|
+
|
62
|
+
it "PageObject class has @url class variable which can be treated as Page specific path inside current domain", :code => 63 do
|
63
|
+
page_object.url.should eq('/')
|
64
|
+
end
|
65
|
+
|
66
|
+
it "init with \'true\' is similar to openning page in browser", :code => 68..69 do
|
67
|
+
PageObjectWrapper.start_browser
|
68
|
+
google_search_page = page_object.new(true)
|
69
|
+
page_object.accessor.title.should eq('Google')
|
70
|
+
end
|
71
|
+
|
72
|
+
it "init with \'false\' just returns new instanse, but does not opens browser on that page", :code => 74..75 do
|
73
|
+
PageObjectWrapper.restart_browser
|
74
|
+
google_search_page = page_object.new(false)
|
75
|
+
page_object.accessor.title.should_not eq('Google')
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
describe "expected element", :code => 80..103 do
|
80
|
+
let(:google_search_with_wrong_expected_element_page_class){
|
81
|
+
class NotGoogleSearchPage < PageObjectWrapper::Page
|
82
|
+
attr_accessor :find_form
|
83
|
+
@url="/"
|
84
|
+
expected_element :text_field, :name => 'some element that does not exist on the page'
|
85
|
+
|
86
|
+
def initialize visit=false
|
87
|
+
super visit
|
88
|
+
end
|
89
|
+
end
|
90
|
+
NotGoogleSearchPage
|
91
|
+
}
|
92
|
+
let(:google_search_with_correct_expected_element_page_class){
|
93
|
+
class GoogleSearchPage < PageObjectWrapper::Page
|
94
|
+
attr_accessor :find_form
|
95
|
+
@url="/"
|
96
|
+
expected_element :text_field, :name => 'q'
|
97
|
+
|
98
|
+
def initialize visit=false
|
99
|
+
super visit
|
100
|
+
end
|
101
|
+
end
|
102
|
+
GoogleSearchPage
|
103
|
+
}
|
104
|
+
|
105
|
+
it "should raise error when trying to init google_search_with_wrong_expected_element_page_class", :code => 106..113 do
|
106
|
+
begin
|
107
|
+
gsearch_page = google_search_with_wrong_expected_element_page_class.new(true)
|
108
|
+
rescue PageError => e
|
109
|
+
e.should be_a(PageError)
|
110
|
+
e.message.should =~ /PROBLEM:/
|
111
|
+
e.message.should =~ /PAGE:/
|
112
|
+
e.message.should =~ /URL:/
|
113
|
+
end
|
114
|
+
end
|
115
|
+
|
116
|
+
it "should init google_search_with_correct_expected_element_page_class successfully", :code => 117..118 do
|
117
|
+
gsearch_page = google_search_with_correct_expected_element_page_class.new(true)
|
118
|
+
gsearch_page.should be_a(google_search_with_correct_expected_element_page_class)
|
119
|
+
end
|
120
|
+
end
|
121
|
+
|
122
|
+
describe "creation of a PageObject method", :code => 123..163 do
|
123
|
+
let(:pages_definition){
|
124
|
+
class GoogleAdvancedSearchPage < PageObjectWrapper::Page
|
125
|
+
attr_accessor :as_form
|
126
|
+
@url="/advanced_search"
|
127
|
+
expected_element :text_field, :name => 'as_q'
|
128
|
+
def initialize visit=false
|
129
|
+
super visit
|
130
|
+
@as_form = form(GoogleResultsPage, {:name => 'f'})
|
131
|
+
@as_form.editable(:text_field, {:name => 'as_q'}, :with_words, 'with_words default value', true)
|
132
|
+
@as_form.editable(:text_field, {:name => 'as_epq'}, :with_phrase, 'with_phrase default value', true)
|
133
|
+
@as_form.editable(:text_field, {:name => 'as_oq'}, :with_any_word, 'with_any_word default value', false)
|
134
|
+
@as_form.submitter(:input, {:type => 'submit'})
|
135
|
+
end
|
136
|
+
end
|
137
|
+
|
138
|
+
class GoogleResultsPage < PageObjectWrapper::Page
|
139
|
+
@url="/"
|
140
|
+
expected_element :button, :name => 'btnG'
|
141
|
+
def initialize visit=false
|
142
|
+
super visit
|
143
|
+
end
|
144
|
+
|
145
|
+
def open_advanced_search
|
146
|
+
@@accessor.span(:id => 'ab_opt_icon').when_present.click
|
147
|
+
@@accessor.a(:id => 'ab_as').when_present.click
|
148
|
+
GoogleAdvancedSearchPage.new
|
149
|
+
end
|
150
|
+
end
|
151
|
+
|
152
|
+
class GoogleSearchPage < PageObjectWrapper::Page
|
153
|
+
attr_accessor :find_form
|
154
|
+
@url="/"
|
155
|
+
expected_element :text_field, :name => 'q'
|
156
|
+
def initialize visit=false
|
157
|
+
super visit
|
158
|
+
@find_form = form(GoogleResultsPage, {:action => '/search'})
|
159
|
+
@find_form.editable(:text_field, {:name => 'q'}, :seach_what, '@find_form default value', true)
|
160
|
+
end
|
161
|
+
end
|
162
|
+
{:gsearch_page_class => GoogleSearchPage, :gresults_page => GoogleResultsPage, :gadv_page => GoogleAdvancedSearchPage}
|
163
|
+
}
|
164
|
+
|
165
|
+
it "return value should be another PageObject instance", :code => 166..170 do
|
166
|
+
gsearch_page = pages_definition[:gsearch_page_class].new(true)
|
167
|
+
gsearch_page.find_form.fill_required
|
168
|
+
gresults_page = gsearch_page.find_form.submit(true)
|
169
|
+
gadv_page = gresults_page.open_advanced_search
|
170
|
+
gadv_page.should be_a(pages_definition[:gadv_page])
|
171
|
+
end
|
172
|
+
end
|
173
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
# -*- encoding : utf-8 -*-
|
2
|
+
require 'spec_helper'
|
3
|
+
describe "Pagination wrapper" do
|
4
|
+
describe "pagination definition" do
|
5
|
+
it "TODO" do
|
6
|
+
pending "Needs to be reimplemented. Current realization is fo rails apps only"
|
7
|
+
end
|
8
|
+
end
|
9
|
+
describe "pagination usage" do
|
10
|
+
it "TODO" do
|
11
|
+
pending "Needs to be reimplemented. Current realization is fo rails apps only"
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
# -*- encoding : utf-8 -*-
|
2
|
+
require "rspec"
|
3
|
+
require 'page_object_wrapper'
|
4
|
+
|
5
|
+
RSpec.configure do |config|
|
6
|
+
config.before(:suite) {
|
7
|
+
PageObjectWrapper.start_browser
|
8
|
+
PageObjectWrapper.domain = 'http://google.com'
|
9
|
+
}
|
10
|
+
|
11
|
+
config.after(:suite) {
|
12
|
+
PageObjectWrapper.stop_browser
|
13
|
+
}
|
14
|
+
end
|
15
|
+
|
data/spec/table_spec.rb
ADDED
@@ -0,0 +1,52 @@
|
|
1
|
+
# -*- encoding : utf-8 -*-
|
2
|
+
require 'spec_helper'
|
3
|
+
|
4
|
+
describe "Table wrapper", :code => 5..19 do
|
5
|
+
before :all do
|
6
|
+
PageObjectWrapper.domain = 'http://wiki.openqa.org'
|
7
|
+
end
|
8
|
+
let(:page_object){
|
9
|
+
class WatirPage < PageObjectWrapper::Page
|
10
|
+
attr_accessor :some_table
|
11
|
+
@url="/display/WTR/HTML+Elements+Supported+by+Watir"
|
12
|
+
expected_element :a, :text => 'HTML Elements Supported by Watir'
|
13
|
+
def initialize visit=false
|
14
|
+
super visit
|
15
|
+
@some_table = table(:class => 'confluenceTable')
|
16
|
+
end
|
17
|
+
end
|
18
|
+
WatirPage
|
19
|
+
}
|
20
|
+
|
21
|
+
describe "table definition" do
|
22
|
+
it "has #table(how_find_hash) method to define a table on the page", :code => 15 do
|
23
|
+
page = page_object.new(true)
|
24
|
+
page.some_table.should be_a(Table)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
describe "table usage" do
|
28
|
+
it "has #cells method which returns all Watir table cells", :code => 29..30 do
|
29
|
+
page = page_object.new(true)
|
30
|
+
page.some_table.cells.first.should be_a(Watir::TableCell)
|
31
|
+
end
|
32
|
+
|
33
|
+
it "has #has_cell?(text) method wich returns true if the table has a cell with specified text", :code => 34..35 do
|
34
|
+
page = page_object.new(true)
|
35
|
+
page.some_table.should have_cell('<td>')
|
36
|
+
end
|
37
|
+
|
38
|
+
it "has #select(column_name, where_hash) method wich returns cell inside specified column wich corresponds to a specified where_hash", :code => 39..42 do
|
39
|
+
page = page_object.new(true)
|
40
|
+
cell = page.some_table.select('HTML tag', :where => {'Watir method' => 'cell'})
|
41
|
+
cell.should be_a(Watir::TableCell)
|
42
|
+
cell.text.should eq '<td>'
|
43
|
+
end
|
44
|
+
|
45
|
+
it "is possible to specify just parts of column names in #select method", :code => 47 do
|
46
|
+
page = page_object.new(true)
|
47
|
+
cell = page.some_table.select('HTML', :where => {'Watir met' => 'cell'})
|
48
|
+
cell.should be_a(Watir::TableCell)
|
49
|
+
cell.text.should eq '<td>'
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'yaml'
|
3
|
+
|
4
|
+
describe "TestData class", :code => 5..16 do
|
5
|
+
let(:user1){
|
6
|
+
"login: user1
|
7
|
+
email: user1@example.com
|
8
|
+
password: secret1
|
9
|
+
etc: other data"
|
10
|
+
}
|
11
|
+
let(:user2){
|
12
|
+
"login: user2
|
13
|
+
email: user2@example.com
|
14
|
+
password: secret2
|
15
|
+
etc: other data"
|
16
|
+
}
|
17
|
+
it "is initialized with hash and generates dynamic attributes for an instance", :code => 18..22 do
|
18
|
+
dynamically_defined_user = PageObjectWrapper::TestData.new(YAML.load(user1))
|
19
|
+
dynamically_defined_user.login.should eq 'user1'
|
20
|
+
dynamically_defined_user.email.should eq 'user1@example.com'
|
21
|
+
dynamically_defined_user.password.should eq 'secret1'
|
22
|
+
dynamically_defined_user.etc.should eq 'other data'
|
23
|
+
end
|
24
|
+
|
25
|
+
it "has .find method which allows finding dynamically defined objects", :code => 26..29 do
|
26
|
+
dynamically_defined_user1 = PageObjectWrapper::TestData.new(YAML.load(user1))
|
27
|
+
dynamically_defined_user2 = PageObjectWrapper::TestData.new(YAML.load(user2))
|
28
|
+
user1 = PageObjectWrapper::TestData.find(:login,'user1')
|
29
|
+
user1.email.should eq 'user1@example.com'
|
30
|
+
end
|
31
|
+
it "has .each method which allows navigating between objects", :code => 32..36 do
|
32
|
+
dynamically_defined_user1 = PageObjectWrapper::TestData.new(YAML.load(user1))
|
33
|
+
dynamically_defined_user2 = PageObjectWrapper::TestData.new(YAML.load(user2))
|
34
|
+
PageObjectWrapper::TestData.each{|user|
|
35
|
+
user.etc.should eq 'other data'
|
36
|
+
}
|
37
|
+
end
|
38
|
+
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: 0.0.
|
4
|
+
version: 0.0.2
|
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: 2012-11-
|
12
|
+
date: 2012-11-25 00:00:00.000000000Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: watir-webdriver
|
16
|
-
requirement: &
|
16
|
+
requirement: &10599620 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,7 +21,18 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *10599620
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: rspec
|
27
|
+
requirement: &10598840 !ruby/object:Gem::Requirement
|
28
|
+
none: false
|
29
|
+
requirements:
|
30
|
+
- - ! '>='
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: 2.0.0
|
33
|
+
type: :development
|
34
|
+
prerelease: false
|
35
|
+
version_requirements: *10598840
|
25
36
|
description: Wraps watir-webdriver with convenient testing interface, based on PageObjects
|
26
37
|
automation testing pattern. Simplifies resulting automated test understanding.
|
27
38
|
email:
|
@@ -36,14 +47,30 @@ files:
|
|
36
47
|
- README.md
|
37
48
|
- Rakefile
|
38
49
|
- lib/page_object_wrapper.rb
|
50
|
+
- lib/page_object_wrapper/Distribution.rb
|
51
|
+
- lib/page_object_wrapper/DynamicClass.rb
|
52
|
+
- lib/page_object_wrapper/Editable.rb
|
53
|
+
- lib/page_object_wrapper/Exceptions.rb
|
54
|
+
- lib/page_object_wrapper/Form.rb
|
55
|
+
- lib/page_object_wrapper/Pagination.rb
|
56
|
+
- lib/page_object_wrapper/Submitter.rb
|
57
|
+
- lib/page_object_wrapper/Table.rb
|
39
58
|
- lib/page_object_wrapper/version.rb
|
40
59
|
- page_object_wrapper.gemspec
|
60
|
+
- spec/example_spec.rb
|
61
|
+
- spec/form_spec.rb
|
62
|
+
- spec/page_object_spec.rb
|
63
|
+
- spec/pagination_spec.rb
|
64
|
+
- spec/spec_helper.rb
|
65
|
+
- spec/table_spec.rb
|
66
|
+
- spec/test_data_spec.rb
|
41
67
|
homepage: https://github.com/evgeniy-khatko/page_object_wrapper
|
42
68
|
licenses: []
|
43
69
|
post_install_message:
|
44
70
|
rdoc_options: []
|
45
71
|
require_paths:
|
46
72
|
- lib
|
73
|
+
- lib/page_object_wrapper
|
47
74
|
required_ruby_version: !ruby/object:Gem::Requirement
|
48
75
|
none: false
|
49
76
|
requirements:
|
@@ -62,4 +89,11 @@ rubygems_version: 1.8.15
|
|
62
89
|
signing_key:
|
63
90
|
specification_version: 3
|
64
91
|
summary: Wraps watir-webdriver with convenient testing interface.
|
65
|
-
test_files:
|
92
|
+
test_files:
|
93
|
+
- spec/example_spec.rb
|
94
|
+
- spec/form_spec.rb
|
95
|
+
- spec/page_object_spec.rb
|
96
|
+
- spec/pagination_spec.rb
|
97
|
+
- spec/spec_helper.rb
|
98
|
+
- spec/table_spec.rb
|
99
|
+
- spec/test_data_spec.rb
|