Houston I have a problem

Validation Step Commands

Follow

The StillAlive Script Editor has many types of steps that you can use to navigate, perform actions and check things on your website.

The commands are broken down into three main categories, navigation, action and validation. This docuemnt explains the different type of Validation Commands you can use to ask StillAlive to ensure something is happening the way it should be or something is or is not there.

There are eight available action steps;

Then I should be on PATH

This step allows you to confirm that you are on a specific path or full URL.

For example, say you were redirecting your old site to your new website, you would want to make sure that redirection stays in place with StillAlive, you could write steps like:

When I go to http://old.example.net/ expecting a 301 response
Then I should be on https://new.example.com/
Then I should see "Welcome to our website"

You can also use this step to make sure you get to the page you are expecting. For example, to make sure that somone who is not authorised to access your site is redirected to the home page with an appropriate message, you could write:

When I go to http://example.net/login
And I fill in "Username" with "hacker"
And I fill in "Password" with "password"
And I press "Log in"
Then I should be on /access_denied
Then I should see "We defeted your feeble attack"

When you are specifying a path, please make sure you give either a full URL or only a full absolute path with a forward slash at the front.

Then I should (not )see "TEXT"( within "CSS#SELECTOR")

This is by far the most common step used on StillAlive. It allows you to assert that some text is on the page you are currently on. For example, this could be a step you use:

When I go to http://example.com/
Then I should see "Welcome to our website"

One common gotcha is that StillAlive is not case sensitive on this matcher, and this includes CSS transforms. So if you have the HTML:

<h1 style="text-transform:uppercase">This is a title</h1>

Then both of the following steps would pass:

When I go to http://example.com/
Then I should see "THIS IS A TITLE"
And I should see "this is a title"

You can also add "not" into the step to ensure that text is missing on this site.

For example:

When I go to http://example.com/
Then I should not see "This is old text"

Just like the I should see step, the matcher is not case sensitive. So if you had text "THIS IS OLD TEXT" on your site then the above step example would fail.

If you have multiple occurances of the same text, you can reduce where StillAlive will look by using a CSS selector.

Then I should (not )see /RegularExpression/( within "CSS#SELECTOR")

This is a powerful step that allows you to use regular expressions to check that text is or is not on a page. For example, if you had text on the page like:

There are 432 users logged in

You could check this text is there by doing steps like:

Then I should see /There are \d+ users logged in/

Which would match any number.

With the negative version of this parser, you can do things like making sure that a certain value is not higher than it should be on a page, for example if you had the text:

Average wait time is 2 minutes

And you wanted to be alerted if this ever went into two digits, you could write:

Then I should not see /Average wait time is \d{2} minutes/

The other thing to note is that regular expressions are case sensitive, if you don't want it to be case sensitive, you can add the i option at the end of the regular expression, like:

Then I should see /THERE ARE \d+ USERS LOGGED IN/i

Would match even though the case is incorrect.

Another thing to remember is that regular expressions do not match across multiple lines by default. A lot of HTML pages tend to have many spaces, for example you could have HTML like:

<p>
  This is a paragraph
  across multiple lines
</p>

Which would only match by using the Regular expression m option, something like:

Then I should see /This is a paragraph\s+across multiple lines/m

Again you can use CSS selectors to narrow your search.

Then the "FIELD NAME OR ID" checkbox( within "CSS#SELECTOR") should (not )be checked

This validation step allows you to confirm that a check box is, or is not checked. For example given the HTML:

<form action='/submit.html'>
  <label for="receive_email">Receive email offers</label>
  <input type='checkbox' id="receive_email" name='receive_email'>
  <label for="receive_email">Receive newsletter</label>
  <input type='checkbox' id="receive_newsletter" name='receive_email' checked="checked">
</form>

Then you could use these steps to confirm that check boxes are checked or not checked:

When I go to http://example.com/signup/
Then the "Receive email offers" checkbox should not be checked
Then the "Receive newsletter" checkbox should be checked

CSS selectors can be also optionally used with this step.

Then the "FIELD NAME OR ID" field( within "CSS#SELECTOR") should (not )contain "Text"

This step allows you to confirm that a field has, or does not have a certain value.

If you wanted to see that a text input or textarea input has a value and had HTML that looked like:

<form id="main" action='http://127.0.0.1:59150/'>
  <label for='given_name'>Name</label>
  <input type='text' name='given_name' value='Given Name' class='textField'>
  <input type='text' name='family_name' value='Family Name' class='textField'>
  <input type="submit" value="Submit" />
</form>

Then the following steps would all pass:

Then the "Name" field should contain "Given name"
And the "family_name" field should contain "Family name" within "form#main"
And the "family_name" field should not contain "Smith"

Then the "FIELD NAME OR ID" radio button( within "CSS#SELECTOR") should have "LABEL" selected

This allows you to make sure that a radio button is selected. For example with the folling HTML:

<form id="main" action='some_place.html'>
  <label for='field_basic_plan'>Basic Plan</label>
  <input type='radio' name='plan' id='field_basic_plan' value='basic' checked='checked'>
  <label for='field_advanced_plan'>Advanced Plan</label>
  <input type='radio' name='plan' id='field_advanced_plan' value='advanced'>
</form>

Then the following steps would pass:

Then the "plan" radio button should have "Basic Plan" selected

Then I should see the "OPTION" option in "SELECT FIELD"( within "CSS#SELECTOR") is selected

This allows you to make sure that an select list has a certain option is or is not selected. For example with the folling HTML:

<form id="main" action='select.html'>
  <label for='select_box'>Test Select</label>
  <select name='select_box' id='select_box'>
    <option value='1' selected='selected'>Option 1</option>
    <option value='2'>Option 2</option>
  </select>
</form>

The following step would pass:

Then I should see the "Option 1" option in "Test Select" within "form@main" is selected

Then the "HEADER-FIELD" header should include "TEXT"

This allows you to confirm that the HTTP headers are what you expect them to be. If your server returns a content header with the following information:

HTTP/1.1 200 OK
Date: Fri, 13 Jan 2012 10:19:18 GMT
Connection: close
Server: TestServer
Content-Length: 123
Content-Type: text/html; charset=utf8

The following steps would check for the right content-type header:

Then the 'Content-Type' header should equal 'text/html'
Then the 'Content-Length' header should equal '123'
Was this article helpful?
0 out of 0 found this helpful

Comments