Example usage for org.openqa.selenium Keys BACK_SPACE

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

Introduction

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

Prototype

Keys BACK_SPACE

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

Click Source Link

Usage

From source file:com.liferay.faces.test.Icefaces4PortletTest.java

License:Open Source License

@Test
@RunAsClient/*  ww  w . ja  va 2s .co  m*/
@InSequence(1500)
public void dataEntry() throws Exception {

    String foo = "";

    logger.log(Level.INFO, "clicking into the firstNameField ...");
    firstNameField.click();
    logger.log(Level.INFO, "tabbing into the next field ...");
    firstNameField.sendKeys(Keys.TAB);

    logger.log(Level.INFO, "firstNameField.getAttribute('value') = " + firstNameField.getAttribute("value"));
    logger.log(Level.INFO,
            "isThere(browser, firstNameFieldErrorXpath) = " + isThere(browser, firstNameFieldErrorXpath));

    if (isThere(browser, firstNameFieldErrorXpath)) { // houston we have a problem
        logger.log(Level.INFO, "firstNameFieldError.isDisplayed() = " + firstNameFieldError.isDisplayed());
        assertFalse(
                "firstNameFieldError should not be displayed after simply tabbing out of the empty field, having never entered any data.  "
                        + "But we see '" + firstNameFieldError.getText() + "'",
                firstNameFieldError.isDisplayed());
    }

    logger.log(Level.INFO, "Shift tabbing back into the firstNameField ...");
    (new Actions(browser)).keyDown(Keys.SHIFT).sendKeys(Keys.TAB).keyDown(Keys.SHIFT).perform();

    logger.log(Level.INFO,
            "isThere(browser, firstNameFieldErrorXpath) = " + isThere(browser, firstNameFieldErrorXpath));

    logger.log(Level.INFO, "entering 'asdf' into the firstNameField and then tabbing out of it...");
    firstNameField.sendKeys("asdf");
    firstNameField.sendKeys(Keys.TAB);

    logger.log(Level.INFO, "firstNameField.getAttribute('value') = " + firstNameField.getAttribute("value"));
    logger.log(Level.INFO,
            "isThere(browser, firstNameFieldErrorXpath) = " + isThere(browser, firstNameFieldErrorXpath));
    assertTrue("The data 'asdf' should be in the firstNameField after tabbing out of it",
            "asdf".equals(firstNameField.getAttribute("value")));

    logger.log(Level.INFO, "Shift tabbing back into the firstNameField ...");
    (new Actions(browser)).keyDown(Keys.SHIFT).sendKeys(Keys.TAB).keyUp(Keys.SHIFT).perform();

    firstNameField.click();
    logger.log(Level.INFO,
            "clearing the firstNameField using the BACKSPACE key, and then tabbing out of the firstNameField ...");
    firstNameField.sendKeys(Keys.BACK_SPACE);

    logger.log(Level.INFO, "Waiting for the firstNameField to contain 'asd' ...");
    try {
        WebDriverWait wait = new WebDriverWait(browser, 10);
        wait.until(ExpectedConditions.textToBePresentInElementValue(By.xpath(firstNameFieldXpath), "asd"));
    } catch (Exception e) {
        logger.log(Level.INFO, "Exception e.getMessage() = " + e.getMessage());
        if (isThere(browser, firstNameFieldXpath)) {
            foo = firstNameField.getText();
        }
        logger.log(Level.INFO, "firstNameField.getText() = " + firstNameField.getText());
        assertTrue(
                "firstNameField should contain 'asd', but " + firstNameFieldXpath + " contains '" + foo + "'.",
                false);
    }

    firstNameField.sendKeys(Keys.BACK_SPACE);

    logger.log(Level.INFO, "Waiting for the firstNameField to contain 'as' ...");
    try {
        WebDriverWait wait = new WebDriverWait(browser, 10);
        wait.until(ExpectedConditions.textToBePresentInElementValue(By.xpath(firstNameFieldXpath), "as"));
    } catch (Exception e) {
        logger.log(Level.INFO, "Exception e.getMessage() = " + e.getMessage());
        if (isThere(browser, firstNameFieldXpath)) {
            foo = firstNameField.getText();
        }
        assertTrue(
                "firstNameField should contain 'as', but " + firstNameFieldXpath + " contains '" + foo + "'.",
                false);
    }

    firstNameField.sendKeys(Keys.BACK_SPACE);

    logger.log(Level.INFO, "Waiting for the firstNameField to contain 'a' ...");
    try {
        WebDriverWait wait = new WebDriverWait(browser, 10);
        wait.until(ExpectedConditions.textToBePresentInElementValue(By.xpath(firstNameFieldXpath), "a"));
    } catch (Exception e) {
        logger.log(Level.INFO, "Exception e.getMessage() = " + e.getMessage());
        if (isThere(browser, firstNameFieldXpath)) {
            foo = firstNameField.getText();
        }
        assertTrue("firstNameField should contain 'a', but " + firstNameFieldXpath + " contains '" + foo + "'.",
                false);
    }

    firstNameField.sendKeys(Keys.BACK_SPACE);

    logger.log(Level.INFO, "Waiting for the firstNameField to contain '' ...");
    try {
        WebDriverWait wait = new WebDriverWait(browser, 10);
        wait.until(ExpectedConditions.textToBePresentInElementValue(By.xpath(firstNameFieldXpath), ""));
    } catch (Exception e) {
        logger.log(Level.INFO, "Exception e.getMessage() = " + e.getMessage());
        if (isThere(browser, firstNameFieldXpath)) {
            foo = firstNameField.getText();
        }
        assertTrue("firstNameField should contain '', but " + firstNameFieldXpath + " contains '" + foo + "'.",
                false);
    }

    firstNameField.sendKeys(Keys.TAB);

    logger.log(Level.INFO, "Waiting for the firstNameFieldError to contain 'Value is required' ...");
    try {
        WebDriverWait wait = new WebDriverWait(browser, 10);
        wait.until(ExpectedConditions.textToBePresentInElementLocated(By.xpath(firstNameFieldErrorXpath),
                "Value is required"));
    } catch (Exception e) {
        logger.log(Level.INFO, "Exception e.getMessage() = " + e.getMessage());
        assertTrue("firstNameFieldError should be visible after tabbing out with no value," + " but "
                + firstNameFieldErrorXpath + " is not visible.", false);
    }

    logger.log(Level.INFO, "firstNameField.getAttribute('value') = " + firstNameField.getAttribute("value"));
    assertTrue(
            "The data 'asdf' should no longer be in the firstNameField after clearing it out with BACK_SPACE and then tabbing out.   "
                    + "But we see '" + firstNameField.getAttribute("value") + "'",
            "".equals(firstNameField.getAttribute("value")));
    logger.log(Level.INFO,
            "isThere(browser, firstNameFieldErrorXpath) = " + isThere(browser, firstNameFieldErrorXpath));
    assertTrue(
            "The firstNameFieldError should at least be in the DOM somewhere by this point, but it is not there",
            isThere(browser, firstNameFieldErrorXpath));
    logger.log(Level.INFO, "firstNameFieldError.getText() = " + firstNameFieldError.getText());
    assertTrue("The firstNameFieldError should say 'Value is required'",
            firstNameFieldError.getText().contains("Value is required"));

}

