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.integration.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 inputDateTime/outputDateTime components
@Test//w  w  w . j  a  v a  2s  . c  om
public void testDateTimeComponents() throws Exception {
    open(URL);

    // initial load
    WebElement elementInputDate = findDomElement(By.cssSelector(".uiInputDateTime .dateTime-inputDate input"));
    WebElement elementInputTime = findDomElement(By.cssSelector(".uiInputDateTime .dateTime-inputTime input"));
    WebElement elementoutput = findDomElement(By.cssSelector("span[class~='uiOutputDateTime']"));
    assertEquals("InputDateTime component rendered with wrong value", "Oct 23, 2004",
            elementInputDate.getAttribute("value"));
    assertEquals("InputDateTime component rendered with wrong value", "4:30 PM",
            elementInputTime.getAttribute("value"));
    assertEquals("outputDateTime component rendered with wrong value", "Oct 23, 2004 4:30:00 PM",
            elementoutput.getText());

    // Tab out
    elementInputDate.click();
    elementInputDate.clear();
    elementInputTime.clear();
    elementInputDate.sendKeys("Oct 23, 2005");
    getAuraUITestingUtil().pressTab(elementInputDate);
    elementInputTime.click();
    elementInputTime.clear();
    elementInputTime.sendKeys("9:30 AM");
    getAuraUITestingUtil().pressTab(elementInputTime);

    assertEquals("InputDateTime component rendered with wrong value", "Oct 23, 2005",
            elementInputDate.getAttribute("value"));
    assertEquals("InputDateTime component rendered with wrong value", "9:30 AM",
            elementInputTime.getAttribute("value"));
    assertEquals("outputDateTime component rendered with wrong value", "Oct 23, 2005 9:30:00 AM",
            elementoutput.getText());

    // Submit click
    elementInputDate.click();
    elementInputDate.clear();
    elementInputTime.clear();
    elementInputDate.sendKeys("Oct 23, 2006");
    getAuraUITestingUtil().pressTab(elementInputDate);
    elementInputTime.click();
    elementInputTime.clear();
    elementInputTime.sendKeys("9:30 AM");
    getAuraUITestingUtil().pressTab(elementInputTime);
    WebElement elementButton = findDomElement(By.cssSelector("button[title~='DateTime']"));
    elementButton.click();

    assertEquals("InputDateTime component rendered with wrong value", "Oct 23, 2006",
            elementInputDate.getAttribute("value"));
    assertEquals("InputDateTime component rendered with wrong value", "9:30 AM",
            elementInputTime.getAttribute("value"));
    assertEquals("outputDateTime component rendered with wrong value", "Oct 23, 2006 9:30:00 AM",
            elementoutput.getText());
}

From source file:org.auraframework.integration.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 inputNumber/outputNumber components
@Ignore/*  w w w .java2 s .  c om*/
@Test
public void testNumberComponents() throws Exception {
    open(URL);

    // initial load
    WebElement elementInput = findDomElement(By.cssSelector("input[class~='uiInputNumber']"));
    WebElement elementoutput = findDomElement(By.cssSelector("span[class~='uiOutputNumber']"));
    assertEquals("InputNumber component rendered with wrong value", "411", elementInput.getAttribute("value"));
    assertEquals("outputNumber component rendered with wrong value", "411", elementoutput.getText());

    // Tab out
    elementInput.click();
    elementInput.clear();
    elementInput.sendKeys("511");
    getAuraUITestingUtil().pressTab(elementInput);

    assertEquals("InputNumber component rendered with wrong value", "511", elementInput.getAttribute("value"));
    assertEquals("outputNumber component rendered with wrong value", "511", elementoutput.getText());

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

    assertEquals("InputNumber component rendered with wrong value", "611", elementInput.getAttribute("value"));
    assertEquals("outputNumber component rendered with wrong value", "611", elementoutput.getText());
}

