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.auraframework.test.localization.LocalizationAppUITest.java

License:Apache License

@ExcludeBrowsers({ BrowserType.IE9, BrowserType.IE10, BrowserType.SAFARI, BrowserType.ANDROID_PHONE,
        BrowserType.ANDROID_TABLET, BrowserType.IPAD, BrowserType.IPHONE })
// Checking functionality of the inputCurrency/outputCurrency components
public void testCurrencyComponents() throws Exception {
    open(URL);/*www  .  j a v  a2  s .c om*/

    // initial load
    WebElement elementInput = findDomElement(By.cssSelector("span[id='MyCurrency'] > input[class~='uiInput']"));
    WebElement elementoutput = findDomElement(By.cssSelector("span[class~='uiOutputCurrency']"));
    assertEquals("InputCurrency component rendered with wrong value", "$123,456.79",
            elementInput.getAttribute("value"));
    assertEquals("outputCurrency component rendered with wrong value", "$123,456.79", elementoutput.getText());

    // Tab out
    elementInput.click();
    elementInput.clear();
    elementInput.sendKeys("123456");
    auraUITestingUtil.pressTab(elementInput);

    assertEquals("InputCurrency component rendered with wrong value", "123456",
            elementInput.getAttribute("value"));
    assertEquals("outputCurrency component rendered with wrong value", "$123,456.00", elementoutput.getText());

    // Submit click
    elementInput.click();
    elementInput.clear();
    elementInput.sendKeys("123.456");
    WebElement elementButton = findDomElement(By.cssSelector("button[title~='Currency']"));
    elementButton.click();

    assertEquals("InputCurrency component rendered with wrong value", "123.456",
            elementInput.getAttribute("value"));
    assertEquals("outputCurrency component rendered with wrong value", "$123.46", elementoutput.getText());
}

From source file:org.auraframework.test.perf.custom.IterationComponentTest.java

License:Apache License

public void TODO_testChangePageCount() throws Throwable {
    final int pageSize = 25;
    final int pageCount = 20;
    WebElement inputText = currentDriver.findElement(By.cssSelector(".pageCount"));
    inputText.clear();
    inputText.sendKeys(Integer.toString(pageCount));
    WebElement button = currentDriver.findElement(By.cssSelector(".changePageCount"));
    button.click();/*w w  w. java 2  s.  co  m*/

    waitUntil(new ExpectedCondition<Boolean>() {
        @Override
        public Boolean apply(WebDriver d) {
            return d.findElements(By.cssSelector(".container div")).size() > pageCount * pageSize;
        }
    });
}

From source file:org.auraframework.test.perf.custom.RenderIfComponentTest.java

License:Apache License

public void TODO_testChangeCount() throws Throwable {
    // Change number of first level renderIf's to 200.
    final int numberOfRows = 200;
    WebElement inputText = currentDriver.findElement(By.cssSelector(".count"));
    inputText.clear();
    inputText.sendKeys(Integer.toString(numberOfRows));
    WebElement button = currentDriver.findElement(By.cssSelector(".changeCount"));
    button.click();/*  w  w w  .j  a va  2 s .  c  o m*/

    waitUntil(new ExpectedCondition<Boolean>() {
        @Override
        public Boolean apply(WebDriver d) {
            return d.findElements(By.cssSelector(".container div")).size() > numberOfRows;
        }
    });
}

From source file:org.auraframework.test.perf.custom.RenderIfComponentTest.java

License:Apache License

public void TODO_testChangeNestedCount() throws Throwable {
    // Change number of second level renderIf's to 5.
    WebElement inputText = currentDriver.findElement(By.cssSelector(".nestedCount"));
    inputText.clear();
    inputText.sendKeys("5");
    WebElement button = currentDriver.findElement(By.cssSelector(".changeNestedCount"));
    button.click();/* www.j av a 2s. c  om*/
}

From source file:org.auraframework.test.util.AuraUITestingUtil.java

