Select a value from a list
  • 12 Apr 2024
  • 2 Minutes to read
  • Contributors
  • Dark
    Light

Select a value from a list

  • Dark
    Light

Article Summary

Step that selects a value from a list

When you record the action that selects a value from a list implemented with a <select> element, a [Select ... From List] step is created.

en_select_from_list

Lists implemented with anything other than the <select> element

When you record an action that selects a value from a list implemented with anything other than a <select> element, it will typically result in two clicks being recorded: a click that opens the options and another click that select an option.

Search target

During test runs, Autify looks at the options within the list and searches for the value set in the "Label".

en-label-list.png

The search target is the value enclosed in the option tag (<option>This string</option>). Currently, Autify does not support options where the option tag doesn't enclose a value, for example <option label="1" value="1"></option>.

Selections other than by label are not supported

The [Select ... From List] step currently does not support selection by any method other than complete label matching, such as:

If the step is not recorded

Autify Recorder detects when a value has changed (such as when a selection has changed) and records steps accordingly. Therefore, if you re-select an already selected value, the [Select ... From List] step will not be recorded.

To record the step, you can first select a different option, then re-select the desired value. Afterward, you can remove any unnecessary steps.

If the value is not recorded

Since Autify does not currently support options where the option tag does not enclose a value, such as <option label="1" value="1"></option>, if you record the action that selects such an option, the value won't be recorded and "..." in [Select ... From List] will be blank.

If you enter a value in the Scenario Edit page afterwards, Local Replay will work, but Autify not will be able to find the option during test execution, causing the test to fail.

The difference between Local Replay and test execution

Local Replay is a feature that helps when updating test scenarios, and its behavior may be different from test execution. This is one such difference. For more details, see Record here (Local replay) - 3. The difference between Local Replay and test execution

Add a locator

When adding a locator, be sure to specify the CSS selector/XPath of the <select> element you want to select, not the <option> element. If you specify a CSS selector/XPath of an element other than the <select> element, Local Replay and test execution will fail.

Please note that specifying the CSS selector/XPath of the option you wish to select in the locator does not result in the selection of that option.

Lists that allow multiple selections

Lists with the "multiple" attribute allow you to select multiple options. If you perform an action that changes the selected option in a list that allows multiple selections, Autify creates two steps: [Unselect ... From List] and [Select ... From List].

If you select "1" and then select "2", these steps will be recorded:

en-select-multiple

If you select "1" and then select "2" while holding down Shift or Ctrl (cmd), the [Unselect ... From List] step will not be created:

en-select-multiple-shift


Was this article helpful?

What's Next
Changing your password will log you out immediately. Use the new password to log back in.
First name must have atleast 2 characters. Numbers and special characters are not allowed.
Last name must have atleast 1 characters. Numbers and special characters are not allowed.
Enter a valid email
Enter a valid password
Your profile has been successfully updated.