From source file:org.auraframework.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 inputDate/outputDate components
public void testDateComponents() throws Exception {
    open(URL);//from   w  w  w  .j  a va  2  s . co m

    // initial load
    WebElement elementInput = findDomElement(By.cssSelector("input[class~='uiInputDate']"));
    WebElement elementoutput = findDomElement(By.cssSelector("span[class~='uiOutputDate']"));
    assertEquals("InputDate component rendered with wrong value", "Sep 23, 2004",
            elementInput.getAttribute("value"));
    assertEquals("outputDate component rendered with wrong value", "Sep 23, 2004", elementoutput.getText());

    // Tab out
    elementInput.click();
    elementInput.clear();
    elementInput.sendKeys("Sep 23, 2005");
    auraUITestingUtil.pressTab(elementInput);

    assertEquals("InputDate component rendered with wrong value", "Sep 23, 2005",
            elementInput.getAttribute("value"));
    assertEquals("outputDate component rendered with wrong value", "Sep 23, 2005", elementoutput.getText());

    // Submit click
    elementInput.click();
    elementInput.clear();
    elementInput.sendKeys("Sep 23, 2006");
    WebElement elementButton = findDomElement(By.cssSelector("button[title~='Date']"));
    elementButton.click();

    assertEquals("InputDate component rendered with wrong value", "Sep 23, 2006",
            elementInput.getAttribute("value"));
    assertEquals("outputDate component rendered with wrong value", "Sep 23, 2006", elementoutput.getText());
}

From source file:org.auraframework.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 inputDateTime/outputDateTime components
public void testDateTimeComponents() throws Exception {
    open(URL);//w w w  .  j  a  v  a  2  s . com

    // initial load
    WebElement elementInput = findDomElement(By.cssSelector("input[class~='uiInputDateTime']"));
    WebElement elementoutput = findDomElement(By.cssSelector("span[class~='uiOutputDateTime']"));
    assertEquals("InputDateTime component rendered with wrong value", "Oct 23, 2004 4:30:00 PM",
            elementInput.getAttribute("value"));
    assertEquals("outputDateTime component rendered with wrong value", "Oct 23, 2004 4:30:00 PM",
            elementoutput.getText());

    // Tab out
    elementInput.click();
    elementInput.clear();
    elementInput.sendKeys("Oct 23, 2005 9:30:00 AM");
    auraUITestingUtil.pressTab(elementInput);

    assertEquals("InputDateTime component rendered with wrong value", "Oct 23, 2005 9:30:00 AM",
            elementInput.getAttribute("value"));
    assertEquals("outputDateTime component rendered with wrong value", "Oct 23, 2005 9:30:00 AM",
            elementoutput.getText());

    // Submit click
    elementInput.click();
    elementInput.clear();
    elementInput.sendKeys("Oct 23, 2006 9:30:00 AM");
    WebElement elementButton = findDomElement(By.cssSelector("button[title~='DateTime']"));
    elementButton.click();

    assertEquals("InputDateTime component rendered with wrong value", "Oct 23, 2006 9:30:00 AM",
            elementInput.getAttribute("value"));
    assertEquals("outputDateTime component rendered with wrong value", "Oct 23, 2006 9:30:00 AM",
            elementoutput.getText());
}

From source file:org.auraframework.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 inputNumber/outputNumber components
public void _testNumberComponents() throws Exception {
    open(URL);/*from www. j a  va2s  .co  m*/

    // initial load
    WebElement elementInput = findDomElement(By.cssSelector("input[class~='uiInputNumber']"));
    WebElement elementoutput = findDomElement(By.cssSelector("span[class~='uiOutputNumber']"));
    assertEquals("InputNumber component rendered with wrong value", "411", elementInput.getAttribute("value"));
    assertEquals("outputNumber component rendered with wrong value", "411", elementoutput.getText());

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

    assertEquals("InputNumber component rendered with wrong value", "511", elementInput.getAttribute("value"));
    assertEquals("outputNumber component rendered with wrong value", "511", elementoutput.getText());

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

    assertEquals("InputNumber component rendered with wrong value", "611", elementInput.getAttribute("value"));
    assertEquals("outputNumber component rendered with wrong value", "611", elementoutput.getText());
}

From source file:org.auraframework.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 inputPercent/outputPercent components
public void testPercentComponents() throws Exception {
    open(URL);//w  w  w  .ja va  2s .c  o  m

    // initial load
    WebElement elementInput = findDomElement(By.cssSelector("input[class~='uiInputPercent']"));
    WebElement elementoutput = findDomElement(By.cssSelector("span[class~='uiOutputPercent']"));
    assertEquals("InputPercent component rendered with wrong value", "1,235%",
            elementInput.getAttribute("value"));
    assertEquals("outputPercent component rendered with wrong value", "1,235%", elementoutput.getText());

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

    assertEquals("InputPercent component rendered with wrong value", ".2235",
            elementInput.getAttribute("value"));
    assertEquals("outputPercent component rendered with wrong value", "22%", elementoutput.getText());

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

    assertEquals("InputPercent component rendered with wrong value", "1.2235",
            elementInput.getAttribute("value"));
    assertEquals("outputPercent component rendered with wrong value", "122%", elementoutput.getText());
}

