Example usage for org.openqa.selenium Keys PAGE_UP

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

Introduction

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

Prototype

Keys PAGE_UP

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

Click Source Link

Usage

From source file:org.eclipse.che.selenium.core.action.GenericActionsTest.java

License:Open Source License

@Test
public void testShouldReturnSameCharSequence() throws Exception {
    GenericActions actions = new GenericActions(webDriver);

    final CharSequence[] charSequences = actions.modifyCharSequence(Keys.END, Keys.HOME, Keys.PAGE_DOWN,
            Keys.PAGE_UP);

    assertNotNull(charSequences);//from   w w w . j a  va  2  s. co  m
    assertEquals(charSequences.length, 4);

    assertEquals(charSequences[0], Keys.END);
    assertEquals(charSequences[1], Keys.HOME);
    assertEquals(charSequences[2], Keys.PAGE_DOWN);
    assertEquals(charSequences[3], Keys.PAGE_UP);
}

From source file:org.eclipse.che.selenium.core.action.MacOSActions.java

License:Open Source License

@Override
protected CharSequence[] modifyCharSequence(CharSequence... keysToSend) {
    final List<CharSequence> modKeysToSend = newArrayList();

    for (CharSequence charSequence : keysToSend) {
        final String key = charSequence.toString();

        if (Keys.END.toString().equals(key)) {
            modKeysToSend.add(Keys.chord(Keys.COMMAND, Keys.RIGHT));
        } else if (Keys.HOME.toString().equals(key)) {
            modKeysToSend.add(Keys.chord(Keys.COMMAND, Keys.LEFT));
        } else if (Keys.PAGE_UP.toString().equals(key)) {
            modKeysToSend.add(Keys.chord(Keys.COMMAND, Keys.UP));
        } else if (Keys.PAGE_DOWN.toString().equals(key)) {
            modKeysToSend.add(Keys.chord(Keys.COMMAND, Keys.DOWN));
        } else {/*from  w w  w  .j  a va2 s.c o  m*/
            modKeysToSend.add(charSequence);
        }
    }

    return modKeysToSend.toArray(new CharSequence[modKeysToSend.size()]);
}

From source file:org.eclipse.che.selenium.core.action.MacOSActionsTest.java

License:Open Source License

@Test
public void testShouldReplacePageUpCharSequence() throws Exception {
    MacOSActions actions = new MacOSActions(webDriver);

    final CharSequence[] charSequences = actions.modifyCharSequence(Keys.ESCAPE, Keys.PAGE_UP);

    assertNotNull(charSequences);//from  ww w  .j a  v  a  2 s  . c  om
    assertEquals(charSequences.length, 2);

    assertEquals(charSequences[0], Keys.ESCAPE);
    assertEquals(charSequences[1], Keys.chord(Keys.COMMAND, Keys.UP));
}

From source file:org.eclipse.che.selenium.git.BranchTest.java

License:Open Source License

