Select Each Option

Premades & Resources to be used with Helium Scraper 3
Post Reply
webmaster
Site Admin
Posts: 521
Joined: Mon Dec 06, 2010 8:39 am
Contact:

Select Each Option

Post by webmaster » 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.

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"
Juan Soldi
The Helium Scraper Team

Post Reply