Example usage for org.openqa.selenium Keys ENTER

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

Introduction

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

Prototype

Keys ENTER

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

Click Source Link

Usage

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

License:Apache License

@Test
public void testNoOpenFromHeaderOrFooter() {
    selectMenuPath("Component", "Footer", "Visible");

    getGridElement().getHeaderCell(0, 0).doubleClick();
    assertEditorClosed();/*from  ww w. j  a v  a  2s .c o m*/

    new Actions(getDriver()).sendKeys(Keys.ENTER).perform();
    assertEditorClosed();

    getGridElement().getFooterCell(0, 0).doubleClick();
    assertEditorClosed();

    new Actions(getDriver()).sendKeys(Keys.ENTER).perform();
    assertEditorClosed();
}

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

License:Apache License

@Test
public void testEditorMoveWithKeyboard() throws InterruptedException {
    selectMenuPath(EDIT_ITEM_100);//from  w  ww .  jav a  2 s .  c o m

    assertEditorOpen();

    getEditorWidgets().get(0).click();
    new Actions(getDriver()).sendKeys(Keys.ENTER).perform();

    String firstFieldValue = getEditorWidgets().get(0).getAttribute("value");
    assertEquals("Editor should move to row 101", "(101, 0)", firstFieldValue);

    for (int i = 0; i < 10; i++) {
        new Actions(getDriver()).keyDown(Keys.SHIFT).sendKeys(Keys.ENTER).keyUp(Keys.SHIFT).perform();

        firstFieldValue = getEditorWidgets().get(0).getAttribute("value");
        int row = 100 - i;
        assertEquals("Editor should move to row " + row, "(" + row + ", 0)", firstFieldValue);
    }
}

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

License:Apache License

@Test
public void testValidationErrorPreventsMove() throws InterruptedException {
    // Because of "out of view" issues, we need to move this for easy access
    selectMenuPath("Component", "Columns", "Column 7", "Column 7 Width", "50px");
    for (int i = 0; i < 6; ++i) {
        selectMenuPath("Component", "Columns", "Column 7", "Move left");
    }/*from  ww w.j ava 2s  . c  o m*/

    selectMenuPath(EDIT_ITEM_5);

    getEditorWidgets().get(1).click();
    String faultyInt = "not a number";
    getEditorWidgets().get(1).sendKeys(faultyInt);

    getGridElement().getCell(10, 0).click();

    assertEquals("Editor should not move from row 5", "(5, 0)",
            getEditorWidgets().get(0).getAttribute("value"));

    getEditorWidgets().get(1).sendKeys(Keys.chord(Keys.CONTROL, "a"));
    getEditorWidgets().get(1).sendKeys("5");
    // FIXME: Needs to trigger one extra validation round-trip for now
    getGridElement().sendKeys(Keys.ENTER);

    getGridElement().getCell(10, 0).click();

    assertEquals("Editor should move to row 10", "(10, 0)", getEditorWidgets().get(0).getAttribute("value"));

}

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

License:Apache License

@Test
public void testScrollEnabledOnKeyboardOpen() {
    int originalScrollPos = getGridVerticalScrollPos();

    GridCellElement cell_5_0 = getGridElement().getCell(5, 0);
    cell_5_0.click();//from  w w w  . j ava2  s  .  c o m
    new Actions(getDriver()).sendKeys(Keys.ENTER).perform();

    scrollGridVerticallyTo(100);
    assertGreater("Grid should scroll vertically while editing in unbuffered mode", getGridVerticalScrollPos(),
            originalScrollPos);
}

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

License:Apache License

@Test
public void testEditorSaveOnRowChange() {
    // Double click sets the focus programmatically
    getGridElement().getCell(5, 2).doubleClick();

    TestBenchElement editor = getGridElement().getEditor().getField(2);
    editor.clear();//from  ww w .  j  av  a 2s  .c  o  m
    // Click to ensure IE focus...
    editor.click(5, 5);
    editor.sendKeys("Foo", Keys.ENTER);

    assertEquals("Editor did not move.", "(6, 0)",
            getGridElement().getEditor().getField(0).getAttribute("value"));
    assertEquals("Editor field value did not update from server.", "(6, 2)",
            getGridElement().getEditor().getField(2).getAttribute("value"));

    assertEquals("Edited value was not saved.", "Foo", getGridElement().getCell(5, 2).getText());
}

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

License:Apache License