@Test
public void checkoutBranchTest() throws Exception {
    // perform init commit
    projectExplorer.waitProjectExplorer();
    projectExplorer.waitItem(PROJECT_NAME);
    projectExplorer.waitAndSelectItem(PROJECT_NAME);
    menu.runCommand(TestMenuCommandsConstants.Git.GIT, TestMenuCommandsConstants.Git.INITIALIZE_REPOSITORY);
    loader.waitOnClosed();/*w w  w .j a va  2s  .co m*/
    askDialog.confirmAndWaitClosed();
    git.waitGitStatusBarWithMess(TestGitConstants.GIT_INITIALIZED_SUCCESS);
    events.clickEventLogBtn();
    events.waitExpectedMessage(TestGitConstants.GIT_INITIALIZED_SUCCESS);
    projectExplorer.waitAndSelectItem(PROJECT_NAME);
    menu.runCommand(TestMenuCommandsConstants.Git.GIT, TestMenuCommandsConstants.Git.COMMIT);
    git.waitAndRunCommit("init");
    loader.waitOnClosed();
    createBranch();
    switchOnTestBranch();

    // create change in AppController.java
    projectExplorer.quickExpandWithJavaScript();
    projectExplorer.openItemByPath(PROJECT_NAME + APP_JAVA_PATH);
    editor.setCursorToLine(16);
    editor.typeTextIntoEditor("\n" + "//some change");
    editor.waitTextIntoEditor("\n" + "//some change");
    loader.waitOnClosed();

    // Create change in index.jsp
    projectExplorer.openItemByPath(PROJECT_NAME + "/src/main/webapp/index.jsp");
    editor.waitActive();
    editor.typeTextIntoEditor(Keys.PAGE_DOWN.toString());
    editor.typeTextIntoEditor(Keys.ENTER.toString());
    editor.typeTextIntoEditor(CHANGE_CONTENT_1);
    editor.waitTextIntoEditor(CHANGE_CONTENT_1);
    loader.waitOnClosed();

    // Create Hello.java class
    projectExplorer.waitAndSelectItem(PROJECT_NAME + "/src/main/java/org/eclipse/qa/examples");
    menu.runCommand(TestMenuCommandsConstants.Project.PROJECT, TestMenuCommandsConstants.Project.New.NEW,
            TestMenuCommandsConstants.Project.New.JAVA_CLASS);
    askForValueDialog.waitNewJavaClassOpen();
    askForValueDialog.typeTextInFieldName("Hello");
    askForValueDialog.clickOkBtnNewJavaClass();
    askForValueDialog.waitNewJavaClassClose();
    projectExplorer.waitVisibilityByName("Hello.java");
    projectExplorer.openItemByVisibleNameInExplorer("Hello.java");
    loader.waitOnClosed();
    editor.closeFileByNameWithSaving("Hello");
    editor.waitWhileFileIsClosed("Hello");

    // Create script.js file
    projectExplorer.waitAndSelectItem(PROJECT_NAME + "/src/main/webapp");
    menu.runCommand(TestMenuCommandsConstants.Project.PROJECT, TestMenuCommandsConstants.Project.New.NEW,
            TestMenuCommandsConstants.Project.New.JAVASCRIPT_FILE);
    askForValueDialog.waitFormToOpen();
    askForValueDialog.typeAndWaitText("script");
    askForValueDialog.clickOkBtn();
    askForValueDialog.waitFormToClose();

    // Check status
    projectExplorer.waitAndSelectItem(PROJECT_NAME + "/src/main");
    menu.runCommand(TestMenuCommandsConstants.Git.GIT, TestMenuCommandsConstants.Git.STATUS);
    loader.waitOnClosed();
    git.waitGitStatusBarWithMess(STATUS_MESSAGE_BEFORE_ADD);

    // add all files to index and check status
    projectExplorer.waitAndSelectItem(PROJECT_NAME + "/src/main");
    menu.runCommand(TestMenuCommandsConstants.Git.GIT, TestMenuCommandsConstants.Git.ADD_TO_INDEX);
    git.waitAddToIndexFormToOpen();
    git.confirmAddToIndexForm();
    git.waitGitStatusBarWithMess(TestGitConstants.GIT_ADD_TO_INDEX_SUCCESS);
    events.clickEventLogBtn();
    events.waitExpectedMessage(TestGitConstants.GIT_ADD_TO_INDEX_SUCCESS);
    menu.runCommand(TestMenuCommandsConstants.Git.GIT, TestMenuCommandsConstants.Git.STATUS);
    git.waitGitStatusBarWithMess(STATUS_MESSAGE_AFTER_ADD);

    // commit to repository and check status
    menu.runCommand(TestMenuCommandsConstants.Git.GIT, TestMenuCommandsConstants.Git.COMMIT);
    git.waitAndRunCommit("first commit");
    git.waitGitStatusBarWithMess(TestGitConstants.COMMIT_MESSAGE_SUCCESS);
    events.clickEventLogBtn();
    events.waitExpectedMessage(TestGitConstants.COMMIT_MESSAGE_SUCCESS);
    loader.waitOnClosed();
    menu.runCommand(TestMenuCommandsConstants.Git.GIT, TestMenuCommandsConstants.Git.STATUS);
    git.waitGitStatusBarWithMess(STATUS_MESSAGE_AFTER_COMMIT);

    // checkout in main branch and check changed files
    switchOnMasterBranch();
    loader.waitOnClosed();
    projectExplorer.openItemByVisibleNameInExplorer("AppController.java");
    editor.waitTextNotPresentIntoEditor("\n" + "//some change");
    projectExplorer.openItemByVisibleNameInExplorer("index.jsp");
    editor.waitTextNotPresentIntoEditor(CHANGE_CONTENT_1);
    projectExplorer.waitDisappearItemByPath(PROJECT_NAME + HELLO_JAVA_PATH);
    projectExplorer.waitDisappearItemByPath(PROJECT_NAME + SCRIPT_FILE_PATH);
    projectExplorer.waitAndSelectItem(PROJECT_NAME + "/src/main");
    menu.runCommand(TestMenuCommandsConstants.Git.GIT, TestMenuCommandsConstants.Git.STATUS);
    git.waitGitStatusBarWithMess(STATUS_MASTER_BRANCH);
    loader.waitOnClosed();

    // switch to test branch again and check earlier changes
    switchOnTestBranch();
    projectExplorer.openItemByVisibleNameInExplorer("AppController.java");
    loader.waitOnClosed();
    editor.waitTextIntoEditor("\n" + "//some change");
    projectExplorer.openItemByVisibleNameInExplorer("index.jsp");
    editor.waitTextIntoEditor(CHANGE_CONTENT_1);
    projectExplorer.openItemByVisibleNameInExplorer("Hello.java");
    loader.waitOnClosed();
    editor.closeFileByNameWithSaving("Hello");
    editor.waitWhileFileIsClosed("Hello");
    projectExplorer.openItemByVisibleNameInExplorer("script.js");
    loader.waitOnClosed();
    editor.closeFileByNameWithSaving("script.js");
    editor.waitWhileFileIsClosed("script.js");

    // Checkout in main branch, change files in master branch (this creates conflict) and check
    // message with conflict
    switchOnMasterBranch();
    projectExplorer.waitProjectExplorer();
    loader.waitOnClosed();
    // create change in GreetingController.java
    projectExplorer.openItemByPath(PROJECT_NAME + APP_JAVA_PATH);
    editor.setCursorToLine(2);
    editor.typeTextIntoEditor("\n" + "//change in master branch");
    editor.waitTextIntoEditor("\n" + "//change in master branch");
    editor.waitTabFileWithSavedStatus("AppController");
    loader.waitOnClosed();
    // create change in index.jsp
    projectExplorer.openItemByPath(PROJECT_NAME + "/src/main/webapp/index.jsp");
    editor.waitTextNotPresentIntoEditor(CHANGE_CONTENT_2);
    editor.typeTextIntoEditor(Keys.ENTER.toString());
    editor.typeTextIntoEditor(Keys.PAGE_UP.toString());
    editor.typeTextIntoEditor(CHANGE_CONTENT_2);
    editor.waitTextIntoEditor(CHANGE_CONTENT_2);
    editor.waitTabFileWithSavedStatus("index.jsp");
    loader.waitOnClosed();

    // Add all files to index and check status
    projectExplorer.waitAndSelectItem(PROJECT_NAME + "/src/main");
    menu.runCommand(TestMenuCommandsConstants.Git.GIT, TestMenuCommandsConstants.Git.ADD_TO_INDEX);
    git.waitGitStatusBarWithMess(TestGitConstants.GIT_ADD_TO_INDEX_SUCCESS);
    events.clickEventLogBtn();
    events.waitExpectedMessage(TestGitConstants.GIT_ADD_TO_INDEX_SUCCESS);
    checkShwithConflict();
}

