Create an action
Actions
Each scenario can have zero, one or multiple actions. Each action must be one of the following types.
check
Check a checkbox or radio element.
Example:
actions:
# Check the checkbox with `tos-accept` ID
- click: checkbox#tos-accept
click
Click an element.
Example:
actions:
# Click the button with .submit class
- click: button.submit
focus
Focus an element.
Example:
actions:
# Focus an input element named `email`
- focus: input[name="email"]
hide
Hide an element - set visibility: hidden !important
.
Example:
actions:
# Hide the element with `cookie-modal` ID
- hide: '#cookie-modal'
hover
Hover an element.
Example:
actions:
# Hover mouse over an element contains `my-chart` ID
- hover: '#my-chart'
input
Type text in an element.
Example:
actions:
# Type `My Name` in an input element with `username` ID
- input: 'input#username'
value: My Name
# `append` is an optional property, with `fase` as the default value
append: false
# Type `my-name@domain.com` in an input element with `email` ID
- input: 'input#email'
value: my-name@domain.com
# `append` is an optional property, with `fase` as the default value
append: true
# Load `data/file1.txt` into the input with `file` ID
- input: 'input#file'
file: file1.txt
# `useFileChooser` is an optional property, with `fase` as the default value
useFileChooser: true
# Load `data/file1.txt` and `data/other/file2.pdf`
# into the input with `files` ID
# Note that the input must allow upload multiple files
- input: 'input#files'
file:
- file1.txt
- other/file2.pdf
# `useFileChooser` is an optional property, with `fase` as the default value
useFileChooser: false
press
Press a key (or key combination) on an element.
Example:
actions:
# Select all text inside a textarea with `message` ID
- press: 'textarea#message'
key: Ctrl+A
remove
Remove an element - set display: none !important
.
Example:
actions:
# Remove a `div` element with class `.random-content`
- remove: div.random-content
scroll
Scroll to an element.
Example:
actions:
# Scroll to an element with `.report` class
- scroll: .report
select
Select an option inside an select
element.
Example:
Let say you have following HTML:
Send via email
Send via SMS
Send via Skype
Then you can create select actions like following sample:
actions:
# Select the option with `email` value
- select: select[name="method"]
value: email
# Select the option with `Send via email` label
- select: select[name="method"]
label: Send via email
# Select options with `sms` or `skype` value
- select: select[name="method"]
value:
- sms
- skype
Notes:
The
select
action requires eithervalue
orlabel
to be set, but not both. Omit or include both of them will leading to an error.
uncheck
Uncheck a checkbox or radio element.
Example:
actions:
# Uncheck the checkbox named `subscrible-email`
- click: checkbox[name="subscrible-email"]
wait
Wait for X miliseconds or wait for an element to appears.
If there is a navigration, add the URL pattern of the target page also.
Example:
actions:
# Delay 2 seconds
- wait: 2000
# Wait for an element with `popup` class to appears
- wait: .popup
# Wait for the navigation to `/quote`, then delay 2 seconds
# `**` means a group of arbitrary characters
- wait: 2000
url: '**/quote'
# Wait for the navigation to `/quote`, then wait for `#my-form` element to appears
# `**` means a group of arbitrary characters
- wait: '#my-form'
url: '**/quote'
Shared properties
The following properties are applicable to all actions.
frame
Type: string | string[]
.
Default: empty.
This property specifies the selector for the target iframe within which the current action should be executed.
Example:
actions:
# Click `#submit` element inside the `.child` iframe
- click: '#submit'
frame: .child
# Click `#submit` element inside the `#grandchild` iframe
# `grandchild` is an element within the `.child` iframe
- click: '#submit'
frame:
- .child
- '#granchild'