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.datefield.DateFieldValueChangeEventsTest.java

License:Apache License

@Test
public void tb2test() throws Exception {
    openTestURL();// w  w  w. j a v a2s.co m
    getPopUpButton().click();
    getCalendarDayElement(2, 1).click();
    Assert.assertEquals("1. Value changes: 1", getLogRow(0));
    getPopUpButton().click();
    new Select(getHoursSelect()).selectByValue("01");
    new Select(getMinutesSelect()).selectByValue("02");
    new Select(getSecondsSelect()).selectByValue("03");
    new Actions(driver).sendKeys(getSecondsSelect(), Keys.ENTER).perform();
    $(LabelElement.class).first().click();
    Assert.assertEquals("2. Value changes: 2", getLogRow(0));
    getResolutionSelect().selectByText("Month");
    getPopUpButton().click();
    getNextMonthButton().click();
    getNextYearButton().click();
    getNextMonthButton().click();
    getNextMonthButton().sendKeys(Keys.ENTER);
    Assert.assertEquals("3. Value changes: 3", getLogRow(0));
}

From source file:com.vaadin.tests.components.grid.basicfeatures.client.DisabledGridClientTest.java

License:Apache License

@Test
public void testEditorOpening() {
    selectMenuPath("Component", "Editor", "Enabled");
    GridRowElement row = getGridElement().getRow(0);
    GridCellElement cell = getGridElement().getCell(0, 0);
    cell.click();/*w  ww  . ja  v a  2  s .  co m*/
    assertNull("Editor should not open", getEditor());

    new Actions(getDriver()).sendKeys(Keys.ENTER).perform();
    assertNull("Editor should not open", getEditor());
}

From source file:com.vaadin.tests.components.grid.basicfeatures.client.GridClientKeyEventsTest.java

License:Apache License

@Test
public void testNoKeyEventsFromWidget() {
    openTestURL();//from   w ww. ja  v  a 2 s .  c om

    selectMenuPath("Component", "Columns", "Column 2", "Header Type", "Widget Header");
    GridCellElement header = getGridElement().getHeaderCell(0, 2);
    header.findElement(By.tagName("button")).click();
    new Actions(getDriver()).sendKeys(Keys.ENTER).perform();

    for (int i = 0; i < 3; ++i) {
        assertTrue("Header key event handler got called unexpectedly.",
                findElements(By.className("v-label")).get(i * 3 + 1).getText().isEmpty());

    }
}

From source file:com.vaadin.tests.components.grid.basicfeatures.client.GridEditorClientTest.java

License:Apache License

@Test
public void testKeyboardOpeningClosing() {

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

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

    assertNotNull(getEditor());/*ww  w .  j av a  2s . c  o m*/

    new Actions(getDriver()).sendKeys(Keys.ESCAPE).perform();
    assertNull(getEditor());
    assertEquals("Row 4 edit cancelled", findElement(By.className("grid-editor-log")).getText());

    // Disable editor
    selectMenuPath("Component", "Editor", "Enabled");

    getGridElement().getCell(5, 0).click();
    new Actions(getDriver()).sendKeys(Keys.ENTER).perform();
    assertNull(getEditor());
}

From source file:com.vaadin.tests.components.grid.basicfeatures.client.GridEditorClientTest.java

License:Apache License

@Test
public void testFocusOnKeyboardOpen() {

    GridCellElement cell = getGridElement().getCell(4, 2);

    cell.click();// w  w w  .  j  a  va2s.  c  o  m
    new Actions(getDriver()).sendKeys(Keys.ENTER).perform();

    WebElement focused = getFocusedElement();

    assertEquals("", "input", focused.getTagName());
    assertEquals("", cell.getText(), focused.getAttribute("value"));
}

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

License:Apache License

@Test
public void testEditorOpening() {
    selectMenuPath("Component", "Editor", "Enabled");

    GridRowElement row = getGridElement().getRow(0);
    GridCellElement cell = getGridElement().getCell(0, 0);
    cell.click();/*from   w  ww . j  a v a2 s .co  m*/
    assertNull("Editor should not open", getEditor());

    new Actions(getDriver()).sendKeys(Keys.ENTER).perform();
    assertNull("Editor should not open", getEditor());
}

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

License:Apache License

@Test
public void testKeyboardSave() {
    selectMenuPath(EDIT_ITEM_100);/*from   w  ww. j  a v a2 s  .  co  m*/

    WebElement textField = getEditorWidgets().get(0);

    textField.click();
    // without this, the click in the middle of the field might not be after
    // the old text on some browsers
    new Actions(getDriver()).sendKeys(Keys.END).perform();

    textField.sendKeys(" changed");

    // Save from keyboard
    new Actions(getDriver()).sendKeys(Keys.ENTER).perform();

    assertEditorClosed();
    assertEquals("(100, 0) changed", getGridElement().getCell(100, 0).getText());
}

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

License:Apache License

@Test
public void testKeyboardSaveWithInvalidEdition() {
    makeInvalidEdition();/*from w ww.j  a v a 2s.co  m*/

    GridEditorElement editor = getGridElement().getEditor();
    TestBenchElement field = editor.getField(7);

    field.click();
    new Actions(getDriver()).sendKeys(Keys.ENTER).perform();

    assertEditorOpen();
    assertEquals("Column 7: Could not convert value to Integer", editor.getErrorMessage());
    assertTrue("Field 7 should have been marked with an error after error", editor.isFieldErrorMarked(7));

    editor.cancel();

    selectMenuPath(EDIT_ITEM_100);
    assertFalse("Exception should not exist", isElementPresent(NotificationElement.class));
    assertEquals("There should be no editor error message", null,
            getGridElement().getEditor().getErrorMessage());
}

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

License:Apache License

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

    GridCellElement cell_5_0 = getGridElement().getCell(5, 0);
    cell_5_0.click();/*from   w ww . j a v a 2 s .  com*/
    new Actions(getDriver()).sendKeys(Keys.ENTER).perform();

    scrollGridVerticallyTo(100);
    assertEquals("Grid shouldn't scroll vertically while editing in buffered mode", originalScrollPos,
            getGridVerticalScrollPos());
}

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

License:Apache License

@Test
public void testKeyboardOpeningClosing() {

    getGridElement().getCell(4, 0).click();
    assertEditorClosed();//from ww  w .java2  s .c o  m

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

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

    // Disable Editor
    selectMenuPath(TOGGLE_EDIT_ENABLED);
    getGridElement().getCell(5, 0).click();
    new Actions(getDriver()).sendKeys(Keys.ENTER).perform();
    assertEditorClosed();
}