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:net.freifunk.autodeploy.selenium.ActorImpl.java

License:Apache License

@Override
public void typeIntoTextInput(final By by, final String text) {
    LOG.trace("typeIntoTextInput: {}, {}", by, text);
    final WebElement element = getElement(by);
    element.clear();
    Preconditions.checkState(//from   www. j a va 2 s  . com
            "input".equals(element.getTagName()) && "text".equals(element.getAttribute("type")),
            "Element should be a text input: {}", element);
    element.sendKeys(text);
    LOG.trace("typeIntoTextInput done: {}, {}", by, text);
}

From source file:net.freifunk.autodeploy.selenium.ActorImpl.java

License:Apache License

@Override
public void typeIntoPasswordInput(final By by, final String password) {
    LOG.trace("typeIntoPasswordInput: {}, ********", by);
    final WebElement element = getElement(by);
    element.clear();
    Preconditions.checkState(/*ww  w .  j  av a 2 s .  c o m*/
            "input".equals(element.getTagName()) && "password".equals(element.getAttribute("type")),
            "Element should be a password input: {}", element);
    element.sendKeys(password);
    LOG.trace("typeIntoPasswordInput done: {}, ********", by);
}

From source file:net.sourceforge.jwebunit.webdriver.WebDriverTestingEngineImpl.java

License:Open Source License

public void setTextField(String inputName, String text) {
    WebElement e = getTextField(inputName);
    e.clear();
    e.sendKeys(text);
}

From source file:nl.surfnet.coin.selenium.SeleniumSupport.java

License:Apache License

protected void enterText(WebElement element, CharSequence keysToSend) {
    waitForElementDisplay(element);
    element.clear();
    element.sendKeys(keysToSend);
}

From source file:nz.co.testamation.core.client.SeleniumBrowserDriver.java

License:Apache License

public void type(final By by, final Object inputText) {
    System.out.println(String.format("typing '%s' into '%s'", inputText, by));
    waitForVisible(by);//w  ww .  ja  v  a 2s.c om
    WebElement element = findElement(by);
    element.clear();
    element.sendKeys(StringUtil.toNotNullString(inputText));
}

From source file:okw.gui.adapter.selenium.SeInputText.java

License:Open Source License

public void SetValue(ArrayList<String> Val) {
    this.LogFunctionStartDebug("SetValue", "Val", Val.toString());

    try {//from w w w.  ja  va 2 s  .c om
        WebElement myMe = this.Me();
        myMe.clear();
        if (Val.get(0).equals(okw.OKW_Const_Sngltn.getInstance().GetOKWConst4Internalname("DELETE"))) {
            myMe.clear();
        } else {
            myMe.sendKeys(Val.get(0));
        }
    } finally {
        this.LogFunctionEndDebug();
    }

    return;
}

From source file:okw.gui.adapter.selenium.SeTextarea.java

License:Open Source License

public void SetValue(ArrayList<String> Values) {
    this.LogFunctionStartDebug("SetValue", "Val", Values.toString());

    try {/*w w  w. ja v a  2 s  .co m*/

        WebElement myMe = this.Me();
        myMe.clear();

        for (String Value : Values) {
            if (Value.equals(OKW_Const_Sngltn.getInstance().GetOKWConst4Internalname("DELETE"))) {
                myMe.clear();
            } else {
                myMe.sendKeys(Value);
            }
        }
    } finally {
        this.LogFunctionEndDebug();
    }

    return;
}

From source file:OnlineStore.CartTest.java

/**
 * Given 1 iphone5 in the cart/*  ww w.j  a  va2  s.co m*/
 * When I try to update the quantity into 3
 * Then I should see the total price triples
 */
@Test
public void updatePositiveProductQuatity() throws InterruptedException {

    driver.get("http://store.demoqa.com/products-page/product-category/n/");
    driver.findElement(By.name("Buy")).submit();
    driver.manage().timeouts().implicitlyWait(50, TimeUnit.SECONDS);
    driver.get("http://store.demoqa.com/products-page/checkout/");
    WebElement quantity = driver.findElement(By.cssSelector("form.adjustform.qty > input[name=\"quantity\"]"));
    quantity.clear();
    quantity.sendKeys("3");
    WebElement update = driver.findElement(By.cssSelector("form.adjustform.qty > input[name=\"submit\"]"));
    update.click();
    Thread.sleep(50000);
    WebElement price = driver
            .findElement(By.cssSelector("td.wpsc_product_price.wpsc_product_price_0>span>span"));

    String total = price.getText();
    System.out.print(total);
    assertEquals("$36.00", total);
}

From source file:OnlineStore.CartTest.java

/**
* Given 1 iphone5 in the cart//from  www .  j  av a2s .  com
* When I try to update the quantity into -1
* Then I should see error message
*/
@Test
public void updateNegativeProductQuatity() throws InterruptedException {
    driver.get("http://store.demoqa.com/products-page/product-category/n/");
    driver.findElement(By.name("Buy")).submit();
    driver.manage().timeouts().implicitlyWait(50, TimeUnit.SECONDS);
    driver.get("http://store.demoqa.com/products-page/checkout/");
    driver.manage().timeouts().implicitlyWait(50, TimeUnit.SECONDS);
    WebElement quantity = driver.findElement(By.cssSelector("form.adjustform.qty > input[name=\"quantity\"]"));
    quantity.clear();
    quantity.sendKeys("-1");
    WebElement update = driver.findElement(By.cssSelector("form.adjustform.qty > input[name=\"submit\"]"));
    update.click();
    Thread.sleep(50000);
    driver.manage().timeouts().implicitlyWait(50, TimeUnit.SECONDS);
    WebElement msg = driver.findElement(By.xpath("//*[@id='post-29']/div"));
    assertEquals("Oops, there is nothing in your cart.", msg.getText());
}

From source file:OnlineStore.SearchTest.java

/**
* Given a not existed product name/*from w  w  w  .j ava 2s . com*/
* When I search the product
* Then I should see message informing me no result
*/
@Test
public void searchNotExistedProduct() {
    driver.get("http://store.demoqa.com/");
    WebElement searchBox = driver.findElement(By.className("search"));
    searchBox.clear();
    searchBox.sendKeys("Samsung");
    searchBox.sendKeys(Keys.ENTER);
    driver.manage().timeouts().implicitlyWait(50, TimeUnit.SECONDS);
    String ans = "Sorry, but nothing matched your search criteria. Please try again with some different keywords.";
    assertEquals(ans, driver.findElement(By.xpath("//*[@id=\"content\"]/p")).getText());
}