Skip to main content

DSL Steps

All Gherkin steps that match the DSL expressions here are readily executable by Gwen. The DSL matched is the operation that will be performed when a step is interpreted for execution.

tip

Use DSL steps in your meta to compose StepDefs. Although it's possible to use them directly in feature specs too, we do not recommend making those DSL-aware. That's what meta is for!

Web pages#

Given..#

the <page> url is "<url>"

Puts the given page into scope and binds the given URL to it.

Where

  • <page> is the name of the page
  • <url> is the page URL (can be in DocString position)

Example

  Given the todo page url is "https://todomvc.com/examples/react"    And the todo field can be located by class "new-todo"
I am on the <page>

Puts the given page into scope and makes its bindings avaialble.

Where

  • <page> is a page name

Example

  Given I navigate to "https://todomvc.com/examples/react"    And I am on the todo page    And the todo field can be located by class "new-todo"   When I enter "Walk the dog" in the todo field

When..#

I navigate to the <page>

Navigates the browser to the URL bound to the given page and puts the page into scope. Starts a new browser window if one is not open.

Where

  • <page> is the name of the page to navigate to

Example

  Given the todo page url is "https://todomvc.com/examples/react"   When I navigate to the todo page
I navigate to "<url>"

Navigates the browser to the given URL. Starts a new browser window if one is not open.

Where

  • <url> is the URL to navigate to (can be in DocString position)

Example

  When I navigate to "https://todomvc.com/examples/react"
I capture the current URL

Captures the current browser URL and binds it as the current URL in the global scope.

Example

  When I capture the current URL   And I navigate to "${the current URL}?q=gwen"
I capture the current URL as <name>

Captures the current browser URL and binds it to the given name in the global scope.

Where

  • <name> is the name to bind the captured URL to

Example

  When I capture the current URL as the base URL   And I navigate to "${the base URL}?q=gwen"  Then the current URL should start with the base URL
I capture the text in the current URL by regex "<expression>" as <name>

Extracts a substring from the current browser URL using the given regex and binds it to the given name in the global scope.

Where

  • <expression> is the regex expression
  • <name> is the name to bind the captured substring to

Example

  When I capture the text in the current URL by regex "q=([^&]*)" as q  Then q should be "gwen"
I refresh the current page

Refreshes the current page in the browser.

Example

  When I refresh the current page

Then..#

the current URL should[ not] <match> "<expression>"

Checks whether or not the current browser URL matches a given expression. Reports an assertion error if the match fails.

Where

  • not negates the match if included
  • <match> is the type of match to perform, one of:
    • be for exact match
    • contain for partial match
    • start with for partial leading match
    • end with for partial trailing match
    • match regex for regex match
    • match xpath for XML match
    • match template for template match, since v2.16.0
    • match template file for template file match, since v2.16.0
  • <expression> is the expression to match (can be in DocString position)

Example

  When I navigate to "https://todomvc.com/examples/react"  Then the current URL should contain "todomvc.com"   And the current URL should not contain "other.com"
the current URL should[ not] <match> <expressionRef>

Checks whether or not the current URL in the browser matches an expression reference. Reports an assertion error if the match fails.

Where

  • not negates the match if included
  • <match> is the type of match to perform, one of:
    • be for exact match
    • contain for partial match
    • start with for partial leading match
    • end with for partial trailing match
    • match regex for regex match
    • match xpath for XML match
    • match template for template match, since v2.16.0
    • match template file for template file match, since v2.16.0
  • <expressionRef> is the name of the binding containing the expression to match

Example

  Given my domain is "todomvc.com"    And some other domain is "someother.com"   When I navigate to "https://todomvc.com/examples/react"   Then the current URL should contain my domain    And the current URL should not contain some other domain
the page title should[ not] <match> "<expression>"

Checks whether or not the title of the current page in the browser matches a given expression. Reports an assertion error if the match fails.

Where

  • not negates the match if included
  • <match> is the type of match to perform, one of:
    • be for exact match
    • contain for partial match
    • start with for partial leading match
    • end with for partial trailing match
    • match regex for regex match
    • match xpath for XML match
    • match json path for JSON path match, since v1.4.0
    • match template for template match, since v2.16.0
    • match template file for template file match, since v2.16.0
  • <expression> is the expression to match (can be in DocString position)

