Example usage for org.openqa.selenium Keys ARROW_UP

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

Introduction

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

Prototype

Keys ARROW_UP

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

Click Source Link

Usage

From source file:org.eclipse.che.selenium.intelligencecommand.MacrosCommandsEditorTest.java

License:Open Source License

@Test(priority = 2)
public void checkCommandMacrosIntoPreviewUrl() {
    commandsEditor.cancelFormInEditorByEscape();
    commandsEditor.setFocusIntoTypeCommandsEditor(PREVIEW_URL_EDITOR);
    commandsEditor.setCursorToLine(1);//from   w  w w . ja  v a  2s . c  om
    commandsEditor.waitActiveEditor();
    commandsEditor.selectMacrosLinkInCommandsEditor(PREVIEW_MACROS_LINK);
    commandsEditor.typeTextIntoSearchMacroField("server.22/");
    commandsEditor.waitTextIntoSearchMacroField("server.22/");
    String[] macrosItems = { "${server.22/tcp.hostname}", "${server.22/tcp.port}", "${server.22/tcp.protocol}",
            "${server.22/tcp}", "Returns hostname of a server registered by name",
            "Returns port of a server registered by name", "Returns protocol of a server registered by name",
            "Returns protocol, hostname and port of an internal server" };
    for (String macrosItem : macrosItems) {
        commandsEditor.waitTextIntoMacrosContainer(macrosItem);
    }
    commandsEditor.enterMacroCommandByEnter("${server.22/tcp.hostname}");
    commandsEditor.waitTextIntoEditor("${server.22/tcp.hostname}");
    commandsEditor.clickOnRunButton();
    consoles.waitExpectedTextIntoPreviewUrl("ssh");
    commandsEditor.setFocusIntoTypeCommandsEditor(PREVIEW_URL_EDITOR);
    commandsEditor.setCursorToLine(1);
    commandsEditor.selectLineAndDelete();
    commandsEditor.waitActiveEditor();
    commandsEditor.selectMacrosLinkInCommandsEditor(PREVIEW_MACROS_LINK);
    commandsEditor.selectMacroCommand("${server.22/tcp}");
    commandsEditor.typeTextIntoEditor(Keys.ARROW_UP.toString());
    commandsEditor.typeTextIntoEditor(Keys.SPACE.toString());
    commandsEditor.waitMacroCommandIsSelected("${server.22/tcp.protocol}");
    commandsEditor.enterMacroCommandByDoubleClick("${server.22/tcp.protocol}");
    commandsEditor.waitTextIntoEditor("${server.22/tcp.protocol}");
    commandsEditor.clickOnRunButton();
    consoles.waitExpectedTextIntoPreviewUrl("ssh");
}

From source file:org.eclipse.che.selenium.miscellaneous.FindTextFeatureTest.java

License:Open Source License

