bauxite 0.6.18 → 0.6.19
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/LICENSE +21 -21
- data/README.md +293 -293
- data/Rakefile +128 -128
- data/bin/bauxite +27 -27
- data/doc/Bauxite.html +6 -9
- data/doc/Bauxite/Action.html +298 -315
- data/doc/Bauxite/ActionModule.html +23 -26
- data/doc/Bauxite/Application.html +36 -38
- data/doc/Bauxite/Context.html +303 -303
- data/doc/Bauxite/Errors.html +6 -9
- data/doc/Bauxite/Errors/AssertionError.html +6 -9
- data/doc/Bauxite/Errors/FileNotFoundError.html +6 -9
- data/doc/Bauxite/Errors/FormatError.html +6 -9
- data/doc/Bauxite/Loggers.html +6 -9
- data/doc/Bauxite/Loggers/CompositeLogger.html +29 -32
- data/doc/Bauxite/Loggers/EchoLogger.html +10 -13
- data/doc/Bauxite/Loggers/FileLogger.html +25 -28
- data/doc/Bauxite/Loggers/HtmlLogger.html +99 -102
- data/doc/Bauxite/Loggers/NullLogger.html +16 -19
- data/doc/Bauxite/Loggers/ReportLogger.html +43 -46
- data/doc/Bauxite/Loggers/TerminalLogger.html +76 -79
- data/doc/Bauxite/Loggers/XtermLogger.html +28 -31
- data/doc/Bauxite/Parser.html +87 -89
- data/doc/Bauxite/ParserModule.html +19 -22
- data/doc/Bauxite/Selector.html +99 -105
- data/doc/Bauxite/SelectorModule.html +27 -30
- data/doc/README_md.html +117 -103
- data/doc/created.rid +58 -58
- data/doc/fonts.css +167 -167
- data/doc/fonts/Lato-Light.ttf +0 -0
- data/doc/fonts/Lato-LightItalic.ttf +0 -0
- data/doc/fonts/Lato-Regular.ttf +0 -0
- data/doc/fonts/Lato-RegularItalic.ttf +0 -0
- data/doc/fonts/SourceCodePro-Bold.ttf +0 -0
- data/doc/fonts/SourceCodePro-Regular.ttf +0 -0
- data/doc/images/add.png +0 -0
- data/doc/images/arrow_up.png +0 -0
- data/doc/images/brick.png +0 -0
- data/doc/images/brick_link.png +0 -0
- data/doc/images/bug.png +0 -0
- data/doc/images/bullet_black.png +0 -0
- data/doc/images/bullet_toggle_minus.png +0 -0
- data/doc/images/bullet_toggle_plus.png +0 -0
- data/doc/images/date.png +0 -0
- data/doc/images/delete.png +0 -0
- data/doc/images/find.png +0 -0
- data/doc/images/loadingAnimation.gif +0 -0
- data/doc/images/macFFBgHack.png +0 -0
- data/doc/images/package.png +0 -0
- data/doc/images/page_green.png +0 -0
- data/doc/images/page_white_text.png +0 -0
- data/doc/images/page_white_width.png +0 -0
- data/doc/images/plugin.png +0 -0
- data/doc/images/ruby.png +0 -0
- data/doc/images/tag_blue.png +0 -0
- data/doc/images/tag_green.png +0 -0
- data/doc/images/transparent.png +0 -0
- data/doc/images/wrench.png +0 -0
- data/doc/images/wrench_orange.png +0 -0
- data/doc/images/zoom.png +0 -0
- data/doc/index.html +117 -103
- data/doc/js/darkfish.js +32 -11
- data/doc/js/jquery.js +0 -0
- data/doc/js/navigation.js +0 -0
- data/doc/js/search.js +0 -0
- data/doc/js/search_index.js +1 -1
- data/doc/js/searcher.js +0 -0
- data/doc/rdoc.css +580 -580
- data/doc/table_of_contents.html +69 -72
- data/lib/bauxite.rb +28 -28
- data/lib/bauxite/actions/alias.rb +51 -51
- data/lib/bauxite/actions/assert.rb +49 -49
- data/lib/bauxite/actions/asserth.rb +60 -60
- data/lib/bauxite/actions/assertm.rb +49 -49
- data/lib/bauxite/actions/assertv.rb +40 -40
- data/lib/bauxite/actions/assertw.rb +47 -47
- data/lib/bauxite/actions/break.rb +39 -39
- data/lib/bauxite/actions/capture.rb +61 -61
- data/lib/bauxite/actions/click.rb +36 -36
- data/lib/bauxite/actions/debug.rb +103 -103
- data/lib/bauxite/actions/doif.rb +43 -43
- data/lib/bauxite/actions/dounless.rb +43 -43
- data/lib/bauxite/actions/echo.rb +36 -36
- data/lib/bauxite/actions/exec.rb +46 -46
- data/lib/bauxite/actions/exit.rb +35 -35
- data/lib/bauxite/actions/failif.rb +52 -52
- data/lib/bauxite/actions/js.rb +41 -41
- data/lib/bauxite/actions/load.rb +49 -49
- data/lib/bauxite/actions/open.rb +35 -35
- data/lib/bauxite/actions/params.rb +40 -40
- data/lib/bauxite/actions/replace.rb +37 -37
- data/lib/bauxite/actions/reset.rb +38 -38
- data/lib/bauxite/actions/return.rb +68 -68
- data/lib/bauxite/actions/ruby.rb +58 -58
- data/lib/bauxite/actions/select.rb +48 -48
- data/lib/bauxite/actions/set.rb +39 -39
- data/lib/bauxite/actions/setif.rb +44 -44
- data/lib/bauxite/actions/source.rb +44 -44
- data/lib/bauxite/actions/store.rb +38 -38
- data/lib/bauxite/actions/submit.rb +37 -37
- data/lib/bauxite/actions/test.rb +67 -67
- data/lib/bauxite/actions/tryload.rb +71 -71
- data/lib/bauxite/actions/wait.rb +38 -38
- data/lib/bauxite/actions/write.rb +44 -44
- data/lib/bauxite/application.rb +349 -349
- data/lib/bauxite/core/action.rb +199 -199
- data/lib/bauxite/core/context.rb +791 -791
- data/lib/bauxite/core/errors.rb +41 -41
- data/lib/bauxite/core/logger.rb +169 -169
- data/lib/bauxite/core/parser.rb +85 -85
- data/lib/bauxite/core/selector.rb +152 -152
- data/lib/bauxite/loggers/composite.rb +91 -91
- data/lib/bauxite/loggers/echo.rb +36 -36
- data/lib/bauxite/loggers/file.rb +68 -68
- data/lib/bauxite/loggers/html.rb +154 -154
- data/lib/bauxite/loggers/terminal.rb +134 -134
- data/lib/bauxite/loggers/xterm.rb +101 -101
- data/lib/bauxite/parsers/csv.rb +43 -43
- data/lib/bauxite/parsers/default.rb +42 -42
- data/lib/bauxite/parsers/html.rb +79 -79
- data/lib/bauxite/selectors/attr.rb +39 -39
- data/lib/bauxite/selectors/frame.rb +60 -60
- data/lib/bauxite/selectors/json.rb +88 -88
- data/lib/bauxite/selectors/sid.rb +38 -38
- data/lib/bauxite/selectors/smart.rb +80 -80
- data/lib/bauxite/selectors/window.rb +77 -77
- data/test/alert.bxt +3 -3
- data/test/alert/page.html +4 -4
- data/test/alias.bxt +9 -9
- data/test/asserth.bxt +2 -2
- data/test/assertv.bxt +1 -1
- data/test/assertw.bxt +7 -7
- data/test/broken.bxt.manual +0 -0
- data/test/bug_load_path.bxt.manual +0 -0
- data/test/bug_load_path/broken.bxt.manual +0 -0
- data/test/bug_load_path/test.bxt +0 -0
- data/test/capture.bxt.manual +20 -20
- data/test/capture/my_test.bxt +1 -1
- data/test/capture/page.html +6 -6
- data/test/capture_on_error.bxt.manual +3 -3
- data/test/capture_on_error/my_test.bxt +1 -1
- data/test/capture_on_error/page.html +2 -2
- data/test/debug.bxt.manual +0 -0
- data/test/default_selector.bxt.manual +7 -7
- data/test/default_selector/page.html +10 -10
- data/test/default_selector_var.bxt +1 -1
- data/test/delay.bxt +2 -2
- data/test/delay/page.html +4 -4
- data/test/doif.bxt +6 -6
- data/test/dounless.bxt +6 -6
- data/test/exec.bxt +6 -6
- data/test/exit.bxt +3 -3
- data/test/exit/test.bxt +3 -3
- data/test/extension.bxt.manual +4 -4
- data/test/extension/custom.rb +12 -12
- data/test/extension/page.html +4 -4
- data/test/failif.bxt +7 -7
- data/test/failif/page.html +5 -5
- data/test/format.bxt +17 -17
- data/test/format/page.html +6 -6
- data/test/frame.bxt +6 -6
- data/test/frame/child_frame.html +6 -6
- data/test/frame/grandchild_frame.html +4 -4
- data/test/frame/page.html +4 -4
- data/test/js.bxt +4 -4
- data/test/json.bxt +19 -19
- data/test/json/array.json +3 -3
- data/test/json/object.json +13 -13
- data/test/load.bxt +18 -18
- data/test/load/child.bxt +12 -12
- data/test/parsers.bxt +1 -1
- data/test/parsers.csv +7 -7
- data/test/parsers.html +32 -32
- data/test/parsers/page.html +6 -6
- data/test/return.bxt +1 -1
- data/test/return/f1.bxt +1 -1
- data/test/return/f2.bxt +1 -1
- data/test/return/f3.bxt +1 -1
- data/test/return/f4.bxt +2 -2
- data/test/ruby.bxt +1 -1
- data/test/ruby/custom.rb +5 -5
- data/test/select.bxt +9 -9
- data/test/select/page.html +8 -8
- data/test/selectors.bxt +7 -7
- data/test/selectors/page.html +6 -6
- data/test/set_builtin.bxt +5 -0
- data/test/set_builtin/page.html +5 -0
- data/test/setif.bxt +3 -3
- data/test/smart_selector.bxt +17 -17
- data/test/smart_selector/page.html +17 -17
- data/test/stdin.bxt +0 -0
- data/test/submit.bxt +4 -4
- data/test/submit/page.html +6 -6
- data/test/submit/page2.html +4 -4
- data/test/test.bxt.manual +6 -6
- data/test/test/test1.bxt +2 -2
- data/test/test/test2.bxt +3 -3
- data/test/test/test3.bxt +2 -2
- data/test/test/test4.bxt +1 -1
- data/test/test/test5.bxt +1 -1
- data/test/window.bxt +14 -14
- data/test/window/page.html +5 -5
- data/test/window/popup.html +4 -4
- metadata +5 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4e4b9b5349a70dbe3cbd5892facb9c4900f8b878
|
4
|
+
data.tar.gz: 9c6ee3877f018770332e0d9633eb88f59616e80b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 374767dfa172b743949b60345399f79accc0627bf1d4e2099011ff1f1013451503b9615a362635316ca347f1d0b600a031c2a7348fbfeb39df7afa94208a481f
|
7
|
+
data.tar.gz: 442c3bd0458d31452c3a68ed32164697a2dd2bdb890fea4787bf23930a442230adb625a0f3d2c91e913f3906924219cb8a71a18d357d9714ddd633076d78af61
|
data/LICENSE
CHANGED
@@ -1,21 +1,21 @@
|
|
1
|
-
The MIT License (MIT)
|
2
|
-
|
3
|
-
Copyright (c) 2014 Patricio Zavolinsky
|
4
|
-
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
7
|
-
in the Software without restriction, including without limitation the rights
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
10
|
-
furnished to do so, subject to the following conditions:
|
11
|
-
|
12
|
-
The above copyright notice and this permission notice shall be included in
|
13
|
-
all copies or substantial portions of the Software.
|
14
|
-
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
-
SOFTWARE.
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2014 Patricio Zavolinsky
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
data/README.md
CHANGED
@@ -1,293 +1,293 @@
|
|
1
|
-
bauxite
|
2
|
-
=======
|
3
|
-
|
4
|
-
Bauxite is a façade over Selenium intended for non-developers
|
5
|
-
|
6
|
-
The idea behind this project was to create a tool that allows non-developers to write web tests in a human-readable language. Another major requirement is to be able to easily extend the test language to create functional abstractions over technical details.
|
7
|
-
|
8
|
-
Take a look at the following Ruby excerpt from http://code.google.com/p/selenium/wiki/RubyBindings:
|
9
|
-
|
10
|
-
require "selenium-webdriver"
|
11
|
-
|
12
|
-
driver = Selenium::WebDriver.for :firefox
|
13
|
-
driver.navigate.to "http://google.com"
|
14
|
-
|
15
|
-
element = driver.find_element(:name, 'q')
|
16
|
-
element.send_keys "Hello WebDriver!"
|
17
|
-
element.submit
|
18
|
-
|
19
|
-
puts driver.title
|
20
|
-
|
21
|
-
driver.quit
|
22
|
-
|
23
|
-
While developers might find that code expressive enough, non-developers might be a bit shocked.
|
24
|
-
|
25
|
-
The equivalent Bauxite test is easier on the eyes:
|
26
|
-
|
27
|
-
open "http://google.com"
|
28
|
-
write "name=q" "Hello WebDriver!"
|
29
|
-
click "gbqfb"
|
30
|
-
|
31
|
-
|
32
|
-
Installation
|
33
|
-
------------
|
34
|
-
|
35
|
-
In a nutshell:
|
36
|
-
|
37
|
-
gem install bauxite
|
38
|
-
|
39
|
-
|
40
|
-
If you don't have Ruby 2.x yet, check the [Installing Ruby](#installing-ruby) section below.
|
41
|
-
|
42
|
-
Remember you should probably install [Firefox](http://www.mozilla.org) (unless you want to use other browsers or Selenium server by specifying the `-p` switch to the `bauxite` executable).
|
43
|
-
|
44
|
-
You might also like to try the [bauxite-capture](https://github.com/pzavolinsky/bauxite-capture) Firefox add-on to record Bauxite tests directly from the browser (please note that this extension is still *very* experimental so its not yet hosted in the Mozilla add-ons page).
|
45
|
-
|
46
|
-
Hello World
|
47
|
-
-----------
|
48
|
-
|
49
|
-
Paste the following text into `hello.bxt`:
|
50
|
-
|
51
|
-
open "http://www.gnu.org/fun/jokes/helloworld.html"
|
52
|
-
|
53
|
-
Launch a terminal/command prompt and type:
|
54
|
-
|
55
|
-
bauxite hello.bxt
|
56
|
-
|
57
|
-
Command-line Interface
|
58
|
-
----------------------
|
59
|
-
|
60
|
-
The `bauxite` command-line program supports several configuration options.
|
61
|
-
|
62
|
-
Refer to the [RDoc documentation](http://pzavolinsky.github.io/bauxite/Bauxite/Application.html) for more details.
|
63
|
-
|
64
|
-
|
65
|
-
The Bauxite Language
|
66
|
-
--------------------
|
67
|
-
|
68
|
-
The Bauxite language is composed of two elements `Actions` and `Selectors`: Actions are testing operations such as "open this page", "click this button", "write this text into that textbox", etc. Selectors are ways of locating interesting elements of a page such as a button, a textbox, a label, etc.
|
69
|
-
|
70
|
-
A typical Bauxite test is a plain text file that contains a series of Actions (one per line). Depending on the Action, a few action arguments might need to be specified as well. For example in:
|
71
|
-
|
72
|
-
open "http://google.com"
|
73
|
-
write "name=q" "Hello WebDriver!"
|
74
|
-
click "gbqfb"
|
75
|
-
|
76
|
-
`open`, `write` and `click` are Actions:
|
77
|
-
- `open` takes a single URL argument (`"http://google.com"`) and opens that URL in the browser.
|
78
|
-
- `write` takes two arguments, a Selector (`name=q`, more on this in a bit) and a text (`"Hello WebDriver!"`), and writes the text into the element specified by the Selector.
|
79
|
-
- `click` takes a single Selector argument (`gbqfb`) and clicks the element specified by the Selector.
|
80
|
-
|
81
|
-
In general, Action arguments can be surrounded by optional double quote characters (`"`). If an argument contains a space character, the quotes are mandatory (this is the case for the second argument to `write` in the example above).
|
82
|
-
|
83
|
-
Some Actions operate on page elements (e.g. `write`, `click`, etc.). In order to locate these elements, Bauxite uses Selectors.
|
84
|
-
|
85
|
-
The trivial Selector is just a text that matches the last portion of the `id` attribute of the target element.
|
86
|
-
|
87
|
-
For example, in this HTML fragment:
|
88
|
-
|
89
|
-
<input type="submit" id="gbqfb" value="Search" />
|
90
|
-
|
91
|
-
If we want to click the "Search" button we can do the following:
|
92
|
-
|
93
|
-
click "gbqfb"
|
94
|
-
|
95
|
-
Bauxite supports several other Selectors such as `name=` in the example above. The `name` Selector finds elements whose `name` attribute matches the text following the `=` sign.
|
96
|
-
|
97
|
-
For example, in this HTML fragment:
|
98
|
-
|
99
|
-
<input type="text" name="q" />
|
100
|
-
|
101
|
-
If we want to type the text "Hello WebDriver!" in the textbox we can do the following:
|
102
|
-
|
103
|
-
write "name=q" "Hello WebDriver!"
|
104
|
-
|
105
|
-
This section presented a brief introduction into the basic Bauxite concepts. For more details and a list of every Action and Selector available, refer to the RDoc generated documentation in:
|
106
|
-
|
107
|
-
- [Available Actions](http://pzavolinsky.github.io/bauxite/Bauxite/Action.html#Action+Methods)
|
108
|
-
- [Available Bauxite Selectors](http://pzavolinsky.github.io/bauxite/Bauxite/Selector.html#Selector+Methods)
|
109
|
-
- [Selenium Standard Selectors](http://pzavolinsky.github.io/bauxite/Bauxite/Selector.html#class-Bauxite::Selector-label-Standard+Selenium+Selectors)
|
110
|
-
- [Bauxite Variables](http://pzavolinsky.github.io/bauxite/Bauxite/Context.html#class-Bauxite::Context-label-Context+variables)
|
111
|
-
- [Creating new Actions](http://pzavolinsky.github.io/bauxite/Bauxite/Action.html)
|
112
|
-
- [Creating new Selectors](http://pzavolinsky.github.io/bauxite/Bauxite/Selector.html)
|
113
|
-
|
114
|
-
Firefox add-on
|
115
|
-
--------------
|
116
|
-
|
117
|
-
As an alternative method of writing Bauxite tests, you might try the [bauxite-capture](https://github.com/pzavolinsky/bauxite-capture) Firefox add-on to record Bauxite tests directly from the browser (please note that this extension is still *very* experimental so its not yet hosted in the Mozilla add-ons page).
|
118
|
-
|
119
|
-
Installing Ruby
|
120
|
-
---------------
|
121
|
-
|
122
|
-
I won't cover all the details of installing Ruby on your system (Google knows best), but the following should probably work.
|
123
|
-
|
124
|
-
In GNU/Linux, you can install [RVM](http://rvm.io/), then Ruby:
|
125
|
-
|
126
|
-
curl -sSL https://get.rvm.io | bash -s stable
|
127
|
-
source ~/.rvm/scripts/rvm
|
128
|
-
rvm install ruby-2.1.0
|
129
|
-
|
130
|
-
In Windows, you can install Ruby 2.x with [RubyInstaller](http://rubyinstaller.org/downloads/). After everything is installed, launch the `Start Command Prompt with Ruby` option in your start menu.
|
131
|
-
|
132
|
-
Regadless of your OS, you should be able to install Bauxite with:
|
133
|
-
|
134
|
-
gem install bauxite
|
135
|
-
|
136
|
-
Implementation
|
137
|
-
--------------
|
138
|
-
|
139
|
-
Bauxite is both a command-line program and a library. You can use the program to run Bauxite tests directly from a terminal, or you can embed the library in your own application.
|
140
|
-
|
141
|
-
The command-line program is called `bauxite` and has several command-line options, refer to the [RDoc documentation](http://pzavolinsky.github.io/bauxite/Bauxite/Application.html) for more details.
|
142
|
-
|
143
|
-
If you are looking to embed Bauxite in your application take a look a the code in `lib/bauxite/application.rb`, that should give you a full example of how to create a Bauxite Context and execute some actions.
|
144
|
-
|
145
|
-
Extending Bauxite
|
146
|
-
-----------------
|
147
|
-
|
148
|
-
Bauxite supports two types of extensions: functional extensions and coded plugins.
|
149
|
-
|
150
|
-
### Functional extensions
|
151
|
-
|
152
|
-
Functional extensions are composite constructs created using existing Bauxite actions to convey functional meaning. For example, imagine a login form:
|
153
|
-
|
154
|
-
<!-- http://hostname/login.html -->
|
155
|
-
<form>
|
156
|
-
<input id="username" name="username" type="text" />
|
157
|
-
<input id="password" name="password" type="password" />
|
158
|
-
<input id="login" type="submit" value="Login"/>
|
159
|
-
</form>
|
160
|
-
|
161
|
-
The Bauxite code to login into this site would be:
|
162
|
-
|
163
|
-
open "http://hostname/login.html"
|
164
|
-
write "username" "jdoe"
|
165
|
-
write "password" "hello world!"
|
166
|
-
click "login"
|
167
|
-
|
168
|
-
If we were creating a suite of automated web tests for our *hostname* site, we'll probably need to login into the site several times. This would mean copy/pasting the four lines above into every test in our suite.
|
169
|
-
|
170
|
-
Of course we can do better. We can split Bauxite tests into many files and include one test into another with the `load` action.
|
171
|
-
|
172
|
-
# my_test.bxt (by the way, this is a comment)
|
173
|
-
load other_test_fragment.bxt
|
174
|
-
...
|
175
|
-
|
176
|
-
Back to our login example, first we can package the login part of our tests into a separate Bauxite file:
|
177
|
-
|
178
|
-
# login.bxt
|
179
|
-
open "http://hostname/login.html"
|
180
|
-
write "username" "jdoe"
|
181
|
-
write "password" "hello world!"
|
182
|
-
click "login"
|
183
|
-
|
184
|
-
Of course we would like to be able to login with different username/password combinations, so we can replace the literals in `login.bxt` with variables:
|
185
|
-
|
186
|
-
# login.bxt
|
187
|
-
open "http://hostname/login.html"
|
188
|
-
write "username" "${username}"
|
189
|
-
write "password" "${password}"
|
190
|
-
click "login"
|
191
|
-
|
192
|
-
Now, we would like to assert that both `username` and `password` variables are set before calling our test (just in case someone forgets). We can do this with `params`
|
193
|
-
|
194
|
-
# login.bxt
|
195
|
-
params username password
|
196
|
-
open "http://hostname/login.html"
|
197
|
-
write "username" "${username}"
|
198
|
-
write "password" "${password}"
|
199
|
-
click "login"
|
200
|
-
|
201
|
-
In our main test we can load `login.bxt` and specify the variables required using this code:
|
202
|
-
|
203
|
-
# main_test.bxt
|
204
|
-
load "login.bxt" "username=jdoe" "password=hello world!"
|
205
|
-
|
206
|
-
# additional actions go here
|
207
|
-
|
208
|
-
We could improve this even further by creating an `alias` to simplify the login process. To do this, lets create an new file called `alias.bxt`:
|
209
|
-
|
210
|
-
# alias.bxt
|
211
|
-
alias "login" "load" "login.bxt" "username=${1}" "password=${2}"
|
212
|
-
|
213
|
-
Note that the `alias` action supports positional arguments.
|
214
|
-
|
215
|
-
Now we can change our main test to use our alias:
|
216
|
-
|
217
|
-
# main_test.bxt
|
218
|
-
load "alias.bxt"
|
219
|
-
|
220
|
-
login "jdoe" "hello world!"
|
221
|
-
|
222
|
-
# additional actions go here
|
223
|
-
|
224
|
-
That was a bit of work but the resulting test is purely functional (minus the load alias part, of course).
|
225
|
-
|
226
|
-
### Coded plugins
|
227
|
-
|
228
|
-
Coded plugins are Ruby files that extend the Bauxite language by providing additional language elements. Coded plugins can be used to create Bauxite actions, selectors and loggers.
|
229
|
-
|
230
|
-
For example lets assume that throughout a web application input elements were identified using a custom HTML attribute instead of `id`. For example:
|
231
|
-
|
232
|
-
<form>
|
233
|
-
<input custom-attr="username" type="text" />
|
234
|
-
<input custom-attr="password" type="password" />
|
235
|
-
<input custom-attr="login" type="submit" value="Login"/>
|
236
|
-
</form>
|
237
|
-
|
238
|
-
Using standard Bauxite language we could select these elements using:
|
239
|
-
|
240
|
-
# === my_test.bxt === #
|
241
|
-
write "attr=custom-attr:username" "jdoe"
|
242
|
-
write "attr=custom-attr:password" "hello world!"
|
243
|
-
click "attr=custom-attr:login"
|
244
|
-
|
245
|
-
But we can improve the overall readability of our test by using a coded plugin:
|
246
|
-
|
247
|
-
# === plugins/custom_selector.rb === #
|
248
|
-
class Bauxite::Selector
|
249
|
-
def custom(value)
|
250
|
-
attr "custom-attr:#{value}"
|
251
|
-
end
|
252
|
-
end
|
253
|
-
|
254
|
-
Now we can change our test to look like this:
|
255
|
-
|
256
|
-
# === my_test.bxt === #
|
257
|
-
write "custom=username" "jdoe"
|
258
|
-
write "custom=password" "hello world!"
|
259
|
-
click "custom=login"
|
260
|
-
|
261
|
-
Finally, to execute Bauxite loading our plugin we can type:
|
262
|
-
|
263
|
-
bauxite -e plugins my_test.bxt
|
264
|
-
|
265
|
-
Jenkins Integration
|
266
|
-
-------------------
|
267
|
-
|
268
|
-
If you want to run Bauxite tests in your [Jenkins CI](http://jenkins-ci.org/) server you must install `xvfb` and `selenium-server-standalone`. Googling for `selenium headless jenkins <your distro>` is a great start. Assuming you installed Ruby and Bauxite for the `jenkins` user (see the instructions above), you can create an execute shell build task with the following text:
|
269
|
-
|
270
|
-
#!/bin/bash
|
271
|
-
source ~/.rvm/scripts/rvm
|
272
|
-
bauxite -t 60 -o 240 --jenkins "$WORKSPACE/test-results" \
|
273
|
-
"$WORKSPACE/test/suite.bxt"
|
274
|
-
|
275
|
-
Assuming you have Selenium Server running on localhost and your workspace (e.g. GIT repo) contains a folder named `test` with a file named `suite.bxt` the configuration above should work like a charm.
|
276
|
-
|
277
|
-
`suite.bxt` could be something like:
|
278
|
-
|
279
|
-
# === suite.bxt === #
|
280
|
-
test login.bxt
|
281
|
-
test register.bxt
|
282
|
-
test browse_around.bxt
|
283
|
-
test purchase_something.bxt
|
284
|
-
# more tests here...
|
285
|
-
|
286
|
-
Note the `--jenkins` option in the configuration above. That option sets the default configuration arguments for Jenkins integration. For more details on the `bauxite` command-line arguments refer to the [RDoc documentation](http://pzavolinsky.github.io/bauxite/Bauxite/Application.html).
|
287
|
-
|
288
|
-
I won't go into the details of configuring the Jenkins publishing plugins to print Bauxite test results, but instead take a look at this [preconfigured Jenkins `config.xml`](https://raw.github.com/pzavolinsky/bauxite/master/jenkins/config.xml). This Jenkins configuration requires the following plugins:
|
289
|
-
|
290
|
-
- [Git](https://wiki.jenkins-ci.org/display/JENKINS/Git+Plugin) (required by the template, optional if you are not using Git)
|
291
|
-
- [Flexible Publish](https://wiki.jenkins-ci.org/display/JENKINS/Flexible+Publish+Plugin) (to archive test results on failed builds)
|
292
|
-
- [Plot](https://wiki.jenkins-ci.org/display/JENKINS/Flexible+Publish+Plugin) (to plot the test result summary)
|
293
|
-
|
1
|
+
bauxite
|
2
|
+
=======
|
3
|
+
|
4
|
+
Bauxite is a façade over Selenium intended for non-developers
|
5
|
+
|
6
|
+
The idea behind this project was to create a tool that allows non-developers to write web tests in a human-readable language. Another major requirement is to be able to easily extend the test language to create functional abstractions over technical details.
|
7
|
+
|
8
|
+
Take a look at the following Ruby excerpt from http://code.google.com/p/selenium/wiki/RubyBindings:
|
9
|
+
|
10
|
+
require "selenium-webdriver"
|
11
|
+
|
12
|
+
driver = Selenium::WebDriver.for :firefox
|
13
|
+
driver.navigate.to "http://google.com"
|
14
|
+
|
15
|
+
element = driver.find_element(:name, 'q')
|
16
|
+
element.send_keys "Hello WebDriver!"
|
17
|
+
element.submit
|
18
|
+
|
19
|
+
puts driver.title
|
20
|
+
|
21
|
+
driver.quit
|
22
|
+
|
23
|
+
While developers might find that code expressive enough, non-developers might be a bit shocked.
|
24
|
+
|
25
|
+
The equivalent Bauxite test is easier on the eyes:
|
26
|
+
|
27
|
+
open "http://google.com"
|
28
|
+
write "name=q" "Hello WebDriver!"
|
29
|
+
click "gbqfb"
|
30
|
+
|
31
|
+
|
32
|
+
Installation
|
33
|
+
------------
|
34
|
+
|
35
|
+
In a nutshell:
|
36
|
+
|
37
|
+
gem install bauxite
|
38
|
+
|
39
|
+
|
40
|
+
If you don't have Ruby 2.x yet, check the [Installing Ruby](#installing-ruby) section below.
|
41
|
+
|
42
|
+
Remember you should probably install [Firefox](http://www.mozilla.org) (unless you want to use other browsers or Selenium server by specifying the `-p` switch to the `bauxite` executable).
|
43
|
+
|
44
|
+
You might also like to try the [bauxite-capture](https://github.com/pzavolinsky/bauxite-capture) Firefox add-on to record Bauxite tests directly from the browser (please note that this extension is still *very* experimental so its not yet hosted in the Mozilla add-ons page).
|
45
|
+
|
46
|
+
Hello World
|
47
|
+
-----------
|
48
|
+
|
49
|
+
Paste the following text into `hello.bxt`:
|
50
|
+
|
51
|
+
open "http://www.gnu.org/fun/jokes/helloworld.html"
|
52
|
+
|
53
|
+
Launch a terminal/command prompt and type:
|
54
|
+
|
55
|
+
bauxite hello.bxt
|
56
|
+
|
57
|
+
Command-line Interface
|
58
|
+
----------------------
|
59
|
+
|
60
|
+
The `bauxite` command-line program supports several configuration options.
|
61
|
+
|
62
|
+
Refer to the [RDoc documentation](http://pzavolinsky.github.io/bauxite/Bauxite/Application.html) for more details.
|
63
|
+
|
64
|
+
|
65
|
+
The Bauxite Language
|
66
|
+
--------------------
|
67
|
+
|
68
|
+
The Bauxite language is composed of two elements `Actions` and `Selectors`: Actions are testing operations such as "open this page", "click this button", "write this text into that textbox", etc. Selectors are ways of locating interesting elements of a page such as a button, a textbox, a label, etc.
|
69
|
+
|
70
|
+
A typical Bauxite test is a plain text file that contains a series of Actions (one per line). Depending on the Action, a few action arguments might need to be specified as well. For example in:
|
71
|
+
|
72
|
+
open "http://google.com"
|
73
|
+
write "name=q" "Hello WebDriver!"
|
74
|
+
click "gbqfb"
|
75
|
+
|
76
|
+
`open`, `write` and `click` are Actions:
|
77
|
+
- `open` takes a single URL argument (`"http://google.com"`) and opens that URL in the browser.
|
78
|
+
- `write` takes two arguments, a Selector (`name=q`, more on this in a bit) and a text (`"Hello WebDriver!"`), and writes the text into the element specified by the Selector.
|
79
|
+
- `click` takes a single Selector argument (`gbqfb`) and clicks the element specified by the Selector.
|
80
|
+
|
81
|
+
In general, Action arguments can be surrounded by optional double quote characters (`"`). If an argument contains a space character, the quotes are mandatory (this is the case for the second argument to `write` in the example above).
|
82
|
+
|
83
|
+
Some Actions operate on page elements (e.g. `write`, `click`, etc.). In order to locate these elements, Bauxite uses Selectors.
|
84
|
+
|
85
|
+
The trivial Selector is just a text that matches the last portion of the `id` attribute of the target element.
|
86
|
+
|
87
|
+
For example, in this HTML fragment:
|
88
|
+
|
89
|
+
<input type="submit" id="gbqfb" value="Search" />
|
90
|
+
|
91
|
+
If we want to click the "Search" button we can do the following:
|
92
|
+
|
93
|
+
click "gbqfb"
|
94
|
+
|
95
|
+
Bauxite supports several other Selectors such as `name=` in the example above. The `name` Selector finds elements whose `name` attribute matches the text following the `=` sign.
|
96
|
+
|
97
|
+
For example, in this HTML fragment:
|
98
|
+
|
99
|
+
<input type="text" name="q" />
|
100
|
+
|
101
|
+
If we want to type the text "Hello WebDriver!" in the textbox we can do the following:
|
102
|
+
|
103
|
+
write "name=q" "Hello WebDriver!"
|
104
|
+
|
105
|
+
This section presented a brief introduction into the basic Bauxite concepts. For more details and a list of every Action and Selector available, refer to the RDoc generated documentation in:
|
106
|
+
|
107
|
+
- [Available Actions](http://pzavolinsky.github.io/bauxite/Bauxite/Action.html#Action+Methods)
|
108
|
+
- [Available Bauxite Selectors](http://pzavolinsky.github.io/bauxite/Bauxite/Selector.html#Selector+Methods)
|
109
|
+
- [Selenium Standard Selectors](http://pzavolinsky.github.io/bauxite/Bauxite/Selector.html#class-Bauxite::Selector-label-Standard+Selenium+Selectors)
|
110
|
+
- [Bauxite Variables](http://pzavolinsky.github.io/bauxite/Bauxite/Context.html#class-Bauxite::Context-label-Context+variables)
|
111
|
+
- [Creating new Actions](http://pzavolinsky.github.io/bauxite/Bauxite/Action.html)
|
112
|
+
- [Creating new Selectors](http://pzavolinsky.github.io/bauxite/Bauxite/Selector.html)
|
113
|
+
|
114
|
+
Firefox add-on
|
115
|
+
--------------
|
116
|
+
|
117
|
+
As an alternative method of writing Bauxite tests, you might try the [bauxite-capture](https://github.com/pzavolinsky/bauxite-capture) Firefox add-on to record Bauxite tests directly from the browser (please note that this extension is still *very* experimental so its not yet hosted in the Mozilla add-ons page).
|
118
|
+
|
119
|
+
Installing Ruby
|
120
|
+
---------------
|
121
|
+
|
122
|
+
I won't cover all the details of installing Ruby on your system (Google knows best), but the following should probably work.
|
123
|
+
|
124
|
+
In GNU/Linux, you can install [RVM](http://rvm.io/), then Ruby:
|
125
|
+
|
126
|
+
curl -sSL https://get.rvm.io | bash -s stable
|
127
|
+
source ~/.rvm/scripts/rvm
|
128
|
+
rvm install ruby-2.1.0
|
129
|
+
|
130
|
+
In Windows, you can install Ruby 2.x with [RubyInstaller](http://rubyinstaller.org/downloads/). After everything is installed, launch the `Start Command Prompt with Ruby` option in your start menu.
|
131
|
+
|
132
|
+
Regadless of your OS, you should be able to install Bauxite with:
|
133
|
+
|
134
|
+
gem install bauxite
|
135
|
+
|
136
|
+
Implementation
|
137
|
+
--------------
|
138
|
+
|
139
|
+
Bauxite is both a command-line program and a library. You can use the program to run Bauxite tests directly from a terminal, or you can embed the library in your own application.
|
140
|
+
|
141
|
+
The command-line program is called `bauxite` and has several command-line options, refer to the [RDoc documentation](http://pzavolinsky.github.io/bauxite/Bauxite/Application.html) for more details.
|
142
|
+
|
143
|
+
If you are looking to embed Bauxite in your application take a look a the code in `lib/bauxite/application.rb`, that should give you a full example of how to create a Bauxite Context and execute some actions.
|
144
|
+
|
145
|
+
Extending Bauxite
|
146
|
+
-----------------
|
147
|
+
|
148
|
+
Bauxite supports two types of extensions: functional extensions and coded plugins.
|
149
|
+
|
150
|
+
### Functional extensions
|
151
|
+
|
152
|
+
Functional extensions are composite constructs created using existing Bauxite actions to convey functional meaning. For example, imagine a login form:
|
153
|
+
|
154
|
+
<!-- http://hostname/login.html -->
|
155
|
+
<form>
|
156
|
+
<input id="username" name="username" type="text" />
|
157
|
+
<input id="password" name="password" type="password" />
|
158
|
+
<input id="login" type="submit" value="Login"/>
|
159
|
+
</form>
|
160
|
+
|
161
|
+
The Bauxite code to login into this site would be:
|
162
|
+
|
163
|
+
open "http://hostname/login.html"
|
164
|
+
write "username" "jdoe"
|
165
|
+
write "password" "hello world!"
|
166
|
+
click "login"
|
167
|
+
|
168
|
+
If we were creating a suite of automated web tests for our *hostname* site, we'll probably need to login into the site several times. This would mean copy/pasting the four lines above into every test in our suite.
|
169
|
+
|
170
|
+
Of course we can do better. We can split Bauxite tests into many files and include one test into another with the `load` action.
|
171
|
+
|
172
|
+
# my_test.bxt (by the way, this is a comment)
|
173
|
+
load other_test_fragment.bxt
|
174
|
+
...
|
175
|
+
|
176
|
+
Back to our login example, first we can package the login part of our tests into a separate Bauxite file:
|
177
|
+
|
178
|
+
# login.bxt
|
179
|
+
open "http://hostname/login.html"
|
180
|
+
write "username" "jdoe"
|
181
|
+
write "password" "hello world!"
|
182
|
+
click "login"
|
183
|
+
|
184
|
+
Of course we would like to be able to login with different username/password combinations, so we can replace the literals in `login.bxt` with variables:
|
185
|
+
|
186
|
+
# login.bxt
|
187
|
+
open "http://hostname/login.html"
|
188
|
+
write "username" "${username}"
|
189
|
+
write "password" "${password}"
|
190
|
+
click "login"
|
191
|
+
|
192
|
+
Now, we would like to assert that both `username` and `password` variables are set before calling our test (just in case someone forgets). We can do this with `params`
|
193
|
+
|
194
|
+
# login.bxt
|
195
|
+
params username password
|
196
|
+
open "http://hostname/login.html"
|
197
|
+
write "username" "${username}"
|
198
|
+
write "password" "${password}"
|
199
|
+
click "login"
|
200
|
+
|
201
|
+
In our main test we can load `login.bxt` and specify the variables required using this code:
|
202
|
+
|
203
|
+
# main_test.bxt
|
204
|
+
load "login.bxt" "username=jdoe" "password=hello world!"
|
205
|
+
|
206
|
+
# additional actions go here
|
207
|
+
|
208
|
+
We could improve this even further by creating an `alias` to simplify the login process. To do this, lets create an new file called `alias.bxt`:
|
209
|
+
|
210
|
+
# alias.bxt
|
211
|
+
alias "login" "load" "login.bxt" "username=${1}" "password=${2}"
|
212
|
+
|
213
|
+
Note that the `alias` action supports positional arguments.
|
214
|
+
|
215
|
+
Now we can change our main test to use our alias:
|
216
|
+
|
217
|
+
# main_test.bxt
|
218
|
+
load "alias.bxt"
|
219
|
+
|
220
|
+
login "jdoe" "hello world!"
|
221
|
+
|
222
|
+
# additional actions go here
|
223
|
+
|
224
|
+
That was a bit of work but the resulting test is purely functional (minus the load alias part, of course).
|
225
|
+
|
226
|
+
### Coded plugins
|
227
|
+
|
228
|
+
Coded plugins are Ruby files that extend the Bauxite language by providing additional language elements. Coded plugins can be used to create Bauxite actions, selectors and loggers.
|
229
|
+
|
230
|
+
For example lets assume that throughout a web application input elements were identified using a custom HTML attribute instead of `id`. For example:
|
231
|
+
|
232
|
+
<form>
|
233
|
+
<input custom-attr="username" type="text" />
|
234
|
+
<input custom-attr="password" type="password" />
|
235
|
+
<input custom-attr="login" type="submit" value="Login"/>
|
236
|
+
</form>
|
237
|
+
|
238
|
+
Using standard Bauxite language we could select these elements using:
|
239
|
+
|
240
|
+
# === my_test.bxt === #
|
241
|
+
write "attr=custom-attr:username" "jdoe"
|
242
|
+
write "attr=custom-attr:password" "hello world!"
|
243
|
+
click "attr=custom-attr:login"
|
244
|
+
|
245
|
+
But we can improve the overall readability of our test by using a coded plugin:
|
246
|
+
|
247
|
+
# === plugins/custom_selector.rb === #
|
248
|
+
class Bauxite::Selector
|
249
|
+
def custom(value)
|
250
|
+
attr "custom-attr:#{value}"
|
251
|
+
end
|
252
|
+
end
|
253
|
+
|
254
|
+
Now we can change our test to look like this:
|
255
|
+
|
256
|
+
# === my_test.bxt === #
|
257
|
+
write "custom=username" "jdoe"
|
258
|
+
write "custom=password" "hello world!"
|
259
|
+
click "custom=login"
|
260
|
+
|
261
|
+
Finally, to execute Bauxite loading our plugin we can type:
|
262
|
+
|
263
|
+
bauxite -e plugins my_test.bxt
|
264
|
+
|
265
|
+
Jenkins Integration
|
266
|
+
-------------------
|
267
|
+
|
268
|
+
If you want to run Bauxite tests in your [Jenkins CI](http://jenkins-ci.org/) server you must install `xvfb` and `selenium-server-standalone`. Googling for `selenium headless jenkins <your distro>` is a great start. Assuming you installed Ruby and Bauxite for the `jenkins` user (see the instructions above), you can create an execute shell build task with the following text:
|
269
|
+
|
270
|
+
#!/bin/bash
|
271
|
+
source ~/.rvm/scripts/rvm
|
272
|
+
bauxite -t 60 -o 240 --jenkins "$WORKSPACE/test-results" \
|
273
|
+
"$WORKSPACE/test/suite.bxt"
|
274
|
+
|
275
|
+
Assuming you have Selenium Server running on localhost and your workspace (e.g. GIT repo) contains a folder named `test` with a file named `suite.bxt` the configuration above should work like a charm.
|
276
|
+
|
277
|
+
`suite.bxt` could be something like:
|
278
|
+
|
279
|
+
# === suite.bxt === #
|
280
|
+
test login.bxt
|
281
|
+
test register.bxt
|
282
|
+
test browse_around.bxt
|
283
|
+
test purchase_something.bxt
|
284
|
+
# more tests here...
|
285
|
+
|
286
|
+
Note the `--jenkins` option in the configuration above. That option sets the default configuration arguments for Jenkins integration. For more details on the `bauxite` command-line arguments refer to the [RDoc documentation](http://pzavolinsky.github.io/bauxite/Bauxite/Application.html).
|
287
|
+
|
288
|
+
I won't go into the details of configuring the Jenkins publishing plugins to print Bauxite test results, but instead take a look at this [preconfigured Jenkins `config.xml`](https://raw.github.com/pzavolinsky/bauxite/master/jenkins/config.xml). This Jenkins configuration requires the following plugins:
|
289
|
+
|
290
|
+
- [Git](https://wiki.jenkins-ci.org/display/JENKINS/Git+Plugin) (required by the template, optional if you are not using Git)
|
291
|
+
- [Flexible Publish](https://wiki.jenkins-ci.org/display/JENKINS/Flexible+Publish+Plugin) (to archive test results on failed builds)
|
292
|
+
- [Plot](https://wiki.jenkins-ci.org/display/JENKINS/Flexible+Publish+Plugin) (to plot the test result summary)
|
293
|
+
|