From source file:com.liferay.faces.test.PlutoTest.java

License:Open Source License

@Test
@RunAsClient/* w  ww .  j  a va  2s .  c  o m*/
@InSequence(1500)
public void dataEntry() throws Exception {

    logger.log(Level.INFO, "clicking into the firstNameField ...");
    firstNameField.click();
    Thread.sleep(50);
    logger.log(Level.INFO, "tabbing into the next field ...");
    firstNameField.sendKeys(Keys.TAB);
    Thread.sleep(500);
    logger.log(Level.INFO, "firstNameField.getAttribute('value') = " + firstNameField.getAttribute("value"));
    logger.log(Level.INFO,
            "isThere(browser, firstNameFieldErrorXpath) = " + isThere(browser, firstNameFieldErrorXpath));

    if (isThere(browser, firstNameFieldErrorXpath)) { // houston we have a problem
        logger.log(Level.INFO, "firstNameFieldError.isDisplayed() = " + firstNameFieldError.isDisplayed());
        assertFalse(
                "firstNameFieldError should not be displayed after simply tabbing out of the empty field, having never entered any data.  "
                        + "But we see '" + firstNameFieldError.getText() + "'",
                firstNameFieldError.isDisplayed());
    }

    logger.log(Level.INFO, "Shift tabbing back into the firstNameField ...");
    (new Actions(browser)).keyDown(Keys.SHIFT).sendKeys(Keys.TAB).keyDown(Keys.SHIFT).perform();
    Thread.sleep(50);
    logger.log(Level.INFO,
            "isThere(browser, firstNameFieldErrorXpath) = " + isThere(browser, firstNameFieldErrorXpath));

    logger.log(Level.INFO, "entering 'asdf' into the firstNameField and then tabbing out of it...");
    firstNameField.sendKeys("asdf");
    firstNameField.sendKeys(Keys.TAB);
    Thread.sleep(50);
    logger.log(Level.INFO, "firstNameField.getAttribute('value') = " + firstNameField.getAttribute("value"));
    logger.log(Level.INFO,
            "isThere(browser, firstNameFieldErrorXpath) = " + isThere(browser, firstNameFieldErrorXpath));
    assertTrue("The data 'asdf' should be in the firstNameField after tabbing out of it",
            "asdf".equals(firstNameField.getAttribute("value")));

    logger.log(Level.INFO, "Shift tabbing back into the firstNameField ...");
    (new Actions(browser)).keyDown(Keys.SHIFT).sendKeys(Keys.TAB).keyDown(Keys.SHIFT).perform();
    Thread.sleep(50);
    logger.log(Level.INFO,
            "clearing the firstNameField using the BACKSPACE key, and then tabbing out of the firstNameField ...");
    firstNameField.sendKeys(Keys.BACK_SPACE);
    Thread.sleep(50);
    firstNameField.sendKeys(Keys.BACK_SPACE);
    Thread.sleep(50);
    firstNameField.sendKeys(Keys.BACK_SPACE);
    Thread.sleep(50);
    firstNameField.sendKeys(Keys.BACK_SPACE);
    Thread.sleep(50);
    firstNameField.sendKeys(Keys.TAB);
    Thread.sleep(50);
    logger.log(Level.INFO, "firstNameField.getAttribute('value') = " + firstNameField.getAttribute("value"));
    assertTrue(
            "The data 'asdf' should no longer be in the firstNameField after clearing it out with BACK_SPACE and then tabbing out.   "
                    + "But we see '" + firstNameField.getAttribute("value") + "'",
            "".equals(firstNameField.getAttribute("value")));
    logger.log(Level.INFO,
            "isThere(browser, firstNameFieldErrorXpath) = " + isThere(browser, firstNameFieldErrorXpath));
    assertTrue(
            "The firstNameFieldError should at least be in the DOM somewhere by this point, but it is not there",
            isThere(browser, firstNameFieldErrorXpath));
    logger.log(Level.INFO, "firstNameFieldError.getText() = " + firstNameFieldError.getText());
    assertTrue("The firstNameFieldError should say 'Value is required'",
            firstNameFieldError.getText().contains("Value is required"));

}