From source file:org.eclipse.che.selenium.git.CheckoutBranchTest.java

License:Open Source License

@Test
public void checkoutBranchTest() throws Exception {
    // perform init commit
    projectExplorer.waitProjectExplorer();
    projectExplorer.waitItem(PROJECT_NAME);
    projectExplorer.selectItem(PROJECT_NAME);
    menu.runCommand(TestMenuCommandsConstants.Git.GIT, TestMenuCommandsConstants.Git.INITIALIZE_REPOSITORY);
    loader.waitOnClosed();/*from   ww w .  java  2s.  c o m*/
    askDialog.confirmAndWaitClosed();
    git.waitGitStatusBarWithMess(TestGitConstants.GIT_INITIALIZED_SUCCESS);
    events.clickProjectEventsTab();
    events.waitExpectedMessage(TestGitConstants.GIT_INITIALIZED_SUCCESS);
    projectExplorer.selectItem(PROJECT_NAME);
    menu.runCommand(TestMenuCommandsConstants.Git.GIT, TestMenuCommandsConstants.Git.COMMIT);
    git.waitAndRunCommit("init");
    loader.waitOnClosed();
    createBranch();
    switchOnTestBranch();

    // create change in AppController.java
    projectExplorer.quickExpandWithJavaScript();
    projectExplorer.openItemByPath(PROJECT_NAME + APP_JAVA_PATH);
    editor.setCursorToLine(16);
    editor.typeTextIntoEditor("\n" + "//some change");
    editor.waitTextIntoEditor("\n" + "//some change");
    loader.waitOnClosed();

    // Create change in index.jsp
    projectExplorer.openItemByPath(PROJECT_NAME + "/src/main/webapp/index.jsp");
    editor.waitActiveEditor();
    editor.typeTextIntoEditor(Keys.PAGE_DOWN.toString());
    editor.typeTextIntoEditor(Keys.ENTER.toString());
    editor.typeTextIntoEditor(CHANGE_CONTENT_1);
    editor.waitTextIntoEditor(CHANGE_CONTENT_1);
    loader.waitOnClosed();

    // Create Hello.java class
    projectExplorer.selectItem(PROJECT_NAME + "/src/main/java/org/eclipse/qa/examples");
    menu.runCommand(TestMenuCommandsConstants.Project.PROJECT, TestMenuCommandsConstants.Project.New.NEW,
            TestMenuCommandsConstants.Project.New.JAVA_CLASS);
    askForValueDialog.waitNewJavaClassOpen();
    askForValueDialog.typeTextInFieldName("Hello");
    askForValueDialog.clickOkBtnNewJavaClass();
    askForValueDialog.waitNewJavaClassClose();
    projectExplorer.waitItemInVisibleArea("Hello.java");
    projectExplorer.openItemByVisibleNameInExplorer("Hello.java");
    loader.waitOnClosed();
    editor.closeFileByNameWithSaving("Hello");
    editor.waitWhileFileIsClosed("Hello");

    // Create script.js file
    projectExplorer.selectItem(PROJECT_NAME + "/src/main/webapp");
    menu.runCommand(TestMenuCommandsConstants.Project.PROJECT, TestMenuCommandsConstants.Project.New.NEW,
            TestMenuCommandsConstants.Project.New.JAVASCRIPT_FILE);
    askForValueDialog.waitFormToOpen();
    askForValueDialog.typeAndWaitText("script");
    askForValueDialog.clickOkBtn();
    askForValueDialog.waitFormToClose();

    // Check status
    projectExplorer.selectItem(PROJECT_NAME + "/src/main");
    menu.runCommand(TestMenuCommandsConstants.Git.GIT, TestMenuCommandsConstants.Git.STATUS);
    loader.waitOnClosed();
    git.waitGitStatusBarWithMess(STATUS_MESSAGE_BEFORE_ADD);

    // add all files to index and check status
    projectExplorer.selectItem(PROJECT_NAME + "/src/main");
    menu.runCommand(TestMenuCommandsConstants.Git.GIT, TestMenuCommandsConstants.Git.ADD_TO_INDEX);
    git.waitAddToIndexFormToOpen();
    git.confirmAddToIndexForm();
    git.waitGitStatusBarWithMess(TestGitConstants.GIT_ADD_TO_INDEX_SUCCESS);
    events.clickProjectEventsTab();
    events.waitExpectedMessage(TestGitConstants.GIT_ADD_TO_INDEX_SUCCESS);
    menu.runCommand(TestMenuCommandsConstants.Git.GIT, TestMenuCommandsConstants.Git.STATUS);
    git.waitGitStatusBarWithMess(STATUS_MESSAGE_AFTER_ADD);

    // commit to repository and check status
    menu.runCommand(TestMenuCommandsConstants.Git.GIT, TestMenuCommandsConstants.Git.COMMIT);
    git.waitAndRunCommit("first commit");
    git.waitGitStatusBarWithMess(TestGitConstants.COMMIT_MESSAGE_SUCCESS);
    events.clickProjectEventsTab();
    events.waitExpectedMessage(TestGitConstants.COMMIT_MESSAGE_SUCCESS);
    loader.waitOnClosed();
    menu.runCommand(TestMenuCommandsConstants.Git.GIT, TestMenuCommandsConstants.Git.STATUS);
    git.waitGitStatusBarWithMess(STATUS_MESSAGE_AFTER_COMMIT);

    // checkout in main branch and check changed files
    switchOnMasterBranch();
    loader.waitOnClosed();
    projectExplorer.openItemByVisibleNameInExplorer("AppController.java");
    editor.waitTextNotPresentIntoEditor("\n" + "//some change");
    projectExplorer.openItemByVisibleNameInExplorer("index.jsp");
    editor.waitTextNotPresentIntoEditor(CHANGE_CONTENT_1);
    projectExplorer.waitDisappearItemByPath(PROJECT_NAME + HELLO_JAVA_PATH);
    projectExplorer.waitDisappearItemByPath(PROJECT_NAME + SCRIPT_FILE_PATH);
    projectExplorer.selectItem(PROJECT_NAME + "/src/main");
    menu.runCommand(TestMenuCommandsConstants.Git.GIT, TestMenuCommandsConstants.Git.STATUS);
    git.waitGitStatusBarWithMess(STATUS_MASTER_BRANCH);
    loader.waitOnClosed();

    // switch to test branch again and check earlier changes
    switchOnTestBranch();
    projectExplorer.openItemByVisibleNameInExplorer("AppController.java");
    loader.waitOnClosed();
    editor.waitTextIntoEditor("\n" + "//some change");
    projectExplorer.openItemByVisibleNameInExplorer("index.jsp");
    editor.waitTextIntoEditor(CHANGE_CONTENT_1);
    projectExplorer.openItemByVisibleNameInExplorer("Hello.java");
    loader.waitOnClosed();
    editor.closeFileByNameWithSaving("Hello");
    editor.waitWhileFileIsClosed("Hello");
    projectExplorer.openItemByVisibleNameInExplorer("script.js");
    loader.waitOnClosed();
    editor.closeFileByNameWithSaving("script.js");
    editor.waitWhileFileIsClosed("script.js");

    // Checkout in main branch, change files in master branch (this creates conflict) and check message with conflict
    switchOnMasterBranch();
    projectExplorer.waitProjectExplorer();
    loader.waitOnClosed();
    // create change in GreetingController.java
    projectExplorer.openItemByPath(PROJECT_NAME + APP_JAVA_PATH);
    editor.setCursorToLine(2);
    editor.typeTextIntoEditor("\n" + "//change in master branch");
    editor.waitTextIntoEditor("\n" + "//change in master branch");
    editor.waitTabFileWithSavedStatus("AppController");
    loader.waitOnClosed();
    // create change in index.jsp
    projectExplorer.openItemByPath(PROJECT_NAME + "/src/main/webapp/index.jsp");
    editor.waitTextNotPresentIntoEditor(CHANGE_CONTENT_2);
    editor.typeTextIntoEditor(Keys.ENTER.toString());
    editor.typeTextIntoEditor(Keys.PAGE_UP.toString());
    editor.typeTextIntoEditor(CHANGE_CONTENT_2);
    editor.waitTextIntoEditor(CHANGE_CONTENT_2);
    editor.waitTabFileWithSavedStatus("index.jsp");
    loader.waitOnClosed();

    // Add all files to index and check status
    projectExplorer.selectItem(PROJECT_NAME + "/src/main");
    menu.runCommand(TestMenuCommandsConstants.Git.GIT, TestMenuCommandsConstants.Git.ADD_TO_INDEX);
    git.waitGitStatusBarWithMess(TestGitConstants.GIT_ADD_TO_INDEX_SUCCESS);
    events.clickProjectEventsTab();
    events.waitExpectedMessage(TestGitConstants.GIT_ADD_TO_INDEX_SUCCESS);
    checkShwithConflict();
}

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

