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:OnlineStore.SearchTest.java

/**
* Given an existed product name//from  w  w w.java 2 s .c  o m
* When I search the product
* Then I should see a list of products
*/
@Test
public void searchExistedProduct() {
    driver.get("http://store.demoqa.com/");
    WebElement searchBox = driver.findElement(By.className("search"));
    searchBox.clear();
    searchBox.sendKeys("iphone");
    searchBox.sendKeys(Keys.ENTER);
    driver.manage().timeouts().implicitlyWait(50, TimeUnit.SECONDS);
    WebElement productList = driver.findElement(By.xpath("//*[@id='grid_view_products_page_container']/div"));
    List<WebElement> images = productList.findElements(By.className("item_image"));
    assertTrue(images.size() == 5);
}

From source file:org.alfresco.po.alfresco.RepositoryAdminConsolePage.java

License:Open Source License

/**
 * Populates the input with command and//from w  w w.ja  v a 2 s. c  o  m
 * submits the form.
 * @param command String command
 */
public void sendCommands(final String command) {
    WebElement input = driver.findElement(INPUT_FIELD);
    input.clear();
    input.sendKeys(command);
    driver.findElement(SUBMIT_BUTTON).click();
}

From source file:org.alfresco.po.alfresco.TenantAdminConsolePage.java

License:Open Source License

/**
 * Populates the input with the create tenant command and
 * submits the form.//from ww  w.ja  v a2  s . c o  m
 * @param tenantName String tenant name 
 * @param password String tenant password
 */
public HtmlPage createTenant(String tenantName, String password) {
    WebElement input = driver.findElement(INPUT_FIELD);
    input.clear();
    input.sendKeys(String.format("create %s %s", tenantName, password));
    driver.findElement(SUBMIT_BUTTON).click();
    return this;
}

From source file:org.alfresco.po.alfresco.TenantAdminConsolePage.java

License:Open Source License

/**
 * Method for sending string to command input field.
 *
 * @param command String to pass./*w ww  .  j a  va2 s .c o m*/
 */
public void sendCommands(final String command) {
    if (StringUtils.isEmpty(command)) {
        throw new IllegalArgumentException("Command value is required");
    }
    WebElement input = driver.findElement(INPUT_FIELD);
    input.clear();
    input.sendKeys(String.format("%s", command));
    driver.findElement(SUBMIT_BUTTON).click();
}

From source file:org.alfresco.po.PageElement.java

License:Open Source License

public void clearAndType(By by, String value) {
    if (by == null) {
        throw new IllegalArgumentException("Element Locator Can't be null.");
    }/* www .  jav a2  s.  c o  m*/
    if (value == null) {
        throw new IllegalArgumentException("Value Can't be null.");
    }
    try {
        WebElement element = driver.findElement(by);
        element.click();
        element.clear();
        element.sendKeys(value);
    } catch (TimeoutException e) {
        throw new PageOperationException("Not able to find the element", e);
    }
}

From source file:org.alfresco.po.share.AddUserToGroupForm.java

License:Open Source License

/**
 * Search user//from   w ww  . j  a v  a2 s  .c o m
 *
 * @param user String
 * @return AddUserToGroupForm
 */
public AddUserToGroupForm searchUser(String user) {
    try {
        WebElement searchField = findAndWait(USER_FINDER_INPUT);
        searchField.clear();
        searchField.sendKeys(user);
        findAndWait(USER_SEARCH_BUTTON).click();

    } catch (TimeoutException te) {
        logger.error("Failed to find user search input field");
    }
    return addUserToGroupForm.render();
}

From source file:org.alfresco.po.share.adminconsole.AddCategoryForm.java

License:Open Source License

/**
 * Fill field with name new category.//from   ww w  .j  a  va  2s  . co  m
 *
 * @param text new categoryName
 */
public void fillNameField(String text) {
    checkNotNull(text);
    WebElement inputField = driver.findElement(NAME_INPUT);
    inputField.clear();
    if (text != null) {
        inputField.sendKeys(text);
    }
}

From source file:org.alfresco.po.share.adminconsole.CategoryManagerPage.java

License:Open Source License

private void fillField(By selector, String text) {
    checkNotNull(text);/*from w  w  w  .  j ava  2 s .  c o  m*/
    WebElement inputField = driver.findElement(selector);
    inputField.clear();
    if (text != null) {
        inputField.sendKeys(text);
    }
}

From source file:org.alfresco.po.share.adminconsole.EditTagForm.java

License:Open Source License

/**
 * Fill field with new tag name.//  w  w w. j a v a2  s .com
 *
 * @param text new tag name
 */
public void fillTagField(String text) {
    checkNotNull(text);
    WebElement inputField = findAndWait(RENAME_TAG_INPUT);
    inputField.clear();
    if (text != null) {
        inputField.sendKeys(text);
    }
}

From source file:org.alfresco.po.share.adminconsole.NodeBrowserPage.java

License:Open Source License

private void fillField(By selector, String text) {
    checkNotNull(text);/* w  ww.j a  v a  2 s. c  o  m*/
    WebElement inputField = findAndWait(selector);
    inputField.clear();
    inputField.sendKeys(text);
}