@Override public void keyPressAndWait(String locator, String keySequence) { super.keyPress(locator, keySequence); super.waitForPageToLoad("30000"); }
@Override public void select(String selectLocator, String optionLocator) { WebElement webElement = getWebElement(selectLocator); Select select = new Select(webElement); List<WebElement> options = select.getOptions(); String label = optionLocator; int index = -1; if (optionLocator.startsWith("index=")) { String indexString = optionLocator.substring(6); index = GetterUtil.getInteger(indexString); } else if (optionLocator.startsWith("label=")) { label = optionLocator.substring(6); } else if (optionLocator.startsWith("value=")) { String value = optionLocator.substring(6); if (value.startsWith("regexp:")) { String regexp = value.substring(7); Pattern pattern = Pattern.compile(regexp); for (WebElement option : options) { String optionValue = option.getAttribute("value"); Matcher matcher = pattern.matcher(optionValue); if (matcher.matches()) { index = options.indexOf(option); break; } } } else { for (WebElement option : options) { String optionValue = option.getAttribute("value"); if (optionValue.equals(value)) { label = option.getText(); break; } } } } if (index > -1) { select.selectByIndex(index); } else { keyPress(selectLocator, "\\36"); if (!label.equals(getSelectedLabel(selectLocator))) { webElement.sendKeys(label); keyPress(selectLocator, "\\13"); } } }