List of usage examples for org.openqa.selenium.interactions Actions keyDown
public Actions keyDown(WebElement target, CharSequence key)
From source file:com.induscorp.prime.testing.ui.core.objects.DOMObjectValidator.java
License:Open Source License
public void performKeyDown(Keys keys, int numRetries) { for (int i = 0; i < 5; i++) { try {// w w w.j a va 2 s .co m WebElement webElem = findElement(numRetries); Actions actions = new Actions(browser.getSeleniumWebDriver()); actions.keyDown(webElem, keys).build().perform(); break; } catch (MoveTargetOutOfBoundsException | ElementNotVisibleException ex) { browser.waitForSeconds(2); } } }
From source file:com.induscorp.prime.testing.ui.core.objects.DOMObjectValidator.java
License:Open Source License
public void performKeyPressed(Keys keys, int numRetries) { for (int i = 0; i < 5; i++) { try {/*from ww w .j a v a 2 s .co m*/ WebElement webElem = findElement(numRetries); Actions actions = new Actions(browser.getSeleniumWebDriver()); actions.keyDown(webElem, keys).keyUp(webElem, keys).build().perform(); break; } catch (MoveTargetOutOfBoundsException | ElementNotVisibleException ex) { browser.waitForSeconds(2); } } }
From source file:com.liferay.cucumber.selenium.BaseWebDriverImpl.java
License:Open Source License
@Override public void keyDown(String locator, String keySequence) { WebElement webElement = getWebElement(locator); WrapsDriver wrapsDriver = (WrapsDriver) webElement; WebDriver webDriver = wrapsDriver.getWrappedDriver(); Actions actions = new Actions(webDriver); String keycode = keySequence.substring(1); Keys keys = Keys.valueOf(keycode);/* w w w . j a va 2s .c o m*/ actions.keyDown(webElement, keys); Action action = actions.build(); action.perform(); }
From source file:com.liferay.cucumber.selenium.BaseWebDriverImpl.java
License:Open Source License
@Override public void keyPress(String locator, String keySequence) { WebElement webElement = getWebElement(locator); if (keySequence.startsWith("\\")) { String keycode = keySequence.substring(1); if (isValidKeycode(keycode)) { Keys keys = Keys.valueOf(keycode); WrapsDriver wrapsDriver = (WrapsDriver) webElement; WebDriver webDriver = wrapsDriver.getWrappedDriver(); Actions actions = new Actions(webDriver); if (keycode.equals("ALT") || keycode.equals("COMMAND") || keycode.equals("CONTROL") || keycode.equals("SHIFT")) { actions.keyDown(webElement, keys); actions.keyUp(webElement, keys); Action action = actions.build(); action.perform();//from www. ja va2 s. c om } else { webElement.sendKeys(keys); } } } else { webElement.sendKeys(keySequence); } }
From source file:org.finra.jtaf.ewd.widget.element.InteractiveElement.java
License:Apache License
@Override public void keyDown(Keys theKey) throws WidgetException { try {// ww w .jav a 2 s. com Actions builder = new Actions(getGUIDriver().getWrappedDriver()); synchronized (InteractiveElement.class) { getGUIDriver().focus(); for (org.openqa.selenium.Keys key : org.openqa.selenium.Keys.values()) { if (key.name().equals(theKey.name())) { builder.keyDown(getWebElement(), key).build().perform(); break; } } } } catch (Exception e) { throw new WidgetException("Error while performing key down using " + theKey.name(), getLocator(), e); } }