The multiplier is (of course) bound to the string, producing “itemitemitem”. Is there a way to get [“first”, “item”, “item”, “item”, “last”] such that this notional method could be coded and get what I wish?
For posterity (and anyone wondering what the hell I wanted that for) …
/**
* Select an item from an ACE dropdown.
* @param selector (String) CSS selector of the target control containing the ACE.
* @param count (int) The number of downarrow keys to send to the ACE.
* @param filter (String) Optional prefix to filter the ACE. (e.g. "Wayne").
*/
void chooseACEItem(String selector, int count, String filter = "") {
WebDriver driver = DriverFactory.getWebDriver()
WebElement elem = driver.findElement(By.cssSelector(selector))
List keys = [Keys.RIGHT, [Keys.DOWN] * count, Keys.ENTER].flatten();
type(selector, filter)
for(def key in keys) {
Thread.sleep(400)
elem.sendKeys(key)
}
}