@Test
public void testKeyboardSortingMultipleHeaders() {
    openTestURL();/* w  w w. j  a  v a  2s .c o m*/
    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.grid.basicfeatures.server.GridSortingTest.java

License:Apache License

@Test
public void testKeyboardSorting() {
    openTestURL();//from   ww  w .  j  a va2  s . c om

    /*
     * We can't click on the header directly, since it will sort the header
     * immediately. We need to focus some other column first, and only then
     * navigate there.
     */
    getGridElement().getCell(0, 0).click();
    sendKey(Keys.ARROW_UP);

    // Sort ASCENDING on first column
    sendKey(Keys.ENTER);
    assertLastSortIsUserOriginated(true);
    assertColumnsAreSortedAs(_(1, SortDirection.ASCENDING));

    // Move to next column
    sendKey(Keys.RIGHT);

    // Add this column to the existing sorting group
    holdKey(Keys.SHIFT);
    sendKey(Keys.ENTER);
    releaseKey(Keys.SHIFT);
    assertColumnsAreSortedAs(_(1, SortDirection.ASCENDING), _(2, SortDirection.ASCENDING));

    // Move to next column
    sendKey(Keys.RIGHT);

    // Add a third column to the sorting group
    holdKey(Keys.SHIFT);
    sendKey(Keys.ENTER);
    releaseKey(Keys.SHIFT);
    assertColumnsAreSortedAs(_(1, SortDirection.ASCENDING), _(2, SortDirection.ASCENDING),
            _(3, SortDirection.ASCENDING));

    // Move back to the second column
    sendKey(Keys.LEFT);

    // Change sort direction of the second column to DESCENDING
    holdKey(Keys.SHIFT);
    sendKey(Keys.ENTER);
    releaseKey(Keys.SHIFT);
    assertColumnsAreSortedAs(_(1, SortDirection.ASCENDING), _(2, SortDirection.DESCENDING),
            _(3, SortDirection.ASCENDING));

    // Move back to the third column
    sendKey(Keys.RIGHT);

    // Set sorting to third column, ASCENDING
    sendKey(Keys.ENTER);
    assertColumnsAreSortedAs(_(2, 1, SortDirection.ASCENDING));

    // Move to the fourth column
    sendKey(Keys.RIGHT);

    // Make sure that single-column sorting also works as expected
    sendKey(Keys.ENTER);
    assertColumnsAreSortedAs(_(3, 1, SortDirection.ASCENDING));

}

From source file:com.vaadin.tests.components.grid.GridClientRenderers.java

License:Apache License

@Test
public void testComplexRendererOnActivate() {
    openTestURL();//  w w w  .j  av a  2 s  . co m

    GridCellElement cell = getGrid().getCell(3, 1);
    cell.click();
    new Actions(getDriver()).sendKeys(Keys.ENTER).perform();

    assertEquals("onActivate was not called on KeyDown Enter.", "Activated!", cell.getText());

    cell = getGrid().getCell(4, 1);
    cell.click();
    new Actions(getDriver()).moveToElement(cell).doubleClick().perform();
    assertEquals("onActivate was not called on double click.", "Activated!", cell.getText());
}

From source file:com.vaadin.tests.components.textfield.AutomaticImmediateTest.java

License:Apache License

@Test
public void test() {
    openTestURL();/*from  ww w  . jav  a2 s.  com*/

    WebElement field = getDriver().findElement(By.id(AutomaticImmediate.FIELD));

    WebElement toggle = getDriver().findElement(By.xpath("//input[@type = 'checkbox']"));

    WebElement explicitFalseButton = getDriver().findElement(By.id(AutomaticImmediate.EXPLICIT_FALSE));

    WebElement hitServerButton = getDriver().findElement(By.id(AutomaticImmediate.BUTTON));

    String string = getRandomString();
    field.sendKeys(string + Keys.ENTER);

    // Non immediate, just the initial server side valuechange
    assertLastLog("1. fireValueChange");

    hitServerButton.click();

    // No value change, but value sent to server
    assertLastLog("2. fireValueChange");

    // listener on -> immediate on
    toggle.click();

    string = getRandomString();
    String delSequence = "" + Keys.BACK_SPACE + Keys.BACK_SPACE;
    field.sendKeys(delSequence + string + Keys.ENTER);
    assertLastLog("4. Value changed: " + string);

    // listener off -> immediate off
    String lastvalue = string;
    toggle.click();
    string = getRandomString();
    field.sendKeys(delSequence + string + Keys.ENTER);
    // No new value change should happen...
    assertLastLog("4. Value changed: " + lastvalue);
    hitServerButton.click();
    // ... but server should receive value with roundtrip
    assertLastLog("5. fireValueChange");

    // explicitly non immediate, but with listener
    explicitFalseButton.click();
    toggle.click();

    string = getRandomString();
    field.sendKeys(delSequence + string + Keys.ENTER);
    // non immediate, no change...
    assertLastLog("5. fireValueChange");
    // ... until server round trip
    hitServerButton.click();
    assertLastLog("7. Value changed: " + string);

}

From source file:com.vaadin.tutorial.addressbook.AddressbookIT.java

License:Apache License

@Test
public void validationError() {
    int index = 1;

    List<WebElement> rows = getRows();

    rows.get(index).findElement(By.tagName("td")).click();

    WebElement form = findElement(By.id("contactform"));
    WebElement phone = form.findElement(By.className("phone"));
    WebElement email = form.findElement(By.className("email"));

    phone.clear();//from w  w  w  .  j  av a 2  s.c  om
    email.clear();

    waitForElementVisible(By.className("v-errorindicator"));

    email.sendKeys("test@test.com", Keys.ENTER);
    waitForElementNotPresent(By.className("v-errorindicator"));
}