From source file:com.liferay.faces.test.Primefaces4UsersPortletTest.java

License:Open Source License

@Test
@RunAsClient//from www.j ava2 s.c om
@InSequence(4000)
public void screenNameColumnFilter() throws Exception {

    waitForElement(browser, screenNameColumnFilterXpath);
    screenNameColumnFilter.sendKeys("john.adams");

    Thread.sleep(1000);

    logger.log(Level.INFO,
            "johnAdamsUserScreenNameCell.isDisplayed() = " + johnAdamsUserScreenNameCell.isDisplayed());
    assertTrue(
            "The Screen Name Cell of the John Adams user should be displayed on the page as john.adams at this point but it is not.",
            johnAdamsUserScreenNameCell.isDisplayed());
    logger.log(Level.INFO,
            "johnAdamsUserLastNameCell.isDisplayed() = " + johnAdamsUserLastNameCell.isDisplayed());
    assertTrue(
            "The Last Name Cell of the John Adams user should be displayed on the page as John at this point but it is not.",
            johnAdamsUserLastNameCell.isDisplayed());
    logger.log(Level.INFO,
            "johnAdamsUserLastNameCell.isDisplayed() = " + johnAdamsUserFirstNameCell.isDisplayed());
    assertTrue(
            "The First Name Cell of the John Adams user should be displayed on the page as Adams at this point but it is not.",
            johnAdamsUserFirstNameCell.isDisplayed());
    logger.log(Level.INFO,
            "johnAdamsUserEmailAddressCell.isDisplayed() = " + johnAdamsUserEmailAddressCell.isDisplayed());
    assertTrue(
            "The Email Address Cell of the John Adams user should be displayed on the page as john.adams@liferay.com at this point but it is not.",
            johnAdamsUserEmailAddressCell.isDisplayed());

    logger.log(Level.INFO, "isThere(browser, samuelAdamsUserScreenNameCellXpath) = "
            + isThere(browser, samuelAdamsUserScreenNameCellXpath));
    assertFalse(
            "The row for Samuel Adams should NOT be displayed now becuase of filtering, but it is displayed.",
            isThere(browser, samuelAdamsUserScreenNameCellXpath));

    for (int i = 0; i < "john.adams".length(); i++) {
        screenNameColumnFilter.sendKeys(Keys.BACK_SPACE);
    }

    Thread.sleep(1000);

    logger.log(Level.INFO, "isThere(browser, samuelAdamsUserScreenNameCellXpath) = "
            + isThere(browser, samuelAdamsUserScreenNameCellXpath));
    assertTrue("The row for Samuel Adams should be displayed now becuase of filtering, but it is not.",
            isThere(browser, samuelAdamsUserScreenNameCellXpath));

}

