Example usage for org.openqa.selenium Keys ARROW_DOWN

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

Introduction

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

Prototype

Keys ARROW_DOWN

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

Click Source Link

Usage

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

License:Apache License

@Test
public void testSimpleKeyboardNavigation() {
    openTestURL();//from w  w w . j a  v  a2 s .c  o m

    GridElement grid = getGridElement();
    grid.getCell(0, 0).click();

    new Actions(getDriver()).sendKeys(Keys.ARROW_DOWN).perform();
    assertTrue("Body cell 1, 0 is not focused after keyboard navigation.", grid.getCell(1, 0).isFocused());

    new Actions(getDriver()).sendKeys(Keys.ARROW_RIGHT).perform();
    assertTrue("Body cell 1, 1 is not focused after keyboard navigation.", grid.getCell(1, 1).isFocused());

    int i;
    for (i = 1; i < 40; ++i) {
        new Actions(getDriver()).sendKeys(Keys.ARROW_DOWN).perform();
    }

    assertFalse("Grid has not scrolled with cell focus", isElementPresent(By.xpath("//td[text() = '(0, 0)']")));
    assertTrue("Cell focus is not visible", isElementPresent(By.xpath("//td[text() = '(" + i + ", 0)']")));
    assertTrue("Body cell " + i + ", 1 is not focused", grid.getCell(i, 1).isFocused());
}

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

License:Apache License

@Test
public void testNavigateFromHeaderToBody() {
    openTestURL();/*from   ww w.  ja  va2s .co  m*/

    GridElement grid = getGridElement();
    grid.scrollToRow(300);
    new Actions(driver).moveToElement(grid.getHeaderCell(0, 7)).click().perform();
    grid.scrollToRow(280);

    assertTrue("Header cell is not focused.", grid.getHeaderCell(0, 7).isFocused());
    new Actions(getDriver()).sendKeys(Keys.ARROW_DOWN).perform();
    assertTrue("Body cell 280, 7 is not focused", grid.getCell(280, 7).isFocused());
}

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

License:Apache License

@Test
public void testNavigateBetweenHeaderAndBodyWithTab() {
    openTestURL();/*  w w w . j  ava2 s .c  o m*/

    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()).keyDown(Keys.SHIFT).sendKeys(Keys.TAB).keyUp(Keys.SHIFT).perform();
    assertTrue("Header cell 0, 2 does not have focus", grid.getHeaderCell(0, 2).isFocused());
    new Actions(getDriver()).sendKeys(Keys.TAB).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()).keyDown(Keys.SHIFT).sendKeys(Keys.TAB).sendKeys(Keys.TAB).keyUp(Keys.SHIFT)
            .sendKeys(Keys.ARROW_DOWN).perform();
    assertTrue("Header cell 0, 2 does not have focus", grid.getHeaderCell(0, 2).isFocused());
}

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

License:Apache License

@Test
public void testKeyboardSortingMultipleHeaders() {
    openTestURL();//  ww w . j  a  va  2 s. 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);

}

From source file:com.vaadin.tests.components.nativeselect.NativeSelectsAndChromeKeyboardNavigationTest.java

License:Apache License

@Test
public void testValueChangeListenerWithKeyboardNavigation() throws InterruptedException {
    setDebug(true);//  w  w  w  .j a  va2  s .  c  om
    openTestURL();
    Thread.sleep(1000);
    menu("Component");
    menuSub("Listeners");
    menuSub("Value change listener");

    getDriver().findElement(By.tagName("body")).click();

    WebElement select = getDriver().findElement(By.tagName("select"));
    select.sendKeys(Keys.ARROW_DOWN);
    select.sendKeys(Keys.ARROW_DOWN);
    select.sendKeys(Keys.ARROW_DOWN);

    String bodytext = getDriver().findElement(By.tagName("body")).getText();

    Assert.assertTrue(bodytext.contains("new value: 'Item 1'"));
    Assert.assertTrue(bodytext.contains("new value: 'Item 2'"));
    Assert.assertTrue(bodytext.contains("new value: 'Item 3'"));

}

From source file:com.vaadin.tests.components.tree.TreeKeyboardNavigationToNoneTest.java

License:Apache License

@Test
public void navigateDownForTheLastItem() {
    $(ButtonElement.class).first().click();
    sendKey(Keys.ARROW_DOWN);
    checkNotificationErrorAbsence("last");
}

From source file:com.vaadin.tests.components.tree.TreeScrollingOnRightClickTest.java

License:Apache License

@Test
public void testScrollingOnRightClick() throws Throwable {
    openTestURL();//from   w  ww  .ja va  2 s .com

    // Focus tree
    WebElement tree = getDriver().findElement(By.id(TreeScrollingOnRightClick.TREE_ID));
    tree.click();

    // Move selection down 50 items
    for (int down = 0; down < 50; down++) {
        tree.sendKeys(Keys.ARROW_DOWN);
    }

    Thread.sleep(1000);

    // Get location of item 40
    Point item40Location = getTreeNode("Node 40").getLocation();

    // Right click on item 45
    WebElement item45 = getTreeNode("Node 45");
    new Actions(getDriver()).moveToElement(item45).contextClick(item45).perform();

    // Ensure location of item 40 is still the same (no scrolling)
    Point item40Location2 = getTreeNode("Node 40").getLocation();
    assertEquals(item40Location.getY(), item40Location2.getY());
}