License:Open Source License

/**
 * scroll terminal by pressing key 'PageUp'
 *
 * @param item is the name of the highlighted item
 *//*from  www  .  ja va  2  s .co  m*/
public void movePageUpListTerminal(String item) {
    loader.waitOnClosed();
    typeIntoActiveTerminal(Keys.PAGE_UP.toString());
    WaitUtils.sleepQuietly(2);
    WebElement element = seleniumWebDriver
            .findElement(By.xpath(format("(//span[contains(text(), '%s')])[position()=1]", item)));
    new WebDriverWait(seleniumWebDriver, REDRAW_UI_ELEMENTS_TIMEOUT_SEC).until(visibilityOf(element));
    new WebDriverWait(seleniumWebDriver, REDRAW_UI_ELEMENTS_TIMEOUT_SEC)
            .until((WebDriver input) -> element.getCssValue("background-color").equals(LINE_HIGHLIGHTED_GREEN));
}

From source file:org.eclipse.scout.rt.testing.ui.rap.RapMock.java

License:Open Source License

protected Keys toSeleniumKey(Key key) {
    switch (key) {
    case Shift://from  w  w  w .  j a v  a2 s . c o  m
        return Keys.SHIFT;
    case Control:
        return Keys.CONTROL;
    case Alt:
        return Keys.ALT;
    case Delete:
        return Keys.DELETE;
    case Backspace:
        return Keys.BACK_SPACE;
    case Enter:
        return Keys.ENTER;
    case Esc:
        return Keys.ESCAPE;
    case Tab:
        return Keys.TAB;
    case ContextMenu:
        throw new IllegalArgumentException("Unknown keyboard key: " + key);
    case Up:
        return Keys.UP;
    case Down:
        return Keys.DOWN;
    case Left:
        return Keys.LEFT;
    case Right:
        return Keys.RIGHT;
    case Windows:
        return Keys.META;
    case F1:
        return Keys.F1;
    case F2:
        return Keys.F2;
    case F3:
        return Keys.F3;
    case F4:
        return Keys.F4;
    case F5:
        return Keys.F5;
    case F6:
        return Keys.F6;
    case F7:
        return Keys.F7;
    case F8:
        return Keys.F8;
    case F9:
        return Keys.F9;
    case F10:
        return Keys.F10;
    case F11:
        return Keys.F11;
    case F12:
        return Keys.F12;
    case Home:
        return Keys.HOME;
    case End:
        return Keys.END;
    case PageUp:
        return Keys.PAGE_UP;
    case PageDown:
        return Keys.PAGE_DOWN;
    case NumPad0:
        return Keys.NUMPAD0;
    case NumPad1:
        return Keys.NUMPAD1;
    case NumPad2:
        return Keys.NUMPAD2;
    case NumPad3:
        return Keys.NUMPAD3;
    case NumPad4:
        return Keys.NUMPAD4;
    case NumPad5:
        return Keys.NUMPAD5;
    case NumPad6:
        return Keys.NUMPAD6;
    case NumPad7:
        return Keys.NUMPAD7;
    case NumPad8:
        return Keys.NUMPAD8;
    case NumPadMultiply:
        return Keys.MULTIPLY;
    case NumPadDivide:
        return Keys.DIVIDE;
    case NumPadAdd:
        return Keys.ADD;
    case NumPadSubtract:
        return Keys.SUBTRACT;
    case NumPadDecimal:
        return Keys.DECIMAL;
    case NumPadSeparator:
        return Keys.SEPARATOR;
    default:
        throw new IllegalArgumentException("Unknown keyboard key: " + key);
    }
}

