Assertions

Assertions are used to verify that the browser is in the desired state.

Syntax

An assertion takes the form of an identifier followed by an operator and an optional value.

{identifier} {operator} [{value}]

-----------------------------------

identifier:
    <identifier>

operator:
    excludes
    includes
    is
    is-not
    exists
    not-exists
    matches

value:
    <string>

Is

Checks if the value being compared equals a given value.

{identifier} is "{value}"

-------------------------

identifier:
    <identifier>

{value}:
    <string>

Arguments

identifier <identifier> An identifier.
value <string> A string, in double quotes.

Examples

- $".selector" is "Hello!"
- $".banner .image".src is "http://example.com/images/banner.png"
- $page.title is "Homepage"
- $page.title is "\"Homepage\"" # (literal double quotes)
- $imported_page_model.elements.sign_in_button is "Sign in"
- $elements.element_name is $page.url # odd but valid
- $elements.element_name is $data.expected_element_value
- $elements.element_name is $env.KEY

Is-not

Checks if the value being compared does not equal a given value.

{identifier} is-not "{value}"

-----------------------------

identifier:
    <identifier>

{value}:
    <string>

Arguments

identifier <identifier> An identifier.
value <string> A string, in double quotes.

Examples

- $".heading" is-not "Error"
- $".user-container .status".data-status is-not "active"
- $page.title is-not "Homepage"
- $page.title is-not "\"Homepage\"" (literal double quotes)
- $imported_page_model.elements.sign_in_button is-not "Sign in"
- $elements.element_name is-not $page.url # odd but valid
- $elements.element_name is-not $data.expected_element_value
- $elements.element_name is-not $env.KEY

Exists

Checks if an element exists on the page.

{identifier} exists

-------------------------------

identifier:
    <identifier>

Arguments

identifier <identifier> An identifier.

Examples

- $".selector" exists
- $".profile":data-image exists
- $"#logo" exists
- $imported_page_model.elements.sign_in_button exists
- $element_name exists

Not-Exists

Checks if an element does not exist on the page.

{identifier} not-exists

-------------------------------

identifier:
    <identifier>

Arguments

identifier <identifier> An identifier.

Examples

- $".username-field":disabled not-exists
- $"#logo" not-exists
- $imported_page_model.elements.sign_in_button not-exists
- $element_name not-exists

Includes

Checks if the value being compared contains a given value.

{identifier} includes "{value}"

-------------------------------

identifier:
    <identifier>

{value}:
    <string>

Everything after the includes keyword (except the space after the keyword) is the value to be used.

Arguments

identifier <identifier> An identifier.
value <string> A string, in double quotes.

Examples

- $".heading" includes "welcome"
- $".heading".title includes "welcome"
- $page.title includes "page"
- $imported_page_model.elements.sign_in_button includes "Sign"
- $elements.element_name includes $page.url # odd but valid
- $elements.element_name includes $data.key
- $elements.element_name includes $env.KEY

Excludes

Checks if the value being compared does not contain a given value.

{identifier} excludes "{value}"

-------------------------------

identifier:
    <identifier>

{value}:
    <string>

Everything after the excludes keyword (except the space after the keyword) is the value to be used.

Arguments

identifier <identifier> An identifier.
value <string> A string, in double quotes.

Examples

- $".heading" includes "error"
- $".heading".title includes "error"
- $page.title excludes "error"
- $imported_page_model.elements.sign_in_button excludes "Log"
- $elements.element_name excludes $page.url # odd but valid
- $elements.element_name excludes $data.key
- $elements.element_name excludes $env.KEY

Matches

Checks if the value being compared matches a given regular expression.

{identifier} matches "{regex}"

------------------------------

identifier:
    <identifier>

{regex}:
    <regular-expression>

The value to be used must be within double quotes. The double quotes are not part of the value.

Arguments

identifier <identifier> An identifier.
regex <regular-expression> A regular expression.

Examples

- $".form .profile" matches "/.*/"
- $".form":action matches "/\/login\//"
- $page.title matches "/homepage$/i"
- $imported_page_model.elements.sign_in_button matches "/^Sign/"
- $elements.element_name matches $data.regex
- $elements.element_name matches $env.REGEX # odd way to go about it but valid

Example List

- $".selector" is "Hello!"
- $".banner .image".src is "http://example.com/images/banner.png"
- $page.title is "Homepage"
- $page.title is "\"Homepage\"" # (literal double quotes)
- $imported_page_model.elements.sign_in_button is "Sign in"
- $elements.element_name is $page.url # odd but valid
- $elements.element_name is $data.expected_element_value
- $elements.element_name is $env.KEY
- $".heading" is-not "Error"
- $".user-container .status".data-status is-not "active"
- $page.title is-not "Homepage"
- $page.title is-not "\"Homepage\"" (literal double quotes)
- $imported_page_model.elements.sign_in_button is-not "Sign in"
- $elements.element_name is-not $page.url # odd but valid
- $elements.element_name is-not $data.expected_element_value
- $elements.element_name is-not $env.KEY
- $".heading" includes "welcome"
- $".heading".title includes "welcome"
- $page.title includes "page"
- $imported_page_model.elements.sign_in_button includes "Sign"
- $elements.element_name includes $page.url # odd but valid
- $elements.element_name includes $data.key
- $elements.element_name includes $env.KEY
- $".heading" includes "error"
- $".heading".title includes "error"
- $page.title excludes "error"
- $imported_page_model.elements.sign_in_button excludes "Log"
- $elements.element_name excludes $page.url # odd but valid
- $elements.element_name excludes $data.key
- $elements.element_name excludes $env.KEY
- $".form .profile" matches "/.*/"
- $".form":action matches "/\/login\//"
- $page.title matches "/homepage$/i"
- $imported_page_model.elements.sign_in_button matches "/^Sign/"
- $elements.element_name matches $data.regex
- $elements.element_name matches $env.REGEX # odd way to go about it but valid
- $".selector" exists
- $".profile":data-image exists
- $"#logo" exists
- $imported_page_model.elements.sign_in_button exists
- $element_name exists
- $".username-field":disabled not-exists
- $"#logo" not-exists
- $imported_page_model.elements.sign_in_button not-exists
- $element_name not-exists