From source file:com.liferay.faces.test.selenium.browser.internal.BrowserDriverImpl.java

License:Open Source License

@Override
public void clearElement(String elementXpath) {

    centerElementInCurrentWindow(elementXpath);

    WebElement element = findElementByXpath(elementXpath);
    String value = element.getAttribute("value");

    if ((value != null) && !value.equals("")) {

        CharSequence[] clearKeys = new CharSequence[value.length()];

        for (int i = 0; i < value.length(); i++) {
            clearKeys[i] = Keys.BACK_SPACE;
        }/*from   ww  w.  j a  v  a  2  s .c om*/

        sendKeysToElement(elementXpath, Keys.END);
        sendKeysToElement(elementXpath, clearKeys);
    }
}

From source file:com.machinepublishers.jbrowserdriver.Robot.java

License:Apache License

void keysType(final CharSequence... charsList) {
    for (CharSequence chars : charsList) {
        if (Util.KEYBOARD_DELETE.equals(chars.toString())) {
            keysTypeHelper(Keys.chord(Keys.CONTROL, "a"));
            keysTypeHelper(Keys.BACK_SPACE.toString());
        } else {//from   w w  w  .  j av  a2 s  .  c o m
            keysTypeHelper(chars);
        }
    }
}

From source file:com.mycompany.selenium.SeleniumTests.java

@Test
public void test3() throws Exception {
    WebElement element = driver.findElement(By.id("filter"));
    element.sendKeys(Keys.BACK_SPACE);
    WebElement table = driver.findElement(By.tagName("tbody"));
    List<WebElement> rows = table.findElements(By.tagName("tr"));
    Assert.assertThat(rows.size(), is(5));
}