From source file:de.iteratec.iteraplan.webtests.poc.page.attributes.AttributesNewElement2Page.java

License:Open Source License

/**
 * Adds responsiblities to an attribute/*from www .j av  a2s.co  m*/
 * @param resp list of responsibilities
 * @return the attributesNewElement2Page
 */
public AttributesNewElement2Page addResponsibilities(List<String> resp) {

    int counter = 1;

    for (String str : resp) {

        String respTextXPath = "//*[@id=\"componentModel.responsibilityAttributeValuesModel.htmlId_table\"]/tbody/tr["
                + counter + "]/td[2]/input";
        By respTextLocator = By.xpath(respTextXPath);

        driver.findElement(respTextLocator).click();
        driver.findElement(respTextLocator).sendKeys(str);

        /*
         * The usage of the wait construct is bad. This should be replaced private By conditional waiting. It is used at this place,
         * because the popup list must be loaded from the server and after THAT an entry can be selected
         * will be fixed soon (hopefully) 
         */

        WaitUtils.wait(2000);

        driver.findElement(respTextLocator).sendKeys(Keys.ARROW_DOWN);
        driver.findElement(respTextLocator).sendKeys(Keys.RETURN);

        WaitUtils.wait(2000);

        clickAddResponsibility();

        counter++;

    }

    return this;

}

From source file:de.iteratec.iteraplan.webtests.poc.page.attributesGroup.AttributesGroupEditElementPage.java

License:Open Source License

/**
 * Adds a list with attributes to an attributes group
 * @param attr list with attributes// w w  w. j  av  a2s.c  om
 * @return the current page
 */
public AttributesGroupEditElementPage addAttributes(List<String> attr) {

    int counter = 1;

    for (String str : attr) {

        String respTextXPath = "//*[@id=\"componentModel.containedAttributeTypesModel.htmlId\"]/tbody/tr["
                + counter + "]/td[2]/input";
        By respTextLocator = By.xpath(respTextXPath);

        driver.findElement(respTextLocator).click();
        driver.findElement(respTextLocator).sendKeys(str);

        /*
         * The usage of the wait construct is bad. This should be replaced By conditional waiting. It is used at this place,
         * because the popup list must be loaded from the server and after THAT an entry can be selected
         * will be fixed soon (hopefully) 
         */

        synchronized (driver) {
            try {
                driver.wait(2000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }

        driver.findElement(respTextLocator).sendKeys(Keys.ARROW_DOWN);
        driver.findElement(respTextLocator).sendKeys(Keys.RETURN);

        synchronized (driver) {
            try {
                driver.wait(2000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }

        clickAddAttribute();

        counter++;

    }

    return this;

}

From source file:de.iteratec.iteraplan.webtests.poc.page.buildingblock.BuildingBlockEditElementPage.java

License:Open Source License

/**
 * This method is used to set a value for a IS in a combo box. The difference between this method and the setISAttribute method is, 
 * that setISAttribute doesn't have the logic to select an entry from a popup. This popup is shown, if an accepted value is insert in the combo box.
 * @param attributeGroup name of attribute group
 * @param attributeName name of attribute
 * @param attributeValue the value of attribute
 * @return the Building Block New Element Page
 *///from w ww. ja  v a2s .co m
public BuildingBlockEditElementPage setISAttributeFromComboBox(String attributeGroup, String attributeName,
        String attributeValue) {
    //first click the attributes tab
    driver.findElement(attributesTabLocator).click();

    //click the attributes tab
    String attributeGroupXpath = "//a/text()[contains(., '" + attributeGroup + "')]/..";
    By attributesGroupLocator = By.xpath(attributeGroupXpath);
    driver.findElement(attributesGroupLocator).click();

    //find the specific label by the attributes name
    String labelXpath = "//*/label/a[contains(text(), '" + attributeName + "')]/../../label/..//input";
    By inputLocator = By.xpath(labelXpath);

    driver.findElement(inputLocator).click();
    driver.findElement(inputLocator).sendKeys(attributeValue);

    /*
     * These wait conditions are bad. But there must be a waiting time for showing the popup and selecting an item
     * This could be solved much better if there are conditional waitings ("is popup visible, otherwise wait")
     * Will be fixed soon (hopefully)
     * 
     */

    WaitUtils.wait(2000);

    driver.findElement(inputLocator).sendKeys(Keys.ARROW_DOWN);

    WaitUtils.wait(2000);

    driver.findElement(inputLocator).sendKeys(Keys.RETURN);

    return this;

}