From source file:org.auraframework.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);//w  w  w. j  av  a2 s .c  om

    // initial load
    WebElement elementInput = findDomElement(
            By.cssSelector("span[id='MyCurrency'] > input[class~='uiInputNumber']"));
    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.AuraNoteUITestCase.java

License:Apache License

protected void sendText(String text, String cssSelector) {
    WebElement e = getElement(cssSelector);
    e.clear();
    e.sendKeys(text);
}

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 inputDate/outputDate components
public void testDateComponents() throws Exception {
    open(URL);//from ww  w.  ja  v a  2s .c  om

    // initial load
    WebElement elementInput = findDomElement(By.cssSelector(".uiInputDate .input"));
    WebElement elementoutput = findDomElement(By.cssSelector(".uiOutputDate"));
    assertEquals("InputDate component rendered with wrong value", "Sep 23, 2004",
            elementInput.getAttribute("value"));
    assertEquals("outputDate component rendered with wrong value", "Sep 23, 2004", elementoutput.getText());

    // Tab out
    elementInput.click();
    elementInput.clear();
    elementInput.sendKeys("Sep 23, 2005");
    auraUITestingUtil.pressTab(elementInput);

    assertEquals("InputDate component rendered with wrong value", "Sep 23, 2005",
            elementInput.getAttribute("value"));
    assertEquals("outputDate component rendered with wrong value", "Sep 23, 2005", elementoutput.getText());

    // Submit click
    elementInput.click();
    elementInput.clear();
    elementInput.sendKeys("Sep 23, 2006");
    WebElement elementButton = findDomElement(By.cssSelector("button[title~='Date']"));
    elementButton.click();

    assertEquals("InputDate component rendered with wrong value", "Sep 23, 2006",
            elementInput.getAttribute("value"));
    assertEquals("outputDate component rendered with wrong value", "Sep 23, 2006", elementoutput.getText());
}

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 inputDateTime/outputDateTime components
public void testDateTimeComponents() throws Exception {
    open(URL);//  w  ww . ja va  2s.  co  m

    // initial load
    WebElement elementInputDate = findDomElement(By.cssSelector(".uiInputDateTime .dateTime-inputDate input"));
    WebElement elementInputTime = findDomElement(By.cssSelector(".uiInputDateTime .dateTime-inputTime input"));
    WebElement elementoutput = findDomElement(By.cssSelector("span[class~='uiOutputDateTime']"));
    assertEquals("InputDateTime component rendered with wrong value", "Oct 23, 2004",
            elementInputDate.getAttribute("value"));
    assertEquals("InputDateTime component rendered with wrong value", "4:30 PM",
            elementInputTime.getAttribute("value"));
    assertEquals("outputDateTime component rendered with wrong value", "Oct 23, 2004 4:30:00 PM",
            elementoutput.getText());

    // Tab out
    elementInputDate.click();
    elementInputDate.clear();
    elementInputTime.clear();
    elementInputDate.sendKeys("Oct 23, 2005");
    auraUITestingUtil.pressTab(elementInputDate);
    elementInputTime.click();
    elementInputTime.clear();
    elementInputTime.sendKeys("9:30 AM");
    auraUITestingUtil.pressTab(elementInputTime);

    assertEquals("InputDateTime component rendered with wrong value", "Oct 23, 2005",
            elementInputDate.getAttribute("value"));
    assertEquals("InputDateTime component rendered with wrong value", "9:30 AM",
            elementInputTime.getAttribute("value"));
    assertEquals("outputDateTime component rendered with wrong value", "Oct 23, 2005 9:30:00 AM",
            elementoutput.getText());

    // Submit click
    elementInputDate.click();
    elementInputDate.clear();
    elementInputTime.clear();
    elementInputDate.sendKeys("Oct 23, 2006");
    auraUITestingUtil.pressTab(elementInputDate);
    elementInputTime.click();
    elementInputTime.clear();
    elementInputTime.sendKeys("9:30 AM");
    auraUITestingUtil.pressTab(elementInputTime);
    WebElement elementButton = findDomElement(By.cssSelector("button[title~='DateTime']"));
    elementButton.click();

    assertEquals("InputDateTime component rendered with wrong value", "Oct 23, 2006",
            elementInputDate.getAttribute("value"));
    assertEquals("InputDateTime component rendered with wrong value", "9:30 AM",
            elementInputTime.getAttribute("value"));
    assertEquals("outputDateTime component rendered with wrong value", "Oct 23, 2006 9:30:00 AM",
            elementoutput.getText());
}