From source file:com.opera.core.systems.DriverKeysTest.java

License:Apache License

@Test
public void testMultipleModifiers() throws Exception {
    new Actions(driver).sendKeys("abc defghij").sendKeys(Keys.CONTROL + "" + Keys.LEFT_SHIFT + Keys.LEFT)
            .sendKeys(Keys.BACK_SPACE).build().perform();

    assertEquals("abc ", fieldOne.getAttribute("value"));
}

From source file:com.pentaho.ctools.issues.cdf.TableComponent.java

License:Apache License

/**
 * ############################### Test Case 1 ###############################
 *
 * Test Case Name://  w w w .j  av a2s. c  om
 *    Table Component tests
 *
 * Description:
 *    CDE-328 - Use more than one parameter for the expand
 *    CDF-357 - Assert search gives back expected results
 *    CDF-548 - Assert no problems with expanding after refresh/change pages
 *
 * Steps:
 *    1. Open created sample search for "class", assert expected result, clear search and assert all is shown
 *    2. Expand first row and assert expansion was successful 
 *    2. Click Refresh button and expand same row asserting expansion was successful
 *    3. Change page and expand second row asserting expansion was successful
 *
 */
@Test
public void tc1_CdfTableComponent_TestIssues() {
    this.log.info("tc1_CdfTableComponent_TestIssues");

    /*
     * ## Step 1
     */
    //Open Created sample
    driver.get(baseUrl
            + "api/repos/%3Apublic%3AIssues%3ACDF%3ATableExpandTest%3AtableExpandTest.wcdf/generatedContent");

    //Wait for loading to finish
    this.elemHelper.WaitForElementInvisibility(driver, By.cssSelector("div.blockUI.blockOverlay"));

    //search for "Mot" and assert shown result
    WebElement searchInput = this.elemHelper.FindElement(driver, By.xpath("//input[@type='search']"));
    assertNotNull(searchInput);
    searchInput.sendKeys("class");
    WebElement firstResult = this.elemHelper.FindElement(driver,
            By.xpath("//table[@id='tblMainTable']/tbody/tr/td"));
    assertNotNull(firstResult);
    this.elemHelper.WaitForTextPresence(driver, By.xpath("//table[@id='tblMainTable']/tbody/tr/td"),
            "Classic Cars");
    String resultClass = this.elemHelper.WaitForElementPresentGetText(driver,
            By.xpath("//table[@id='tblMainTable']/tbody/tr/td"));
    assertEquals("Classic Cars", resultClass);
    assertTrue(this.elemHelper.WaitForElementNotPresent(driver,
            By.xpath("//table[@id='tblMainTable']/tbody/tr[2]/td")));

    //Clear search and assert all results shown
    searchInput = this.elemHelper.FindElement(driver, By.xpath("//input[@type='search']"));
    assertNotNull(searchInput);
    searchInput.sendKeys(Keys.BACK_SPACE);
    searchInput.sendKeys(Keys.BACK_SPACE);
    searchInput.sendKeys(Keys.BACK_SPACE);
    searchInput.sendKeys(Keys.BACK_SPACE);
    this.elemHelper.WaitForTextPresence(driver, By.xpath("//table[@id='tblMainTable']/tbody/tr/td"),
            "Motorcycles");
    String resultOne = this.elemHelper.WaitForElementPresentGetText(driver,
            By.xpath("//table[@id='tblMainTable']/tbody/tr/td"));
    assertEquals("Motorcycles", resultOne);
    this.elemHelper.WaitForTextPresence(driver, By.xpath("//table[@id='tblMainTable']/tbody/tr[2]/td"),
            "Classic Cars");
    String resultTwo = this.elemHelper.WaitForElementPresentGetText(driver,
            By.xpath("//table[@id='tblMainTable']/tbody/tr[2]/td"));
    assertEquals("Classic Cars", resultTwo);
    this.elemHelper.WaitForTextPresence(driver, By.xpath("//table[@id='tblMainTable']/tbody/tr[3]/td"),
            "Trucks and Buses");
    String resultThree = this.elemHelper.WaitForElementPresentGetText(driver,
            By.xpath("//table[@id='tblMainTable']/tbody/tr[3]/td"));
    assertEquals("Trucks and Buses", resultThree);

    /*
     * ## Step 2
     */
    //Click first row and assert expansion was successful
    WebElement firstRow = this.elemHelper.FindElement(driver,
            By.xpath("//table[@id='tblMainTable']/tbody/tr/td"));
    assertNotNull(firstRow);
    firstRow.click();
    WebElement subTable = this.elemHelper.FindElement(driver,
            By.xpath("//table[@id='tblSubTable']/tbody/tr/td"));
    assertNotNull(subTable);
    String tableTitle = this.elemHelper.WaitForElementPresentGetText(driver,
            By.xpath("//table[@id='tblSubTable']/thead/tr/th/div"));
    assertEquals("PRODUCTNAME", tableTitle);
    String thirdRow = this.elemHelper.WaitForElementPresentGetText(driver,
            By.xpath("//table[@id='tblSubTable']/tbody/tr[3]/td"));
    assertEquals("2003 Harley-Davidson Eagle Drag Bike", thirdRow);
    String ninthRow = this.elemHelper.WaitForElementPresentGetText(driver,
            By.xpath("//table[@id='tblSubTable']/tbody/tr[9]/td"));
    assertEquals("1982 Ducati 900 Monster", ninthRow);

    /*
     * ## Step 2
     */
    //Click Refresh button
    WebElement refreshButton = this.elemHelper.FindElement(driver, By.xpath("//div[@id='btnRefresh']/button"));
    assertNotNull(refreshButton);
    refreshButton.click();

    //Wait for loading to finish
    this.elemHelper.WaitForElementInvisibility(driver, By.cssSelector("div.blockUI.blockOverlay"));

    //Click first row and assert expansion was successful
    firstRow = this.elemHelper.FindElement(driver, By.xpath("//table[@id='tblMainTable']/tbody/tr/td"));
    assertNotNull(firstRow);
    firstRow.click();
    subTable = this.elemHelper.FindElement(driver, By.xpath("//table[@id='tblSubTable']/tbody/tr/td"));
    assertNotNull(subTable);
    tableTitle = this.elemHelper.WaitForElementPresentGetText(driver,
            By.xpath("//table[@id='tblSubTable']/thead/tr/th/div"));
    assertEquals("PRODUCTNAME", tableTitle);
    thirdRow = this.elemHelper.WaitForElementPresentGetText(driver,
            By.xpath("//table[@id='tblSubTable']/tbody/tr[3]/td"));
    assertEquals("2003 Harley-Davidson Eagle Drag Bike", thirdRow);
    ninthRow = this.elemHelper.WaitForElementPresentGetText(driver,
            By.xpath("//table[@id='tblSubTable']/tbody/tr[9]/td"));
    assertEquals("1982 Ducati 900 Monster", ninthRow);

    /*
     * ## Step 3
     */
    //Click Next page button
    WebElement nextPage = this.elemHelper.FindElement(driver, By.id("tblMainTable_next"));
    assertNotNull(nextPage);
    nextPage.click();
    this.elemHelper.WaitForElementNotPresent(driver, By.xpath("//table[@id='tblSubTable']/tbody/tr/td"));

    //Click second row and assert expansion was successful
    WebElement secondRow = this.elemHelper.FindElement(driver,
            By.xpath("//table[@id='tblMainTable']/tbody/tr[2]/td"));
    assertNotNull(secondRow);
    String secondProduct = this.elemHelper
            .FindElement(driver, By.xpath("//table[@id='tblMainTable']/tbody/tr[2]/td")).getText();
    assertEquals("Planes", secondProduct);
    secondRow.click();
    subTable = this.elemHelper.FindElement(driver, By.xpath("//table[@id='tblSubTable']/tbody/tr/td"));
    assertNotNull(subTable);
    tableTitle = this.elemHelper.WaitForElementPresentGetText(driver,
            By.xpath("//table[@id='tblSubTable']/thead/tr/th/div"));
    assertEquals("PRODUCTNAME", tableTitle);
    thirdRow = this.elemHelper.WaitForElementPresentGetText(driver,
            By.xpath("//table[@id='tblSubTable']/tbody/tr[3]/td"));
    assertEquals("1928 British Royal Navy Airplane", thirdRow);
    ninthRow = this.elemHelper.WaitForElementPresentGetText(driver,
            By.xpath("//table[@id='tblSubTable']/tbody/tr[9]/td"));
    assertEquals("ATA: B757-300", ninthRow);
}

