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:be.rubus.web.testing.widget.extension.angularprime.PuiInput.java

License:Apache License

public void sendUpArrowFromKeyboard() {
    root.sendKeys(Keys.ARROW_UP);

}

From source file:browsermator.com.UpArrowKeyAction.java

@Override
public void RunAction(WebDriver driver) {
    try {//from   w  ww. j a v a 2 s  .c  o m

        WebElement element = driver.switchTo().activeElement();
        element.sendKeys(Keys.ARROW_UP);
        this.Pass = true;
    } catch (Exception ex) {
        this.Pass = false;
    }

}

From source file:com.gargoylesoftware.htmlunit.selenium.TypingTest.java

License:Apache License

/**
 * A test.//from  ww w  .  j  a  va 2s. co  m
 */
@Test
public void shouldReportKeyCodeOfArrowKeys() {
    final WebDriver driver = getWebDriver("/javascriptPage.html");

    final WebElement result = driver.findElement(By.id("result"));
    final WebElement element = driver.findElement(By.id("keyReporter"));

    element.sendKeys(Keys.ARROW_DOWN);
    checkRecordedKeySequence(result, 40);

    element.sendKeys(Keys.ARROW_UP);
    checkRecordedKeySequence(result, 38);

    element.sendKeys(Keys.ARROW_LEFT);
    checkRecordedKeySequence(result, 37);

    element.sendKeys(Keys.ARROW_RIGHT);
    checkRecordedKeySequence(result, 39);

    // And leave no rubbish/printable keys in the "keyReporter"
    assertThat(element.getAttribute("value"), is(""));
}

From source file:com.gargoylesoftware.htmlunit.selenium.TypingTest.java

License:Apache License

/**
 * A test.//from  ww w  . j  av  a  2  s . co  m
 */
@Test
public void shouldReportKeyCodeOfArrowKeysUpDownEvents() {
    final WebDriver driver = getWebDriver("/javascriptPage.html");

    final WebElement result = driver.findElement(By.id("result"));
    final WebElement element = driver.findElement(By.id("keyReporter"));

    element.sendKeys(Keys.ARROW_DOWN);
    assertThat(result.getText().trim(), containsString("down: 40"));
    assertThat(result.getText().trim(), containsString("up: 40"));

    element.sendKeys(Keys.ARROW_UP);
    assertThat(result.getText().trim(), containsString("down: 38"));
    assertThat(result.getText().trim(), containsString("up: 38"));

    element.sendKeys(Keys.ARROW_LEFT);
    assertThat(result.getText().trim(), containsString("down: 37"));
    assertThat(result.getText().trim(), containsString("up: 37"));

    element.sendKeys(Keys.ARROW_RIGHT);
    assertThat(result.getText().trim(), containsString("down: 39"));
    assertThat(result.getText().trim(), containsString("up: 39"));

    // And leave no rubbish/printable keys in the "keyReporter"
    assertThat(element.getAttribute("value"), is(""));
}

From source file:com.github.fscheffer.arras.demo.DropdownIT.java

License:Apache License

@Test
public void testKeyInteraction() {

    // check keys
    click("#drop_1");
    sendKeys(Keys.ARROW_DOWN);//from   w w  w  .java  2s .  co m
    waitUntil(focused(dropdownItem(1)));

    // cant move up. it's the first element. focus should stay on the first element
    sendKeys(Keys.ARROW_UP);
    waitUntil(focused(dropdownItem(1)));

    sendKeys(Keys.ARROW_DOWN);
    waitUntil(focused(dropdownItem(2)));

    // skip divider
    sendKeys(Keys.ARROW_DOWN);
    waitUntil(focused(dropdownItem(4)));

    // cant move down. we are at the last element. focus should stay on the last element
    sendKeys(Keys.ARROW_DOWN);
    waitUntil(focused(dropdownItem(4)));

    // skip divider
    sendKeys(Keys.ARROW_UP);
    waitUntil(focused(dropdownItem(2)));

    sendKeys(Keys.ESCAPE);
    waitUntil(notContainsText("BODY", "Item 1"));
    waitUntil(focused("ul.nav.nav-pills > li:nth-child(2) > a"));
}

From source file:com.thoughtworks.selenium.webdriven.commands.TypeKeys.java

