Example usage for org.openqa.selenium Keys CONTROL

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

Introduction

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

Prototype

Keys CONTROL

To view the source code for org.openqa.selenium Keys CONTROL.

Click Source Link

Usage

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

License:Open Source License

/**
 * Convert a Java KEYCODE to a Selenium WebDriver Keys Enum
 * @param keycode int, a java keycode//from   www.  j  av a2  s .c  om
 * @return Keys enum for (primarily) non-printable (control) characters, or null.
 */
public static Keys convertToKeys(int keycode) {
    Keys key = null;
    switch (keycode) {
    case java.awt.event.KeyEvent.VK_ADD:
        key = Keys.ADD;
        break;
    case java.awt.event.KeyEvent.VK_ALT:
        key = Keys.ALT;
        break;
    case java.awt.event.KeyEvent.VK_KP_DOWN:
        key = Keys.ARROW_DOWN;
        break;
    case java.awt.event.KeyEvent.VK_KP_LEFT:
        key = Keys.ARROW_LEFT;
        break;
    case java.awt.event.KeyEvent.VK_KP_RIGHT:
        key = Keys.ARROW_RIGHT;
        break;
    case java.awt.event.KeyEvent.VK_KP_UP:
        key = Keys.ARROW_UP;
        break;
    case java.awt.event.KeyEvent.VK_BACK_SPACE:
        key = Keys.BACK_SPACE;
        break;
    case java.awt.event.KeyEvent.VK_CANCEL:
        key = Keys.CANCEL;
        break;
    case java.awt.event.KeyEvent.VK_CLEAR:
        key = Keys.CLEAR;
        break;
    case java.awt.event.KeyEvent.VK_WINDOWS:
        key = Keys.COMMAND;
        break;
    case java.awt.event.KeyEvent.VK_CONTROL:
        key = Keys.CONTROL;
        break;
    case java.awt.event.KeyEvent.VK_DECIMAL:
        key = Keys.DECIMAL;
        break;
    case java.awt.event.KeyEvent.VK_DELETE:
        key = Keys.DELETE;
        break;
    case java.awt.event.KeyEvent.VK_DIVIDE:
        key = Keys.DIVIDE;
        break;
    case java.awt.event.KeyEvent.VK_DOWN:
        key = Keys.DOWN;
        break;
    case java.awt.event.KeyEvent.VK_END:
        key = Keys.END;
        break;
    case java.awt.event.KeyEvent.VK_ENTER:
        key = Keys.ENTER;
        break;
    case java.awt.event.KeyEvent.VK_EQUALS:
        key = Keys.EQUALS;
        break;
    case java.awt.event.KeyEvent.VK_ESCAPE:
        key = Keys.ESCAPE;
        break;
    case java.awt.event.KeyEvent.VK_F1:
        key = Keys.F1;
        break;
    case java.awt.event.KeyEvent.VK_F2:
        key = Keys.F2;
        break;
    case java.awt.event.KeyEvent.VK_F3:
        key = Keys.F3;
        break;
    case java.awt.event.KeyEvent.VK_F4:
        key = Keys.F4;
        break;
    case java.awt.event.KeyEvent.VK_F5:
        key = Keys.F5;
        break;
    case java.awt.event.KeyEvent.VK_F6:
        key = Keys.F6;
        break;
    case java.awt.event.KeyEvent.VK_F7:
        key = Keys.F7;
        break;
    case java.awt.event.KeyEvent.VK_F8:
        key = Keys.F8;
        break;
    case java.awt.event.KeyEvent.VK_F9:
        key = Keys.F9;
        break;
    case java.awt.event.KeyEvent.VK_F10:
        key = Keys.F10;
        break;
    case java.awt.event.KeyEvent.VK_F11:
        key = Keys.F11;
        break;
    case java.awt.event.KeyEvent.VK_F12:
        key = Keys.F12;
        break;
    case java.awt.event.KeyEvent.VK_HELP:
        key = Keys.HELP;
        break;
    case java.awt.event.KeyEvent.VK_HOME:
        key = Keys.HOME;
        break;
    case java.awt.event.KeyEvent.VK_INSERT:
        key = Keys.INSERT;
        break;
    case java.awt.event.KeyEvent.VK_LEFT:
        key = Keys.LEFT;
        break;
    case java.awt.event.KeyEvent.VK_META:
        key = Keys.META;
        break;
    case java.awt.event.KeyEvent.VK_MULTIPLY:
        key = Keys.MULTIPLY;
        break;
    case java.awt.event.KeyEvent.VK_NUMPAD0:
        key = Keys.NUMPAD0;
        break;
    case java.awt.event.KeyEvent.VK_NUMPAD1:
        key = Keys.NUMPAD1;
        break;
    case java.awt.event.KeyEvent.VK_NUMPAD2:
        key = Keys.NUMPAD2;
        break;
    case java.awt.event.KeyEvent.VK_NUMPAD3:
        key = Keys.NUMPAD3;
        break;
    case java.awt.event.KeyEvent.VK_NUMPAD4:
        key = Keys.NUMPAD4;
        break;
    case java.awt.event.KeyEvent.VK_NUMPAD5:
        key = Keys.NUMPAD5;
        break;
    case java.awt.event.KeyEvent.VK_NUMPAD6:
        key = Keys.NUMPAD6;
        break;
    case java.awt.event.KeyEvent.VK_NUMPAD7:
        key = Keys.NUMPAD7;
        break;
    case java.awt.event.KeyEvent.VK_NUMPAD8:
        key = Keys.NUMPAD8;
        break;
    case java.awt.event.KeyEvent.VK_NUMPAD9:
        key = Keys.NUMPAD9;
        break;
    case java.awt.event.KeyEvent.VK_PAGE_DOWN:
        key = Keys.PAGE_DOWN;
        break;
    case java.awt.event.KeyEvent.VK_PAGE_UP:
        key = Keys.PAGE_UP;
        break;
    case java.awt.event.KeyEvent.VK_PAUSE:
        key = Keys.PAUSE;
        break;
    case java.awt.event.KeyEvent.VK_RIGHT:
        key = Keys.RIGHT;
        break;
    case java.awt.event.KeyEvent.VK_SEMICOLON:
        key = Keys.SEMICOLON;
        break;
    case java.awt.event.KeyEvent.VK_SEPARATOR:
        key = Keys.SEPARATOR;
        break;
    case java.awt.event.KeyEvent.VK_SHIFT:
        key = Keys.SHIFT;
        break;
    case java.awt.event.KeyEvent.VK_SPACE:
        key = Keys.SPACE;
        break;
    case java.awt.event.KeyEvent.VK_SUBTRACT:
        key = Keys.SUBTRACT;
        break;
    case java.awt.event.KeyEvent.VK_TAB:
        key = Keys.TAB;
        break;
    case java.awt.event.KeyEvent.VK_UP:
        key = Keys.UP;
        break;
    }
    return key;
}

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/*w  ww  . jav a  2s  . 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);
    }
}

From source file:org.tomitribe.tribestream.registryng.functionaltests.pages.ApplicationDetailsPage.java

License:Apache License

public void enterApplicationName(final String newTitle) throws IOException {
    titleField.click();//from w w  w  . ja  va 2s  .co  m

    waitGui();

    WebElement textField = titleField.findElement(By.cssSelector("input[type='text']"));
    // No Ctrl+A because on Mac it's probably COMMAND+A
    textField.sendKeys(Keys.chord(Keys.CONTROL, "a"), Keys.BACK_SPACE);
    textField.sendKeys(newTitle);
    guardNoRequest(checkButton).click();

}

From source file:org.tomitribe.tribestream.registryng.functionaltests.pages.ApplicationDetailsPage.java

License:Apache License

public void enterVersion(final String newVersion) throws IOException {
    versionField.click();/*w ww  .j  a v a 2  s.c  o m*/
    waitGui();
    WebElement textField = versionField.findElement(By.cssSelector("input[type='text']"));
    textField.sendKeys(Keys.chord(Keys.CONTROL, "a"), Keys.BACK_SPACE);
    textField.sendKeys(newVersion);
    guardNoRequest(checkButton).click();
}