Example

  When I navigate to "https://todomvc.com/examples/react"  Then the page title should contain "TodoMVC"
the page title should[ not] <match> <expressionRef>

Checks whether or not the title of the current page in the browser matches an expression reference. Reports an assertion error if the match fails.

Where

  • not negates the match if included
  • <match> is the type of match to perform, one of:
    • be for exact match
    • contain for partial match
    • start with for partial leading match
    • end with for partial trailing match
    • match regex for regex match
    • match xpath for XML match
    • match json path for JSON path match, since v1.4.0
    • match template for template match, since v2.16.0
    • match template file for template file match, since v2.16.0
  • <expressionRef> is the name of the binding containing the expression to match

Example

  Given the app name is "TodoMVC"   When I navigate to "https://todomvc.com/examples/react"   Then the page title should contain the app name

Web elements#

Given..#

<element> can be located by <selector> "<expression>"

Binds a selector for a web element to the current scope with a default timeout.

Where

  • <element> is the web element name
  • <selector> is the selector type, one of:
    • id for selecting by id attribute
    • name for selecting by name attribute
    • tag name (or tag since v2.46.0) for selecting by tag name
    • css selector (or css since v2.46.0) for selecting by css expression
    • class name (or class since v2.46.0) for selecting by class attribute
    • xpath for selecting by XPath
    • link text for selecting by link text
    • partial link text for selecting by partial link text
    • javascript (or js since v2.46.0) for selecting by JavaScript
  • <expression> is the selector expression

Example

  Given the todo field can be located by class "new-todo"   When I enter "Walk the dog" in the todo field
<element> can be located by <selector> "<expression>" with no <wait|timeout>

Binds a selector for a web element to the current scope with no timeout.

Where

  • <element> is the web element name
  • <selector> is the selector type, one of:
    • id for selecting by id attribute
    • name for selecting by name attribute
    • tag name (or tag since v2.46.0) for selecting by tag name
    • css selector (or css since v2.46.0) for selecting by css expression
    • class name (or class since v2.46.0) for selecting by class attribute
    • xpath for selecting by XPath
    • link text for selecting by link text
    • partial link text for selecting by partial link text
    • javascript (or js since v2.46.0) for selecting by JavaScript
  • <expression> is the selector expression
  • <wait|timeout> is either wait or timeout

Example

  Given the todo field can be located by css ".new-todo" with no timeout   When I enter "Walk the dog" in the todo field
<element> can be located by <selector> "<expression>" with <timeoutSecs> second <wait|timeout>

Binds a selector for a web element to the current scope with a given timeout .

Where

  • <element> is the web element name
  • <selector> is the selector type, one of:
    • id for selecting by id attribute
    • name for selecting by name attribute
    • tag name (or tag since v2.46.0) for selecting by tag name
    • css selector (or css since v2.46.0) for selecting by css expression
    • class name (or class since v2.46.0) for selecting by class attribute
    • xpath for selecting by XPath
    • link text for selecting by link text
    • partial link text for selecting by partial link text
    • javascript (or js since v2.46.0) for selecting by JavaScript
  • <expression> is the selector expression
  • <timeoutSecs> is the timeout period in seconds
  • <wait|timeout> is either wait or timeout

Example

  Given the todo field can be located by css ".new-todo" with 5 second timeout   When I enter "Walk the dog" in the todo field
<element> can be located by <selector> "<expression>" <relativeTo> <otherElement>

Binds a relative selector for a web element to the current scope with a default timeout.

Where

  • <element> is the web element name
  • <selector> is the selector type, one of:
    • id for selecting by id attribute
    • name for selecting by name attribute
    • tag name (or tag since v2.46.0) for selecting by tag name
    • css selector (or css since v2.46.0) for selecting by css expression
    • class name (or class since v2.46.0) for selecting by class attribute
    • xpath for selecting by XPath
    • link text for selecting by link text
    • partial link text for selecting by partial link text
    • javascript (or js since v2.46.0) for selecting by JavaScript
  • <expression> is the selector expression
  • <relativeTo> is the relationship to <otherElement>, one of:
    • in for a contained relationship
    • More relative options coming to Gwen 3
  • <otherElement> is the name of the web element that this one is relative to

Example

  Given the footer can be located by class "footer"    And the displayed count can be located by tag "strong" in the footer   Then the displayed count should be "3"
<element> can be located by <selector> "<expression>" <relativeTo> <otherElement> with no <wait|timeout>

