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:DesktopChosenIT.java

License:Apache License

/**
 * Tests that we can remove the last option with two backspaces.
 *///ww  w .  j av a  2s  . c  om
@Test
public void doubleBackstroke_removeLastOption() {
    // Given
    loadTestCase(new SimpleMultiValueListBox());
    clickOption(AUDI, RENDERER);
    clickOption(BMW, RENDERER);

    // When
    getInput().sendKeys(Keys.BACK_SPACE);

    // Then last option not disabled
    assertThat(getSelectedOptionTexts())
            .isEqualTo(Lists.newArrayList(RENDERER.render(AUDI), RENDERER.render(BMW)));

    // When
    getInput().sendKeys(Keys.BACK_SPACE);

    // Then
    assertThat(getSelectedOptionTexts()).isEqualTo(Lists.newArrayList(RENDERER.render(AUDI)));
}

From source file:DesktopChosenIT.java

License:Apache License

/**
 * Tests that we can remove the last option with one backspace of the option <code>singleBackstrokeDelete</code> is
 * enabled.// www .ja  v  a2  s . c  o  m
 */
@Test
public void singleBackstrokeDelete_removeLastOption() {
    // Given
    loadTestCase(new SingleBackstrokeDelete());

    // When
    clickOption(AUDI, RENDERER);
    clickOption(BMW, RENDERER);

    // Then
    assertThat(getSelectedOptionTexts())
            .isEqualTo(Lists.newArrayList(RENDERER.render(AUDI), RENDERER.render(BMW)));

    // When
    getInput().sendKeys(Keys.BACK_SPACE);

    // Then
    assertThat(getSelectedOptionTexts()).isEqualTo(Lists.newArrayList(RENDERER.render(AUDI)));
}

From source file:testTheClient.java

@Test
public void removeFilterTest() throws Exception {
    WebElement element = driver.findElement(By.id("filter"));
    element.sendKeys(Keys.BACK_SPACE);
    WebElement tableBody = (new WebDriverWait(driver, WAIT_MAX))
            .until((ExpectedCondition<WebElement>) (WebDriver d) -> {
                return d.findElement(By.tagName("tbody"));
            });/*from   www . j  av  a  2  s. c  o m*/
    List<WebElement> rows = tableBody.findElements(By.tagName("tr"));
    Assert.assertThat(rows.size(), is(5));
}

From source file:Filter2002Test.java

@Test
public void test_2() {
    WebElement filter = driver.findElement(By.id("filter"));
    filter.sendKeys(Keys.BACK_SPACE);
    WebElement table = driver.findElement(By.id("tbodycars"));
    List<WebElement> tableRows = table.findElements(By.tagName("tr"));
    // There should be five rows of data.
    assertThat(tableRows.size(), is(5));
}

From source file:TestWithSelenium.java

@Test
public void vTestClearFilter() {
    //searching for filter & sending key
    WebElement filter = (new WebDriverWait(driver, MAX))
            .until((ExpectedCondition<WebElement>) (WebDriver d) -> {
                return d.findElement(By.id("filter"));
            });/*from w  ww. j  ava2  s  .c o  m*/

    filter.sendKeys(Keys.BACK_SPACE);

    //searching for tbody
    WebElement table = (new WebDriverWait(driver, MAX)).until((ExpectedCondition<WebElement>) (WebDriver d) -> {
        return d.findElement(By.tagName("tbody"));
    });

    //checking whether number of rows is 5
    Assert.assertThat(table.findElements(By.tagName("tr")).size(), is(5));
}

From source file:br.gov.frameworkdemoiselle.behave.runner.webdriver.ui.WebTextField.java

License:Open Source License

/**
 * O mtodo de limpar o campo do WebDriver no funciona corretamente com
 * campos com mscara. Segue abaixo o que esta escrito no javadoc do
 * Webdriver.//  w  w w.ja v a  2s.c  o m
 * 
 * ------------------------------------------------------------------------
 * If this element is a text entry element, this will clear the value. Has
 * no effect on other elements. Text entry elements are INPUT and TEXTAREA
 * elements.
 * 
 * Note that the events fired by this event may not be as you'd expect. In
 * particular, we don't fire any keyboard or mouse events. If you want to
 * ensure keyboard events are fired, consider using something like
 * {@link #sendKeys(CharSequence...)} with the backspace key. To ensure you
 * get a change event, consider following with a call to
 * {@link #sendKeys(CharSequence...)} with the tab key.
 * ------------------------------------------------------------------------
 */
public void clear() {
    waitElement(0);

    // Limpa o campo enviando BACKSPACE
    getElements().get(0).sendKeys(getValueToSend(Keys.chord(Keys.BACK_SPACE)));
}

From source file:ca.nrc.cadc.web.selenium.AbstractTestWebPage.java

License:Open Source License

public void sendKeys(final WebElement webElement, final String value) throws Exception {
    webElement.clear();/*from   w ww. j  a  v  a  2s. c o  m*/
    webElement.sendKeys(Keys.BACK_SPACE);
    webElement.sendKeys(value);
}

From source file:cat.calidos.morfeu.webapp.ui.UIWidget.java

License:Apache License

@SuppressWarnings("unchecked")
public T pressBackspace() {

    WebDriver driver = element.getWrappedDriver();
    Actions actions = new Actions(driver);
    actions.sendKeys(Keys.BACK_SPACE);
    actions.build().perform();//from w  w w .j a va 2s  .co m

    return (T) this;

}

From source file:com.atanas.kanchev.testframework.selenium.handlers.Interact.java

License:Apache License

/**
 * {@inheritDoc}/*  w  w w .  j  a v  a2 s  .  co m*/
 */
@Override
public Interact clear() {
    try {
        ((SeleniumContext) context().getCurrentContext()).getCurrentElement().clear();
        // Fire change event
        ((SeleniumContext) context().getCurrentContext()).getCurrentElement().sendKeys(Keys.BACK_SPACE);
    } catch (NoSuchElementException nsee) {
        logger.error("Clear() : Element not, or within FORM, element");
    }
    return this;
}

From source file:com.coderoad.automation.common.util.old.BasePage.java

License:Open Source License

/**
 * Clear text.
 * 
 * @param fieldName the field name
 */
protected void clearText(WebElement fieldName) {

    fieldName.sendKeys(Keys.SHIFT, Keys.HOME, Keys.BACK_SPACE);
}