From source file:org.tomitribe.tribestream.registryng.functionaltests.pages.ApplicationDetailsPage.java

License:Apache License

public void enterDescription(final String newDescription) throws Exception {

    // TODO: No idea how to edit the markdown component. SeleniumIDE does not see any actions as well... :-(
    //        assertTrue(descriptionField.isDisplayed());
    //        Actions actions = new Actions(driver).moveToElement(descriptionField);
    //        createScreenshot("target/aftermove.png");
    //        actions.click();
    //        createScreenshot("target/afterclick.png");

    descriptionField.click();/*from www  .java 2s . com*/
    Thread.sleep(5000);
    guardNoRequest(descriptionEditor).sendKeys(Keys.chord(Keys.CONTROL, "a"), Keys.BACK_SPACE, newDescription);
    guardNoRequest(checkButton).click();

}

From source file:org.tomitribe.tribestream.registryng.functionaltests.pages.EndpointDetailsPage.java

License:Apache License

public void enterVerb(final String newVerb) throws Exception {
    WebElement textField = verbSingleSelect.findElement(By.cssSelector("input[type='text']"));
    verbSingleSelect.click();/*ww w  . ja  v a2s  .c  om*/
    Thread.sleep(5000);
    guardNoRequest(textField).sendKeys(Keys.chord(Keys.CONTROL, "a"), Keys.BACK_SPACE, newVerb, Keys.ENTER);
}