Binds a relative selector for a web element to the current scope with no timeout.

Where

  • <element> is the web element name
  • <selector> is the selector type, one of:
    • id for selecting by id attribute
    • name for selecting by name attribute
    • tag name (or tag since v2.46.0) for selecting by tag name
    • css selector (or css since v2.46.0) for selecting by css expression
    • class name (or class since v2.46.0) for selecting by class attribute
    • xpath for selecting by XPath
    • link text for selecting by link text
    • partial link text for selecting by partial link text
    • javascript (or js since v2.46.0) for selecting by JavaScript
  • <expression> is the selector expression
  • <relativeTo> is the relationship to <otherElement>, one of:
    • in for a contained relationship
    • More relative options coming to Gwen 3
  • <otherElement> is the name of the web element that this one is relative to
  • <wait|timeout> is either wait or timeout

Example

  Given the footer can be located by class "footer"    And the displayed count can be located by tag "strong" in the footer with no wait   Then the displayed count should be "3"
<element> can be located by <selector> "<expression>" <relativeTo> <otherElement>  with <timeoutSecs> second <wait|timeout>

Binds a relative selector for a web element to the current scope with a given timeout.

Where

  • <element> is the web element name
  • <selector> is the selector type, one of:
    • id for selecting by id attribute
    • name for selecting by name attribute
    • tag name (or tag since v2.46.0) for selecting by tag name
    • css selector (or css since v2.46.0) for selecting by css expression
    • class name (or class since v2.46.0) for selecting by class attribute
    • xpath for selecting by XPath
    • link text for selecting by link text
    • partial link text for selecting by partial link text
    • javascript (or js since v2.46.0) for selecting by JavaScript
  • <expression> is the selector expression
  • <relativeTo> is the relationship to <otherElement>, one of:
    • in for a contained relationship
    • More relative options coming to Gwen 3
  • <otherElement> is the name of the web element that this one is relative to
  • <timeoutSecs> is the timeout period in seconds
  • <wait|timeout> is either wait or timeout

Example

   Given the footer can be located by class "footer"     And the displayed count can be located by tag "strong" in the footer with no wait    Then the displayed count should be "3"
<element> can be located by <selector> "<expression>" at index <index>

Binds an indexed selector for a web element to the current scope with a default timeout.

Where

  • <element> is the web element name
  • <selector> is the selector type, one of:
    • id for selecting by id attribute
    • name for selecting by name attribute
    • tag name (or tag since v2.46.0) for selecting by tag name
    • css selector (or css since v2.46.0) for selecting by css expression
    • class name (or class since v2.46.0) for selecting by class attribute
    • xpath for selecting by XPath
    • link text for selecting by link text
    • partial link text for selecting by partial link text
    • javascript (or js since v2.46.0) for selecting by JavaScript
  • <expression> is the selector expression
  • <index> is the index of the element to select in list returned by <expression>

Example

  Given the first item can be located by css ".todo-list label" at index 0   Then the first item should contain "Walk the dog"
<element> can be located by <selector> "<expression>" at index <index> with no <wait|timeout>

Binds an indexed selector for a web element to the current scope with no timeout.

Where

  • <element> is the web element name
  • <selector> is the selector type, one of:
    • id for selecting by id attribute
    • name for selecting by name attribute
    • tag name (or tag since v2.46.0) for selecting by tag name
    • css selector (or css since v2.46.0) for selecting by css expression
    • class name (or class since v2.46.0) for selecting by class attribute
    • xpath for selecting by XPath
    • link text for selecting by link text
    • partial link text for selecting by partial link text
    • javascript (or js since v2.46.0) for selecting by JavaScript
  • <expression> is the selector expression
  • <index> is the index of the element to select in list returned by <expression>
  • <wait|timeout> is either wait or timeout

Example

  Given the first item can be located by css ".todo-list label" at index 0 with no timeout   Then the first item should contain "Walk the dog"
<element> can be located by <selector> "<expression>" at index <index> with <timeoutSecs> second <wait|timeout>

Binds an indexed selector for a web element to the current scope with a given timeout .

