Select Each Option
Posted: Sat Mar 31, 2018 11:00 pm
The following code selects each option in a drop down menu. Must occur below a selector that selects the drop down element. To use this on your project, follow these instructions.
To skip options from the top, use the Sequence.Skip function as in the following example (this example assumes the project already contains a selector called DropDown that selects the menu element, and the code above was pasted under a global called SelectEach):
An additional requirement may be to extract the text of the currently selected item. This can be achieved with the drop down selector, followed by a CSS selector that selects the selected option:
Code: Select all
Browser.EvalScript
· "return Array.from(element.querySelectorAll('option')).map(a => a.value)"
· 0
as value
Browser.InputValue
· value
Code: Select all
Select.DropDown
Sequence.Skip
· 1
· SelectEach
Code: Select all
Select.DropDown
SelectBy.Css
· "option:checked"