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:org.richfaces.tests.metamer.ftest.richCollapsibleSubTable.TestCollapsibleSubTableFiltering.java

License:Open Source License

@Test
@UseWithField(field = "sample", valuesFrom = ValuesFrom.STRINGS, value = sampleBuiltIn)
@IssueTracking("https://issues.jboss.org/browse/RF-14150")
public void testFilterNameBuiltInAppliesAfterEnterPressed() {
    for (String testedValue : new String[] { "Alexander", "aLEX" }) {
        // filter men table
        getDataTable().getNameInput().clear().sendKeys(testedValue);
        Graphene.guardAjax(keyboard).pressKey(Keys.ENTER);
        // filter women table
        getDataTable().getNameInput2().clear().sendKeys(testedValue);
        Graphene.guardAjax(keyboard).pressKey(Keys.ENTER);
        // check/*from  w  w w.  ja va  2  s .c o  m*/
        verifyFilteringInSubTable(BY_NAME, Boolean.TRUE);
        verifyFilteringInSubTable(BY_NAME, Boolean.FALSE);
    }
}

From source file:org.richfaces.tests.metamer.ftest.richInplaceSelect.TestInplaceSelectJSApi.java

License:Open Source License

@Test
public void open() {
    openButton.click();/*  w ww  .ja  va  2 s  . c om*/

    inplaceSelect.advanced().waitForPopupToShow().perform();
    assertTrue(inplaceSelect.advanced().isInState(InplaceComponentState.ACTIVE));
    keyboard.sendKeys(Keys.ARROW_DOWN);
    keyboard.sendKeys(Keys.ENTER);
    Graphene.guardAjax(keyboard).sendKeys(Keys.TAB);
    assertEquals(outputTextElement.getText(), "Alabama");
    assertTrue(inplaceSelect.advanced().isInState(InplaceComponentState.CHANGED));
}

From source file:org.richfaces.tests.metamer.ftest.richSelect.TestSelectJSApi.java

License:Open Source License

@Test
public void testFocus() {
    focusButton.click();/*w  w  w  .  j  a  v a 2s.  c  om*/

    keyboard.sendKeys("ala");
    select.advanced().waitUntilSuggestionsAreVisible().perform();
    keyboard.sendKeys(Keys.ARROW_DOWN);
    keyboard.sendKeys(Keys.ENTER);
    Graphene.guardAjax(keyboard).sendKeys(Keys.TAB);
    assertEquals(output.getText(), "Alabama");
}

From source file:org.richfaces.ui.select.ITSelectKeyboardSelection.java

License:Open Source License

@Test
public void test_selection_by_keyboard() {
    browser.get(contextPath.toExternalForm());

    selectInput.sendKeys("t");
    waitAjax().until().element(tampaBayOption).is().visible();

    keyboard.pressKey(Keys.ARROW_DOWN);/*from   ww  w.j  av  a2 s . c  o m*/
    waitAjax().until().element(tampaBayOption).attribute("class").contains("rf-sel-sel");

    if (FIREFOX.is(browser)) {
        keyboard.pressKey(Keys.RETURN);
    } else {
        keyboard.pressKey(Keys.ENTER);
    }
    waitGui().until().element(selectInput).attribute("value").equalTo("Tampa Bay");
}

From source file:org.rstudio.studio.selenium.DataImportTests.java

License:Open Source License

@Test
public void testImportCSVFile() throws Exception {
    WebElement menuEntry = MenuNavigator.getMenuItem(driver_, "Tools", "Import Dataset", "From Text File...");

    menuEntry.click();/*  w  w  w  .j  av a  2s.co  m*/
    final WebElement importFileDialog = DialogTestUtils.waitForModalToAppear(driver_);

    DialogTestUtils.waitForFocusedInput(driver_, importFileDialog);

    Actions typeName = new Actions(driver_);
    File csvFile = new File("test/org/rstudio/studio/selenium/resources/banklist.csv");
    typeName.sendKeys(csvFile.getAbsolutePath());
    typeName.perform();
    DialogTestUtils.respondToModalDialog(driver_, "Open");

    // After a moment the modal prompting for the path will disappear, and
    // the modal prompting for input will appear. 
    (new WebDriverWait(driver_, 5)).until(new ExpectedCondition<Boolean>() {
        public Boolean apply(WebDriver d) {
            List<WebElement> elements = driver_.findElements(By.className("gwt-DialogBox-ModalDialog"));
            if (elements.size() > 0) {
                if (elements.get(0).getText().contains("Import Dataset")) {
                    return true;
                }
            }
            return false;
        }
    });

    DialogTestUtils.respondToModalDialog(driver_, "Import");
    ConsoleTestUtils.waitForConsoleContainsText(driver_, "read.csv");

    // Once the CSV has been read, make sure all the rows made it to the
    // generated object
    ConsoleTestUtils.beginConsoleInteraction(driver_);
    (new Actions(driver_)).sendKeys(Keys.ESCAPE + "nrow(banklist)" + Keys.ENTER).perform();
    ConsoleTestUtils.waitForConsoleContainsText(driver_, "515");
}

From source file:org.rstudio.studio.selenium.RConsoleInteraction.java