Where

  • <element> is the web element name
  • <selector> is the selector type, one of:
    • id for selecting by id attribute
    • name for selecting by name attribute
    • tag name (or tag since v2.46.0) for selecting by tag name
    • css selector (or css since v2.46.0) for selecting by css expression
    • class name (or class since v2.46.0) for selecting by class attribute
    • xpath for selecting by XPath
    • link text for selecting by link text
    • partial link text for selecting by partial link text
    • javascript (or js since v2.46.0) for selecting by JavaScript
  • <expression> is the selector expression
  • <index> is the index of the element to select in list returned by <expression>
  • <timeoutSecs> is the timeout period in seconds
  • <wait|timeout> is either wait or timeout

Example

  Given the first item can be located by css ".todo-list label" at index 0 with 5 second timeout   Then the first item should contain "Walk the dog"
<element> can be located by <selector> "<expression>" at index <index> <relativeTo> <otherElement>

Binds a relative selector for a web element to the current scope with a default timeout.

Where

  • <element> is the web element name
  • <selector> is the selector type, one of:
    • id for selecting by id attribute
    • name for selecting by name attribute
    • tag name (or tag since v2.46.0) for selecting by tag name
    • css selector (or css since v2.46.0) for selecting by css expression
    • class name (or class since v2.46.0) for selecting by class attribute
    • xpath for selecting by XPath
    • link text for selecting by link text
    • partial link text for selecting by partial link text
    • javascript (or js since v2.46.0) for selecting by JavaScript
  • <expression> is the selector expression
  • <index> is the index of the element to select in list returned by <expression>
  • <relativeTo> is the relationship to <otherElement>, one of:
    • in for a contained relationship
    • More relative options coming to Gwen 3
  • <otherElement> is the name of the web element that this one is relative to

Example

  Given the count info can be located by class "todo-count"    And the count unit can be located by tag "span" at index 1 in the count info   Then the count unit should contain "item"
<element> can be located by <selector> "<expression>" at index <index> <relativeTo> <otherElement> with no <wait|timeout>

Binds a relative indexed selector for a web element to the current scope with no timeout.

Where

  • <element> is the web element name
  • <selector> is the selector type, one of:
    • id for selecting by id attribute
    • name for selecting by name attribute
    • tag name (or tag since v2.46.0) for selecting by tag name
    • css selector (or css since v2.46.0) for selecting by css expression
    • class name (or class since v2.46.0) for selecting by class attribute
    • xpath for selecting by XPath
    • link text for selecting by link text
    • partial link text for selecting by partial link text
    • javascript (or js since v2.46.0) for selecting by JavaScript
  • <expression> is the selector expression
  • <index> is the index of the element to select in list returned by <expression>
  • <relativeTo> is the relationship to <otherElement>, one of:
    • in for a contained relationship
    • More relative options coming to Gwen 3
  • <otherElement> is the name of the web element that this one is relative to
  • <wait|timeout> is either wait or timeout

Example

  Given the count info can be located by class "todo-count"    And the count unit can be located by tag "span" at index 1 in the count info with no wait   Then the count unit should contain "item"
<element> can be located by <selector> "<expression>" at index <index> <relativeTo> <otherElement>  with <timeoutSecs> second <wait|timeout>

Binds a relative indexed selector for a web element to the current scope with a given timeout.

Where

  • <element> is the web element name
  • <selector> is the selector type, one of:
    • id for selecting by id attribute
    • name for selecting by name attribute
    • tag name (or tag since v2.46.0) for selecting by tag name
    • css selector (or css since v2.46.0) for selecting by css expression
    • class name (or class since v2.46.0) for selecting by class attribute
    • xpath for selecting by XPath
    • link text for selecting by link text
    • partial link text for selecting by partial link text
    • javascript (or js since v2.46.0) for selecting by JavaScript
  • <expression> is the selector expression
  • <index> is the index of the element to select in list returned by <expression>
  • <relativeTo> is the relationship to <otherElement>, one of:
    • in for a contained relationship
    • More relative options coming to Gwen 3
  • <otherElement> is the name of the web element that this one is relative to
  • <timeoutSecs> is the timeout period in seconds
  • <wait|timeout> is either wait or timeout

Example

   Given the count info can be located by class "todo-count"     And the count unit can be located by tag "span" at index 1 in the count info with 5 second wait    Then the count unit should contain "item"
<element> can be located by  | <selector 1> | <expression 1> |  | <selector 2> | <expression 2> |  |      ..      |       ..       |  | <selector n> | <expression n> |

