Example usage for org.openqa.selenium Keys RETURN

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

Introduction

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

Prototype

Keys RETURN

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

Click Source Link

Usage

From source file:info.magnolia.integrationtests.uitest.ConfigurationAppUITest.java

License:Open Source License

private void renameTableItemByDoubleClick(String oldName, String newName) {
    WebElement propertyElement = getTreeTableItem(oldName);
    doubleClick(propertyElement);/*  www  . j a v  a2  s  .  c o  m*/
    WebElement textField = getElementByXpath(
            "//*[contains(@class, 'v-table-cell-wrapper')]/input[@type = 'text']", newName);
    textField.clear();
    textField.sendKeys(newName);
    simulateKeyPress(Keys.RETURN);
}

From source file:info.magnolia.integrationtests.uitest.KeyboardShortcutUITest.java

License:Open Source License

/**
 * Get a detailEditor to test by running 'Add contact' action.
 * Fill in a field, then hit the ESCAPE key and verify that a confirmation is displayed.
 * Hit ESCAPE and verify that the confirmation closes.
 * Hit ESCAPE again and verify that confirmation is displayed.
 * Hit ENTER to confirm and verify the dialog is closed.
 *///from  www.ja va  2 s  .c o m
@Test
public void escapeHandlingOnDetailEditor() {
    // GIVEN
    final String nameFirst = "escapeHandlingOnDetailEditor";
    WebElement confirmation;

    getAppIcon("Contacts").click();
    waitUntil(appIsLoaded());
    assertAppOpen("Contacts");
    getActionBarItem("Add contact").click();
    waitUntil(appIsLoaded());
    openTabWithCaption("Personal");
    waitUntil(tabIsOpen("Personal"));
    setFormTextFieldText("First name", nameFirst);

    // First pass - we cancel the ESCAPE action.
    // WHEN
    simulateKeyPress(Keys.ESCAPE);
    waitUntil(visibilityOfElementLocated(byConfirmationOverlay));
    // THEN
    confirmation = getConfirmationOverlay();
    assertTrue("ESC key should have caused confirmation overlay.", isExisting(confirmation));

    // WHEN
    simulateKeyPress(Keys.ESCAPE);
    // THEN
    waitUntil(invisibilityOfElementLocated(byConfirmationOverlay));

    // Now do it again, but this time confirm the detailEditor closing.

    // WHEN
    simulateKeyPress(Keys.ESCAPE);
    waitUntil(visibilityOfElementLocated(byConfirmationOverlay));
    // THEN
    confirmation = getConfirmationOverlay();
    assertTrue("ESC key should have caused confirmation overlay.", isExisting(confirmation));
    // WHEN
    simulateKeyPress(Keys.RETURN);
    // THEN
    waitUntil(invisibilityOfElementLocated(byConfirmationOverlay));
}

From source file:info.magnolia.integrationtests.uitest.KeyboardShortcutUITest.java

License:Open Source License

/**
 * Get a dialog to test by running 'Add page' action.
 * Fill in small form, then hit the ENTER key.
 * Verify that page was created, then cleanup by deleting it.
 *//* w  w w .j a  v  a  2s .  c om*/
@Test
@Site
public void whenEnterPressedOnDialogItCommits() {
    // GIVEN
    final String pageName = "testCommitOnEnter";
    getAppIcon("Pages").click();
    waitUntil(appIsLoaded());
    assertAppOpen("Pages");

    // WHEN
    getActionBarItem("Add page").click();
    waitUntil(dialogIsOpen(ADD_NEW_PAGE_DIALOG_TITLE));
    setFormTextFieldText("Page name", pageName);
    getSelectTabElement("Template").click();

    // Click on selector item
    selectElementOfTabListForLabel("Redirect");

    // We move back to the page name input field, so return is triggered more easily
    // Selenium might get hiccups when stuck in the select field
    moveToElement(getFormTextField("Page name"));

    simulateKeyPress(Keys.RETURN);
    // Instead of waiting for the page dialog to be closed we rather wait for the callback dialog to be open
    waitUntil(dialogIsOpen("Redirect"));
    getDialogCommitButton().click();

    // THEN
    // Check that entry is added
    WebElement newRow = getTreeTableItem(pageName);
    assertTrue("ENTER key should have caused new page to be created.", isExisting(newRow));

    // Cleanup - delete the created page
    deleteTreeTableRow("Delete page", pageName);
    waitUntil(invisibilityOfElementLocated(By.xpath(
            String.format("//*[contains(@class, 'v-table-cell-wrapper') and text() = '%s']", pageName))));
}

