public void setSelected() { element.setSelected(); }
public void setSelected() { element.setSelected(); }
public ResultType call() throws Exception { try { getElement().setSelected(); } catch (Exception e) { throw e; } return ResultType.SUCCESS; }
/** * Check a toggle-button (checkbox/radio) * * @param locator an <a href="#locators">element locator</a> */ public void check(String locator) { findElement(locator).setSelected(); }
public ResultType call() throws Exception { try { getElement().setSelected(); } catch (Exception e) { throw e; } return ResultType.SUCCESS; }
/** * Select the option at the given index. This is done by examing the "index" attribute of an * element, and not merely by counting. * * @param index The option at this index will be selected */ public void selectByIndex(int index) { String match = String.valueOf(index); for (WebElement option : getOptions()) { if (match.equals(option.getAttribute("index"))) { option.setSelected(); if (isMultiple()) { return; } } } }
/** * Select the option at the given index. This is done by examing the "index" attribute of an * element, and not merely by counting. * * @param index The option at this index will be selected */ public void selectByIndex(int index) { String match = String.valueOf(index); for (WebElement option : getOptions()) { if (match.equals(option.getAttribute("index"))) { option.setSelected(); if (isMultiple()) { return; } } } }
public boolean select(List<WebElement> fromOptions, String selectThis, boolean setSelected, boolean allowMultipleSelect) { try { int index = Integer.parseInt(selectThis); WebElement option = (WebElement) fromOptions.get(index); if (setSelected) option.setSelected(); else if (option.isSelected()) { option.toggle(); } return true; } catch (Exception e) { // Do nothing. Handled below } return false; } }
/** * Select all options that have a value matching the argument. That is, when given "foo" this * would select an option like: * * <option value="foo">Bar</option> * * @param value The value to match against */ public void selectByValue(String value) { StringBuilder builder = new StringBuilder(".//option[@value = "); builder.append(escapeQuotes(value)); builder.append("]"); List<WebElement> options = element.findElements(By.xpath(builder.toString())); for (WebElement option : options) { option.setSelected(); if (isMultiple()) { return; } } }
public boolean select(List<WebElement> fromOptions, String selectThis, boolean setSelected, boolean allowMultipleSelect) { boolean matchMade = false; Iterator<WebElement> allOptions = fromOptions.iterator(); while (allOptions.hasNext()) { WebElement option = allOptions.next(); boolean matchThisTime = selectOption(option, selectThis); if (matchThisTime) { if (setSelected) option.setSelected(); else if (option.isSelected()) { option.toggle(); } } matchMade |= matchThisTime; if (matchMade && !allowMultipleSelect) return true; } return matchMade; }
/** * Select all options that have a value matching the argument. That is, when given "foo" this * would select an option like: * * <option value="foo">Bar</option> * * @param value The value to match against */ public void selectByValue(String value) { StringBuilder builder = new StringBuilder(".//option[@value = "); builder.append(escapeQuotes(value)); builder.append("]"); List<WebElement> options = element.findElements(By.xpath(builder.toString())); for (WebElement option : options) { option.setSelected(); if (isMultiple()) { return; } } }
/** * Select all options that display text matching the argument. That is, when given "Bar" this * would select an option like: * * <option value="foo">Bar</option> * * @param text The visible text to match against */ public void selectByVisibleText(String text) { StringBuilder builder = new StringBuilder(".//option[. = "); builder.append(escapeQuotes(text)); builder.append("]"); List<WebElement> options = element.findElements(By.xpath(builder.toString())); for (WebElement option : options) { option.setSelected(); if (isMultiple()) { return; } } }
option.setSelected(); if (!isMultiple()) { return; } option.setSelected(); if (!isMultiple()) { return; }