Interaction Steps
Select Option
Select options from dropdown menus and select elements
Overview
The Select Option step allows you to select options from dropdown menus, select elements, and other option-based form controls. It supports selecting by visible text, value attribute, or index.
Form Fields
Field Name | Type | Required | Description |
---|---|---|---|
Locator | string | Yes | CSS selector for the select element |
Option Value | string | Yes | Text or value of the option to select |
Form Configuration
Locator Field
- Text input field for entering CSS selectors
- Supports element picker for visual selection
- Should target the
<select>
element or dropdown container
Option Value Field
- Text input field for specifying which option to select
- Supports environment variables using
{{VARIABLE_NAME}}
syntax - Can match by:
- Visible text (what the user sees)
- Value attribute of the option
- Partial text matching
Examples
Select by Visible Text
- Locator:
select[name='country']
- Option Value:
United States
Select by Value Attribute
- Locator:
#size-selector
- Option Value:
large
Select with Environment Variable
- Locator:
select[name='region']
- Option Value:
{{USER_REGION}}
Select from Custom Dropdown
- Locator:
.custom-dropdown[data-testid='priority']
- Option Value:
High Priority
Best Practices
Locator Selection
- Use specific, stable CSS selectors for the select element
- Prefer
data-testid
attributes for better test stability - Ensure the locator targets the actual select element, not individual options
Option Identification
- Use the visible text that users see when possible
- Use value attributes for programmatic consistency
- Avoid using option index numbers as they may change
Dropdown Types
- For standard HTML
<select>
elements, target the select tag - For custom dropdowns, target the container or trigger element
- Ensure the dropdown is in an open/expanded state if required
Common Issues
Element Not Found
- Verify the select element is visible and enabled
- Check that the locator correctly targets the select element
- Ensure any parent forms or containers are loaded
Option Not Available
- Confirm the option text or value exists in the dropdown
- Check for dynamic loading of options
- Verify option text matches exactly (case-sensitive)
Custom Dropdown Issues
- Some custom dropdowns require clicking to open before selection
- May need to use Click step first to open the dropdown
- Consider wait conditions for dynamically loaded options
Timing Problems
- Add wait conditions for dropdowns that load options dynamically
- Ensure the select element is interactive before attempting selection
- Handle cases where options are populated by AJAX calls
Related Steps
- Click - For opening custom dropdowns before selection
- Wait for Element - For waiting on dynamic options
- Fill - For text input fields vs. dropdowns