License:Apache License

@Override
protected Void handleSeleneseCommand(WebDriver driver, String locator, String value) {
    alertOverride.replaceAlertMethod(driver);

    value = value.replace("\\10", Keys.ENTER);
    value = value.replace("\\13", Keys.RETURN);
    value = value.replace("\\27", Keys.ESCAPE);
    value = value.replace("\\38", Keys.ARROW_UP);
    value = value.replace("\\40", Keys.ARROW_DOWN);
    value = value.replace("\\37", Keys.ARROW_LEFT);
    value = value.replace("\\39", Keys.ARROW_RIGHT);

    finder.findElement(driver, locator).sendKeys(value);

    return null;/*from  ww w. jav a  2s  .c om*/
}

From source file:com.thoughtworks.selenium.webdriven.commands.TypeKeysTest.java

License:Apache License

@Test
public void substitutesArrowKeys() {
    String expected = newString(Keys.ARROW_DOWN, Keys.ARROW_LEFT, Keys.ARROW_RIGHT, Keys.ARROW_UP);
    String input = "\\40\\37\\39\\38";

    new TypeKeys(new AlertOverrideStub(), elementFinder).apply(null, new String[] { "foo", input });

    verify(element).sendKeys(expected);//from   ww  w  . ja  va  2  s.c o m
}

From source file:com.vaadin.tests.components.grid.basicfeatures.server.GridKeyboardNavigationTest.java

License:Apache License

@Test
public void testNavigationFromFooterToBody() {
    openTestURL();/*w  w  w. j  av  a 2 s  . c  o m*/

    selectMenuPath("Component", "Footer", "Visible");

    GridElement grid = getGridElement();
    grid.scrollToRow(300);
    grid.getFooterCell(0, 2).click();

    assertTrue("Footer cell does not have focus.", grid.getFooterCell(0, 2).isFocused());
    new Actions(getDriver()).sendKeys(Keys.ARROW_UP).perform();
    assertTrue("Body cell 300, 2 does not have focus.", grid.getCell(300, 2).isFocused());
}

From source file:com.vaadin.tests.components.grid.basicfeatures.server.GridKeyboardNavigationTest.java

License:Apache License

@Test
public void testNavigateBetweenFooterAndBodyWithTab() {
    openTestURL();/*from w w  w  .ja  va 2s . c  o m*/

    selectMenuPath("Component", "Footer", "Visible");

    GridElement grid = getGridElement();
    grid.getCell(10, 2).click();

    assertTrue("Body cell 10, 2 does not have focus", grid.getCell(10, 2).isFocused());
    new Actions(getDriver()).sendKeys(Keys.TAB).perform();
    assertTrue("Footer cell 0, 2 does not have focus", grid.getFooterCell(0, 2).isFocused());
    new Actions(getDriver()).keyDown(Keys.SHIFT).sendKeys(Keys.TAB).keyUp(Keys.SHIFT).perform();
    assertTrue("Body cell 10, 2 does not have focus", grid.getCell(10, 2).isFocused());

    // Navigate out of the Grid and try to navigate with arrow keys.
    new Actions(getDriver()).sendKeys(Keys.TAB).sendKeys(Keys.TAB).sendKeys(Keys.ARROW_UP).perform();
    assertTrue("Footer cell 0, 2 does not have focus", grid.getFooterCell(0, 2).isFocused());
}

From source file:com.vaadin.tests.components.grid.basicfeatures.server.GridSortingTest.java

License:Apache License

@Test
public void testKeyboardSortingMultipleHeaders() {
    openTestURL();//from w w  w  .j a  v a  2s . com
    selectMenuPath("Component", "Header", "Append row");

    // Sort according to first column by clicking
    getGridElement().getHeaderCell(0, 0).click();
    assertColumnIsSorted(0);

    // Try to sort according to second column by pressing enter on the new
    // header
    sendKey(Keys.ARROW_RIGHT);
    sendKey(Keys.ARROW_DOWN);
    sendKey(Keys.ENTER);

    // Should not have sorted
    assertColumnIsSorted(0);

    // Sort using default header
    sendKey(Keys.ARROW_UP);
    sendKey(Keys.ENTER);

    // Should have sorted
    assertColumnIsSorted(1);

}