@Test(priority = 2)
public void checkFindTextBasic() {
    projectExplorer.waitProjectExplorer();
    projectExplorer.selectItem(PROJECT_NAME);
    menu.runCommand(TestMenuCommandsConstants.Edit.EDIT, TestMenuCommandsConstants.Edit.FIND);
    findText.waitFindTextMainFormIsOpen();
    findText.waitSearchBtnMainFormIsDisabled();
    findText.typeTextIntoFindField("dddhhh");
    findText.waitTextIntoFindField("dddhhh");
    loader.waitOnClosed();/*  ww  w.  j ava2s . c  om*/
    findText.clickOnSearchButtonMainForm();
    findText.waitFindInfoPanelIsOpen();
    findText.waitExpectedTextInFindInfoPanel(FIND_NOTHING);
    findText.clickHideBtnFindInfoPanel();
    findText.clickFindTab();
    findText.waitFindInfoPanelIsOpen();

    projectExplorer.selectItem(PROJECT_NAME);
    findText.launchFindFormByKeyboard();
    findText.waitFindTextMainFormIsOpen();
    findText.typeTextIntoFindField("String");
    findText.waitTextIntoFindField("String");
    findText.setAndWaitStateSearchRootCheckbox(false);
    findText.waitPathIntoRootField("/" + PROJECT_NAME);
    findText.clickOnSearchButtonMainForm();
    findText.waitFindInfoPanelIsOpen();
    findText.waitExpectedTextInFindInfoPanel(PR_1_EXPECTED_TEXT_1);
    findText.selectItemInFindInfoPanel("guess_num.jsp");
    findText.sendCommandByKeyboardInFindInfoPanel(Keys.ENTER.toString());
    editor.waitActiveEditor();
    editor.waitActiveTabFileName("guess_num.jsp");
    editor.waitTextIntoEditor("String");
    findText.selectItemInFindInfoPanelByDoubleClick("SayHello.java");
    editor.waitActiveEditor();
    editor.waitActiveTabFileName("SayHello");
    editor.waitTextIntoEditor("String");
    findText.selectItemInFindInfoPanel("guess_num.jsp");
    findText.sendCommandByKeyboardInFindInfoPanel(Keys.ARROW_UP.toString());
    findText.sendCommandByKeyboardInFindInfoPanel(Keys.ENTER.toString());
    editor.waitActiveTabFileName("SayHelloTest");
    editor.closeAllTabs();
}

From source file:org.eclipse.che.selenium.miscellaneous.FindUsagesBaseOperationTest.java

License:Open Source License