From source file:org.tomitribe.tribestream.registryng.functionaltests.pages.EndpointDetailsPage.java

License:Apache License

public void enterPath(final String newPath) throws IOException {
    pathTextField.click();//from w  w w.  j av  a  2 s .c  o m
    waitGui();
    WebElement textField = pathTextField.findElement(By.cssSelector("input[type='text']"));
    textField.sendKeys(Keys.chord(Keys.CONTROL, "a"), Keys.BACK_SPACE);
    textField.sendKeys(newPath);
    guardNoRequest(checkButton).click();
}

From source file:org.tomitribe.tribestream.registryng.functionaltests.pages.SearchPage.java

License:Apache License

public void refresh() throws InterruptedException {
    searchField.sendKeys(Keys.chord(Keys.CONTROL, "a"), Keys.DELETE, Keys.RETURN);
    Thread.sleep(5000);//from  ww  w.java2 s . c  om
}

From source file:org.usapi.nodetypes.AbstractNode.java

License:Apache License

private void modifierKeyDown(int modifierKey) throws USAPIException {
    switch (modifierKey) {
    case ALT_KEY:
        getKeyboard().pressKey(Keys.ALT);
        break;/*www .j  a  v  a2 s.  c  o  m*/
    case CTRL_KEY:
        getKeyboard().pressKey(Keys.CONTROL);
        break;
    case SHIFT_KEY:
        getKeyboard().pressKey(Keys.SHIFT);
        break;
    }
}

From source file:org.usapi.nodetypes.AbstractNode.java

License:Apache License

private void modifierKeyUp(int modifierKey) throws USAPIException {
    switch (modifierKey) {
    case ALT_KEY:
        getKeyboard().releaseKey(Keys.ALT);
        break;// w  ww.  j  a  v a 2  s .  c o  m
    case CTRL_KEY:
        getKeyboard().releaseKey(Keys.CONTROL);
        break;
    case SHIFT_KEY:
        getKeyboard().releaseKey(Keys.SHIFT);
        break;
    }
}