Skip to main content

Element actions

I <click|right click|double click> <element>

Clicks a web element.

Where

  • <click|right click|double click> is one of:

    • click to click the element
    • right click to right click the element, since v2.8.0
    • double click to double click the element, since v2.12.0
  • <element> is the name of the element to click

Example

  Given the start button can be located by name "commit"
When I navigate to "https://challengers.flood.io/start"
And I click the start button
I <click|right click|double click> <element> of <context>

Clicks a context sensitive web element.

Where

  • <click|right click|double click> is one of:

    • click to click the element
    • right click to right click the element, since v2.8.0
    • double click to double click the element, since v2.12.0
  • <element> is the name of the element to click
  • <context> is the context element to focus into (in order to click <element>)

Example

  Given the menu item can be located by id "menu-item-id"
And the action button can be located by id "action-button-id"
When I click the action button of the menu item
I <modifierKeys> <click|right click|double click> <element>

Holds down the specified modifier keys and clicks an element.

Where

  • <modifierKeys> is a + separated list of modifier keys to hold down during the click

    • Modifier keys can be single keyboard characters or any supported key constants
    • Node: Keys behave differently on different platforms
  • <click|right click|double click> is one of:

    • click to click the element
    • right click to right click the element
    • double click to double click the element, since v2.12.0
  • <element> is the name of the element to click

Example

  Given the button can be located by tag "button"
And I COMMAND+SHIFT click the button
I <check|uncheck|tick|untick> <checkbox>

Ticks or unticks a checkbox element.

Where

  • <check|uncheck|tick|untick> is one of:

    • check (or tick since v2.4.0) to tick the checkbox element
    • uncheck (or untick since v2.4.0) to untick the checkbox element
  • <checkbox> is the name of the checkbox element

Example

  Given the email checkbox can be located by id "checkbox1"
When I navigate to "https://automationintesting.com/selenium/testpage"
And I tick the email checkbox
I move to <element>

Moves to a web element and gives it the focus.

Where

  • <element> is the name of the element to move to

Example

  Given the surname field can be located by id "surname"
When I navigate to "https://automationintesting.com/selenium/testpage"
And I move to the surname field
I <enter|type> "<text>" in <element>

Enters or types text into a web element.

Where

  • <enter|type> is one of:

    • enter to send the text to the field followed by the enter key
    • type to send the text to the field only (without trailing enter key)
  • <text> is the text to send to the field
  • <element> is the name of the field to send the text to

Example

  Given the todo field can be located by class "new-todo"
When I navigate to "https://todomvc.com/examples/react/dist"
And I enter "Walk the dog" in the todo field
I <enter|type> <textRef> in <element>

Enters or types a text reference value into a web element.

Where

  • <enter|type> is one of:

    • enter to send the text to the field followed by the enter key
    • type to send the text to the field only (without trailing enter key)
  • <textRef> is the name of the binding containing the text to send to the field

    • Can be the name of any binding that contains or resolves to a text value, including a web element in which case the text in the element will be dynamically retrieved and used.
  • <element> is the name of the field to send the text to

Example

  Given the todo field can be located by class "new-todo"
And my item is "Walk the dog"
When I navigate to "https://todomvc.com/examples/react/dist"
And I enter my item in the todo field
I append "<text>" to <element>

Appends the given text to the current text value of an element.

Where

  • <text> is the text to append
  • <element> is name of the element to append the text to

Example

  Given the search field can be located by name "q"
When I navigate to "https://google.com"
And I type "Gwen" in the search field
And I append " automation" to the search field
I append <textRef> to <element>

Appends the given referenced text to the current text value of an element.

Where

  • <textRef> is the name of the binding containing the text to append to the element

    • Can be the name of any binding that contains or resolves to a text value, including a web element in which case the text in the element will be dynamically retrieved and used.
  • <element> is name of the element to append the text to

Example

  Given the search field can be located by name "q"
And my additional search term is " automation"
When I navigate to "https://google.com"
And I type "Gwen" in the search field
And I append my additional search term to the search field
I press <enter|tab> in <element>

Send the enter or tab key to a web element.

Where

  • <enter|tab> is one of:

    • enter to send the enter key
    • tab to send the tab key
  • <element> is the name of the element to send the key to

Example

  Given the surname field can be located by id "surname"
When I navigate to "https://automationintesting.com/selenium/testpage"
And I press tab in the surname field
I send "<keys>" to <element>

Sends a sequence of keys to an element (for emulating keyboard shortcuts).

Where

  • <keys> is a , or + (since v2.53.0) separated list of keys to send.

    • Keys can be single keyboard characters or any supported key constants
    • Note: Keys behave differently on different platforms
  • <element> is the name of the element to send the keys to

Example

  Given the search field can be located by name "q"
When I navigate to "https://google.com"
And I type "automation" in the search field
And I send "COMMAND+A" to the search field
And I send "COMMAND+C" to the search field
And I clear the search field
And I send "COMMAND+V" to the search field
And I send "ARROW_DOWN" to the search field
And I press enter in the search field
I insert a new line in <textarea>

Inserts a new line into a textarea element.

Where

  • <textarea> is the name of the textarea element to insert the new line into

Example

  Given the more field can be located by tag "textarea"
When I navigate to "https://automationintesting.com/selenium/testpage"
And I type "Hi," in the more field
And I insert a new line in the more field
And I type "I like Gwen." in the more field
And I insert a new line in the more field
And I type "Bye!" in the more field
Then the more field should contain
"""
Hi,
I like Gwen.
Bye!
"""
I clear <element>

Clears a text element.

Where

  • <element> is the name of the element to clear

Example

  Given the surname field can be located by id "surname"
When I navigate to "https://automationintesting.com/selenium/testpage"
And I clear the surname field