use of com.gargoylesoftware.htmlunit.junit.BrowserRunner.Alerts in project htmlunit by HtmlUnit.
the class HtmlRangeInputTest method clearInput.
/**
* @throws Exception if the test fails
*/
@Test
@Alerts("50")
public void clearInput() throws Exception {
final String html = "<html>\n" + "<body>\n" + "<form>\n" + " <input type='range' id='tester' value='42'>\n" + "</form>\n" + "</body>\n" + "</html>";
final WebDriver driver = loadPage2(html);
final WebElement element = driver.findElement(By.id("tester"));
element.clear();
assertEquals(getExpectedAlerts()[0], element.getAttribute("value"));
}
use of com.gargoylesoftware.htmlunit.junit.BrowserRunner.Alerts in project htmlunit by HtmlUnit.
the class HtmlResetInput2Test method onclickDisables.
/**
* @throws Exception if the test fails
*/
@Test
@Alerts({ "foo", "foonewValue", "foonewValue" })
public void onclickDisables() throws Exception {
final String html = "<html><head>\n" + " <script type='text/javascript'>\n" + " function submitForm() {\n" + " document.deliveryChannelForm.resetBtn.disabled = true;\n" + " }\n" + " </script>\n" + "</head>\n" + "<body>\n" + " <form action='test' name='deliveryChannelForm'>\n" + " <input type='text' id='textfield' value='foo'/>\n" + " <input name='resetBtn' type='reset' value='Save' title='Save' onclick='submitForm();'>\n" + " </form>" + "</script>\n" + "</body></html>";
final WebDriver webDriver = loadPage2(html);
final WebElement textfield = webDriver.findElement(By.id("textfield"));
assertEquals(getExpectedAlerts()[0], textfield.getAttribute("value"));
textfield.sendKeys("newValue");
assertEquals(getExpectedAlerts()[1], textfield.getAttribute("value"));
final WebElement reset = webDriver.findElement(By.name("resetBtn"));
reset.click();
assertEquals(getExpectedAlerts()[2], textfield.getAttribute("value"));
}
use of com.gargoylesoftware.htmlunit.junit.BrowserRunner.Alerts in project htmlunit by HtmlUnit.
the class HtmlResetInput2Test method reset.
/**
* @throws Exception if the test fails
*/
@Test
@Alerts({ "foo", "foonewValue", "foo" })
public void reset() throws Exception {
final String html = "<html><head>\n" + " <script type='text/javascript'>\n" + " function submitForm() {\n" + " }\n" + " </script>\n" + "</head>\n" + "<body>\n" + " <form action='test' name='deliveryChannelForm'>\n" + " <input type='text' id='textfield' value='foo'/>\n" + " <input name='resetBtn' type='reset' value='Save' title='Save' onclick='submitForm();'>\n" + " </form>" + "</script>\n" + "</body></html>";
final WebDriver webDriver = loadPage2(html);
final WebElement textfield = webDriver.findElement(By.id("textfield"));
assertEquals(getExpectedAlerts()[0], textfield.getAttribute("value"));
textfield.sendKeys("newValue");
assertEquals(getExpectedAlerts()[1], textfield.getAttribute("value"));
final WebElement reset = webDriver.findElement(By.name("resetBtn"));
reset.click();
assertEquals(getExpectedAlerts()[2], textfield.getAttribute("value"));
}
use of com.gargoylesoftware.htmlunit.junit.BrowserRunner.Alerts in project htmlunit by HtmlUnit.
the class HtmlPasswordInputTest method minLengthValidationValid.
/**
* @throws Exception if an error occurs
*/
@Test
@Alerts({ "abcdefghi", "§§URL§§second/", "2" })
public void minLengthValidationValid() throws Exception {
final String html = "<!DOCTYPE html>\n" + "<html><head></head>\n" + "<body>\n" + " <form id='myForm' action='" + URL_SECOND + "' method='" + HttpMethod.POST + "'>\n" + " <input type='password' minlength='5' id='foo'>\n" + " <button id='myButton' type='submit'>Submit</button>\n" + " </form>\n" + "</body></html>";
final String secondContent = "<html><head><title>second</title></head><body>\n" + " <p>hello world</p>\n" + "</body></html>";
getMockWebConnection().setResponse(URL_SECOND, secondContent);
expandExpectedAlertsVariables(URL_FIRST);
final WebDriver driver = loadPage2(html, URL_FIRST);
final WebElement foo = driver.findElement(By.id("foo"));
foo.sendKeys("abcdefghi");
assertEquals(getExpectedAlerts()[0], foo.getAttribute("value"));
// valid data
driver.findElement(By.id("myButton")).click();
assertEquals(getExpectedAlerts()[1], getMockWebConnection().getLastWebRequest().getUrl());
assertEquals(Integer.parseInt(getExpectedAlerts()[2]), getMockWebConnection().getRequestCount());
}
use of com.gargoylesoftware.htmlunit.junit.BrowserRunner.Alerts in project htmlunit by HtmlUnit.
the class HtmlPasswordInputTest method typeDoesNotChangeValueAttribute.
/**
* @throws Exception if the test fails
*/
@Test
@Alerts({ "null", "null" })
public void typeDoesNotChangeValueAttribute() throws Exception {
final String html = "<html>\n" + "<head></head>\n" + "<body>\n" + " <input type='password' id='p'/>\n" + " <button id='check' onclick='alert(document.getElementById(\"p\").getAttribute(\"value\"));'>" + "DoIt</button>\n" + "</body></html>";
final WebDriver driver = loadPage2(html);
final WebElement p = driver.findElement(By.id("p"));
final WebElement check = driver.findElement(By.id("check"));
check.click();
verifyAlerts(driver, getExpectedAlerts()[0]);
p.sendKeys("abc");
check.click();
verifyAlerts(driver, getExpectedAlerts()[1]);
}
Aggregations