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:org.openlmis.pageobjects.ProgramProductISAPage.java

License:Open Source License

public void enterValueInRatioTextField(String ratio) {
    testWebDriver.waitForElementToAppear(ratioTextBox);
    ratioTextBox.sendKeys(Keys.ARROW_RIGHT);
    ratioTextBox.sendKeys(Keys.BACK_SPACE);
    ratioTextBox.sendKeys(ratio);/*from   www. ja v  a  2 s .  co  m*/
}

From source file:org.openmrs.reference.page.ManageProviderPage.java

License:Mozilla Public License

public void setProviderNameOrId(String text) {
    setText(SEARCH_ELEMENT, text);/*from   w  w  w . j a va  2s.c  o  m*/
    findElement(SEARCH_ELEMENT).sendKeys(Keys.BACK_SPACE);
    waitForTextToBePresentInElement(SEARCH_STATUS, text.substring(0, text.length() - 1));
}

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

License:Open Source License

@Test
@IssueTracking("https://issues.jboss.org/browse/RF-14259")
public void testSelectTypeDelete_errorStyleClassWillBeRemoved() {
    selectAttributes.set(SelectAttributes.enableManualInput, Boolean.TRUE);
    WebElement spanElement = select.advanced().getRootElement().findElement(By.tagName("span"));
    // the input has not the error styleClass
    assertFalse(spanElement.getAttribute("class").contains("rf-sel-fld-err"));

    // open select and select the first option
    Graphene.guardAjax(select.openSelect()).select(0);
    assertEquals(output.getText(), "Alabama", "Output should be Alabama");

    // type 'a'// w  w w  . jav a  2 s  .  c  o  m
    select.advanced().getInput().sendKeys("a");
    // the input has the error styleClass
    assertTrue(spanElement.getAttribute("class").contains("rf-sel-fld-err"));
    // no suggestions will be available
    assertEquals(select.advanced().getSuggestionsElements().size(), 0);

    // remove the last character
    select.advanced().getInput().sendKeys(Keys.BACK_SPACE);
    // the input has not the error styleClass
    assertFalse(spanElement.getAttribute("class").contains("rf-sel-fld-err"));
    // all suggestions will be available
    assertEquals(select.advanced().getSuggestionsElements().size(), 50);

    // select the second suggestion
    Graphene.guardAjax(select.openSelect()).select(1);
    assertEquals(output.getText(), "Alaska", "Output should be Alaska");
    // the input has not the error styleClass
    assertFalse(spanElement.getAttribute("class").contains("rf-sel-fld-err"));
}

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

License:Open Source License

@Test
@IssueTracking("https://issues.jboss.org/browse/RF-14254")
public void testTypingUnknownWillNotShowSuggestions() {
    selectAttributes.set(SelectAttributes.enableManualInput, Boolean.TRUE);
    WebElement spanElement = select.advanced().getRootElement().findElement(By.tagName("span"));
    // the input has not error styleClass
    assertFalse(spanElement.getAttribute("class").contains("rf-sel-fld-err"));

    // type 'q' (unknown)
    select.type("q");
    // no suggestions will be available
    assertEquals(select.advanced().getSuggestionsElements().size(), 0);
    spanElement = select.advanced().getRootElement().findElement(By.tagName("span"));
    // the input has error styleClass
    assertTrue(spanElement.getAttribute("class").contains("rf-sel-fld-err"));

    // delete/*from   www. ja  va2  s.c o m*/
    select.advanced().getInput().sendKeys(Keys.BACK_SPACE);
    // all suggestions will be available
    assertEquals(select.advanced().getSuggestionsElements().size(), 50);
    spanElement = select.advanced().getRootElement().findElement(By.tagName("span"));
    // the input has not error styleClass
    assertFalse(spanElement.getAttribute("class").contains("rf-sel-fld-err"));

    // type 'q' (unknown)
    select.type("q");
    // no suggestions will be available
    assertEquals(select.advanced().getSuggestionsElements().size(), 0);
    spanElement = select.advanced().getRootElement().findElement(By.tagName("span"));
    // the input has error styleClass
    assertTrue(spanElement.getAttribute("class").contains("rf-sel-fld-err"));

    // type 'a'
    select.type("a");
    // 4 suggestions will be available
    assertEquals(select.advanced().getSuggestionsElements().size(), 4);
    spanElement = select.advanced().getRootElement().findElement(By.tagName("span"));
    // the input has not error styleClass
    assertFalse(spanElement.getAttribute("class").contains("rf-sel-fld-err"));

    // type 'aq' (unknown)
    select.type("aq");
    // no suggestions will be available
    assertEquals(select.advanced().getSuggestionsElements().size(), 0);
    spanElement = select.advanced().getRootElement().findElement(By.tagName("span"));
    // the input has not error styleClass
    assertTrue(spanElement.getAttribute("class").contains("rf-sel-fld-err"));
}