From source file:org.richfaces.tests.metamer.ftest.richCalendar.TestCalendarModel.java

License:Open Source License

@Test
@IssueTracking("https://issues.jboss.org/browse/RF-14199")
public void testDisabledDayCannotBePickedByKeyboard() {
    DateTime referenceDate = new DateTime().withYear(2015).withMonthOfYear(11).withDayOfMonth(2)
            .withHourOfDay(12).withMinuteOfHour(0);
    // set reference date
    Graphene.guardAjax(popupCalendar).setDateTime(referenceDate);
    performStabilizationWorkaround();//w  ww . java 2 s .co  m

    popupCalendar.openPopup();
    checkSelectedDate(referenceDate);

    // try to select tuesday (disabled)
    keyboard.sendKeys(Keys.ARROW_RIGHT);
    keyboard.sendKeys(Keys.ENTER);
    assertTrue(popupCalendar.getPopup().isVisible());
    // check date is still the same (no move through enabled and already not selected days)
    checkSelectedDate(referenceDate);

    // try to select sunday (disabled)
    keyboard.sendKeys(Keys.ARROW_LEFT);
    keyboard.sendKeys(Keys.ARROW_LEFT);
    keyboard.sendKeys(Keys.ENTER);
    assertTrue(popupCalendar.getPopup().isVisible());
    // check date is still the same (no move through enabled and already not selected days)
    checkSelectedDate(referenceDate);

    // try to select saturday from previous month (disabled)
    Graphene.guardAjax(keyboard).sendKeys(Keys.ARROW_LEFT);// move to previous month will trigger an ajax request
    keyboard.sendKeys(Keys.ENTER);
    assertTrue(popupCalendar.getPopup().isVisible());
    // check date is still the same (no move through enabled and already not selected days)
    checkSelectedDate(referenceDate);

    // try to select thursday from previous year (disabled)
    Graphene.guardAjax(keyboard).sendKeys(Keys.chord(Keys.SHIFT, Keys.PAGE_UP));// move to previous year will trigger an ajax request
    keyboard.sendKeys(Keys.ARROW_LEFT);
    keyboard.sendKeys(Keys.ENTER);
    assertTrue(popupCalendar.getPopup().isVisible());
    // check selected date has changed (day moved to friday when the year was switched)
    // 2x to the left and 1x to previous year
    referenceDate = referenceDate.minusDays(2).minusYears(1);
    checkSelectedDate(referenceDate);

    // finally, select wednesday (enabled)
    Graphene.guardAjax(keyboard).sendKeys(Keys.ARROW_LEFT);
    keyboard.sendKeys(Keys.ENTER);
    popupCalendar.getPopup().waitUntilIsNotVisible().perform();

    referenceDate = referenceDate.withYear(2014).withMonthOfYear(10).withDayOfMonth(29);
    checkSelectedDate(referenceDate);
}

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 w  w  w.j a va2s  . co  m*/
 * @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.testeditor.fixture.web.EclipseRapFixture.java

License:Open Source License

/**
 * Selects the given value from drop down.
 * /*w  ww  .  j  a v a2 s.c  o m*/
 * @param value
 *            the value to select
 * @param elementListKey
 *            the input field of the combo box
 * @param replaceArgs
 *            values to replace the place holders in the element list entry
 * @return true if value was selectable
 */
public boolean selectInDropDown(String value, String elementListKey, String... replaceArgs) {
    boolean result = false;

    /*
     * Because RAP doesn't render drop downs as select-tags with options, we
     * can't use the standard web driver Select-class. RAP creates combo
     * boxes as input field with attached divs. Input field and divs don't
     * share a common XPATH.
     */

    WebElement element = findWebelement(elementListKey, replaceArgs);

    element.click();
    element.sendKeys(Keys.PAGE_UP);

    String currentValue = element.getAttribute("value");
    String before = null;

    do {
        if (value.equals(currentValue)) {
            element.click();
            result = true;
        } else {
            before = currentValue;
            element.sendKeys(Keys.DOWN);
            currentValue = element.getAttribute("value");
        }
    } while (!currentValue.equals(before) && !result);

    return result;
}