Steps
This is a reference for the steps included with the library. For details on creating your own custom steps, refer to this page.
Notes: - Details about Resolved Variables mentioned herein can be found here - The fields that are required are highlighted in bold
Base Fields
All steps must have the following two fields in the YAML, so that they can be identified and validated by the parser.
title
The title field is used as a unique namespace for a step within a bot. This name is used for storing and accessing performance_context for the step as well as for a few other tasks that require namespacing such as screenshots, passing back validation errors, etc.
action
This field is used to identify the class of the Step that needs to be performed. Each of the core steps have their own identifier that they're registered using, and any custom steps must also be registered with their own unique identifier through the selenium_yaml.steps.registered_steps.selenium_step decorator as described here.
Core Steps
NavigateStep
- title: Navigate to URL
action: navigate
url: <URL to navigate to>
url-CharFieldfor the URL that the driver should be navigated to
This step performs a driver.get action with the provided URL.
WaitStep
- title: Wait for a fixed amount of time
action: wait
seconds: <Seconds to wait for>
seconds-IntegerFieldfor the number of steps to wait for
This step performs a wait for the given number of seconds using time.sleep().
WaitForElementStep
- title: Wait for the element to be clickable
action: wait_for_element
element: <Xpath selector for the element>
seconds: <Seconds to wait for>
element-CharFieldfor the XPath selector for the element to wait forseconds-IntegerFieldfor the number of seconds to wait for
This step performs waits for the presence of the given element for the given number of seconds.
ClickElementStep
- title: Click on an element
action: click
element: <Xpath Selector for the Element>
element-CharFieldfor the XPath selector for the element to click on
This step clicks on the element identified by the XPath using driver.click().
TypeTextStep
- title: Type text into an element
action: type
element: <Xpath Selector for the Element>
text: Text to type into the element
clear: True|False
element-CharFieldfor the XPath selector for the element to send text totext-CharFieldfor the text to send to the elementclear-BooleanField; if True, clears the field prior to sending any text
This step sends the given text to the given element using driver.send_keys().
SelectOptionStep
- title: Select an option from a `select` element
action: select
element: <Xpath selector for the Select element>
option: <Value of the option that should be selected>
element-CharFieldfor the XPath selector for the select elementoption-CharFieldfor the value of the option in the select element that should be selected
This step selects the given option in the given select element.
RunBotStep
- title: Run another bot with it's file path
action: run_bot
path: /path/to/the/bot
save_screenshots: True|False
parse_template: True|False
template_context:
- Key: Value
path-FilePathFieldto the path of the both that should be runsave_screenshots-BooleanFieldfor whether this bot should have screenshots' saved or notparse_template-BooleanField; if True, thetemplate_contextfield will be used for rendering the Bot's YAML as a Jinja Template prior to executiontemplate_context-ResolvedVariableField(required_type=dict)field that can either be a resolved variable or a dictionary, and will be used for rendering the Bot's YAML ifparse_templateis True
This step is used for running another bot with the current performance context available in the bot.
CallAPIStep
- title: Call an API and store it's response and status code
action: make_request
method: GET
url: https://url-to-request.com/?queryParams=value
body:
Key: Value
headers:
Key: Value
url-CharFieldfor the URL that should be requestedmethod-CharField(options=["GET", "PUT", "POST"])for the request method that should be usedbody-DictFieldfor the request bodyheaders-DictFieldfor the request headers
This step is used for sending a request with the given details and storing the response's body in the context and status_code performance context variables under the step's namespace
IteratorStep
- title: Iterate over an array (resolved/directly provided)
action: iterate_over
iterator:
- Array
steps:
- title: Array of steps (step-1)
action: navigate
url: navigate-url
...
iterator-ResolvedVariableField(required_type=list)field for the array to iterate oversteps-NestedStepsFieldcontaining an array of steps that should be performed for each element in theiterator
This step is used to perform all of the steps in the steps array for each element in the iterator. The context for each iteration is stored under the step_title__iter_index__sub_step_title namespace. The iterator could also be a resolved variable if required. In the steps in the iterator, a performance context variable for the current element being iterated over is available at ${current_iterator}.
ConditionalStep
- title: Conditionally run a step
action: conditional
value: Value to be checked
equals: This is what `value` needs to equal
negate: True|False
steps:
- title: Array of steps (step-1)
action: navigate
url: navigate-url
...
value-CharFieldthat can be an XPath selector to a value (not an element), or a string, or a resolved variable of any other typeequals-CharFieldthat thevalueis check againstnegate-BooleanField; if True, thevaluemust equalequalsfor the condition to pass - otherwise, thevaluemust not equalequalsfor the condition to passsteps-NestedStepsFieldcontaining an array of steps that should be performed if the condition passes
This step is used for conditionally running a set of steps.
StoreXpathStep
- title: Store the result of a given xpath selector in the performance context
action: store_xpath
selector: "//xpath/selector/@attribute"
variable: Variable To Store Result In
select_first: True|False
selector-CharFieldfor the selector to the attribute/prop that should be storedvariable-CharFieldfor the variable name that theselector's result will be stored in under the step's namespaceselect_first-BooleanField; if True, will store only the first match for the selector - otherwise, stores all of the matches in thevariableas an array
This step is used for storing something in the page in the performance context for later use.
StorePageUrlStep
- title: Store the current page's URL in a <Step Title>__url variable for later use
action: store_page_url
This step is used for storing the current page URL in a url variable under the step's namespace.