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.jitsi.meet.test.web.WebParticipant.java

License:Apache License

/**
 * {@inheritDoc}/*from   w w  w  .j  a  va 2s.c  o  m*/
 */
@Override
public void setDisplayName(String name) {
    WebDriver driver = getDriver();

    WebElement elem = driver
            .findElement(By.xpath("//span[@id='localVideoContainer']" + "//span[@id='localDisplayName']"));
    // hover the element before clicking
    Actions actions = new Actions(driver);
    actions.moveToElement(elem);
    actions.perform();

    elem.click();

    WebElement inputElem = driver
            .findElement(By.xpath("//span[@id='localVideoContainer']" + "//input[@id='editDisplayName']"));
    actions = new Actions(driver);
    actions.moveToElement(inputElem);
    actions.perform();

    if (name != null && name.length() > 0) {
        inputElem.sendKeys(name);
    } else {
        inputElem.sendKeys(Keys.BACK_SPACE);
    }

    inputElem.sendKeys(Keys.RETURN);
    // just click somewhere to lose focus, to make sure editing has ended
    MeetUIUtils.clickOnLocalVideo(driver);
}

From source file:org.jspringbot.keyword.selenium.SeleniumHelper.java

License:Open Source License

private String mapAsciiKeyCodeToKey(int keyCode) {
    Map<Integer, Keys> keysMap = new HashMap<Integer, Keys>();
    keysMap.put(0, Keys.NULL);//  w  w  w.  j ava  2 s. c  o m
    keysMap.put(8, Keys.BACK_SPACE);
    keysMap.put(9, Keys.TAB);
    keysMap.put(10, Keys.RETURN);
    keysMap.put(13, Keys.ENTER);
    keysMap.put(24, Keys.CANCEL);
    keysMap.put(27, Keys.ESCAPE);
    keysMap.put(32, Keys.SPACE);
    keysMap.put(42, Keys.MULTIPLY);
    keysMap.put(43, Keys.ADD);
    keysMap.put(44, Keys.SUBTRACT);
    keysMap.put(56, Keys.DECIMAL);
    keysMap.put(57, Keys.DIVIDE);
    keysMap.put(59, Keys.SEMICOLON);
    keysMap.put(61, Keys.EQUALS);
    keysMap.put(127, Keys.DELETE);
    Keys key = keysMap.get(keyCode);

    if (key == null) {
        Character c = (char) keyCode;
        return c.toString();
    }

    return key.toString();
}

From source file:org.kuali.rice.krad.demo.uif.library.controls.DemoControlCheckboxDefaultAft.java

License:Educational Community License

protected void testCheckboxControlEnableWhenChanged() throws Exception {
    navigateToExample("Demo-CheckboxControl-Example8");

    waitForElementPresentById("ST-DemoCheckboxControlExample8-Input1_control");
    waitForElementPresentById("ST-DemoCheckboxControlExample8-Input2_control");
    assertTextPresent("Specifies the property names of fields that when changed, will enable this component");

    // check that checkbox controls is visible, not selected and disabled
    assertTrue(isVisibleById("ST-DemoCheckboxControlExample8-Input2_control"));
    assertFalse(isCheckedById("ST-DemoCheckboxControlExample8-Input2_control"));
    assertFalse(isEnabledById("ST-DemoCheckboxControlExample8-Input2_control"));

    // backspace input1 and remove focus from input1 (by doing an arrow down on the div)
    driver.findElement(By.id("ST-DemoCheckboxControlExample8-Input1_control")).sendKeys(Keys.BACK_SPACE);
    driver.findElement(By.id("Demo-CheckboxControl-Example8")).sendKeys(Keys.ARROW_DOWN);

    // check that checkbox controls is visible, not selected and disabled
    assertTrue(isVisibleById("ST-DemoCheckboxControlExample8-Input2_control"));
    assertFalse(isCheckedById("ST-DemoCheckboxControlExample8-Input2_control"));
    assertFalse(isEnabledById("ST-DemoCheckboxControlExample8-Input2_control"));

    // type "Hello" in input1 and remove focus from input1 (by doing an arrow down on the div)
    driver.findElement(By.id("ST-DemoCheckboxControlExample8-Input1_control")).sendKeys("Hello");
    driver.findElement(By.id("Demo-CheckboxControl-Example8")).sendKeys(Keys.ARROW_DOWN);

    // check that checkbox controls is visible, not selected and enabled
    assertTrue(isVisibleById("ST-DemoCheckboxControlExample8-Input2_control"));
    assertFalse(isCheckedById("ST-DemoCheckboxControlExample8-Input2_control"));
    assertTrue(isEnabledById("ST-DemoCheckboxControlExample8-Input2_control"));
}

From source file:org.kuali.rice.krad.demo.uif.library.controls.DemoControlCheckboxDefaultAft.java

License:Educational Community License

protected void testCheckboxControlDisableWhenChanged() throws Exception {
    navigateToExample("Demo-CheckboxControl-Example9");

    waitForElementPresentById("ST-DemoCheckboxControlExample9-Input1_control");
    waitForElementPresentById("ST-DemoCheckboxControlExample9-Input2_control");
    assertTextPresent("Specifies the property names of fields that when changed, will disable this component");

    // check that checkbox controls is visible, not selected and enabled
    assertTrue(isVisibleById("ST-DemoCheckboxControlExample9-Input2_control"));
    assertFalse(isCheckedById("ST-DemoCheckboxControlExample9-Input2_control"));
    assertTrue(isEnabledById("ST-DemoCheckboxControlExample9-Input2_control"));

    // backspace input1 and remove focus from input1 (by doing an arrow down on the checkbox)
    driver.findElement(By.id("ST-DemoCheckboxControlExample9-Input1_control")).sendKeys(Keys.BACK_SPACE);
    driver.findElement(By.id("Demo-CheckboxControl-Example9")).sendKeys(Keys.ARROW_DOWN);

    // check that checkbox controls is visible, not selected and enabled
    assertTrue(isVisibleById("ST-DemoCheckboxControlExample9-Input2_control"));
    assertFalse(isCheckedById("ST-DemoCheckboxControlExample9-Input2_control"));
    assertTrue(isEnabledById("ST-DemoCheckboxControlExample9-Input2_control"));

    // type "Hello" in input1 and remove focus from input1 (by doing an arrow down on the checkbox)
    driver.findElement(By.id("ST-DemoCheckboxControlExample9-Input1_control")).sendKeys("Hello");
    driver.findElement(By.id("Demo-CheckboxControl-Example9")).sendKeys(Keys.ARROW_DOWN);

    // check that checkbox controls is visible, not selected and disabled
    assertTrue(isVisibleById("ST-DemoCheckboxControlExample9-Input2_control"));
    assertFalse(isCheckedById("ST-DemoCheckboxControlExample9-Input2_control"));
    assertFalse(isEnabledById("ST-DemoCheckboxControlExample9-Input2_control"));
}

From source file:org.kuali.rice.krad.demo.uif.library.controls.LibraryControlCheckboxDefaultAft.java

License:Educational Community License

protected void testCheckboxControlEnableWhenChanged() throws Exception {
    navigateToExample("Demo-CheckboxControl-Example8");

    waitForElementPresentById("ST-DemoCheckboxControlExample8-Input1_control");
    waitForElementPresentById("ST-DemoCheckboxControlExample8-Input2_control");
    assertTextPresent("Specifies the property names of fields that when changed, will enable this component");

    // check that checkbox controls is visible, not selected and disabled
    assertTrue(isVisibleById("ST-DemoCheckboxControlExample8-Input2_control"));
    assertFalse(isCheckedById("ST-DemoCheckboxControlExample8-Input2_control"));
    assertFalse(isEnabledById("ST-DemoCheckboxControlExample8-Input2_control"));

    // backspace input1 and remove focus from input1 (by doing an arrow down on the div)
    driver.findElement(By.id("ST-DemoCheckboxControlExample8-Input1_control")).sendKeys(Keys.BACK_SPACE);
    actionSendKeysArrowDown("Demo-CheckboxControl-Example8");

    // check that checkbox controls is visible, not selected and disabled
    assertTrue(isVisibleById("ST-DemoCheckboxControlExample8-Input2_control"));
    assertFalse(isCheckedById("ST-DemoCheckboxControlExample8-Input2_control"));
    assertFalse(isEnabledById("ST-DemoCheckboxControlExample8-Input2_control"));

    // type "Hello" in input1 and remove focus from input1 (by doing an arrow down on the div)
    driver.findElement(By.id("ST-DemoCheckboxControlExample8-Input1_control")).sendKeys("Hello");
    actionSendKeysArrowDown("Demo-CheckboxControl-Example8");

    // check that checkbox controls is visible, not selected and enabled
    assertTrue(isVisibleById("ST-DemoCheckboxControlExample8-Input2_control"));
    assertFalse(isCheckedById("ST-DemoCheckboxControlExample8-Input2_control"));
    assertTrue(isEnabledById("ST-DemoCheckboxControlExample8-Input2_control"));
}