@Test
public void checkFindUsagesBaseOperation() {
    projectExplorer.waitProjectExplorer();
    projectExplorer.waitItem(PROJECT_NAME);
    projectExplorer.expandPathInProjectExplorerAndOpenFile(PATH_FOR_EXPAND, "AppController.java");

    // Check basic operations of the 'find usages' panel
    editor.selectTabByName("AppController");
    editor.setCursorToDefinedLineAndChar(26, 17);
    menu.runCommand(TestMenuCommandsConstants.Assistant.ASSISTANT,
            TestMenuCommandsConstants.Assistant.FIND_USAGES);
    loader.waitOnClosed();//from  ww w . ja  v  a 2  s .c  o  m
    findUsages.waitFindUsagesPanelIsOpen();
    findUsages.clickFindUsagesTab();
    findUsages.waitFindUsegesPanelIsClosed();
    findUsages.clickFindUsagesTab();
    findUsages.waitFindUsagesPanelIsOpen();
    findUsages.waitExpectedTextInFindUsagesPanel(EXPECTED_TEXT);
    findUsages.waitSelectedElementInFindUsagesPanel("numGuessByUser");

    // Check nodes in the 'find usages' panel by 'double click' and click on the icon node
    findUsages.clickOnIconNodeInFindUsagesPanel(PROJECT_NAME);
    findUsages.waitExpectedTextIsNotPresentInFindUsagesPanel(EXPECTED_TEXT_1);
    findUsages.selectNodeInFindUsagesByDoubleClick(PROJECT_NAME);
    findUsages.waitExpectedTextIsNotPresentInFindUsagesPanel(EXPECTED_TEXT_1);
    findUsages.selectNodeInFindUsagesByDoubleClick("org.eclipse.qa.examples");
    findUsages.selectNodeInFindUsagesByDoubleClick("AppController");
    findUsages.selectNodeInFindUsagesByDoubleClick("handleRequest(HttpServletRequest, HttpServletResponse)");
    findUsages.waitExpectedTextInFindUsagesPanel(EXPECTED_TEXT_1);
    findUsages.selectNodeInFindUsagesByDoubleClick("AppController");
    findUsages.waitExpectedTextIsNotPresentInFindUsagesPanel(EXPECTED_TEXT_2);
    findUsages.clickOnIconNodeInFindUsagesPanel("AppController");
    findUsages.waitExpectedTextIsNotPresentInFindUsagesPanel(EXPECTED_TEXT_2);
    findUsages.clickOnIconNodeInFindUsagesPanel("handleRequest(HttpServletRequest, HttpServletResponse)");
    findUsages.waitExpectedTextInFindUsagesPanel(EXPECTED_TEXT_2);

    // Check nodes in the 'find usages' panel by 'Enter'
    findUsages.selectNodeInFindUsagesPanel(PROJECT_NAME);
    findUsages.sendCommandByKeyboardInFindUsagespanel(Keys.ENTER.toString());
    findUsages.waitExpectedTextIsNotPresentInFindUsagesPanel(EXPECTED_TEXT_1);
    findUsages.sendCommandByKeyboardInFindUsagespanel(Keys.ENTER.toString());
    findUsages.waitExpectedTextIsNotPresentInFindUsagesPanel(EXPECTED_TEXT_1);
    findUsages.selectNodeInFindUsagesPanel("org.eclipse.qa.examples");
    findUsages.sendCommandByKeyboardInFindUsagespanel(Keys.ENTER.toString());
    findUsages.selectNodeInFindUsagesPanel("AppController");
    findUsages.sendCommandByKeyboardInFindUsagespanel(Keys.ENTER.toString());
    findUsages.selectNodeInFindUsagesPanel("handleRequest(HttpServletRequest, HttpServletResponse)");
    findUsages.sendCommandByKeyboardInFindUsagespanel(Keys.ENTER.toString());
    findUsages.waitExpectedTextInFindUsagesPanel(EXPECTED_TEXT_1);
    findUsages.selectNodeInFindUsagesPanel("AppController");
    findUsages.sendCommandByKeyboardInFindUsagespanel(Keys.ENTER.toString());
    findUsages.waitExpectedTextIsNotPresentInFindUsagesPanel(EXPECTED_TEXT_2);
    findUsages.sendCommandByKeyboardInFindUsagespanel(Keys.ENTER.toString());
    findUsages.waitExpectedTextIsNotPresentInFindUsagesPanel(EXPECTED_TEXT_2);
    findUsages.selectNodeInFindUsagesPanel("handleRequest(HttpServletRequest, HttpServletResponse)");
    findUsages.sendCommandByKeyboardInFindUsagespanel(Keys.ENTER.toString());
    findUsages.waitExpectedTextInFindUsagesPanel(EXPECTED_TEXT_2);

    // Check nodes in the 'find usages' panel by keyboard
    findUsages.selectNodeInFindUsagesPanel("handleRequest(HttpServletRequest, HttpServletResponse)");
    findUsages.sendCommandByKeyboardInFindUsagespanel(Keys.ARROW_LEFT.toString());
    findUsages.waitExpectedTextIsNotPresentInFindUsagesPanel(EXPECTED_TEXT_2);
    findUsages.sendCommandByKeyboardInFindUsagespanel(Keys.ARROW_RIGHT.toString());
    findUsages.waitExpectedTextInFindUsagesPanel(EXPECTED_TEXT_2);
    findUsages.sendCommandByKeyboardInFindUsagespanel(Keys.ARROW_UP.toString());
    findUsages.sendCommandByKeyboardInFindUsagespanel(Keys.ARROW_UP.toString());
    findUsages.sendCommandByKeyboardInFindUsagespanel(Keys.ARROW_UP.toString());
    findUsages.sendCommandByKeyboardInFindUsagespanel(Keys.ARROW_LEFT.toString());
    findUsages.waitExpectedTextIsNotPresentInFindUsagesPanel(EXPECTED_TEXT_1);
    findUsages.sendCommandByKeyboardInFindUsagespanel(Keys.ARROW_RIGHT.toString());
    findUsages.waitExpectedTextIsNotPresentInFindUsagesPanel(EXPECTED_TEXT_1);
    findUsages.sendCommandByKeyboardInFindUsagespanel(Keys.ARROW_DOWN.toString());
    findUsages.sendCommandByKeyboardInFindUsagespanel(Keys.ARROW_RIGHT.toString());
    findUsages.sendCommandByKeyboardInFindUsagespanel(Keys.ARROW_DOWN.toString());
    findUsages.sendCommandByKeyboardInFindUsagespanel(Keys.ARROW_RIGHT.toString());
    findUsages.sendCommandByKeyboardInFindUsagespanel(Keys.ARROW_DOWN.toString());
    findUsages.sendCommandByKeyboardInFindUsagespanel(Keys.ARROW_RIGHT.toString());
    findUsages.waitExpectedTextInFindUsagesPanel(EXPECTED_TEXT_2);
    findUsages.waitExpectedTextInFindUsagesPanel(EXPECTED_TEXT_1);

    // Check the found items in the editor
    findUsages.selectHighlightedItemInFindUsagesByDoubleClick(29);
    editor.typeTextIntoEditor(Keys.ARROW_LEFT.toString());
    editor.expectedNumberOfActiveLine(29);
    editor.waitTextElementsActiveLine("numGuessByUser");
    findUsages.selectNodeInFindUsagesPanel("handleRequest(HttpServletRequest, HttpServletResponse)");
    findUsages.sendCommandByKeyboardInFindUsagespanel(Keys.ARROW_DOWN.toString());
    findUsages.sendCommandByKeyboardInFindUsagespanel(Keys.ARROW_DOWN.toString());
    findUsages.sendCommandByKeyboardInFindUsagespanel(Keys.ARROW_DOWN.toString());
    findUsages.sendCommandByKeyboardInFindUsagespanel(Keys.ENTER.toString());
    editor.typeTextIntoEditor(Keys.ARROW_LEFT.toString());
    editor.expectedNumberOfActiveLine(33);
    editor.waitTextElementsActiveLine("numGuessByUser");
}

