-
Notifications
You must be signed in to change notification settings - Fork 0
Actions
Volt provides a wide range of actions you can use within the steps array of your YAML scripts.
Navigates the browser to a specific URL.
-
Parameters:
url - Example:
- action: navigate
url: "https://example.com"Clicks on an element matching the selector.
-
Parameters:
selector - Example:
- action: click
selector: "button#submit"Fills a text input with the provided value.
-
Parameters:
selector,value - Example:
- action: type
selector: "input[name='email']"
value: "test@example.com"Simulates pressing a keyboard key on a specific element.
-
Parameters:
selector,value(e.g. "Enter", "Tab", "Escape") - Example:
- action: press_key
selector: "input[name='q']"
value: "Enter"Hovers the mouse over an element.
-
Parameters:
selector - Example:
- action: hover
selector: ".dropdown-menu"Checks or unchecks a checkbox or radio button.
-
Parameters:
selector - Example:
- action: check
selector: "#agree-terms"Selects an option in a <select> dropdown.
-
Parameters:
selector,value(value of the option) - Example:
- action: select
selector: "select#country"
value: "FR"Uploads a file to an input element of type file.
-
Parameters:
selector,file(path to the file) - Example:
- action: upload
selector: "input[type='file']"
file: "./assets/image.png"Scrolls the page to a specific element or to the top/bottom.
-
Parameters:
selectorORvalue("top" or "bottom") - Example:
- action: scroll
value: "bottom"Repeats a set of actions based on a start and end index.
-
Parameters:
from,to,do(array of steps) - Example:
- action: loop
from: 1
to: 3
do:
- action: log
message: "Iteration {{loop.index}}"Iterates over a list of items and performs actions for each.
-
Parameters:
for_each(array of items),iterator(variable name),do(array of steps) - Example:
- action: for_each
iterator: item
for_each:
- "apple"
- "banana"
do:
- action: log
message: "Current item: {{item}}"Executes specific steps conditionally based on a JavaScript expression.
-
Parameters:
condition,then(array of steps),else(array of steps) - Example:
- action: if
condition: "true"
then:
- action: log
message: "Condition is true!"
else:
- action: log
message: "Condition is false!"Pauses execution for a specified number of seconds.
-
Parameters:
duration(integer) - Example:
- action: wait
duration: 3Waits until an element becomes visible or hidden.
-
Parameters:
selector - Example:
- action: wait_visible
selector: ".loading-spinner"Fails the script if the element is not currently visible/hidden.
-
Parameters:
selector - Example:
- action: assert_visible
selector: "#success-message"Fails the script if the text content of the element doesn't exactly match the value.
-
Parameters:
selector,value - Example:
- action: assert_text
selector: "h1"
value: "Welcome"Fails the script if the provided JavaScript expression does not evaluate to true.
-
Parameters:
value(JS expression) - Example:
- action: assert_eval
value: "document.title.includes('Dashboard')"Extracts structured data from the page and saves it as JSON.
-
Parameters:
scrape(object withparentandfields),name(optional variable name to store) - Example:
- action: scrape
name: "products"
scrape:
parent: ".product-item"
fields:
title: ".title"
price: ".price"
url: "a@href" # Use @ to get attributesStores a literal value in a state variable.
-
Parameters:
name,as(value) - Example:
- action: store_value
name: "my_var"
as: "123"Extracts text from an element and saves it to a variable.
-
Parameters:
selector,name - Example:
- action: store_text
selector: ".username"
name: "current_user"Extracts an attribute from an element and saves it to a variable.
-
Parameters:
selector,attribute,name - Example:
- action: store_attribute
selector: "a.link"
attribute: "href"
name: "link_url"Evaluates a JavaScript expression and saves the result to a variable.
-
Parameters:
value(JS expression),name - Example:
- action: store_eval
value: "window.location.href"
name: "current_url"Prints a message to the console.
-
Parameters:
message - Example:
- action: log
message: "Hello world"Takes a screenshot of the page or a specific area.
-
Parameters:
pathname(optional),position(optional) - Example:
- action: screenshot
pathname: "./screenshots/page.png"Clears all browser cookies.
- Example:
- action: clear_cookiesModifies the HTTP headers sent with browser requests.
-
Parameters:
name,value(for set/add) - Example:
- action: set_header
name: "Authorization"
value: "Bearer token"