From source file:com.seleniumtests.uipage.htmlelements.DatePickerElement.java

License:Apache License

/**
 * Clear text field but assumes element exists
 *//*www .  j a  va2 s  .  com*/
private void clearField() {

    if (element == null) {
        throw new ScenarioException("Element should not be null");
    }

    BrowserType browser = WebUIDriver.getWebUIDriver(false).getConfig().getBrowser();
    if (browser == BrowserType.INTERNET_EXPLORER) {
        new Actions(driver).doubleClick(element)
                .sendKeys(Keys.DELETE, Keys.DELETE, Keys.DELETE, Keys.DELETE, Keys.DELETE, Keys.DELETE,
                        Keys.DELETE, Keys.DELETE, Keys.DELETE, Keys.DELETE)
                .sendKeys(Keys.BACK_SPACE, Keys.BACK_SPACE, Keys.BACK_SPACE, Keys.BACK_SPACE, Keys.BACK_SPACE,
                        Keys.BACK_SPACE, Keys.BACK_SPACE, Keys.BACK_SPACE, Keys.BACK_SPACE, Keys.BACK_SPACE)
                .perform();
    } else {
        super.clear();
    }
}

From source file:com.thoughtworks.selenium.webdriven.commands.SendKeys.java

License:Apache License

@Override
protected Void handleSeleneseCommand(WebDriver driver, String locator, String value) {
    alertOverride.replaceAlertMethod(driver);

    value = value.replace("${KEY_ALT}", Keys.ALT);
    value = value.replace("${KEY_CONTROL}", Keys.CONTROL);
    value = value.replace("${KEY_CTRL}", Keys.CONTROL);
    value = value.replace("${KEY_META}", Keys.META);
    value = value.replace("${KEY_COMMAND}", Keys.COMMAND);
    value = value.replace("${KEY_SHIFT}", Keys.SHIFT);

    value = value.replace("${KEY_BACKSPACE}", Keys.BACK_SPACE);
    value = value.replace("${KEY_BKSP}", Keys.BACK_SPACE);
    value = value.replace("${KEY_DELETE}", Keys.DELETE);
    value = value.replace("${KEY_DEL}", Keys.DELETE);
    value = value.replace("${KEY_ENTER}", Keys.ENTER);
    value = value.replace("${KEY_EQUALS}", Keys.EQUALS);
    value = value.replace("${KEY_ESCAPE}", Keys.ESCAPE);
    value = value.replace("${KEY_ESC}", Keys.ESCAPE);
    value = value.replace("${KEY_INSERT}", Keys.INSERT);
    value = value.replace("${KEY_INS}", Keys.INSERT);
    value = value.replace("${KEY_PAUSE}", Keys.PAUSE);
    value = value.replace("${KEY_SEMICOLON}", Keys.SEMICOLON);
    value = value.replace("${KEY_SPACE}", Keys.SPACE);
    value = value.replace("${KEY_TAB}", Keys.TAB);

    value = value.replace("${KEY_LEFT}", Keys.LEFT);
    value = value.replace("${KEY_UP}", Keys.UP);
    value = value.replace("${KEY_RIGHT}", Keys.RIGHT);
    value = value.replace("${KEY_DOWN}", Keys.DOWN);
    value = value.replace("${KEY_PAGE_UP}", Keys.PAGE_UP);
    value = value.replace("${KEY_PGUP}", Keys.PAGE_UP);
    value = value.replace("${KEY_PAGE_DOWN}", Keys.PAGE_DOWN);
    value = value.replace("${KEY_PGDN}", Keys.PAGE_DOWN);
    value = value.replace("${KEY_END}", Keys.END);
    value = value.replace("${KEY_HOME}", Keys.HOME);

    value = value.replace("${KEY_NUMPAD0}", Keys.NUMPAD0);
    value = value.replace("${KEY_N0}", Keys.NUMPAD0);
    value = value.replace("${KEY_NUMPAD1}", Keys.NUMPAD1);
    value = value.replace("${KEY_N1}", Keys.NUMPAD1);
    value = value.replace("${KEY_NUMPAD2}", Keys.NUMPAD2);
    value = value.replace("${KEY_N2}", Keys.NUMPAD2);
    value = value.replace("${KEY_NUMPAD3}", Keys.NUMPAD3);
    value = value.replace("${KEY_N3}", Keys.NUMPAD3);
    value = value.replace("${KEY_NUMPAD4}", Keys.NUMPAD4);
    value = value.replace("${KEY_N4}", Keys.NUMPAD4);
    value = value.replace("${KEY_NUMPAD5}", Keys.NUMPAD5);
    value = value.replace("${KEY_N5}", Keys.NUMPAD5);
    value = value.replace("${KEY_NUMPAD6}", Keys.NUMPAD6);
    value = value.replace("${KEY_N6}", Keys.NUMPAD6);
    value = value.replace("${KEY_NUMPAD7}", Keys.NUMPAD7);
    value = value.replace("${KEY_N7}", Keys.NUMPAD7);
    value = value.replace("${KEY_NUMPAD8}", Keys.NUMPAD8);
    value = value.replace("${KEY_N8}", Keys.NUMPAD8);
    value = value.replace("${KEY_NUMPAD9}", Keys.NUMPAD9);
    value = value.replace("${KEY_N9}", Keys.NUMPAD9);
    value = value.replace("${KEY_ADD}", Keys.ADD);
    value = value.replace("${KEY_NUM_PLUS}", Keys.ADD);
    value = value.replace("${KEY_DECIMAL}", Keys.DECIMAL);
    value = value.replace("${KEY_NUM_PERIOD}", Keys.DECIMAL);
    value = value.replace("${KEY_DIVIDE}", Keys.DIVIDE);
    value = value.replace("${KEY_NUM_DIVISION}", Keys.DIVIDE);
    value = value.replace("${KEY_MULTIPLY}", Keys.MULTIPLY);
    value = value.replace("${KEY_NUM_MULTIPLY}", Keys.MULTIPLY);
    value = value.replace("${KEY_SEPARATOR}", Keys.SEPARATOR);
    value = value.replace("${KEY_SEP}", Keys.SEPARATOR);
    value = value.replace("${KEY_SUBTRACT}", Keys.SUBTRACT);
    value = value.replace("${KEY_NUM_MINUS}", Keys.SUBTRACT);

    value = value.replace("${KEY_F1}", Keys.F1);
    value = value.replace("${KEY_F2}", Keys.F2);
    value = value.replace("${KEY_F3}", Keys.F3);
    value = value.replace("${KEY_F4}", Keys.F4);
    value = value.replace("${KEY_F5}", Keys.F5);
    value = value.replace("${KEY_F6}", Keys.F6);
    value = value.replace("${KEY_F7}", Keys.F7);
    value = value.replace("${KEY_F8}", Keys.F8);
    value = value.replace("${KEY_F9}", Keys.F9);
    value = value.replace("${KEY_F10}", Keys.F10);
    value = value.replace("${KEY_F11}", Keys.F11);
    value = value.replace("${KEY_F12}", Keys.F12);

    finder.findElement(driver, locator).sendKeys(value);

    return null;/*from  www .  jav  a2s . co  m*/
}