From source file:info.magnolia.integrationtests.uitest.KeyboardShortcutUITest.java

License:Open Source License

/**
 * Get a dialog to test by running 'Add page' action.
 * Fill in small form, then focus on a textarea and hit the ENTER key.
 * Verify that the dialog is not closed.
 *///w  ww .ja  v a 2s .c  o  m
@Test
@Site
public void whenEnterPressedOnDialogInTextAreaItDoesntCommit() {
    // GIVEN
    final String pageName = "testEnterInTextAreaDoesntCommit";
    getAppIcon("Pages").click();
    waitUntil(appIsLoaded());
    assertAppOpen("Pages");

    getActionBarItem("Add page").click();
    waitUntil(dialogIsOpen(ADD_NEW_PAGE_DIALOG_TITLE));
    setFormTextFieldText("Page name", pageName);
    getSelectTabElement("Template").click();
    // Click on selector item.
    selectElementOfTabListForLabel("Home");
    delay(1, "Give time for change event to proceed");

    getDialogCommitButton().click();
    waitUntil(dialogIsOpen("Home"));

    // WHEN
    // Ensure a text area has focus and hit ENTER.
    setFormTextFieldText("Headline", "The headline");
    delay(1, "Wait for changes to be propagated");
    getFormTextAreaField("Abstract").sendKeys(Keys.RETURN);
    delay(1, "Give time for change event to proceed");

    // THEN
    // Check that dialog is still open
    waitUntil(visibilityOfElementLocated(byDialogTitle("Home")));
}

From source file:info.magnolia.integrationtests.uitest.KeyboardShortcutUITest.java

License:Open Source License

/**
 * Get a DetailEditor to test by running 'Add contact' action.
 * Fill in required fields, then focus on something other then textArea and hit the ENTER key.
 * Verify that DetailEditor is closed and new contact is created.
 * Cleanup by deleting the new contact./*from w ww .  j  av  a2  s . c  om*/
 */
@Test
public void whenEnterPressedOnDetailEditorItCommits() {
    // GIVEN
    final String nameFirst = "Joe";
    final String nameLast = "Testkeyboard";
    String contactName = nameFirst + " " + nameLast;
    String email = nameFirst + "@" + nameLast + ".com";

    getAppIcon("Contacts").click();
    waitUntil(appIsLoaded());
    assertAppOpen("Contacts");
    getActionBarItem("Add contact").click();
    waitUntil(appIsLoaded());

    fillInRequiredContactFields(nameFirst, nameLast, email);

    // WHEN
    simulateKeyPress(Keys.RETURN);
    delay(2, "");

    // THEN
    //Check that editor is closed
    waitUntil(elementIsGone(byTabContainingCaption(contactName)));

    // Check that entry is added.
    waitUntil(visibilityOfElementLocated(byTreeTableItem(email)));
}

From source file:info.magnolia.integrationtests.uitest.KeyboardShortcutUITest.java

License:Open Source License

/**
 * Get a DetailEditor to test by running 'Add contact' action.
 * Fill in required fields, then focus on a textArea and hit the ENTER key.
 * Verify that DetailEditor remains open.
 *///from   ww w .j av  a  2s.c o m
