Created
September 6, 2011 16:58
-
-
Save ajayk/1198169 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package org.openqa.selenium; | |
import static org.openqa.selenium.Ignore.Driver.OPERA; | |
@Ignore(OPERA) | |
public class ClearTest extends AbstractDriverTestCase { | |
public void testWritableTextInputShouldClear() { | |
driver.get(pages.readOnlyPage); | |
WebElement element = driver.findElement(By.id("writableTextInput")); | |
element.clear(); | |
assertEquals("", element.getAttribute("value")); | |
} | |
public void testTextInputShouldNotClearWhenDisabled() { | |
driver.get(pages.readOnlyPage); | |
try { | |
WebElement element = driver.findElement(By.id("textInputnotenabled")); | |
assertEquals(false, element.isEnabled()); | |
element.clear(); | |
assertEquals("Test", element.getAttribute("value")); | |
} catch (ElementNotEditableException e) { | |
// This is expected | |
} | |
} | |
public void testTextInputShouldNotClearWhenReadOnly() { | |
try { | |
driver.get(pages.readOnlyPage); | |
WebElement element = driver.findElement(By.id("readOnlyTextInput")); | |
element.clear(); | |
assertEquals("Test", element.getAttribute("value")); | |
} catch (ElementNotEditableException e) { | |
// This is expected | |
} | |
} | |
public void testWritableTextAreaShouldClear() { | |
driver.get(pages.readOnlyPage); | |
WebElement element = driver.findElement(By.id("writableTextArea")); | |
element.clear(); | |
assertEquals("", element.getAttribute("value")); | |
} | |
public void testTextAreaShouldNotClearWhenDisabled() { | |
try { | |
driver.get(pages.readOnlyPage); | |
WebElement element = driver.findElement(By.id("textAreaNotenabled")); | |
element.clear(); | |
assertEquals("text area which is not supposed to be cleared", element.getAttribute("value")); | |
} catch (ElementNotEditableException e) { | |
// This is expected | |
} | |
} | |
public void testTextAreaShouldNotClearWhenReadOnly() { | |
try { | |
driver.get(pages.readOnlyPage); | |
WebElement element = driver.findElement(By.id("textAreaReadOnly")); | |
element.clear(); | |
assertEquals("text area which is not supposed to be cleared", element.getAttribute("value")); | |
} catch (ElementNotEditableException e) { | |
// This is expected | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment