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.links.AbstractLinkForm.java

License:Open Source License

/**
 * Method for setting an input into the field
 *
 * @param input/*from ww w .j  a  v a2 s  . c o  m*/
 * @param value
 */
private void setInput(final WebElement input, final String value) {
    try {
        input.clear();
        input.sendKeys(value);
    } catch (NoSuchElementException e) {
        throw new ShareException("Unable to find " + input);
    }
}

From source file:org.alfresco.po.share.site.links.AbstractLinkForm.java

License:Open Source License

protected void addTag(final String tag) {
    WebElement tagField = findAndWait(TAG_INPUT);
    tagField.clear();
    tagField.sendKeys(tag);/*from   w ww. ja  v  a  2  s.  c  om*/
    driver.findElement(ADD_TAG_BUTTON).click();
}

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

License:Open Source License

private String clearAndTypeInput(By by, String text) {
    WebElement element = driver.findElement(by);
    element.clear();
    element.sendKeys(text);//  www  .j a  v  a  2 s. c o m

    return getValidationMessage(element);
}

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

License:Open Source License

/**
 * Mimic serach invitation on page./*  w  w w . j  a va 2  s .c  o  m*/
 *
 * @param searchText
 */
public void search(String searchText) {
    checkNotNull(searchText);
    WebElement inputField = findAndWait(SEARCH_FIELD);
    inputField.clear();
    inputField.sendKeys(searchText);
    WebElement searchButton = findAndWait(SEARCH_BTN);
    searchButton.click();
}

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

License:Open Source License

/**
 * Mimic to search for specific user Requested on ManagePendingRequestpage.
 *
 * @param searchText//from ww  w .  ja v  a  2s  .c  om
 */
public PendingInvitesPage searchRequest(String searchText) {
    try {
        checkNotNull(searchText);
        WebElement inputField = findAndWait(REQUEST_SEARCH_FIELD);
        inputField.clear();
        inputField.sendKeys(searchText);
        WebElement searchButton = findAndWait(REQUEST_SEARCH_BTN);
        searchButton.click();
        return this;
    } catch (NoSuchElementException | TimeoutException ne) {
        logger.error("REQUEST_SEARCH_BTN not available : " + REQUEST_SEARCH_BTN.toString());
        throw new PageException("Not able to find the request search button.", ne);
    }

}

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

License:Open Source License

/**
 * Search for a site form action./*from www.  j  a  va2s .  c om*/
 * 
 * @param title String name of site
 * @return HtmlPage page object response
 */
public HtmlPage searchForSite(final String title) {
    if (title == null) {
        throw new IllegalArgumentException("Title can't be null.");
    }
    WebElement input = driver.findElement(By.cssSelector("input[id$='site-finder_x0023_default-term']"));
    input.clear();
    input.sendKeys(title);
    WebElement searchSiteButton = driver.findElement(SEARCH_SUBMIT);
    searchSiteButton.click();
    searchActioned();

    return getCurrentPage();
}

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

License:Open Source License

/**
 * This method search for the given groupName and returns the list of groups.
 *
 * @param groupName String/*from   ww w.j  a va  2 s.com*/
 * @return List<String>
 */
public List<String> searchGroup(String groupName) {
    if (groupName == null) {
        throw new UnsupportedOperationException("GroupName value is required");
    }
    if (logger.isTraceEnabled()) {
        logger.trace("Groups page: searchGroup :" + groupName);
    }
    try {
        WebElement groupRoleSearchTextBox = findAndWait(SEARCH_GROUP_ROLE_TEXT);
        groupRoleSearchTextBox.clear();
        groupRoleSearchTextBox.sendKeys(groupName);

        WebElement searchButton = findAndWait(SEARCH_GROUP_ROLE_BUTTON);
        searchButton.click();
        List<WebElement> list = findAndWaitForElements(LIST_OF_GROUPS, getDefaultWaitTime());
        List<String> groupNamesList = new ArrayList<String>();
        for (WebElement group : list) {
            WebElement groupNameElement = group.findElement(GROUP_NAME_FROM_LIST);
            if (groupNameElement != null && groupNameElement.getText() != null) {
                groupNamesList.add(groupNameElement.getText());
            }
        }
        return groupNamesList;
    } catch (NoSuchElementException e) {
        if (logger.isTraceEnabled()) {
            logger.trace("Unable to find the group list css.", e);
        }
    } catch (TimeoutException e) {
        if (logger.isTraceEnabled()) {
            logger.trace("Time exceeded to find the group list css.", e);
        }
    }
    return Collections.emptyList();
}

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

License:Open Source License

/**
 * This method search for the given userName and returns the list of users.
 *
 * @param userName String//from   ww  w .  j av  a 2 s. c o m
 * @return List<String>
 */
public List<String> searchUser(String userName) {
    if (userName == null) {
        throw new UnsupportedOperationException("UserName value is required");
    }
    if (logger.isTraceEnabled()) {
        logger.trace("Members page: searchUser :" + userName);
    }
    try {
        WebElement userRoleSearchTextBox = driver.findElement(SEARCH_USER_ROLE_TEXT);
        userRoleSearchTextBox.clear();
        userRoleSearchTextBox.sendKeys(userName);

        WebElement searchButton = driver.findElement(SEARCH_USER_ROLE_BUTTON);
        searchButton.click();
        List<WebElement> list = findAndWaitForElements(LIST_OF_USERS, getDefaultWaitTime());
        List<String> userNamesList = new ArrayList<String>();
        for (WebElement user : list) {
            WebElement userNameElement = user.findElement(USER_NAME_FROM_LIST);
            if (userNameElement != null && userNameElement.getText() != null) {
                userNamesList.add(userNameElement.getText());
            }
        }
        return userNamesList;
    } catch (NoSuchElementException e) {
        if (logger.isTraceEnabled()) {
            logger.trace("Unable to find the users list css.", e);
        }
    } catch (TimeoutException e) {
        if (logger.isTraceEnabled()) {
            logger.trace("Time exceeded to find the users list css.", e);
        }
    }
    return Collections.emptyList();
}

From source file:org.alfresco.po.share.site.wiki.WikiPage.java

License:Open Source License

/**
 * Method to rename Wiki Page//w  ww .  j a v  a  2s. c om
 *
 * @param newTitle String
 * @return WikiPage
 */
public WikiPage renameWikiPage(String newTitle) {
    logger.info("Renaming wiki page to" + newTitle);
    try {
        findAndWait(RENAME_BUTTON).click();
        WebElement inputField = findAndWait(By.cssSelector("input[id$='default-renameTo']"));
        inputField.clear();
        inputField.sendKeys(newTitle);
        findAndWait(RENAME_SAVE_BTN).click();
        waitUntilAlert();
        logger.info("Renamed Wiki page");
        return getCurrentPage().render();
    } catch (TimeoutException te) {
        throw new ShareException("The operation has timed out");
    }
}

From source file:org.alfresco.po.share.systemsummary.directorymanagement.EditLdapFrame.java

License:Open Source License

private void fillField(By selector, String text) {
    checkNotNull(selector);//www  .j ava  2 s  . co m
    WebElement inputField = findAndWait(selector);
    inputField.clear();
    if (text != null) {
        inputField.sendKeys(text);
    }
}