use of com.gargoylesoftware.htmlunit.junit.BrowserRunner.HtmlUnitNYI in project htmlunit by HtmlUnit.
the class HtmlNumberInputTest method typeCharsAndClear.
/**
* @throws Exception if the test fails
*/
@Test
@Alerts(DEFAULT = { "120", "120-0-0-true", "", "-0-0-true", "", "-0-0-true" }, FF = { "120", "120-0-0-true", "", "-0-0-true", "", "-0-0-false" }, FF_ESR = { "120", "120-0-0-true", "", "-0-0-true", "", "-0-0-false" }, IE = { "012", "012-0-0-true", "", "-0-0-true", "", "-0-0-true" })
@HtmlUnitNYI(FF = { "120", "120-0-0-true", "", "-0-0-true", "abc", "-0-0-false" }, FF_ESR = { "120", "120-0-0-true", "", "-0-0-true", "abc", "-0-0-false" }, IE = { "120", "120-0-0-true", "", "-0-0-true", "abc", "-0-0-false" })
public void typeCharsAndClear() throws Exception {
final String html = "<html>\n" + "<head>\n" + "<script>\n" + " function test() {\n" + " var input = document.getElementById('inpt');\n" + " document.title = input.value + '-' " + "+ input.defaultValue + '-' " + "+ input.getAttribute('value')+ '-' " + "+ input.checkValidity();\n" + " }\n" + "</script>\n" + "</head>\n" + "<body>\n" + " <input type='number' id='inpt' min='0' max='999' value='0' />\n" + " <button id='check' onclick='test()');'>" + "DoIt</button>\n" + "</body>\n" + "</html>";
final WebDriver driver = loadPage2(html);
final WebElement input = driver.findElement(By.id("inpt"));
final WebElement check = driver.findElement(By.id("check"));
input.sendKeys("12");
assertEquals(getExpectedAlerts()[0], input.getAttribute("value"));
check.click();
assertEquals(getExpectedAlerts()[1], driver.getTitle());
input.clear();
assertEquals(getExpectedAlerts()[2], input.getAttribute("value"));
check.click();
assertEquals(getExpectedAlerts()[3], driver.getTitle());
input.sendKeys("abc");
assertEquals(getExpectedAlerts()[4], input.getAttribute("value"));
check.click();
assertEquals(getExpectedAlerts()[5], driver.getTitle());
}
use of com.gargoylesoftware.htmlunit.junit.BrowserRunner.HtmlUnitNYI in project htmlunit by HtmlUnit.
the class HtmlNumberInputTest method typeIntegerNegativeInvalid.
/**
* @throws Exception if the test fails
*/
@Test
@Alerts(DEFAULT = { "", "--null-false", "-12", "-12--null-false" }, IE = { "", "--null-true", "12", "12--null-true" })
@HtmlUnitNYI(CHROME = { "-", "--null-false", "-12", "-12--null-false" }, EDGE = { "-", "--null-false", "-12", "-12--null-false" }, FF = { "-", "--null-false", "-12", "-12--null-false" }, FF_ESR = { "-", "--null-false", "-12", "-12--null-false" }, IE = { "-", "--null-false", "-12", "-12--null-false" })
public void typeIntegerNegativeInvalid() throws Exception {
final String html = "<html>\n" + "<head>\n" + "<script>\n" + " function test() {\n" + " var input = document.getElementById('inpt');\n" + " document.title = input.value + '-' " + "+ input.defaultValue + '-' " + "+ input.getAttribute('value')+ '-' " + "+ input.checkValidity();\n" + " }\n" + "</script>\n" + "</head>\n" + "<body>\n" + " <input type='number' id='inpt' min='1' max='1234'/>\n" + " <button id='check' onclick='test()');'>" + "DoIt</button>\n" + "</body>\n" + "</html>";
final WebDriver driver = loadPage2(html);
final WebElement input = driver.findElement(By.id("inpt"));
final WebElement check = driver.findElement(By.id("check"));
input.sendKeys("-");
assertEquals(getExpectedAlerts()[0], input.getAttribute("value"));
check.click();
assertEquals(getExpectedAlerts()[1], driver.getTitle());
input.sendKeys("12");
assertEquals(getExpectedAlerts()[2], input.getAttribute("value"));
check.click();
assertEquals(getExpectedAlerts()[3], driver.getTitle());
}
use of com.gargoylesoftware.htmlunit.junit.BrowserRunner.HtmlUnitNYI in project htmlunit by HtmlUnit.
the class HtmlNumberInputTest method issue321.
/**
* @throws Exception if the test fails
*/
@Test
@Alerts(DEFAULT = "-0-0-true", FF = "-0-0-false", FF_ESR = "-0-0-false")
@HtmlUnitNYI(IE = "-0-0-false")
public void issue321() throws Exception {
final String html = "<html>\n" + "<head>\n" + "<script>\n" + LOG_TITLE_FUNCTION + " function test() {\n" + " var input = document.getElementById('inpt');\n" + " log(input.value + '-' " + "+ input.defaultValue + '-' " + "+ input.getAttribute('value')+ '-' " + "+ input.checkValidity());\n" + " }\n" + "</script>\n" + "</head>\n" + "<body>\n" + " <input type='number' id='inpt' min='0' max='999' value='0' />\n" + " <button id='check' onclick='test()');'>" + "DoIt</button>\n" + "</body>\n" + "</html>";
final WebDriver driver = loadPage2(html);
final WebElement input = driver.findElement(By.id("inpt"));
input.clear();
input.sendKeys("abc");
((JavascriptExecutor) driver).executeScript("test();");
verifyTitle2(driver, getExpectedAlerts());
}
use of com.gargoylesoftware.htmlunit.junit.BrowserRunner.HtmlUnitNYI in project htmlunit by HtmlUnit.
the class HtmlNumberInputTest method typeIntegerWithDot.
/**
* @throws Exception if the test fails
*/
@Test
@Alerts(DEFAULT = { "1", "1--null-true", "1", "1--null-true", "1.2", "1.2--null-false" }, FF = { "1", "1--null-true", "", "--null-false", "1.2", "1.2--null-false" }, IE = { "1", "1--null-true", "1.", "1.--null-true", "1.2", "1.2--null-false" })
@HtmlUnitNYI(CHROME = { "1", "1--null-true", "1.", "1.--null-true", "1.2", "1.2--null-false" }, EDGE = { "1", "1--null-true", "1.", "1.--null-true", "1.2", "1.2--null-false" }, FF = { "1", "1--null-true", "1.", "--null-false", "1.2", "1.2--null-false" }, FF_ESR = { "1", "1--null-true", "1.", "1.--null-true", "1.2", "1.2--null-false" })
public void typeIntegerWithDot() throws Exception {
final String html = "<html>\n" + "<head>\n" + "<script>\n" + " function test() {\n" + " var input = document.getElementById('inpt');\n" + " document.title = input.value + '-' " + "+ input.defaultValue + '-' " + "+ input.getAttribute('value')+ '-' " + "+ input.checkValidity();\n" + " }\n" + "</script>\n" + "</head>\n" + "<body>\n" + " <input type='number' id='inpt' />\n" + " <button id='check' onclick='test()');'>" + "DoIt</button>\n" + "</body>\n" + "</html>";
final WebDriver driver = loadPage2(html);
final WebElement input = driver.findElement(By.id("inpt"));
final WebElement check = driver.findElement(By.id("check"));
input.sendKeys("1");
assertEquals(getExpectedAlerts()[0], input.getAttribute("value"));
check.click();
assertEquals(getExpectedAlerts()[1], driver.getTitle());
input.sendKeys(".");
assertEquals(getExpectedAlerts()[2], input.getAttribute("value"));
check.click();
assertEquals(getExpectedAlerts()[3], driver.getTitle());
input.sendKeys("2");
assertEquals(getExpectedAlerts()[4], input.getAttribute("value"));
check.click();
assertEquals(getExpectedAlerts()[5], driver.getTitle());
}
use of com.gargoylesoftware.htmlunit.junit.BrowserRunner.HtmlUnitNYI in project htmlunit by HtmlUnit.
the class HtmlForm2Test method buttonWithFormAction.
/**
* @throws Exception if the test fails
*/
@Test
@Alerts(DEFAULT = { "2", "third" }, IE = { "1", "third" })
@HtmlUnitNYI(IE = { "2", "third" })
public void buttonWithFormAction() throws Exception {
final String html = "<!DOCTYPE html>\n" + "<html><head><title>first</title></head>\n" + "<body>\n" + " <p>hello world</p>\n" + " <form id='myForm' action='" + URL_SECOND + "'>\n" + " <button id='myButton' type='submit' formaction='" + URL_THIRD + "'>Submit with different form action</button>\n" + " </form>\n" + "</body></html>";
final String secondContent = "<html><head><title>second</title></head>\n" + "<body>\n" + " <p>hello world</p>\n" + "</body></html>";
final String thirdContent = "<html><head><title>third</title></head>\n" + "<body>\n" + " <p>hello world</p>\n" + "</body></html>";
getMockWebConnection().setResponse(URL_SECOND, secondContent);
getMockWebConnection().setResponse(URL_THIRD, thirdContent);
final WebDriver driver = loadPage2(html);
driver.findElement(By.id("myButton")).click();
assertEquals(Integer.parseInt(getExpectedAlerts()[0]), getMockWebConnection().getRequestCount());
assertTrue(driver.getPageSource().contains(getExpectedAlerts()[1]));
}
Aggregations