From source file:org.richfaces.tests.metamer.ftest.richValidator.TestRF13127.java

License:Open Source License

private void checkInputsValidation(List<WebElement> inputs, boolean sendsAjaxOnBlur) {
    Set<Integer> unchangedIndexes = Sets.newHashSet(0, 1, 2, 3, 4, 5, 6, 7, 8, 9);
    Set<Integer> invalidIndexes = Sets.newHashSet();
    int[] testedIndexes = new int[] { 5, 9, 1 };
    WebElement element;/*from w w w. jav  a2s  .  c o  m*/

    for (int index : testedIndexes) {
        element = inputs.get(index);
        element.sendKeys("a");
        blurCurrentInput(sendsAjaxOnBlur);
        unchangedIndexes.remove(index);
        invalidIndexes.add(index);

        for (int i : invalidIndexes) {
            element = inputs.get(i);
            assertTrue(isChanged(element), format("Input at index <{0}> should be changed.", i));
            assertTrue(isInvalid(element), format("Input at index <{0}> should be invalid.", i));
        }
        for (int i : unchangedIndexes) {
            element = inputs.get(i);
            assertFalse(isChanged(element), format("Input at index <{0}> should not be changed.", i));
            assertFalse(isInvalid(element), format("Input at index <{0}> should not be invalid.", i));
            assertFalse(isValid(element), format("Input at index <{0}> should not be valid.", i));
        }
    }
    Set<Integer> validIndexes = Sets.newHashSet();
    for (int index : testedIndexes) {
        element = inputs.get(index);
        element.sendKeys(Keys.BACK_SPACE);
        blurCurrentInput(sendsAjaxOnBlur);
        validIndexes.add(index);
        invalidIndexes.remove(index);

        for (int i : invalidIndexes) {
            element = inputs.get(i);
            assertTrue(isChanged(element), format("Input at index <{0}> should be changed.", i));
            assertTrue(isInvalid(element), format("Input at index <{0}> should be invalid.", i));
        }
        for (int i : unchangedIndexes) {
            element = inputs.get(i);
            assertFalse(isChanged(element), format("Input at index <{0}> should not be changed.", i));
            assertFalse(isInvalid(element), format("Input at index <{0}> should not be invalid.", i));
            assertFalse(isValid(element), format("Input at index <{0}> should not be valid.", i));
        }
        for (int i : validIndexes) {
            element = inputs.get(i);
            assertTrue(isChanged(element), format("Input at index <{0}> should not be changed.", i));
            assertTrue(isValid(element), format("Input at index <{0}> should be valid.", i));
        }
    }
}

From source file:org.richfaces.tests.metamer.ftest.richValidator.TestValidatorEvent.java

License:Open Source License

private void setInvalidValue(TextInputComponentImpl input) {
    // focus//from  ww w.j  a v  a  2  s  . c  o  m
    input.advanced().getInputElement().click();
    keyboard.sendKeys(Keys.BACK_SPACE);
    keyboard.sendKeys("1");
}

From source file:org.richfaces.tests.page.fragments.impl.calendar.common.editor.time.spinner.RichFacesSpinner.java

License:Open Source License

/**
 * Sets spinner value by direct input writing
 * @param value value to be set//from  ww  w .j av  a 2  s .  c  o m
 */
public void setValueByTyping(T value) {
    if (!isSameValueAreadySet(value)) {
        new Actions(driver).click(inputElement).sendKeys(Keys.BACK_SPACE)//delete 1 character from value in input
                .sendKeys(Keys.BACK_SPACE)//delete 1 character from value in input, the input should be clear now
                .sendKeys(value.toString())//set desired value
                .build().perform();
    }
}

From source file:org.richfaces.tests.page.fragments.impl.input.TextInputComponentImpl.java