@Test
public void whenEnterPressedOnDetailEditorInTextAreaItDoesntCommit() {
    // GIVEN
    final String nameFirst = "Joe2";
    final String nameLast = "Testkeyboard";
    String email = nameFirst + "@" + nameLast + ".com";

    getAppIcon("Contacts").click();
    waitUntil(appIsLoaded());
    assertAppOpen("Contacts");
    getActionBarItem("Add contact").click();
    waitUntil(appIsLoaded());

    fillInRequiredContactFields(nameFirst, nameLast, email);

    // WHEN
    openTabWithCaption("Address");
    waitUntil(tabIsOpen("Address"));

    getFormTextAreaField("Street address").sendKeys(Keys.RETURN);
    delay(1, "");

    // THEN
    //Check that editor is not closed
    WebElement fieldToCheck = getFormTextAreaField("Street address");
    assertTrue("ENTER key should not have closed the DetailEditor subapp when TextArea has focus.",
            isExisting(fieldToCheck));
}

From source file:io.appium.java_client.ios.IOSWebViewTest.java

License:Apache License

@Test
public void webViewPageTestCase() throws Throwable {
    driver.findElementByXPath("//UIATextField[@value='Enter URL']").sendKeys("www.google.com");
    driver.findElementByClassName("UIAButton").click();
    driver.findElementByClassName("UIAWebView").click();
    Thread.sleep(10000);//from w  ww.  j  a  v  a 2 s  .c o m
    driver.context("WEBVIEW");
    Thread.sleep(10000);
    WebElement el = driver.findElementByClassName("gsfi");
    el.sendKeys("Appium");
    el.sendKeys(Keys.RETURN);
    Thread.sleep(1000);
    assertEquals(true, driver.getTitle().contains("Appium"));
}

From source file:io.v.webdriver.chat.MainPage.java

License:Open Source License

public void checkMessageIsDelivered() {
    // First, let's find the text box where we can enter our message.
    // Since its React ID could easily change (autogenerated), we use xpath to identify it.
    WebElement input = driver.findElement(By.xpath("//div[@class='compose']/form/input"));
    String message = "Vanadium Bot says Hello!";
    input.sendKeys(message);//from  w  w w  . java 2s . co  m
    Util.takeScreenshot((TakesScreenshot) driver, "message-written.png", "Message Written", htmlReportData);

    // And then send the text.
    input.sendKeys(Keys.RETURN);
    Util.takeScreenshot((TakesScreenshot) driver, "message-sent.png", "Message Sent", htmlReportData);

    // Now, wait until the text shows up on screen!
    CheckMessage messageChecker = new CheckMessage(username, message);
    try {
        new WebDriverWait(driver, CHAT_TIMEOUT).until(messageChecker);
    } catch (TimeoutException e) {
        e.printStackTrace();
        Assert.fail(e.toString());
    }
    Util.takeScreenshot((TakesScreenshot) driver, "message-received.png", "Message Received", htmlReportData);
}

From source file:net.codestory.simplelenium.filters.LazyDomElement.java

License:Apache License

@Override
public LazyDomElement pressReturn() {
    return execute("pressReturn()", element -> element.sendKeys(Keys.RETURN));
}

From source file:OnlineShopTest.OnlineShopTest.java

@Test
public void loginSuccessfully() {
    driver.get("http://store.demoqa.com/products-page/your-account/");
    driver.findElement(By.id("log")).sendKeys("Xun" + Keys.RETURN);
    driver.findElement(By.id("pwd")).sendKeys("tZRO7dFmGE$t2rVR" + Keys.RETURN);
    driver.findElement(By.id("login")).click();

    By topToolBar = By.id("wp-admin-bar-my-account");
    waitUntil(d -> d.findElement(topToolBar).isDisplayed());
    System.out.print(driver.findElement(topToolBar).getText());
    assertEquals("Howdy, Xun", driver.findElement(topToolBar).getText());

}