Binds primary and fallback selectors for a web element to the current scope with a default timeout. Lookups will be attempted in the order specified until one succeeds.

Where

  • <element> is the web element name
  • <selector n> is the nth selector type, one of:
    • id for selecting by id attribute
    • name for selecting by name attribute
    • tag name (or tag since v2.46.0) for selecting by tag name
    • css selector (or css since v2.46.0) for selecting by css expression
    • class name (or class since v2.46.0) for selecting by class attribute
    • xpath for selecting by XPath
    • link text for selecting by link text
    • partial link text for selecting by partial link text
    • javascript (or js since v2.46.0) for selecting by JavaScript
  • <expression n> is the nth selector expression

Example

  Given the todo field can be located by        | name  | todo-field  |        | css   | .todo input |        | class | new-todo    |   When I type "Feed the cat" in the todo field
<element> can be located at index <index> by  | <selector 1> | <expression 1> |  | <selector 2> | <expression 2> |  |      ..      |       ..       |  | <selector n> | <expression n> |

Binds indexed primary and fallback selectors for a web element to the current scope with a default timeout. Lookups will be attempted in the order specified until one succeeds.

Where

  • <element> is the web element name
  • <selector n> is the nth selector type, one of:
    • id for selecting by id attribute
    • name for selecting by name attribute
    • tag name (or tag since v2.46.0) for selecting by tag name
    • css selector (or css since v2.46.0) for selecting by css expression
    • class name (or class since v2.46.0) for selecting by class attribute
    • xpath for selecting by XPath
    • link text for selecting by link text
    • partial link text for selecting by partial link text
    • javascript (or js since v2.46.0) for selecting by JavaScript
  • <expression n> is the nth selector expression
  • <index> is the index of the element to select in list returned by <expression n>

Example

  Given the second item can be located at index 1 by        | name  | todo-label       |        | class | todo-label       |        | css   | .todo-list label |   Then the second item should contain "Feed the cat"
<element> can be located at index <index> with no <wait|timeout> by  | <selector 1> | <expression 1> |  | <selector 2> | <expression 2> |  |      ..      |       ..       |  | <selector n> | <expression n> |

Binds indexed primary and fallback selectors for a web element to the current scope with no timeout. Lookups will be attempted in the order specified until one succeeds.

Where

  • <element> is the web element name
  • <selector n> is the nth selector type, one of:
    • id for selecting by id attribute
    • name for selecting by name attribute
    • tag name (or tag since v2.46.0) for selecting by tag name
    • css selector (or css since v2.46.0) for selecting by css expression
    • class name (or class since v2.46.0) for selecting by class attribute
    • xpath for selecting by XPath
    • link text for selecting by link text
    • partial link text for selecting by partial link text
    • javascript (or js since v2.46.0) for selecting by JavaScript
  • <expression n> is the nth selector expression
  • <index> is the index of the element to select in list returned by <expression n>
  • <wait|timeout> is either wait or timeout

Example

  Given the second item can be located at index 1 with no timeout by        | name  | todo-label       |        | class | todo-label       |        | css   | .todo-list label |   Then the second item should contain "Feed the cat"
<element> can be located at index <index> with <timeoutSecs> second <wait|timeout> by  | <selector 1> | <expression 1> |  | <selector 2> | <expression 2> |  |      ..      |       ..       |  | <selector n> | <expression n> |

Binds indexed primary and fallback selectors for a web element to the current scope with a given timeout . Lookups will be attempted in the order specified until one succeeds.

Where

  • <element> is the web element name
  • <selector n> is the nth selector type, one of:
    • id for selecting by id attribute
    • name for selecting by name attribute
    • tag name (or tag since v2.46.0) for selecting by tag name
    • css selector (or css since v2.46.0) for selecting by css expression
    • class name (or class since v2.46.0) for selecting by class attribute
    • xpath for selecting by XPath
    • link text for selecting by link text
    • partial link text for selecting by partial link text
    • javascript (or js since v2.46.0) for selecting by JavaScript
  • <expression n> is the nth selector expression
  • <index> is the index of the element to select in list returned by <expression n>
  • <timeoutSecs> is the timeout period in seconds
  • <wait|timeout> is either wait or timeout

Example

  Given the second item can be located at index 1 with 5 second timeout by        | name  | todo-label       |        | class | todo-label       |        | css   | .todo-list label |   Then the second item should contain "Feed the cat"