License:Open Source License

@Override
public TextInputComponent clear(ClearType clearType) {
    int valueLength = root.getAttribute("value").length();
    Actions builder = new Actions(getWebDriver());
    JavascriptExecutor executor = (JavascriptExecutor) getWebDriver();
    switch (clearType) {
    case BACKSPACE:
        for (int i = 0; i < valueLength; i++) {
            builder.sendKeys(root, Keys.BACK_SPACE);
        }/*from  www  .  ja  va2s. c  om*/
        builder.build().perform();
        break;
    case DELETE:
        String ctrlADel = Keys.chord(Keys.CONTROL, "a", Keys.DELETE);
        builder.sendKeys(root, ctrlADel);
        builder.build().perform();
        break;
    case ESCAPE_SQ:
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < valueLength; i++) {
            sb.append("\b");
        }
        root.sendKeys(sb.toString());
        root.click();
        break;
    case JS:
        executor.executeScript("jQuery(arguments[0]).val('')", root);
        break;
    case WD:
        root.clear();
        break;
    default:
        throw new UnsupportedOperationException("Unknown type of clear method " + clearType);
    }
    return this;
}

From source file:org.richfaces.tests.showcase.notify.page.NotifyAttributesPage.java

License:Open Source License

public void setStayTime(long time) {
    inputForStayTime.click();/*from   w ww .j  av a  2s.  c  o m*/
    inputForStayTime.clear();
    inputForStayTime.click();
    actions.sendKeys(inputForStayTime, Keys.BACK_SPACE, Keys.BACK_SPACE, Keys.BACK_SPACE, Keys.DELETE,
            Keys.DELETE, Keys.DELETE, Long.toString(time)).build().perform();
}

From source file:org.safs.selenium.webdriver.lib.WDLibrary.java

License:Open Source License

/**
 * Convert a Java KEYCODE to a Selenium WebDriver Keys Enum
 * @param keycode int, a java keycode/*from  w  w  w .  jav  a 2 s.  c o  m*/
 * @return Keys enum for (primarily) non-printable (control) characters, or null.
 */
