gridium 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +128 -9
- data/lib/gridium/version.rb +1 -1
- data/lib/page.rb +3 -3
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 128a36730a47c9d8f3c6bed5def080fd4f8c1692
|
4
|
+
data.tar.gz: ca6bcbdd9debb00d9b2ca31e27a15bdaba5897d0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 59820cb2977737c52b1f91fe657e3a3a7c7ea01746a6bac40095ffef1f7d0ad5eb67ed0e5391f90105e080446c1749cc6a093f0e94896fec8905ef13fbcc6acd
|
7
|
+
data.tar.gz: cb4d201b778b91883ac4bd02f2cacc5b3feddc77579b55625a6ed74da1501bb7dfba81fdeae2fb7e6c0e1e9a32c06c4eb4c36f88da480be61737ced4943550bd
|
data/README.md
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
# Gridium
|
2
|
+
[![Gem Version](https://badge.fury.io/rb/gridium.svg)](http://badge.fury.io/rb/gridium)
|
2
3
|
|
3
4
|
Welcome to Gridium! Gridium helps you build better automated tests using only Selenium and your advanced knowledge of page objects. This is a replacement gem for Capybara. I found it more difficult to use Capybara with Firefox and Selenium, and wanted to take advantage of everything that Selenium offered and Capybara lacked.
|
4
5
|
|
@@ -12,24 +13,142 @@ Add this line to your application's Gemfile:
|
|
12
13
|
```ruby
|
13
14
|
gem 'gridium'
|
14
15
|
```
|
15
|
-
|
16
|
-
And then execute:
|
17
|
-
|
18
|
-
$ bundle
|
19
|
-
|
20
16
|
Or install it yourself as:
|
21
17
|
|
22
18
|
$ gem install gridium
|
23
19
|
|
24
20
|
## Usage
|
25
21
|
|
26
|
-
|
22
|
+
Gridium is built to support the Page Object Design pattern for automated User Interface tests. Gridium works best when page objects are abstracted from the test files. While Rspec is preferred, you should still be able to use Gridium with other test runners.
|
23
|
+
|
24
|
+
In order to use Gridium, you will first need to need to add it to your automtion suite. Gridium comes with Selenium and is currently configured to run tests on Firefox only. Future updates will be available to run tests on other browsers and Selenium Grid.
|
25
|
+
|
26
|
+
#### Spec Helper
|
27
|
+
To get started using Gridium add the Gem to your automated test library. Include the following section in your `spec_helper.rb` file:
|
28
|
+
|
29
|
+
```ruby
|
30
|
+
Gridium.configure do |config|
|
31
|
+
config.report_dir = '/path/to/automation/project'
|
32
|
+
config.target_environment = "Integration"
|
33
|
+
config.browser = :firefox
|
34
|
+
config.url = "http://www.applicationundertest.com"
|
35
|
+
config.page_load_timeout = 30
|
36
|
+
config.element_timeout = 30
|
37
|
+
config.visible_elements_only = true
|
38
|
+
config.log_level = :debug
|
39
|
+
config.highlight_verifications = true
|
40
|
+
config.highlight_duration = 0.100
|
41
|
+
config.screenshot_on_failure = false
|
42
|
+
end
|
43
|
+
```
|
44
|
+
|
45
|
+
Additionally, there are some options that should be configured in the `Rspec.configure` section of your `spec_helper.rb` file:
|
46
|
+
|
47
|
+
```ruby
|
48
|
+
RSpec.configure do |config|
|
49
|
+
include Gridium
|
50
|
+
config.before :all do
|
51
|
+
# Create the test report root directory
|
52
|
+
report_root_dir = File.expand_path(File.join(Gridium.config.report_dir, 'spec_reports'))
|
53
|
+
Dir.mkdir(report_root_dir) if not File.exist?(report_root_dir)
|
54
|
+
|
55
|
+
# Create the sub-directory for the test suite run
|
56
|
+
current_run_report_dir = File.join(report_root_dir, "spec_results__" + DateTime.now.strftime("%m_%d_%Y__%H_%M_%S"))
|
57
|
+
$current_run_dir = current_run_report_dir
|
58
|
+
Dir.mkdir(current_run_report_dir)
|
59
|
+
|
60
|
+
# Add the output log file for the rspec test run to the logger
|
61
|
+
Log.add_device(File.open(File.join(current_run_report_dir, "spec_logging_output.log"), File::WRONLY | File::APPEND | File::CREAT))
|
62
|
+
|
63
|
+
# Reset Suite statistics
|
64
|
+
$verifications_total = 0
|
65
|
+
$warnings_total = 0
|
66
|
+
$errors_total = 0
|
67
|
+
|
68
|
+
#Setup Gridium Spec Data
|
69
|
+
Spec_data.load_suite_state
|
70
|
+
Spec_data.load_spec_state
|
71
|
+
end #end before:all
|
72
|
+
end #end Rspec.config
|
73
|
+
```
|
74
|
+
|
75
|
+
#### Settings Overview
|
76
|
+
|
77
|
+
You may be saying to yourself - 'Holy Crap that's a lot of settings!'. Yeah. It is. Let me preface by saying, I would rather give to many configuration options than not enough. That being said, we'll probably take some away at some point or make combine them into fewer configuration settings. With that in Mind let's go over the settings we have now:
|
78
|
+
|
79
|
+
##### Gridium Configuration Options:
|
80
|
+
`config.report_dir = '/path/to/automation/project'`: This setting tells Gridium where to write reports (i.e. Log files) out to. This could and probably will be changed at some point to eliminate some required Rspec.configuration options.
|
81
|
+
`config.target_environment = "Stage"`: This is a simple log entry to tell remind you which environment you're testing.
|
82
|
+
`config.browser = :firefox`: This tells gridium which browser you will be testing. Only firefox is working currently. Future browsers to come.
|
83
|
+
`config.url = "http://www.applicationundertest.com"`: Where's the entry point for your web application?
|
84
|
+
`config.page_load_timeout = 30` Along with Element Timeout, how long (in seconds) should Selenium wait when finding an element?
|
85
|
+
`config.visible_elements_only = true`: With this enabled Gridium will only find VISIBLE elements on the page. Hidden elements or non-enabled elements will not be matched.
|
86
|
+
`config.log_level = :debug`: There are a few levels here `:debug` `:info` `:warn` `:error` and `:fatal`. Your Gridium tests objects can have different levels of logging. Adjusting this setting will turn those log levels on or off depending on your needs at the time.
|
87
|
+
`config.highlight_verifications = true`: Will highlight the element Gridium finds in the browser. This makes watching tests run easier to follow, although it does slow the test execution time down. Recommend this is turned off for automated tests running in Jenkins or headless mode.
|
88
|
+
`config.highlight_duration = 0.100`: How long should the element be highlighted (in miliseconds) before the action is performed on the element.
|
89
|
+
`config.screenshot_on_failure = false`: Take a screenshot on failure. On or off. Obviously.
|
90
|
+
|
91
|
+
##### Rspec Configuration Options:
|
92
|
+
The first bit of the Rspec configuration section is used to set up a log file directory. I like to have log files kept in seperate dated directories. However, that may not be needed depending on your preference. If you choose to use a single directory for your log files, you will need to make sure that the log file name is unique, as screenshots are saved into the same directory. Whichever method you prefer, you will need to setup the Gridium Log Device.
|
93
|
+
`Log.add_device(File.open(File.join(current_run_report_dir, "spec_logging_output.log"), File::WRONLY | File::APPEND | File::CREAT))`: This tells Gridium where to write the logs to for any paticular test run.
|
94
|
+
|
95
|
+
The following is used for throughout the test execution and displayed in the logs to quickly access how many of each paticular failure your tests are discovering. This can be used for quick metrics and climate checks of your aplication under test.
|
96
|
+
```ruby
|
97
|
+
# Reset Suite statistics
|
98
|
+
$verifications_total = 0
|
99
|
+
$warnings_total = 0
|
100
|
+
$errors_total = 0
|
101
|
+
|
102
|
+
#Setup Gridium Spec Data
|
103
|
+
Spec_data.load_suite_state
|
104
|
+
Spec_data.load_spec_state
|
105
|
+
```
|
106
|
+
|
107
|
+
##Page Objects
|
108
|
+
|
109
|
+
Page objects are required for Gridium. Page objects abstract the functionality of the page away from the test. There's a million reasons why page objects are the way to go. Not the least of all is that it helps you maintain your tests.
|
110
|
+
|
111
|
+
####Sample Page Object
|
112
|
+
```ruby
|
113
|
+
include Gridium
|
114
|
+
class LoginPage < Page
|
115
|
+
|
116
|
+
def initialize
|
117
|
+
@username = Element.new("UserName - Stage", :css, "input#login_username")
|
118
|
+
@password = Element.new("Password - Stage", :css, "input#login_password")
|
119
|
+
@login = Element.new("Login Button", :xpath, "//a[@class='submit button']")
|
120
|
+
end
|
121
|
+
|
122
|
+
def login(user_name, password)
|
123
|
+
Log.info("- Login to staging site Username: #{user_name} Password: #{password}")
|
124
|
+
@username.text = user_name
|
125
|
+
@password.text = password
|
126
|
+
@login.click
|
127
|
+
end
|
128
|
+
end
|
129
|
+
```
|
130
|
+
|
131
|
+
Notice that to use Gridium functionality, Gridium needs to be included at the top of the page object definition. Also notice that the LoginPage inherits from the Gridium `Page`. The `Page` object in gridium provides methods that emulate some of Capybara's API. For more information checkout the `lib/page.rb`.
|
132
|
+
|
133
|
+
Page object are made up of Elements. The methods on the page object tells the test how interact with the elements. For example, the Login method shown in the example sets the Username field, the password field and then clicks the login button.
|
134
|
+
|
135
|
+
This action will return a new page, that our test is setup to handle.
|
136
|
+
|
137
|
+
##Elements
|
138
|
+
|
139
|
+
Elements are the building blocks of page objects. Elements are anything that a user, or a test would care about on the page. To create a new Element, you will need three things:
|
140
|
+
*Element Name - A human readable string used to identify the element to the tester. Used primarily in the log file.
|
141
|
+
*Locator Type - `:css` `:xpath` `:link` `:link_text` `:id` `:class` `:class_name` `:name` `:tag_name` are all valid.
|
142
|
+
*Locator - This is the chosen locator Type string to find the element.
|
27
143
|
|
28
|
-
|
144
|
+
It's important to remember that Elements are not actually found on the page, until an action is attempted. Only then will the element be attempted to be located.
|
29
145
|
|
30
|
-
|
146
|
+
##Helper Blog Posts:
|
147
|
+
[Beginner's Guide to Automated Testing](http://www.electricsheepdreams.com/2014/12/4/a-beginners-guide-to-automated-test-design)
|
148
|
+
[How to build Xpath locators](http://www.electricsheepdreams.com/2014/12/4/1wq9pbds8m9vktez0qc2w0r0xxlhp6)
|
149
|
+
[Browser Tools and Plugins](http://www.electricsheepdreams.com/2014/12/4/su5lssyi84k4ycrmuaceuswbf9ojwr)
|
150
|
+
[Automation Pyramid - Theory](http://www.electricsheepdreams.com/2014/12/4/zje1wyef0621gv1w4r7tn3g7h3j19h)
|
31
151
|
|
32
|
-
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
33
152
|
|
34
153
|
## Contributing
|
35
154
|
|
data/lib/gridium/version.rb
CHANGED
data/lib/page.rb
CHANGED
@@ -57,16 +57,16 @@ module Gridium
|
|
57
57
|
end
|
58
58
|
|
59
59
|
def self.scroll_to_bottom
|
60
|
-
Driver.
|
60
|
+
Driver.execute_script_driver('window.scrollTo(0,100000)')
|
61
61
|
end
|
62
62
|
|
63
63
|
def self.scroll_to_top
|
64
64
|
#TODO Verify this
|
65
|
-
Driver.
|
65
|
+
Driver.execute_script_driver('window.scrollTo(100000,0)')
|
66
66
|
end
|
67
67
|
|
68
68
|
def self.execute_script(script)
|
69
|
-
Driver.
|
69
|
+
Driver.execute_script_driver(script)
|
70
70
|
end
|
71
71
|
|
72
72
|
def all(by, locator)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gridium
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Seth Urban
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-08-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|