From source file:org.kuali.rice.krad.demo.uif.library.controls.LibraryControlCheckboxDefaultAft.java

License:Educational Community License

protected void testCheckboxControlDisableWhenChanged() throws Exception {
    navigateToExample("Demo-CheckboxControl-Example9");

    waitForElementPresentById("ST-DemoCheckboxControlExample9-Input1_control");
    waitForElementPresentById("ST-DemoCheckboxControlExample9-Input2_control");
    assertTextPresent("Specifies the property names of fields that when changed, will disable this component");

    // check that checkbox controls is visible, not selected and enabled
    assertTrue(isVisibleById("ST-DemoCheckboxControlExample9-Input2_control"));
    assertFalse(isCheckedById("ST-DemoCheckboxControlExample9-Input2_control"));
    assertTrue(isEnabledById("ST-DemoCheckboxControlExample9-Input2_control"));

    // backspace input1 and remove focus from input1 (by doing an arrow down on the checkbox)
    driver.findElement(By.id("ST-DemoCheckboxControlExample9-Input1_control")).sendKeys(Keys.BACK_SPACE);
    // chrome is giving a WebDriverException: unknown error: cannot focus element error here, when not using Actions
    //        driver.findElement(By.id("Demo-CheckboxControl-Example9")).sendKeys(Keys.ARROW_DOWN);
    actionSendKeysArrowDown("ST-DemoCheckboxControlExample9-Input1_control");

    // check that checkbox controls is visible, not selected and enabled
    assertTrue(isVisibleById("ST-DemoCheckboxControlExample9-Input2_control"));
    assertFalse(isCheckedById("ST-DemoCheckboxControlExample9-Input2_control"));
    assertTrue(isEnabledById("ST-DemoCheckboxControlExample9-Input2_control"));

    // type "Hello" in input1 and remove focus from input1 (by doing an arrow down on the checkbox)
    driver.findElement(By.id("ST-DemoCheckboxControlExample9-Input1_control")).sendKeys("Hello");
    // chrome is giving a WebDriverException: unknown error: cannot focus element error here, when not using Actions
    //        driver.findElement(By.id("Demo-CheckboxControl-Example9")).sendKeys(Keys.ARROW_DOWN);
    actionSendKeysArrowDown("Demo-CheckboxControl-Example9");

    // check that checkbox controls is visible, not selected and disabled
    assertTrue(isVisibleById("ST-DemoCheckboxControlExample9-Input2_control"));
    assertFalse(isCheckedById("ST-DemoCheckboxControlExample9-Input2_control"));
    assertFalse(isEnabledById("ST-DemoCheckboxControlExample9-Input2_control"));
}

From source file:org.kuali.rice.testtools.selenium.JiraIssueCreation.java

License:Educational Community License