Browser windows and tabs#

Given..#

I have an open browser

Opens a browser if none are open

Example

  Given I have an open browser   When I navigate to "https://todomvc.com/examples/react"   Then I should have 1 open browser
I have no open browser

Closes all open browsers

Example

  Given I have no open browser   When I navigate to "https://todomvc.com/examples/react"   Then I should have 1 open browser

When..#

I start a new browser

Starts a new browser session (or switches to exising one if it is already open).

Example

 Given I have no open browser  When I start a new browser  Then I should have 1 open browser
I close the[ current] browser

Closes the current browser session (or does nothing if one is not open).

Where

  • [ current] including the word current is optional and makes no difference, since v1.3.0

Example

  When I navigate to "https://todomvc.com/examples/react"   And I close the current browser   And I navigate to "https://todomvc.com/examples/vue/"   And I close the browser
I start a browser for <name>

Starts a new browser session with the given name (closes any existing browser of that name first).

Where

  • <name> is a name assigned to the browser session

Example

  When I start a browser for React   And I navigate to "https://todomvc.com/examples/react"   And I start a browser for Vue   And I navigate to "https://todomvc.com/examples/vue/"  Then I should have 2 open browsers
I switch to <name>

Switches to a named browser session (starts a new browser if one of that name is not already open). All browser actions performed after this will execute in the named session.

Where

  • <name> is the name of the browser session to switch to

Example

  When I start a browser for React   And I navigate to "https://todomvc.com/examples/react"   And I start a browser for Vue   And I navigate to "https://todomvc.com/examples/vue/"   And I switch to React  Then the current URL should contain "react"
I close the browser for <name>

Closes a named browser session (does nothing if one of that name is not open).

Where

  • <name> is the name of the browser session to close

Example

  When I start a browser for React   And I navigate to "https://todomvc.com/examples/react"   And I close the browser for React
I switch to the default content

Switches from an iframe to the default or main content window.

Example

  When I navigate to "https://page-with-iframes"   And I switch to the default content
I switch to the child <tab|window>

Switches to the most recently opened child tab or window (without closing the parent window)

Where

  • <tab|window> is either tab or window

Example

  Given the new window button can be located by name "newbrowserwindow123"   When I navigate to "https://nxtgenaiacademy.com/multiplewindows/"    And I click the new window button    And I switch to the child window
I close the child <tab|window>

Closes the currently active child tab or window and passes control back to the parent window.

Where

  • <tab|window> is either tab or window

Example

  Given the new tab button can be located by name "newbrowsertab453"   When I navigate to "https://nxtgenaiacademy.com/multiplewindows/"    And I click the new tab button    And I switch to the child tab    And I close the child tab
I switch to child <tab|window> <occurrence>

Switches to a child tab or window occurrence (without closing the parent window).

Where

  • <tab|window> is either tab or window
  • <occurrence> is the tab or window occurrence to switch to (1st opened is occurrence 1, 2nd is 2, ..)

Example

  Given the new window button can be located by name "newbrowserwindow123"   When I navigate to "https://nxtgenaiacademy.com/multiplewindows/"    And I click the new window button    And I switch to child window 1
I close child <tab|window> <occurrence>

Closes a child tab or window occurrence and passes control back to the parent window.

Where

  • <tab|window> is either tab or window
  • <occurrence> is the tab or window occurrence to close (1st opened is occurrence 1, 2nd is 2, ..)

Example

  Given the new tab button can be located by name "newbrowsertab453"   When I navigate to "https://nxtgenaiacademy.com/multiplewindows/"    And I click the new tab button    And I switch to child tab 1    And I close child tab 1
I switch to the <parent|root> <tab|window>

Switches to the parent window (without closing the currently active child window).

Where

  • <parent|root> is either parent (or root since v2.49.0)
  • <tab|window> is either tab or window

Example

  Given the new window button can be located by name "newbrowserwindow123"   When I navigate to "https://nxtgenaiacademy.com/multiplewindows/"    And I click the new window button    And I switch to child window 1    And I switch to the parent window
I <maximize|maximise> the window

Maximizes the currently active browser window to fill the entire screen area.

Where

  • <maximize|maximise> is either maximize or maximise (makes no difference)

Example

  When I navigate to "https://todomvc.com/examples/react"   And I maximize the window
I resize the window to width <w> and height <h>