License:Open Source License

@Test
public void testBasicRInteraction() {
    Actions do42 = new Actions(driver_);
    do42.sendKeys(Keys.chord(Keys.CONTROL, "l"));
    do42.sendKeys(Keys.ESCAPE);
    do42.sendKeys("41 + 1");
    do42.sendKeys(Keys.ENTER);
    do42.perform();

    ConsoleTestUtils.waitForConsoleContainsText(driver_, "42");
}

From source file:org.rstudio.studio.selenium.RConsoleInteraction.java

License:Open Source License

@Test
public void testPlotGeneration() {
    ConsoleTestUtils.resumeConsoleInteraction(driver_);

    Actions plotCars = new Actions(driver_);
    plotCars.sendKeys(Keys.ESCAPE + "plot(cars)" + Keys.ENTER);
    plotCars.perform();// w  w w. ja  v  a 2  s .c  o m

    // Wait for the Plot window to activate
    final WebElement plotWindow = (new WebDriverWait(driver_, 5)).until(ExpectedConditions
            .presenceOfElementLocated(By.id(ElementIds.getElementId(ElementIds.PLOT_IMAGE_FRAME))));

    // Wait for a plot to appear in the window
    Assert.assertEquals(plotWindow.getTagName(), "iframe");
    driver_.switchTo().frame(plotWindow);

    (new WebDriverWait(driver_, 5)).until(ExpectedConditions.presenceOfElementLocated(By.tagName("img")));

    // Switch back to document context
    driver_.switchTo().defaultContent();
}

From source file:org.rstudio.studio.selenium.RConsoleInteraction.java

License:Open Source License

@Test
public void testInvokeHelp() {
    ConsoleTestUtils.resumeConsoleInteraction(driver_);
    Actions help = new Actions(driver_);
    help.sendKeys(Keys.ESCAPE + "?lapply" + Keys.ENTER);
    help.perform();//from w  w w.  j  a va2  s  . co m

    // Wait for the Help window to activate
    final WebElement helpWindow = (new WebDriverWait(driver_, 5)).until(
            ExpectedConditions.presenceOfElementLocated(By.id(ElementIds.getElementId(ElementIds.HELP_FRAME))));

    // Wait for help to appear in the window
    Assert.assertEquals(helpWindow.getTagName(), "iframe");
    driver_.switchTo().frame(helpWindow);

    (new WebDriverWait(driver_, 5))
            .until(ExpectedConditions.textToBePresentInElement(By.tagName("body"), "lapply"));

    // Switch back to document context
    driver_.switchTo().defaultContent();
}

From source file:org.rstudio.studio.selenium.SourceInteraction.java

License:Open Source License

@Test
public void createAndSourceRFile() {
    createRFile();/*  ww w  . j  ava 2 s  . co  m*/

    // Type some code into the file. Note that the matching brace is auto 
    // completed.
    Actions a = new Actions(driver_);
    a.sendKeys("f <- function() {" + Keys.ENTER);
    a.sendKeys(Keys.TAB + "42");
    a.perform();

    // Source the entire file
    WebElement sourceMenuEntry = MenuNavigator.getMenuItem(driver_, "Code", "Source");
    sourceMenuEntry.click();

    // Wait for the console to contain the string "source"
    ConsoleTestUtils.waitForConsoleContainsText(driver_, "source(");

    closeUnsavedRFile();
}

From source file:org.rstudio.studio.selenium.SourceInteraction.java

License:Open Source License

@Test
public void findAndReplace() {
    createRFile();/*  www .java2 s. c  om*/

    // Type some code into the file
    String preReplaceCode = "foo <- 'bar'";
    Actions a = new Actions(driver_);
    a.sendKeys(preReplaceCode + Keys.ENTER);
    a.perform();

    // Find the ACE editor instance that the code appears in. (CONSIDER: 
    // This is not the best way to find the code editor instance.)
    WebElement editor = null;
    List<WebElement> editors = driver_.findElements(By.className("ace_content"));
    for (WebElement e : editors) {
        if (e.getText().contains(preReplaceCode)) {
            editor = e;
            break;
        }
    }
    Assert.assertNotNull(editor);

    // Invoke find and replace
    WebElement findMenuEntry = MenuNavigator.getMenuItem(driver_, "Edit", "Find...");
    findMenuEntry.click();

    // Wait for the find and replace panel to come up
    (new WebDriverWait(driver_, 2)).until(ExpectedConditions
            .presenceOfElementLocated(By.id(ElementIds.getElementId(ElementIds.FIND_REPLACE_BAR))));

    // Type the text and the text to be replaced (replace 'bar' with 'foo')
    Actions rep = new Actions(driver_);
    rep.sendKeys("bar" + Keys.TAB + "foo" + Keys.ENTER);
    rep.perform();

    DialogTestUtils.respondToModalDialog(driver_, "OK");

    Actions dismiss = new Actions(driver_);
    dismiss.sendKeys(Keys.ESCAPE);
    dismiss.perform();

    // Ensure that the source has been updated
    Assert.assertTrue(editor.getText().contains("foo <- 'foo'"));

    closeUnsavedRFile();
}