From source file:org.eclipse.che.selenium.miscellaneous.WorkingWithTerminalTest.java

License:Open Source License

@Test(priority = 13)
public void shouldEditFileIntoMCEdit() {
    openMC("/projects/" + PROJECT_NAME);

    //check End, Home, F4, Delete keys
    terminal.typeIntoTerminal("" + Keys.END + Keys.ENTER + Keys.END + Keys.ARROW_UP + Keys.F4);
    //select editor
    terminal.typeIntoTerminal(valueOf(1) + Keys.ENTER);

    terminal.waitExpectedTextIntoTerminal(
            "README.md          " + "[----]  0 L:[  1+ 0   1/  1] *(0   /  21b) 0035 0x023");
    terminal.typeIntoTerminal("<!-some comment->");
    terminal.typeIntoTerminal(/*from w  w w  . j a  v  a2 s . com*/
            "" + Keys.HOME + Keys.ARROW_RIGHT + Keys.ARROW_RIGHT + Keys.ARROW_RIGHT + Keys.DELETE);
    terminal.waitExpectedTextIntoTerminal("<!-ome comment->");
}

From source file:org.eclipse.che.selenium.pageobject.CheTerminal.java

License:Open Source License

/**
 * scroll terminal by pressing key 'End'
 *
 * @param item is the name of the highlighted item
 *//*from   w  ww.j  a v  a 2  s. c o m*/
public void moveDownListTerminal(String item) {
    loader.waitOnClosed();
    typeIntoActiveTerminal(Keys.END.toString());
    WaitUtils.sleepQuietly(2);

    WebElement element = seleniumWebDriver
            .findElement(By.xpath(format("(//span[contains(text(), '%s')])[position()=1]", item)));

    if (!element.getCssValue("background-color").equals(LINE_HIGHLIGHTED_GREEN)) {
        typeIntoActiveTerminal(Keys.ARROW_UP.toString());
        element = seleniumWebDriver
                .findElement(By.xpath(format("(//span[contains(text(), '%s')])[position()=1]", item)));
        WaitUtils.sleepQuietly(2);
    }
    new WebDriverWait(seleniumWebDriver, REDRAW_UI_ELEMENTS_TIMEOUT_SEC).until(visibilityOf(element));
    WebElement finalElement = element;
    new WebDriverWait(seleniumWebDriver, REDRAW_UI_ELEMENTS_TIMEOUT_SEC).until(
            (WebDriver input) -> finalElement.getCssValue("background-color").equals(LINE_HIGHLIGHTED_GREEN));
}

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