Resizes the currently active browser window to the given dimensions.

Where

  • <w> is the width in pixels
  • <h> is the height in pixels

Example

  When I navigate to "https://todomvc.com/examples/react"   And I resize the window to width 1280 and height 720

Then..#

I should have 1 open browser

Checks that only one browser session is currently open. Reports an assertion error if not.

Example

 Given I have no open browser  When I navigate to "https://todomvc.com/examples/react"  Then I should have 1 open browser
I should have <count> open browsers

Checks that the given number of browsers are currently open. Reports an assertion error if not.

Where

  • count the expected number of open browsers

Example

 Given I have no open browser  When I navigate to "https://todomvc.com/examples/react"   And I start a browser for Vue   And I navigate to "https://todomvc.com/examples/vue"  Then I should have 2 open browsers

Alerts and popups#

When..#

I accept the <alert|confirmation> popup

Accepts and closes an alert or confirmation popup by clicking OK.

Where

  • <alert|confirmation> is either:
    • alert for an alert box with an OK button
    • confirmation for a confirmation box with OK and Cancel buttons

Example

  Given the alert button can be located by css ".btn" at index 0   When I navigate to "https://www.seleniumeasy.com/test/javascript-alert-box-demo.html"    And I click the alert button    And I accept the alert popup
I dismiss the confirmation popup

Dismisses and closes a confirmation popup by clicking Cancel.

Example

  Given the confirmation button can be located by css ".btn" at index 1   When I navigate to "https://www.seleniumeasy.com/test/javascript-alert-box-demo.html"    And I click the confirmation button    And I dismiss the confirmation popup
I capture the <alert|confirmation> popup message

Captures the alert or confirmation popup message and binds it to the <alert|confirmation> popup message in the global scope.

Where

  • <alert|confirmation> is either:
    • alert for an alert box with an OK button
    • confirmation for a confirmation box with OK and Cancel buttons

Example

  Given the alert button can be located by css ".btn" at index 0   When I navigate to "https://www.seleniumeasy.com/test/javascript-alert-box-demo.html"    And I click the alert button    And I capture the alert popup message
I capture the <alert|confirmation> popup message as <name>

Captures the alert or confirmation popup message and binds it to the given name in the global scope.

Where

  • <alert|confirmation> is either:
    • alert for an alert box with an OK button
    • confirmation for a confirmation box with OK and Cancel buttons

Example

  Given the confirmation button can be located by css ".btn" at index 1   When I navigate to "https://www.seleniumeasy.com/test/javascript-alert-box-demo.html"    And I click the confirmation button    And I capture the confirmation popup message as the alert message

Then..#

the <alert|confirmation> popup message should[ not] <match> "<expression>"

Checks whether or not the message in the alert or confirmation popup box matches a given expression. Reports an assertion error if the match fails.

Where

  • not negates the match if included
  • <match> is the type of match to perform, one of:
    • be for exact match
    • contain for partial match
    • start with for partial leading match
    • end with for partial trailing match
    • match regex for regex match
    • match xpath for XML match
    • match template for template match, since v2.16.0
    • match template file for template file match, since v2.16.0
  • <expression> is the expression to match (can be in DocString position)

Example

  Given the alert button can be located by css ".btn" at index 0   When I navigate to "https://www.seleniumeasy.com/test/javascript-alert-box-demo.html"    And I click the alert button   Then the alert popup message should be "I am an alert box!"
the <alert|confirmation> popup message should[ not] <match> <expressionRef>

Checks whether or not the message in the alert or confirmation popup box matches an expression reference. Reports an assertion error if the match fails.

Where

  • not negates the match if included
  • <match> is the type of match to perform, one of:
    • be for exact match
    • contain for partial match
    • start with for partial leading match
    • end with for partial trailing match
    • match regex for regex match
    • match xpath for XML match
    • match template for template match, since v2.16.0
    • match template file for template file match, since v2.16.0
  • <expressionRef> is the name of the binding containing the expression to match

Example

  Given the confirmation button can be located by css ".btn" at index 1    And the expected message is "Press a button!"   When I navigate to "https://www.seleniumeasy.com/test/javascript-alert-box-demo.html"    And I click the confirmation button   Then the confirmation popup message should be the expected message
We're migrating our docs

We will post more here soon. In the meantime, see the complete DSL guide on our wiki by clicking the link below: