Returns the elements in the given sequence as long as the
condition sequence produces a non-empty sequence, and then skips the remaining elements.
Sequence.WhileAny · [sequence] · [condition]
- The sequence to return elements from.
- A sequence that runs after evaluating each element of
sequence, and produces either an empty or a non-empty sequence. As soon as an empty sequence is encountered, the original sequence is trimmed.
A trimmed version of
As an example, suppose example.com contains a list of links and a next button to turn the pages. The following would visit each of the links until a link with the text "Last Item" is encountered:
Sequence.WhileAny · Browser.Load · "https://www.example.com" Browser.TurnPages · Select.NextButton Select.Link · Gather.Text as text if · = · text · "Last Item" · Sequence.Empty · Sequence.Default Browser.Navigate
In this example, the first argument of
Sequence.WhileAny is a sequence that loads a page, turns the pages, and selects each of the links. While each link is selected, the second argument gets the
text of the link and, if it's equal to "Last Item", it returns
Sequence.Empty to stop the extraction.
This way the,
Browser.Navigate action at the bottom (and every other action below) will only run on links that appeared before the "Last Item" link.