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.
{
"api": "1.0.2.1",
"name": "SelectEach",
"options": {
"selector": "Drop Down Selector",
"skip": true
}
}
Code: Select all
Browser.EvalScript
· "return Array.from(element.querySelectorAll('option')).map(a => a.value)"
· 0
as value
Browser.InputValue
· value
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):
Code: Select all
Select.DropDown
Sequence.Skip
· 1
· 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
Select.DropDown
SelectBy.Css
· "option:checked"