public static Keys convertToKeys(int keycode) {
    Keys key = null;
    switch (keycode) {
    case java.awt.event.KeyEvent.VK_ADD:
        key = Keys.ADD;
        break;
    case java.awt.event.KeyEvent.VK_ALT:
        key = Keys.ALT;
        break;
    case java.awt.event.KeyEvent.VK_KP_DOWN:
        key = Keys.ARROW_DOWN;
        break;
    case java.awt.event.KeyEvent.VK_KP_LEFT:
        key = Keys.ARROW_LEFT;
        break;
    case java.awt.event.KeyEvent.VK_KP_RIGHT:
        key = Keys.ARROW_RIGHT;
        break;
    case java.awt.event.KeyEvent.VK_KP_UP:
        key = Keys.ARROW_UP;
        break;
    case java.awt.event.KeyEvent.VK_BACK_SPACE:
        key = Keys.BACK_SPACE;
        break;
    case java.awt.event.KeyEvent.VK_CANCEL:
        key = Keys.CANCEL;
        break;
    case java.awt.event.KeyEvent.VK_CLEAR:
        key = Keys.CLEAR;
        break;
    case java.awt.event.KeyEvent.VK_WINDOWS:
        key = Keys.COMMAND;
        break;
    case java.awt.event.KeyEvent.VK_CONTROL:
        key = Keys.CONTROL;
        break;
    case java.awt.event.KeyEvent.VK_DECIMAL:
        key = Keys.DECIMAL;
        break;
    case java.awt.event.KeyEvent.VK_DELETE:
        key = Keys.DELETE;
        break;
    case java.awt.event.KeyEvent.VK_DIVIDE:
        key = Keys.DIVIDE;
        break;
    case java.awt.event.KeyEvent.VK_DOWN:
        key = Keys.DOWN;
        break;
    case java.awt.event.KeyEvent.VK_END:
        key = Keys.END;
        break;
    case java.awt.event.KeyEvent.VK_ENTER:
        key = Keys.ENTER;
        break;
    case java.awt.event.KeyEvent.VK_EQUALS:
        key = Keys.EQUALS;
        break;
    case java.awt.event.KeyEvent.VK_ESCAPE:
        key = Keys.ESCAPE;
        break;
    case java.awt.event.KeyEvent.VK_F1:
        key = Keys.F1;
        break;
    case java.awt.event.KeyEvent.VK_F2:
        key = Keys.F2;
        break;
    case java.awt.event.KeyEvent.VK_F3:
        key = Keys.F3;
        break;
    case java.awt.event.KeyEvent.VK_F4:
        key = Keys.F4;
        break;
    case java.awt.event.KeyEvent.VK_F5:
        key = Keys.F5;
        break;
    case java.awt.event.KeyEvent.VK_F6:
        key = Keys.F6;
        break;
    case java.awt.event.KeyEvent.VK_F7:
        key = Keys.F7;
        break;
    case java.awt.event.KeyEvent.VK_F8:
        key = Keys.F8;
        break;
    case java.awt.event.KeyEvent.VK_F9:
        key = Keys.F9;
        break;
    case java.awt.event.KeyEvent.VK_F10:
        key = Keys.F10;
        break;
    case java.awt.event.KeyEvent.VK_F11:
        key = Keys.F11;
        break;
    case java.awt.event.KeyEvent.VK_F12:
        key = Keys.F12;
        break;
    case java.awt.event.KeyEvent.VK_HELP:
        key = Keys.HELP;
        break;
    case java.awt.event.KeyEvent.VK_HOME:
        key = Keys.HOME;
        break;
    case java.awt.event.KeyEvent.VK_INSERT:
        key = Keys.INSERT;
        break;
    case java.awt.event.KeyEvent.VK_LEFT:
        key = Keys.LEFT;
        break;
    case java.awt.event.KeyEvent.VK_META:
        key = Keys.META;
        break;
    case java.awt.event.KeyEvent.VK_MULTIPLY:
        key = Keys.MULTIPLY;
        break;
    case java.awt.event.KeyEvent.VK_NUMPAD0:
        key = Keys.NUMPAD0;
        break;
    case java.awt.event.KeyEvent.VK_NUMPAD1:
        key = Keys.NUMPAD1;
        break;
    case java.awt.event.KeyEvent.VK_NUMPAD2:
        key = Keys.NUMPAD2;
        break;
    case java.awt.event.KeyEvent.VK_NUMPAD3:
        key = Keys.NUMPAD3;
        break;
    case java.awt.event.KeyEvent.VK_NUMPAD4:
        key = Keys.NUMPAD4;
        break;
    case java.awt.event.KeyEvent.VK_NUMPAD5:
        key = Keys.NUMPAD5;
        break;
    case java.awt.event.KeyEvent.VK_NUMPAD6:
        key = Keys.NUMPAD6;
        break;
    case java.awt.event.KeyEvent.VK_NUMPAD7:
        key = Keys.NUMPAD7;
        break;
    case java.awt.event.KeyEvent.VK_NUMPAD8:
        key = Keys.NUMPAD8;
        break;
    case java.awt.event.KeyEvent.VK_NUMPAD9:
        key = Keys.NUMPAD9;
        break;
    case java.awt.event.KeyEvent.VK_PAGE_DOWN:
        key = Keys.PAGE_DOWN;
        break;
    case java.awt.event.KeyEvent.VK_PAGE_UP:
        key = Keys.PAGE_UP;
        break;
    case java.awt.event.KeyEvent.VK_PAUSE:
        key = Keys.PAUSE;
        break;
    case java.awt.event.KeyEvent.VK_RIGHT:
        key = Keys.RIGHT;
        break;
    case java.awt.event.KeyEvent.VK_SEMICOLON:
        key = Keys.SEMICOLON;
        break;
    case java.awt.event.KeyEvent.VK_SEPARATOR:
        key = Keys.SEPARATOR;
        break;
    case java.awt.event.KeyEvent.VK_SHIFT:
        key = Keys.SHIFT;
        break;
    case java.awt.event.KeyEvent.VK_SPACE:
        key = Keys.SPACE;
        break;
    case java.awt.event.KeyEvent.VK_SUBTRACT:
        key = Keys.SUBTRACT;
        break;
    case java.awt.event.KeyEvent.VK_TAB:
        key = Keys.TAB;
        break;
    case java.awt.event.KeyEvent.VK_UP:
        key = Keys.UP;
        break;
    }
    return key;
}