@Test
public void testCreateJira() throws InterruptedException, IOException {
    for (Map<String, String> jiraMap : jiraMaps.values()) {

        // Jira//  w  ww.  j  ava 2s  .  c  o m
        WebDriverUtils.waitFor(driver, WebDriverUtils.configuredImplicityWait(), By.id("create_link"),
                this.getClass().toString());
        driver.get(jiraBase + "/secure/CreateIssue!default.jspa");

        // Project
        WebDriverUtils.waitFor(driver, WebDriverUtils.configuredImplicityWait(), By.id("project-field"),
                this.getClass().toString()).sendKeys(jiraMap.get("jira.project"));

        // Issue type
        WebElement issue = WebDriverUtils.waitFor(driver, WebDriverUtils.configuredImplicityWait(),
                By.id("issuetype-field"), this.getClass().toString());
        issue.click();
        issue.sendKeys(Keys.BACK_SPACE);
        issue.sendKeys(jiraMap.get("jira.issuetype"));
        //            issue.sendKeys(Keys.ARROW_DOWN);
        issue.sendKeys(Keys.TAB);

        WebDriverUtils.waitFor(driver, WebDriverUtils.configuredImplicityWait(), By.id("issue-create-submit"),
                this.getClass().toString()).click();

        // Summary // TODO remove things that look like java object references
        // TODO if the error messages are the same for all jiras then include it in the summary
        WebDriverUtils.waitFor(driver, WebDriverUtils.configuredImplicityWait(), By.id("summary"),
                this.getClass().toString()).sendKeys(jiraMap.get("jira.summary"));

        // Components
        WebElement component = WebDriverUtils.waitFor(driver, WebDriverUtils.configuredImplicityWait(),
                By.id("components-textarea"), this.getClass().toString());
        String components = jiraMap.get("jira.component");
        StringTokenizer tokens = new StringTokenizer(components);
        while (tokens.hasMoreElements()) {
            component.click();
            component.sendKeys(tokens.nextToken());
            //                component.sendKeys(Keys.ARROW_DOWN);
            component.sendKeys(Keys.TAB);
        }

        // Description
        WebElement descriptionElement = WebDriverUtils.waitFor(driver, WebDriverUtils.configuredImplicityWait(),
                By.id("description"), this.getClass().toString());
        descriptionElement.click();
        descriptionElement.sendKeys(jiraMap.get("jira.description"));

        // Priority
        WebElement priority = WebDriverUtils.waitFor(driver, WebDriverUtils.configuredImplicityWait(),
                By.id("priority-field"), this.getClass().toString());
        priority.click();
        priority.sendKeys(Keys.BACK_SPACE);
        priority.sendKeys(jiraMap.get("jira.priority"));
        //            priority.sendKeys(Keys.ARROW_DOWN);
        priority.sendKeys(Keys.TAB);

        // Version
        WebElement version = WebDriverUtils.waitFor(driver, WebDriverUtils.configuredImplicityWait(),
                By.id("versions-textarea"), this.getClass().toString());
        version.click();
        version.sendKeys(jiraMap.get("jira.versions"));
        //            version.sendKeys(Keys.ARROW_DOWN);
        version.sendKeys(Keys.TAB);

        // Fix version
        WebElement fixVersion = WebDriverUtils.waitFor(driver, WebDriverUtils.configuredImplicityWait(),
                By.id("fixVersions-textarea"), this.getClass().toString());
        fixVersion.click();
        fixVersion.sendKeys(jiraMap.get("jira.fixVersions"));
        //            fixVersion.sendKeys(Keys.ARROW_DOWN);
        fixVersion.sendKeys(Keys.TAB);

        // Release notes unchecked
        WebDriverUtils.waitFor(driver, WebDriverUtils.configuredImplicityWait(), By.id("customfield_11621-1"),
                this.getClass().toString()).click();

        WebDriverUtils.waitFor(driver, 8, By.id("issue-create-submit"), this.getClass().toString());

        //            WebDriverUtils.acceptAlertIfPresent(driver); // Dialog present when running Se.....
    }
}

From source file:org.neo4j.server.webdriver.WebdriverLibrary.java

License:Open Source License

public void clearInput(ElementReference el) {
    int len = el.getValue().length();

    CharSequence[] backspaces = new CharSequence[len];
    Arrays.fill(backspaces, Keys.BACK_SPACE);

    el.sendKeys(backspaces);//from  w  w w  .j  a  v  a  2  s.c om
}

From source file:org.openfaces.requests.JSFC_2257Test.java

License:LGPL

@Test
public void testTextAreaIsNotAffectedByOpenFacesValidation() throws Exception {
    testAppFunctionalPage("/requests/JSFC_2257.jsf");

    assertPageContainsErrorIcon(false);// ww  w. j  ava 2s .  c  o  m
    TextAreaInspector textArea = new TextAreaInspector("fm:ta");
    textArea.type("Some text");
    ElementInspector button = element("fm:bt");
    button.clickAndWait();
    textArea.assertValue("Some text");
    for (int i = 0; i < "Some text".length(); i++)
        textArea.keyPress(Keys.BACK_SPACE);
    assertPageContainsErrorIcon(false);
    button.click();
    assertPageContainsErrorIcon(true);
}

From source file:org.openfaces.test.ValidationTest.java

License:LGPL

private void fillInvalidDataForClientSideAPI() {
    getDriver().findElement(By.id("testForm:required")).clear();

    CalendarInspector calendar = calendar("testForm:c");
    calendar.selectCalendarCell(1, 6);/*  www . j  a v  a 2s . c  o  m*/
    calendar.selectCalendarCell(2, 6);
    calendar.none().mouseUp();
    dateChooser("testForm:dch").field().clear();
    twoListSelection("testForm:tls").removeAllButton().click();

    DropDownFieldInspector dropDownField = dropDownField("testForm:ddf");
    dropDownField.field().clear();
    dropDownField.field().type("t");
    dropDownField.field().keyPress(Keys.BACK_SPACE);
    element("testForm:fillInvalidData").click();
}