Example usage for org.openqa.selenium WebElement clear

List of usage examples for org.openqa.selenium WebElement clear

Introduction

In this page you can find the example usage for org.openqa.selenium WebElement clear.

Prototype

void clear();

Source Link

Document

If this element is a form entry element, this will reset its value.

Usage

From source file:org.alfresco.po.share.site.CreateSitePage.java

License:Open Source License

/**
 * Set the Name of the site// ww  w . j a v  a 2 s .c  om
 * 
 * @param siteName String site name
 */

public void setSiteName(String siteName) {
    WebElement inputSiteName = findAndWait(INPUT_TITLE);
    inputSiteName.clear();
    inputSiteName.sendKeys(siteName);
    inputSiteName.sendKeys(Keys.TAB);
}

From source file:org.alfresco.po.share.site.CreateSitePage.java

License:Open Source License

/**
 * Set the URL of the site//from   w ww .j  ava2s .  c  om
 * 
 * @param siteURL String site name
 */

public void setSiteURL(String siteURL) {
    WebElement inputSiteURL = driver.findElement(By.name("shortName"));

    inputSiteURL.clear();
    inputSiteURL.sendKeys(siteURL);
    inputSiteURL.sendKeys(Keys.TAB);
}

From source file:org.alfresco.po.share.site.discussions.AbstractTopicForm.java

License:Open Source License

/**
 * Method to set String input in the field
 *
 * @param input WebElement//from   w  w  w. j  a v  a2s. c  o  m
 * @param value String
 */

private void setInput(final WebElement input, final String value) {
    try {
        input.clear();
        input.sendKeys(value);
    } catch (NoSuchElementException e) {
        logger.debug("Unable to find " + input);
    }
}

From source file:org.alfresco.po.share.site.discussions.AbstractTopicForm.java

License:Open Source License

/**
 * Method to add tag// w w  w .  j  a  va2s  .  c  o m
 *
 * @param tag String
 */
protected void addTag(final String tag) {
    try {
        WebElement tagField = findAndWait(TAG_INPUT);
        tagField.clear();
        tagField.sendKeys(tag);
        driver.findElement(ADD_TAG_BUTTON).click();
    } catch (NoSuchElementException e) {
        logger.debug("Unable to find tag input");
    }
}

From source file:org.alfresco.po.share.site.document.AbstractEditProperties.java

License:Open Source License

/**
 * Clear the input field and inserts the new value.
 *
 * @param input {@link WebElement} represents the form input
 * @param value String input value to enter
 *//*  ww w.j  a v a 2 s.com*/
public void setInput(final WebElement input, final String value) {
    input.clear();
    input.sendKeys(value);
}

From source file:org.alfresco.po.share.site.document.CreatePlainTextContentPage.java

License:Open Source License

protected void createContent(ContentDetails details) {
    if (details != null) {
        if (details.getName() != null) {
            WebElement nameElement = driver.findElement(NAME);
            nameElement.clear();
            nameElement.sendKeys(details.getName());
        }//w ww .  j  av  a2 s. co  m

        if (details.getTitle() != null) {
            WebElement titleElement = driver.findElement(TITLE);
            titleElement.clear();
            titleElement.sendKeys(details.getTitle());
        }

        if (details.getDescription() != null) {
            WebElement descriptionElement = driver.findElement(DESCRIPTION);
            descriptionElement.clear();
            descriptionElement.sendKeys(details.getDescription());
        }
        createContentField(details);
    }
}

From source file:org.alfresco.po.share.site.document.CreatePlainTextContentPage.java

License:Open Source License

protected void createContentField(ContentDetails details) {
    if (details != null && details.getContent() != null) {
        WebElement contentElement = driver.findElement(CONTENT);
        contentElement.clear();
        contentElement.sendKeys(details.getContent());
    }/* w ww .j av  a 2 s .c  o  m*/
}

From source file:org.alfresco.po.share.site.document.FileDirectoryInfoImpl.java

License:Open Source License

@Override
public void contentNameEnter(String newContentName) {
    try {/*from w w  w. j a v  a 2  s . c om*/
        WebElement inputBox = findElement(By.cssSelector(INPUT_CONTENT_NAME));
        if (inputBox.isDisplayed()) {
            WebElement inputCOntentName = findAndWait(By.cssSelector(INPUT_CONTENT_NAME));
            inputCOntentName.clear();
            inputCOntentName.sendKeys(newContentName);
            return;
        } else {
            throw new PageException("Input is not displayed displayed");
        }
    } catch (NoSuchElementException e) {
        logger.error("Input should be displayed", e);
        throw new PageOperationException("Input should be displayed");
    }

}

From source file:org.alfresco.po.share.site.document.TagPage.java

License:Open Source License

/**
 * Enter the tag name and click to Add tag.
 *
 * @param tagName String//  www  .j a  va 2 s . c o  m
 * @return HtmlPage
 */
public HtmlPage enterTagValue(String tagName) {
    try {
        WebElement input = findAndWait(ENTER_TAG_VALUE);
        input.clear();
        input.sendKeys(tagName);

        WebElement createButton = findAndWait(CREATE_TAG);
        createButton.click();
        canResume();
        HtmlPage page = getCurrentPage();
        if (page instanceof ShareDialogue) {
            return getCurrentPage();
        }
        return page;
    } catch (NoSuchElementException nse) {
        logger.error("Unable to find the EnterTagName or CreateTag css.", nse);
    }

    throw new PageOperationException("Error in finding the Enter tag value css.");
}

From source file:org.alfresco.po.share.site.InviteMembersPage.java

License:Open Source License

/**
 * This method search for the given userName and returns the list of
 * results./*  ww  w  .  ja v a  2 s.  co m*/
 * 
 * @param userName String identifier
 * @return List<String> list of users
 */

public List<String> searchUser(String userName) {
    if (logger.isTraceEnabled()) {
        logger.trace("Members page: searchUser :" + userName);
    }

    if (userName == null || userName.trim().isEmpty()) {
        throw new UnsupportedOperationException("userName input required");
    }

    try {
        WebElement searchTextBox = findAndWait(By.cssSelector(SEARCH_USER_ROLE_TEXT));
        searchTextBox.clear();
        searchTextBox.sendKeys(userName);

        findAndWait(By.cssSelector(SEARCH_USER_ROLE_BUTTON)).click();
        waitUntilElementDisappears(By.xpath(SEARCH_IS_IN_PROGRESS_BUTTON), 25);

        List<WebElement> users = getListOfInvitees();
        if (users != null && !users.isEmpty()) {
            List<String> userNames = new ArrayList<String>();
            for (WebElement element : users) {
                userNames.add(element.findElement(SEARCH_USER_FROM_LIST).getText());
            }
            return userNames;
        }
    } catch (NoSuchElementException e) {
        if (logger.isTraceEnabled()) {
            logger.trace("Unable to find the username for the userElement.", e);
        }
    }

    return Collections.emptyList();
}