Example usage for org.openqa.selenium Keys toString

List of usage examples for org.openqa.selenium Keys toString

Introduction

In this page you can find the example usage for org.openqa.selenium Keys toString.

Prototype

@Override
    public String toString() 

Source Link

Usage

From source file:de.learnlib.alex.data.entities.actions.web.PressKeyAction.java

License:Apache License

@Override
protected ExecuteResult execute(WebSiteConnector connector) {
    final String unescapedKey = StringEscapeUtils.unescapeJava(this.key);
    final Keys keyToPress = Keys.getKeyFromUnicode(unescapedKey.toCharArray()[0]);

    final WebElementLocator nodeWithVariables = new WebElementLocator(insertVariableValues(node.getSelector()),
            node.getType());/*w ww. ja va2 s .  com*/

    try {
        final WebElement element = connector.getElement(nodeWithVariables);
        element.sendKeys(keyToPress);
        LOGGER.info(LoggerMarkers.LEARNER, "Pressed the key '{}' on the element '{}'.", keyToPress.toString(),
                nodeWithVariables);
        return getSuccessOutput();
    } catch (Exception e) {
        LOGGER.info(LoggerMarkers.LEARNER, "Could not press key '{}' on element '{}'.", keyToPress.toString(),
                nodeWithVariables, e);
        return getFailedOutput();
    }
}

From source file:org.eclipse.che.selenium.pageobject.intelligent.CommandsPalette.java

License:Open Source License

/**
 * Search and start command by name/*from w w w. ja  va 2 s. com*/
 *
 * @param mt where to move(down or up)
 * @param steps
 */
public void moveAndStartCommand(MoveTypes mt, int steps) {
    Keys k = mt.equals(MoveTypes.UP) ? Keys.ARROW_UP : Keys.ARROW_DOWN;

    for (int i = 0; i < steps; i++) {
        actionsFactory.createAction(seleniumWebDriver).sendKeys(k.toString()).perform();
        loader.waitOnClosed();
    }
    actionsFactory.createAction(seleniumWebDriver).sendKeys(Keys.ENTER.toString()).perform();
}

From source file:org.jspringbot.keyword.selenium.SeleniumHelper.java

License:Open Source License

private String mapAsciiKeyCodeToKey(int keyCode) {
    Map<Integer, Keys> keysMap = new HashMap<Integer, Keys>();
    keysMap.put(0, Keys.NULL);/* w  w w .  j  ava 2s.c o m*/
    keysMap.put(8, Keys.BACK_SPACE);
    keysMap.put(9, Keys.TAB);
    keysMap.put(10, Keys.RETURN);
    keysMap.put(13, Keys.ENTER);
    keysMap.put(24, Keys.CANCEL);
    keysMap.put(27, Keys.ESCAPE);
    keysMap.put(32, Keys.SPACE);
    keysMap.put(42, Keys.MULTIPLY);
    keysMap.put(43, Keys.ADD);
    keysMap.put(44, Keys.SUBTRACT);
    keysMap.put(56, Keys.DECIMAL);
    keysMap.put(57, Keys.DIVIDE);
    keysMap.put(59, Keys.SEMICOLON);
    keysMap.put(61, Keys.EQUALS);
    keysMap.put(127, Keys.DELETE);
    Keys key = keysMap.get(keyCode);

    if (key == null) {
        Character c = (char) keyCode;
        return c.toString();
    }

    return key.toString();
}

From source file:org.safs.selenium.webdriver.lib.WDLibrary.java

License:Open Source License

/**
 *
 * @param key Keys, the selenium Keys value
 * @return int the value of java KeyEvent
 * @throws SeleniumPlusException/*from w  w  w.  j  a  v a  2 s .  co  m*/
 */
static int toJavaKeyCode(Keys key) throws SeleniumPlusException {
    String debugmsg = StringUtils.debugmsg(WDLibrary.class, "toJavaKeyCode");
    if (Keys.SHIFT.equals(key))
        return KeyEvent.VK_SHIFT;
    else if (Keys.LEFT_SHIFT.equals(key))
        return KeyEvent.VK_SHIFT;
    else if (Keys.CONTROL.equals(key))
        return KeyEvent.VK_CONTROL;
    else if (Keys.LEFT_CONTROL.equals(key))
        return KeyEvent.VK_CONTROL;
    else if (Keys.ALT.equals(key))
        return KeyEvent.VK_ALT;
    else if (Keys.LEFT_ALT.equals(key))
        return KeyEvent.VK_ALT;
    else {
        String msg = " No handled key '" + (key == null ? "null" : key.toString()) + "'.";
        IndependantLog.debug(debugmsg + msg);
        throw new SeleniumPlusException(msg);
    }
}