License:Open Source License

/**
 * Search and start command by name/*  w  w  w.  j a  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.eclipse.che.selenium.projectexplorer.PreviewHtmlFileTest.java

License:Open Source License

@Test
public void checkPreviewHtmlFile() {
    projectExplorer.waitProjectExplorer();
    projectExplorer.waitItem(PROJECT_NAME);
    currentWindow = ide.driver().getWindowHandle();
    projectExplorer.quickExpandWithJavaScript();
    projectExplorer.openContextMenuByPathSelectedItem(PROJECT_NAME + "/file.html");
    projectExplorer.clickOnItemInContextMenu(TestProjectExplorerContextMenuConstants.PREVIEW);
    seleniumWebDriver.switchToNoneCurrentWindow(currentWindow);
    checkWebElementsHtmlFile("//h1[text()='Hello, this is check!']");
    ide.driver().close();/*from  w ww. jav a  2s .c  o  m*/
    ide.driver().switchTo().window(currentWindow);

    // type a content into editor and check it by preview feature
    projectExplorer.waitProjectExplorer();
    projectExplorer.waitItem(PROJECT_NAME + "/file.html");
    projectExplorer.openItemByPath(PROJECT_NAME + "/file.html");
    editor.waitActiveEditor();
    editor.setCursorToLine(19);
    editor.typeTextIntoEditor(Keys.ENTER.toString());
    editor.typeTextIntoEditor(Keys.ARROW_UP.toString());
    editor.typeTextIntoEditor(H2_CONTENT);
    editor.waitTextIntoEditor(H2_CONTENT);
    projectExplorer.openContextMenuByPathSelectedItem(PROJECT_NAME + "/file.html");
    projectExplorer.clickOnItemInContextMenu(TestProjectExplorerContextMenuConstants.PREVIEW);
    seleniumWebDriver.switchToNoneCurrentWindow(currentWindow);
    checkWebElementsHtmlFile("//h2[@style='color:red' and text()='Test content']");
    ide.driver().switchTo().window(currentWindow);
    editor.setCursorToLine(19);
    editor.typeTextIntoEditor(Keys.ENTER.toString());
    editor.typeTextIntoEditor(Keys.ARROW_UP.toString());
    editor.typeTextIntoEditor(BODY_CONTENT);
    editor.waitTextIntoEditor(BODY_CONTENT);
    seleniumWebDriver.switchToNoneCurrentWindow(currentWindow);
    loader.waitOnClosed();
    checkWebElementsHtmlFile("//h2[@style='color:red' and text()='Test content']");
    loader.waitOnClosed();
    ide.driver().navigate().refresh();
    checkWebElementsHtmlFile("//b[text()='Content of file']");
}

From source file:org.eclipse.che.selenium.subversion.DiffViewTest.java

License:Open Source License

