uptime_monitor 0.0.2 → 0.0.4
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 +202 -13
- data/Rakefile +1 -1
- data/VERSION +1 -1
- data/lib/uptime_monitor/browser.rb +3 -2
- data/spec/browser_spec.rb +5 -1
- data/uptime_monitor.gemspec +3 -3
- metadata +5 -4
data/README.md
CHANGED
@@ -2,7 +2,208 @@ uptime_monitor (Hercules)
|
|
2
2
|
==========================
|
3
3
|
[](https://travis-ci.org/obi-a/uptime_monitor)
|
4
4
|
|
5
|
-
|
5
|
+
Uptime_monitor is a [ragios](https://github.com/obi-a/ragios) plugin that uses a real web browser to perform transactions on a website to ensure that features of the site are still working correctly. It can check elements of a webpage to ensure they still exist and it can also perform transactions like a website login to ensure that the process still works correctly.
|
6
|
+
|
7
|
+
##Requirements
|
8
|
+
[Ragios](https://github.com/obi-a/ragios)
|
9
|
+
|
10
|
+
##Installation:
|
11
|
+
Add the uptime_monitor gem to your ragios Gemfile
|
12
|
+
```ruby
|
13
|
+
gem "uptime_monitor"
|
14
|
+
```
|
15
|
+
Run bundle install from the ragios root directory
|
16
|
+
```
|
17
|
+
bundle install
|
18
|
+
```
|
19
|
+
Restart ragios
|
20
|
+
|
21
|
+
##usage:
|
22
|
+
A quick example, to monitor the title tag of a web page to ensure that it hasn't changed. Using [Ragios ruby client](http://www.whisperservers.com/ragios/ragios-saint-ruby/using-ragios)
|
23
|
+
````ruby
|
24
|
+
monitor = {monitor: "My Blog title tag",
|
25
|
+
url: "http://obi-akubue.org",
|
26
|
+
every: "5m",
|
27
|
+
contact: "admin@obiora.com",
|
28
|
+
via: "gmail_notifier",
|
29
|
+
plugin: "uptime_monitor",
|
30
|
+
exists?: [
|
31
|
+
[:title, [text: "Obi Akubue"]]
|
32
|
+
],
|
33
|
+
browser: ["firefox"]
|
34
|
+
}
|
35
|
+
ragios.add [monitor]
|
36
|
+
```
|
37
|
+
The above example will create a ragios monitor that will, every 5 minutes, use firefox to visit the website url http://obi-akubue.org, and verify that the title tag on the page matches the text "Obi Akubue".
|
38
|
+
|
39
|
+
###Using the plugin
|
40
|
+
To use the uptime monitor plugin add the key/value pair to the monitor
|
41
|
+
```ruby
|
42
|
+
plugin: "uptime_monitor"
|
43
|
+
```
|
44
|
+
|
45
|
+
###Browsers
|
46
|
+
The browser to use is specified, by adding a browser key/value pair to the monitor
|
47
|
+
```ruby
|
48
|
+
browser: ["firefox"]
|
49
|
+
```
|
50
|
+
Supported browsers include Firefox, Chrome, Safari and Phantomjs. Other browsers can be specified as
|
51
|
+
```ruby
|
52
|
+
browser: ["chrome"]
|
53
|
+
browser: ["safari"]
|
54
|
+
browser: ["phantomjs"]
|
55
|
+
```
|
56
|
+
uptime_monitor uses [Watir Webdriver](http://watirwebdriver.com), firefox runs out of the box with no configuration requried. To use Chrome or Safari see the Watir Webdriver documentation on downloading the appropriate driver binary and configuration.
|
57
|
+
|
58
|
+
By default, the browsers don't run headless, to run the browser headless, you can specify it in the format below:
|
59
|
+
```ruby
|
60
|
+
browser: ["firefox", headless: true]
|
61
|
+
```
|
62
|
+
This will run firefox as a headless browser. You should have [Xvfb](https://en.wikipedia.org/wiki/Xvfb) installed to run a non-headless browsers as headless. Headless browsers like Phantomjs don't require Xvfb.
|
63
|
+
|
64
|
+
You can also specify headless as false
|
65
|
+
```ruby
|
66
|
+
browser: ["firefox", headless: false]
|
67
|
+
```
|
68
|
+
The above example will run firefox as a non-headless browser.
|
69
|
+
|
70
|
+
###Validations
|
71
|
+
To verify that a html element exists on the web page, a validation needs to be added to the monitor. Validations are specified with the exists? key/value pair which takes an array of html elements as it's value. It verifies that the html elements in the array exists on the current web page.
|
72
|
+
```ruby
|
73
|
+
exists?: [
|
74
|
+
[:h1]
|
75
|
+
[:div]
|
76
|
+
]
|
77
|
+
```
|
78
|
+
The above example will verify that an h1 and a div exists on the page.
|
79
|
+
|
80
|
+
####HTML Elements
|
81
|
+
The simplest way to specify a html element is using a symbol.
|
82
|
+
```ruby
|
83
|
+
exists?: [
|
84
|
+
[:h1]
|
85
|
+
[:div]
|
86
|
+
[:a]
|
87
|
+
[:img]
|
88
|
+
[:span]
|
89
|
+
]
|
90
|
+
```
|
91
|
+
HTML elements can also be specified as a hash with their name as key and attributes as value.
|
92
|
+
```ruby
|
93
|
+
exists?: [
|
94
|
+
[div: {class: "box_content"}]
|
95
|
+
]
|
96
|
+
```
|
97
|
+
The above will verify that a div with class "box_content" exists on the page.
|
98
|
+
|
99
|
+
Other examples:
|
100
|
+
```ruby
|
101
|
+
[img: {src: "https://fc03.deviantart.net/fs14/f/2007/047/f/2/Street_Addiction_by_gizmodus.jpg"}]
|
102
|
+
|
103
|
+
```
|
104
|
+
Specifies an img tag with src="https://fc03.deviantart.net/fs14/f/2007/047/f/2/Street_Addiction_by_gizmodus.jpg".
|
105
|
+
|
106
|
+
```ruby
|
107
|
+
[div: {id:"test", class: "test-section"}]
|
108
|
+
```
|
109
|
+
Specifes a div with id="test" and class="test-section".
|
110
|
+
|
111
|
+
####Standard attributes
|
112
|
+
|
113
|
+
Only standard attributes for an element can be included in the hash, for example a div can only include all or any of the following attributes id, class, lang, dir, title, align, onclick, ondblclick, onmousedown, onmouseup, onmouseover, onmousemove, onmouseout, onkeypress, onkeydown, onkeyup.
|
114
|
+
|
115
|
+
Custom or data attributes cannot be included, for example to specify a div by data attributes, for example
|
116
|
+
```html
|
117
|
+
<div data-brand="toyota">
|
118
|
+
```
|
119
|
+
The following
|
120
|
+
```ruby
|
121
|
+
[div: {"data-brand" => "toyota"}]
|
122
|
+
```
|
123
|
+
will give an error because "data-brand" is not a standard attibute for div, to specify elements by data or custom attributes use css selectors, see below.
|
124
|
+
|
125
|
+
|
126
|
+
####Using CSS Selectors
|
127
|
+
HTML elements can also be specified with css selectors.
|
128
|
+
```ruby
|
129
|
+
[element: {css: '#rss-link'}]
|
130
|
+
```
|
131
|
+
This specifies an element with id="rss-link".
|
132
|
+
|
133
|
+
To specify an element by data attributes
|
134
|
+
```ruby
|
135
|
+
[element: {css: '[data-brand="toyota"]'}]
|
136
|
+
```
|
137
|
+
|
138
|
+
####Helpers for HTML elements
|
139
|
+
Helpers are available to make some elements easier to reason about:
|
140
|
+
|
141
|
+
#####Links
|
142
|
+
An anchor tag could be specified by a link, this makes it more readable and easier to reason about
|
143
|
+
Using the anchor tag
|
144
|
+
```ruby
|
145
|
+
[a: {text: "Click Here"}]
|
146
|
+
```
|
147
|
+
|
148
|
+
More readble using helper
|
149
|
+
```ruby
|
150
|
+
[link: {text: "Click Here"}]
|
151
|
+
```
|
152
|
+
|
153
|
+
```ruby
|
154
|
+
[link: {href: "https://www.southmunn.com/aboutus"}]
|
155
|
+
```
|
156
|
+
|
157
|
+
#####Buttons
|
158
|
+
```ruby
|
159
|
+
[button: {id: "searchsubmit"}]
|
160
|
+
```
|
161
|
+
|
162
|
+
#####Text Fields
|
163
|
+
```ruby
|
164
|
+
[text_field: {id: "search"}]
|
165
|
+
```
|
166
|
+
|
167
|
+
More readable than the input tag
|
168
|
+
```ruby
|
169
|
+
[input: {id: "search", type: "text"}]
|
170
|
+
```
|
171
|
+
|
172
|
+
#####Checkbox
|
173
|
+
```ruby
|
174
|
+
[checkbox: {value: "Butter"}]
|
175
|
+
```
|
176
|
+
#####Radio Buttons
|
177
|
+
```ruby
|
178
|
+
[radio: {name: "group1", value: "Milk"}]
|
179
|
+
```
|
180
|
+
|
181
|
+
######Drop Down menus
|
182
|
+
```html
|
183
|
+
<select name="mydropdown">
|
184
|
+
<option value="Milk">Fresh Milk</option>
|
185
|
+
<option value="Cheese">Old Cheese</option>
|
186
|
+
<option value="Bread">Hot Bread</option>
|
187
|
+
</select>
|
188
|
+
```
|
189
|
+
Helper
|
190
|
+
```ruby
|
191
|
+
[select_list: {name: "mydropdown"}]
|
192
|
+
```
|
193
|
+
|
194
|
+
Or HTML select tag
|
195
|
+
```ruby
|
196
|
+
[select: {name: "mydropdown"}]
|
197
|
+
```
|
198
|
+
|
199
|
+
Options of the drop-down menu can be specified using option
|
200
|
+
```ruby
|
201
|
+
[option: {value: "Milk"}]
|
202
|
+
```
|
203
|
+
|
204
|
+
####Text Validations
|
205
|
+
|
206
|
+
... more documentation coming soon
|
6
207
|
|
7
208
|
##Specification:
|
8
209
|
|
@@ -95,16 +296,4 @@ u.test_result
|
|
95
296
|
# :does_not_exist_as_expected}
|
96
297
|
</pre>
|
97
298
|
|
98
|
-
###Supported browsers:
|
99
|
-
Firefox, Chrome, Safari, Phantomjs
|
100
|
-
|
101
|
-
### Browser Format:
|
102
|
-
<pre lang="ruby">
|
103
|
-
browser: ["firefox", headless: true]
|
104
|
-
browser: ["firefox", headless: false]
|
105
|
-
browser: ["firefox"]
|
106
|
-
browser: ["chrome"]
|
107
|
-
</pre>
|
108
|
-
Running a browser headless requires xvfb installed.
|
109
|
-
|
110
299
|
###More details coming soon
|
data/Rakefile
CHANGED
@@ -18,7 +18,7 @@ Jeweler::Tasks.new do |gem|
|
|
18
18
|
gem.homepage = "http://github.com/obi-a/uptime_monitor"
|
19
19
|
gem.license = "MIT"
|
20
20
|
gem.summary = %Q{Real browser website uptime monitoring plugin for Ragios}
|
21
|
-
gem.description = %Q{
|
21
|
+
gem.description = %Q{A Ragios plugin that uses a real web browser to monitor transactions on a website for availability}
|
22
22
|
gem.email = "obioraakubue@yahoo.com"
|
23
23
|
gem.authors = ["obi-a"]
|
24
24
|
# dependencies defined in Gemfile
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.4
|
@@ -22,7 +22,7 @@ module Hercules
|
|
22
22
|
begin
|
23
23
|
first_exists = element.exists?
|
24
24
|
rescue Exception => e
|
25
|
-
message = "Cannot find page element in this form: #{page_element.first.inspect}, you may use a css
|
25
|
+
message = "Cannot find page element in this form: #{page_element.first.inspect}, you may use a css selector form"
|
26
26
|
raise(Hercules::UptimeMonitor::UnknownPageElement.new(error: message), message)
|
27
27
|
end
|
28
28
|
if first_exists && !rest(page_element).empty?
|
@@ -32,7 +32,8 @@ module Hercules
|
|
32
32
|
end
|
33
33
|
end
|
34
34
|
def get_element(first)
|
35
|
-
if first.is_a? Symbol
|
35
|
+
if (first.is_a? Symbol) || (first.is_a? String)
|
36
|
+
first.to_sym
|
36
37
|
@browser.send(first)
|
37
38
|
elsif first.is_a? Hash
|
38
39
|
key, value = first.first
|
data/spec/browser_spec.rb
CHANGED
@@ -127,8 +127,12 @@ describe Hercules::UptimeMonitor::Browser do
|
|
127
127
|
element = @browser.get_element({element: {css: '#rss-link'}})
|
128
128
|
element.exists?.should == true
|
129
129
|
end
|
130
|
+
it "can check if an element in string form exists" do
|
131
|
+
element = @browser.get_element("title")
|
132
|
+
element.exists?.should == true
|
133
|
+
end
|
130
134
|
it "cannot check if an element exists if element has incorrect form" do
|
131
|
-
expect{@browser.get_element(
|
135
|
+
expect{@browser.get_element(1)}.to raise_error(Hercules::UptimeMonitor::InvalidPageElement)
|
132
136
|
end
|
133
137
|
it "can check if a symbol form page element exists" do
|
134
138
|
@browser.page_element_exists?([:title]).should == true
|
data/uptime_monitor.gemspec
CHANGED
@@ -5,12 +5,12 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = "uptime_monitor"
|
8
|
-
s.version = "0.0.
|
8
|
+
s.version = "0.0.4"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["obi-a"]
|
12
|
-
s.date = "2014-
|
13
|
-
s.description = "
|
12
|
+
s.date = "2014-04-06"
|
13
|
+
s.description = "A Ragios plugin that uses a real web browser to monitor transactions on a website for availability"
|
14
14
|
s.email = "obioraakubue@yahoo.com"
|
15
15
|
s.extra_rdoc_files = [
|
16
16
|
"LICENSE",
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: uptime_monitor
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-
|
12
|
+
date: 2014-04-06 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: headless
|
@@ -155,7 +155,8 @@ dependencies:
|
|
155
155
|
- - ! '>='
|
156
156
|
- !ruby/object:Gem::Version
|
157
157
|
version: '0'
|
158
|
-
description:
|
158
|
+
description: A Ragios plugin that uses a real web browser to monitor transactions
|
159
|
+
on a website for availability
|
159
160
|
email: obioraakubue@yahoo.com
|
160
161
|
executables: []
|
161
162
|
extensions: []
|
@@ -195,7 +196,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
195
196
|
version: '0'
|
196
197
|
segments:
|
197
198
|
- 0
|
198
|
-
hash:
|
199
|
+
hash: 660930515595020497
|
199
200
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
200
201
|
none: false
|
201
202
|
requirements:
|