For future reference, this is how we addressed the use case:
{items=
map(
{site: html;
xpath=//*[contains(concat(' ', @class, ' '), ' parentClass ')][.//span[contains(@id, 'condition1')] or .//span[contains(@id, 'condition2')]];
multiple=yes},
x->extractregex(x, "id=\"(.+?)\""))}
{repeat: for item in items}
{sel="#" & item & " #checkbox input"}
{click: selector={=sel}}{wait: delay=0.5s}{endrepeat}
We used the newly launched dynamic click CSS selector in this as well! The flow is:
- Use the
{site}command to grab each element on the page such that it has a child in its subtree that matches the given condition.{site}withmultiple=yesgrabs all elements as a list. - Use the
mapfunction to extract the unique 'id' of each such element, by usingextractregex. - We then
repeatthrough the list. - On each iteration, we build the selector for the checkbox input by string concatenation. Note this selector is dynamically generated on each repeat iteration.
- Then we
{click}on the dynamic selector.