License:Apache License

public WebElement findElementAndTypeEventNameInIt(String event) {
    String locatorTemplate = "input[class*='%s']";
    String locator = String.format(locatorTemplate, event);
    WebElement input = findDomElement(By.cssSelector(locator));
    input.click(); // IE7 need to bring focus
    input.clear();
    input.sendKeys(event);//  w  w  w.j  a  va2  s  . com
    return input;
}

From source file:org.auraframework.throwable.quickfix.CreateAttributeQuickFixUITest.java

License:Apache License

private void setAttributeNameType(String name, String type) {
    By nameCssPath = By.cssSelector("input[name='attName']");
    WebElement nameTextBox = getDriver().findElement(nameCssPath);
    nameTextBox.click();//from  www.j a  v  a2 s . c  o m
    nameTextBox.clear();
    nameTextBox.sendKeys(name);

    By typeCssPath = By.cssSelector("input[name='type']");
    WebElement typeTextBox = getDriver().findElement(typeCssPath);
    typeTextBox.click();
    typeTextBox.clear();
    typeTextBox.sendKeys(type);
}

From source file:org.bigtester.ate.model.page.elementaction.ClearTextAction.java

License:Apache License

/**
 * {@inheritDoc}/*  ww  w .  ja v  a  2s. c  om*/
 */
@Override
public void doAction(final WebElement webElm) {
    if (webElm.isDisplayed()) {
        webElm.clear();
    } else {
        throw GlobalUtils.createNotInitializedException("web element display status wrong");
    }
}

From source file:org.callimachusproject.webdriver.helpers.WebBrowserDriver.java

License:Apache License

public void type(By locator, String text) {
    waitForScript();//from w w w. j  av  a2  s  . c o m
    WebElement element = driver.findElement(locator);
    element.clear();
    sendKeys(element, text);
    // tab to the next element to fire onchange event
    sendKeys(element, Keys.TAB);
}

From source file:org.cerberus.service.engine.impl.WebDriverService.java

License:Open Source License

@Override
public MessageEvent doSeleniumActionType(Session session, Identifier identifier, String property,
        String propertyName) {//from w w  w  .  j  a v a  2  s  .com
    MessageEvent message;
    try {
        AnswerItem answer = this.getSeleniumElement(session, identifier, true, true);
        if (answer.isCodeEquals(MessageEventEnum.ACTION_SUCCESS_WAIT_ELEMENT.getCode())) {
            WebElement webElement = (WebElement) answer.getItem();
            if (webElement != null) {
                webElement.clear();
                if (!StringUtil.isNull(property)) {
                    webElement.sendKeys(property);
                }
                message = new MessageEvent(MessageEventEnum.ACTION_SUCCESS_TYPE);
                message.setDescription(message.getDescription().replaceAll("%ELEMENT%",
                        identifier.getIdentifier() + "=" + identifier.getLocator()));
                if (!StringUtil.isNull(property)) {
                    message.setDescription(message.getDescription().replaceAll("%DATA%",
                            ParameterParserUtil.securePassword(property, propertyName)));
                } else {
                    message.setDescription(message.getDescription().replaceAll("%DATA%", "No property"));
                }
                return message;
            }
        }
        return answer.getResultMessage();
    } catch (NoSuchElementException exception) {
        message = new MessageEvent(MessageEventEnum.ACTION_FAILED_TYPE_NO_SUCH_ELEMENT);
        message.setDescription(message.getDescription().replaceAll("%ELEMENT%",
                identifier.getIdentifier() + "=" + identifier.getLocator()));
        MyLogger.log(WebDriverService.class.getName(), Level.DEBUG, exception.toString());
        return message;
    } catch (WebDriverException exception) {
        message = new MessageEvent(MessageEventEnum.ACTION_FAILED_SELENIUM_CONNECTIVITY);
        MyLogger.log(WebDriverService.class.getName(), Level.FATAL, exception.toString());
        return message;
    }
}