@Test
public void checkDiffView() throws InterruptedException {
    projectExplorer.waitProjectExplorer();
    menu.runCommand(WORKSPACE, IMPORT_PROJECT);
    subversion.waitAndTypeImporterAsSvnInfo(svnRepo2urlProvider.get(), PROJECT_NAME, svnUsernameProvider.get(),
            svnPasswordProvider.get());/*from  ww  w. j  av a 2s  . c o  m*/
    importProjectFromLocation.waitMainFormIsClosed();

    wizard.waitOpenProjectConfigForm();
    wizard.clickSaveButton();
    wizard.waitCloseProjectConfigForm();

    loader.waitOnClosed();
    projectExplorer.waitItem(PROJECT_NAME);
    projectExplorer.openItemByPath(PROJECT_NAME);

    // Change the file 'readme'
    projectExplorer.waitItem(PROJECT_NAME);
    projectExplorer.openItemByPath(PROJECT_NAME + "/trunk");
    projectExplorer.openItemByPath(PROJECT_NAME + "/trunk/diff-view-test");
    projectExplorer.openItemByPath(PROJECT_NAME + "/trunk/diff-view-test/readme");
    editor.waitActiveEditor();
    editor.typeTextIntoEditor(Keys.ENTER.toString());
    editor.typeTextIntoEditor(Keys.ARROW_UP.toString());
    editor.typeTextIntoEditor("###### qa");
    editor.waitTextIntoEditor("###### qa");

    // Change the file 'document.html'
    projectExplorer.openItemByPath(PROJECT_NAME + "/trunk/diff-view-test/document.html");
    editor.waitActiveEditor();
    editor.typeTextIntoEditor(Keys.ENTER.toString());
    editor.typeTextIntoEditor(Keys.ARROW_UP.toString());
    editor.typeTextIntoEditor("<!*** change content ***>");
    editor.waitTextIntoEditor("<!*** change content ***>");

    projectExplorer.selectItem(PROJECT_NAME);
    menu.runCommand(SUBVERSION, SVN_COMMIT);
    subversion.waitSvnCommitFormOpened();
    subversion.clickSvnCommitDiffButton(FILE_NAME_1, FOLDER_NAME);
    loader.waitOnClosed();
    subversion.waitSvnCommitFormOpened();
    subversion.waitTextDiffView(DIFF_MESS_1);
    subversion.clickSvnCommitClosedButtonDiffView();

    // Check the diff view 'document.html' in the svn commit form
    subversion.clickSvnCommitDiffButton(FILE_NAME_2, FOLDER_NAME);
    loader.waitOnClosed();
    subversion.waitSvnCommitFormOpened();
    subversion.waitTextDiffView(DIFF_MESS_2);
    subversion.clickSvnCommitClosedButtonDiffView();
    subversion.waitSvnCommitFormOpened();
    subversion.clickSvnCommiCancelButtont();

    // Check the 'View Diff' in the svn status bar
    projectExplorer.selectItem(PROJECT_NAME + "/trunk/diff-view-test/readme");
    menu.runCommand(SUBVERSION, SVN_VIEW_DIFF);
    loader.waitOnClosed();

    subversion.waitSvnInfoPanelWithMessage(DIFF_MESS_1);
    projectExplorer.selectItem(PROJECT_NAME + "/trunk/diff-view-test/document.html");
    menu.runCommand(SUBVERSION, SVN_VIEW_DIFF);
    loader.waitOnClosed();

    subversion.waitSvnInfoPanelWithMessage(DIFF_MESS_2);
}

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// ww w .j a  v a  2 s . com
 * @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.xwiki.test.selenium.framework.AbstractXWikiTestCase.java

License:Open Source License

/**
 * Makes sure the specified element is not covered by the floating menu which is displayed at the top of the window.
 * Use this method before clicking on an element that can end up beneath the floating menu.
 * /*ww  w.  ja va  2s .c o  m*/
 * @param locator an element locator
 */
public void ensureElementIsNotCoveredByFloatingMenu(By locator) {
    WebDriver driver = getDriver();
    // First scroll the element into view, if needed, by moving the mouse to the top left corner of the element.
    new Actions(driver).moveToElement(driver.findElement(locator), 0, 0).perform();
    // Then scroll the page up a bit so that the element is not at the top of the window where the floating menu is.
    driver.findElement(By.xpath("//body")).sendKeys(Keys.ARROW_UP);
}