Status:
Alpha.
Parser/Executor is working for the syntax (below). More operations
and better output is required before we can go to beta.
Goal:
This project's goal is to create tests in a meta-language where tests can be written and understood in a syntax closer to english.
Overview:
This project is an attempt to make
maintenance of automated browser tests easier for web applications.
When the code in a project matures, the amount of tests grows and changes become more complex and potentially have a broader impact. As a developer I want to be able to offload some of the test maintenance and creation to the qa and/or business so I can spend more time on building cool new features. Possible opportunities would be the high-level tests like of defining critical paths through the site or new features. These tests that will probably live the longest because they have the least coupling with implementation. Some of the more technical tests that are a bit closer to the metal will always be maintained by developers, but you don't need to be a developer to understand the high-level business requirements and script basic tests against the application.
Sample Syntax:
Here is the syntax for a test scenario:
test
the home page.
show
that the page loads.
use
firefox, ie, chrome.
define
target page as http://www.google.com.
define
search box as element named 'q'.
{
go
to the target page.
clear
the search box.
send
'asdf' to the search box.
assert
the search box has value 'asdf'
}
The first line will define the target page for the story:
test
the home page.
The second line defines what we are testing:
show
that the page loads.
The third line will define the browsers we want to test the story against.
use firefox, ie, chrome.
The next lines will define variables I can push into the test steps
define target page as http://www.google.com.
define search box as element
named 'q'.
And finally the test steps are embedded in brackets:
{
go
to the target page.
clear
the search box.
send
'asdf' to the search box.
assert
the search box has value
'asdf'
}
Made possible by:
http://phantomjs.org/
https://github.com/sprache/Sprache
http://docs.seleniumhq.org/
Primary projects in this solution:
- MC.Selenium.DSL : the project that parses and runs the test stept
- MC.Selenium.Runner: the command line to execute the test
- MC.Selenium.DSL.Runner.Model: the project the parses the scenario syntax
Project:
MC.Selenium.DSL
this
project extends the OpenQA.Selenium.IWebDriver by adding a
.ExecuteCommand() method that you can pass a test step, or series of
test steps to.
Sample supported commands:
- clear element with id "gbqfq"
- clear element with name 'q'
- clear element named 'q'
- send 'C6E2E7D1-1D7B-4390-9E7C-4626B18CC137' to element with name 'q'
- send 'asdf' to element named 'q'
- click element with css selector '#gbqfb'
- click element with xpath "//button[@id='gbqfb']"
- click element with link text 'asdf'
- set element with name 'asdf' text to '1234'
- set text box with id '10' to '1234'
- set text area with id '10' to '1234'
- set radio button group with id '10' to 'x'
- set radio button with id '10' to 'x'
- set radio with id '10' to 'x'
- set check box with id 'xyz' to checked
- set check box with id 'xyz' to unchecked
- set check box with id 'xyz' to not checked
- set option with id 'opt2' to selected
- set option with id 'opt2' to unselected
- set option with id 'opt2' to not selected
- set select with id 'xyz' to 'option2'
- assert element with id '10' has attribute 'x'
- assert that element with id '10' has attribute 'x'
- assert that element with id '10' has value 'x'
- assert that element with id '10' has value that ends with 'x'
- assert that element with id '10' has value ending with 'x'
- assert that element with id '10' has value that begins with 'x'
- assert that element with id '10' has value beginning with 'x'
- assert that element with id '10' has value that contains 'x'
- assert that element with id '10' has value containing 'x'
- assert element with id '10' has attribute 'x' that ends with 'x'
- assert element with id '10' has attribute 'x' that contains 'asdf'
- assert element with id '10' has attribute 'x' ending with 'x'
- assert element with id '10' has attribute 'x' containing 'asdf'
- assert element with id '10' has attribute 'x' with value 'x'
- assert element with id '10' has css key 'x'
- assert element with id '10' has css key 'x' that ends with 'x'
- assert element with id '10' has css key 'x' that contains 'asdf'
- assert element with id '10' has css key 'x' ending with 'x'
- assert element with id '10' has css key 'x' containing 'asdf'
- assert element with id '10' has css key 'x' with value 'x'
- assert element with id '10' has text with value 'x'
- assert element with id '10' has text that ends with 'x'
- assert element with id '10' has text that contains 'asdf'
- assert element with id '10' has text ending with 'x'
- assert element with id '10' has text containing 'asdf'
- assert text box with id '10' has text with value '1234'
- assert text box with id '10' has value ending with '1234'
- assert text box with id '10' has value '1234'
- assert text box with id '10' has text ending with '1234'
- assert text area with id '10' has text with value '1234'
- assert radio button group with id '10' has text with value 'x'
- assert check box with id 'xyz' has attribute 'checked' with value 'true'
- assert check box with id 'xyz' is checked
- assert check box with id 'xyz' is unchecked
- assert check box with id 'xyz' is not checked
- assert select with id 'xyz' has value 'option2'
- assert select list with id 'xyz' has value 'option2'
- assert option with id 'opt1' is selected
- assert option with id 'opt1' is not selected
- assert option with id 'opt1' is
You
can combine commands by putting them in order and optionally
separating them with a period, comma, or 'then' text. The following
would be valid test instructions:
assert
select with id 'y' has value 'one',
assert
option with id 'opt1' is selected
then
assert option with id 'opt2' is not selected.
set
option with id 'opt2' to selected,
then
assert select with id 'y' has value 'two' assert option with id
'opt1' is not selected
assert
option with id 'opt2' is selected.
set
option with id 'opt2' to not selected,
assert
select with id 'y' has value ''
- expanded syntax
- javascript execution
- more form interactions
- better
logging/reporting
- parsing
- execution
- mono version
Project:
MC.Selenium.DSL.Runner
This project contains the executable to run tests:
|
SeleniumDSLRunner.exe Sample1.rst |
- better logging/output
- supporting nunit xml output (for build server integration)
- mono version
This project contains the model code for the Runner.
Working on:
- better
reporting/logging
- parsing
- execution
- adding more test definition syntax
-
mono version