centric_page_object 2.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.coveralls.yml +1 -0
- data/.gitignore +8 -0
- data/.rspec +2 -0
- data/.ruby-gemset +1 -0
- data/.ruby-version +1 -0
- data/.travis.yml +17 -0
- data/ChangeLog +931 -0
- data/Gemfile +12 -0
- data/Guardfile +20 -0
- data/LICENSE +20 -0
- data/README.md +114 -0
- data/Rakefile +29 -0
- data/centric_page_object.gemspec +31 -0
- data/cucumber.yml +8 -0
- data/lib/page-object/accessors.rb +1201 -0
- data/lib/page-object/element_locators.rb +21 -0
- data/lib/page-object/elements/area.rb +9 -0
- data/lib/page-object/elements/audio.rb +9 -0
- data/lib/page-object/elements/bold.rb +9 -0
- data/lib/page-object/elements/button.rb +12 -0
- data/lib/page-object/elements/canvas.rb +10 -0
- data/lib/page-object/elements/check_box.rb +9 -0
- data/lib/page-object/elements/date_field.rb +10 -0
- data/lib/page-object/elements/div.rb +9 -0
- data/lib/page-object/elements/element.rb +212 -0
- data/lib/page-object/elements/file_field.rb +9 -0
- data/lib/page-object/elements/form.rb +9 -0
- data/lib/page-object/elements/heading.rb +14 -0
- data/lib/page-object/elements/hidden_field.rb +9 -0
- data/lib/page-object/elements/image.rb +10 -0
- data/lib/page-object/elements/italic.rb +9 -0
- data/lib/page-object/elements/label.rb +9 -0
- data/lib/page-object/elements/link.rb +9 -0
- data/lib/page-object/elements/list_item.rb +9 -0
- data/lib/page-object/elements/media.rb +11 -0
- data/lib/page-object/elements/option.rb +9 -0
- data/lib/page-object/elements/ordered_list.rb +43 -0
- data/lib/page-object/elements/paragraph.rb +9 -0
- data/lib/page-object/elements/radio_button.rb +9 -0
- data/lib/page-object/elements/select_list.rb +42 -0
- data/lib/page-object/elements/span.rb +9 -0
- data/lib/page-object/elements/table.rb +85 -0
- data/lib/page-object/elements/table_cell.rb +10 -0
- data/lib/page-object/elements/table_row.rb +52 -0
- data/lib/page-object/elements/text_area.rb +9 -0
- data/lib/page-object/elements/text_field.rb +10 -0
- data/lib/page-object/elements/unordered_list.rb +42 -0
- data/lib/page-object/elements/video.rb +9 -0
- data/lib/page-object/elements.rb +62 -0
- data/lib/page-object/indexed_properties.rb +41 -0
- data/lib/page-object/javascript/angularjs.rb +14 -0
- data/lib/page-object/javascript/jquery.rb +14 -0
- data/lib/page-object/javascript/prototype.rb +14 -0
- data/lib/page-object/javascript/yui.rb +19 -0
- data/lib/page-object/javascript_framework_facade.rb +80 -0
- data/lib/page-object/locator_generator.rb +183 -0
- data/lib/page-object/nested_elements.rb +17 -0
- data/lib/page-object/page_factory.rb +108 -0
- data/lib/page-object/page_populator.rb +105 -0
- data/lib/page-object/platforms/watir/page_object.rb +1155 -0
- data/lib/page-object/platforms/watir.rb +50 -0
- data/lib/page-object/section_collection.rb +16 -0
- data/lib/page-object/version.rb +4 -0
- data/lib/page-object/widgets.rb +98 -0
- data/lib/page-object.rb +431 -0
- data/pageobject.gems +1 -0
- metadata +239 -0
data/Gemfile
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
source 'https://rubygems.org'
|
2
|
+
|
3
|
+
# adding rake so travis-ci will build properly
|
4
|
+
gem 'coveralls', require: false
|
5
|
+
gem 'listen', '3.0.8' #Last version that supports ruby 2.0
|
6
|
+
gem 'rake'
|
7
|
+
gem 'growl'
|
8
|
+
gem 'guard-cucumber'
|
9
|
+
gem 'guard-rspec'
|
10
|
+
gem 'rb-fsevent', :require => false if RUBY_PLATFORM =~ /darwin/i
|
11
|
+
|
12
|
+
gemspec
|
data/Guardfile
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
# A sample Guardfile
|
2
|
+
# More info at https://github.com/guard/guard#readme
|
3
|
+
|
4
|
+
|
5
|
+
guard :rspec, cmd: 'rspec --color --format documentation' do
|
6
|
+
watch(%r{^spec/.+_spec\.rb$})
|
7
|
+
watch(%r{^lib/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
|
8
|
+
watch(%r{^lib/page-object/platforms/(.+)/.+\.rb$}) do |m|
|
9
|
+
["spec/page-object/platforms/#{m[1]}/", "spec/page-object/page-object_spec.rb"]
|
10
|
+
end
|
11
|
+
watch('spec/spec_helper.rb') { "spec" }
|
12
|
+
end
|
13
|
+
|
14
|
+
guard 'cucumber', notification: true, all_after_pass: false, cli: '--profile focus' do
|
15
|
+
watch(%r{^features/.+\.feature$})
|
16
|
+
watch(%r{^features/support/.+$}) { "features" }
|
17
|
+
watch(%r{^features/step_definitions/(.+)_steps\.rb$}) { |m| Dir[File.join("**/#{m[1]}.feature")][0] || 'features' }
|
18
|
+
watch(%r{^lib/.+\.rb$}) { "features" }
|
19
|
+
watch(%r{^cucumber.yml$}) { "features" }
|
20
|
+
end
|
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2011-2012 Jeff Morgan
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,114 @@
|
|
1
|
+
# page-object
|
2
|
+
|
3
|
+
[![Gem Version](https://badge.fury.io/rb/page-object.svg)](https://rubygems.org/gems/page-object)
|
4
|
+
[![Build Status](https://travis-ci.org/cheezy/page-object.svg)](https://travis-ci.org/cheezy/page-object)
|
5
|
+
[![Coverage Status](https://coveralls.io/repos/cheezy/page-object/badge.svg?nocache)](https://coveralls.io/r/cheezy/page-object)
|
6
|
+
|
7
|
+
|
8
|
+
A simple gem that assists in creating flexible page objects for testing browser based applications. The goal is to facilitate creating abstraction layers in your tests to decouple the tests from the item they are testing and to provide a simple interface to the elements on a page. It works with both watir and selenium-webdriver.
|
9
|
+
|
10
|
+
## Documentation
|
11
|
+
|
12
|
+
The project [wiki](https://github.com/cheezy/page-object/wiki/page-object) is the first place to go to learn about how to use page-object.
|
13
|
+
|
14
|
+
The rdocs for this project can be found at [rubydoc.info](http://rubydoc.info/gems/page-object/frames).
|
15
|
+
|
16
|
+
To see the changes from release to release please look at the [ChangeLog](https://raw.github.com/cheezy/page-object/master/ChangeLog)
|
17
|
+
|
18
|
+
To read about the motivation for this gem please read this [blog entry](http://www.cheezyworld.com/2010/11/19/ui-tests-introducing-a-simple-dsl/)
|
19
|
+
|
20
|
+
There is a book that describes in detail how to use this gem and others to create a complete view of testing web and other types of applications. The book is named [Cucumber & Cheese](http://leanpub.com/cucumber_and_cheese)
|
21
|
+
|
22
|
+
## Support
|
23
|
+
|
24
|
+
If you need help using the page-object gem please ask your questions on [Stack Overflow](http://stackoverflow.com). Please be sure to use the [page-object-gem](http://stackoverflow.com/questions/tagged/page-object-gem) tag. If you wish to report an issue or request a new feature use the [github issue tracking page](http://github.com/cheezy/page-object/issues).
|
25
|
+
|
26
|
+
## Basic Usage
|
27
|
+
|
28
|
+
### Defining your page object
|
29
|
+
|
30
|
+
You define a new page object by including the PageObject module:
|
31
|
+
|
32
|
+
````ruby
|
33
|
+
class LoginPage
|
34
|
+
include PageObject
|
35
|
+
end
|
36
|
+
````
|
37
|
+
|
38
|
+
When you include this module numerous methods are added to your class that allow you to easily define your page. For the login page you might add the following:
|
39
|
+
|
40
|
+
````ruby
|
41
|
+
class LoginPage
|
42
|
+
include PageObject
|
43
|
+
|
44
|
+
text_field(:username, :id => 'username')
|
45
|
+
text_field(:password, :id => 'password')
|
46
|
+
button(:login, :id => 'login')
|
47
|
+
end
|
48
|
+
````
|
49
|
+
|
50
|
+
Calling the _text_field_ and _button_ methods adds several methods to our page object that allow us to interact with the items on the page. To login using this page we could simply write the following code:
|
51
|
+
|
52
|
+
````ruby
|
53
|
+
login_page.username = 'cheezy'
|
54
|
+
login_page.password = 'secret'
|
55
|
+
login_page.login
|
56
|
+
````
|
57
|
+
|
58
|
+
Another approach might be to create higher level methods on our page object that hide the implementation details even further. Our page object might look like this:
|
59
|
+
|
60
|
+
````ruby
|
61
|
+
class LoginPage
|
62
|
+
include PageObject
|
63
|
+
|
64
|
+
text_field(:username, :id => 'username')
|
65
|
+
text_field(:password, :id => 'password')
|
66
|
+
button(:login, :id => 'login')
|
67
|
+
|
68
|
+
def login_with(username, password)
|
69
|
+
self.username = username
|
70
|
+
self.password = password
|
71
|
+
login
|
72
|
+
end
|
73
|
+
end
|
74
|
+
````
|
75
|
+
|
76
|
+
and your usage of the page would become:
|
77
|
+
|
78
|
+
````ruby
|
79
|
+
login_page.login_with 'cheezy', 'secret'
|
80
|
+
````
|
81
|
+
|
82
|
+
### Creating your page object
|
83
|
+
page-object supports both [watir](https://github.com/watir/watir) and [selenium-webdriver](http://seleniumhq.org/docs/03_webdriver.html). The one used will be determined by which driver you pass into the constructor of your page object. The page object can be created like this:
|
84
|
+
|
85
|
+
````ruby
|
86
|
+
browser = Watir::Browser.new :firefox
|
87
|
+
my_page_object = MyPageObject.new(browser)
|
88
|
+
````
|
89
|
+
|
90
|
+
or
|
91
|
+
|
92
|
+
````ruby
|
93
|
+
browser = Selenium::WebDriver.for :firefox
|
94
|
+
my_page_object = MyPageObject.new(browser)
|
95
|
+
````
|
96
|
+
|
97
|
+
|
98
|
+
## Known Issues
|
99
|
+
|
100
|
+
See [http://github.com/cheezy/page-object/issues](http://github.com/cheezy/page-object/issues)
|
101
|
+
|
102
|
+
## Contribute
|
103
|
+
|
104
|
+
* Fork the project.
|
105
|
+
* Test drive your feature addition or bug fix. Adding specs is important and I will not accept a pull request that does not have tests.
|
106
|
+
* Make sure you describe your new feature with a cucumber scenario.
|
107
|
+
* Make sure you provide RDoc comments for any new public method you add. Remember, others will be using this gem.
|
108
|
+
* Commit, do not mess with Rakefile, version, or ChangeLog.
|
109
|
+
(if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
|
110
|
+
* Send me a pull request. Bonus points for topic branches.
|
111
|
+
|
112
|
+
## Copyright
|
113
|
+
|
114
|
+
Copyright (c) 2011-2012 Jeffrey S. Morgan. See LICENSE for details.
|
data/Rakefile
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'bundler'
|
3
|
+
require 'rspec/core/rake_task'
|
4
|
+
require 'cucumber'
|
5
|
+
require 'cucumber/rake/task'
|
6
|
+
require 'coveralls/rake/task'
|
7
|
+
|
8
|
+
Coveralls::RakeTask.new
|
9
|
+
Bundler::GemHelper.install_tasks
|
10
|
+
|
11
|
+
RSpec::Core::RakeTask.new(:spec) do |spec|
|
12
|
+
spec.ruby_opts = "-I lib:spec"
|
13
|
+
spec.pattern = 'spec/**/*_spec.rb'
|
14
|
+
end
|
15
|
+
task :spec
|
16
|
+
|
17
|
+
Cucumber::Rake::Task.new(:features, "Run the cucumber features")
|
18
|
+
|
19
|
+
|
20
|
+
desc 'Run all specs and cukes'
|
21
|
+
task :test => ['spec', 'features']
|
22
|
+
|
23
|
+
task :lib do
|
24
|
+
$LOAD_PATH.unshift(File.expand_path("lib", File.dirname(__FILE__)))
|
25
|
+
end
|
26
|
+
|
27
|
+
task :test_with_coveralls => [:test, 'coveralls:push']
|
28
|
+
|
29
|
+
task :default => :test_with_coveralls
|
@@ -0,0 +1,31 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require 'page-object/version'
|
4
|
+
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = 'centric_page_object'
|
8
|
+
s.version = PageObject::VERSION
|
9
|
+
s.platform = Gem::Platform::RUBY
|
10
|
+
s.authors = ['Jeff Morgan', 'Alexis Andersen', 'Joseph Ours']
|
11
|
+
s.email = ['jeff.morgan@leandog.com', 'alexis.t.andersen@gmail.com', 'joseph.ours@centricconsulting.com']
|
12
|
+
s.license = 'MIT'
|
13
|
+
s.homepage = 'http://github.com/centricconsulting/page_object'
|
14
|
+
s.summary = %q{Page Object DSL for browser testing}
|
15
|
+
s.description = %q{Page Object DSL that works with both Watir and Selenium}
|
16
|
+
|
17
|
+
s.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(pkg|spec|features|coverage)/}) }
|
18
|
+
s.require_paths = ['lib']
|
19
|
+
|
20
|
+
s.add_dependency 'centric_page_navigation', '>= 0.11'
|
21
|
+
s.add_dependency 'watir', '>= 6.10.3'
|
22
|
+
|
23
|
+
s.add_development_dependency 'coveralls', '~> 0.8.1'
|
24
|
+
s.add_development_dependency 'cucumber', '~> 2.0'
|
25
|
+
s.add_development_dependency 'net-http-persistent'
|
26
|
+
s.add_development_dependency 'rack', '~> 1.0'
|
27
|
+
s.add_development_dependency 'rspec', '~> 3.0'
|
28
|
+
s.add_development_dependency 'webdrivers'
|
29
|
+
s.add_development_dependency 'yard', '>= 0.7.2'
|
30
|
+
|
31
|
+
end
|
data/cucumber.yml
ADDED