Search in sources :

Example 61 with HtmlUnitNYI

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());
}
Also used : WebDriver(org.openqa.selenium.WebDriver) WebElement(org.openqa.selenium.WebElement) Test(org.junit.Test) Alerts(com.gargoylesoftware.htmlunit.junit.BrowserRunner.Alerts) HtmlUnitNYI(com.gargoylesoftware.htmlunit.junit.BrowserRunner.HtmlUnitNYI)

Example 62 with HtmlUnitNYI

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());
}
Also used : WebDriver(org.openqa.selenium.WebDriver) WebElement(org.openqa.selenium.WebElement) Test(org.junit.Test) Alerts(com.gargoylesoftware.htmlunit.junit.BrowserRunner.Alerts) HtmlUnitNYI(com.gargoylesoftware.htmlunit.junit.BrowserRunner.HtmlUnitNYI)

Example 63 with HtmlUnitNYI

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());
}
Also used : WebDriver(org.openqa.selenium.WebDriver) JavascriptExecutor(org.openqa.selenium.JavascriptExecutor) WebElement(org.openqa.selenium.WebElement) Test(org.junit.Test) Alerts(com.gargoylesoftware.htmlunit.junit.BrowserRunner.Alerts) HtmlUnitNYI(com.gargoylesoftware.htmlunit.junit.BrowserRunner.HtmlUnitNYI)

Example 64 with HtmlUnitNYI

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());
}
Also used : WebDriver(org.openqa.selenium.WebDriver) WebElement(org.openqa.selenium.WebElement) Test(org.junit.Test) Alerts(com.gargoylesoftware.htmlunit.junit.BrowserRunner.Alerts) HtmlUnitNYI(com.gargoylesoftware.htmlunit.junit.BrowserRunner.HtmlUnitNYI)

Example 65 with HtmlUnitNYI

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]));
}
Also used : WebDriver(org.openqa.selenium.WebDriver) Test(org.junit.Test) Alerts(com.gargoylesoftware.htmlunit.junit.BrowserRunner.Alerts) HtmlUnitNYI(com.gargoylesoftware.htmlunit.junit.BrowserRunner.HtmlUnitNYI)

Aggregations

Alerts (com.gargoylesoftware.htmlunit.junit.BrowserRunner.Alerts)72 HtmlUnitNYI (com.gargoylesoftware.htmlunit.junit.BrowserRunner.HtmlUnitNYI)72 Test (org.junit.Test)68 WebDriver (org.openqa.selenium.WebDriver)54 HtmlPageTest (com.gargoylesoftware.htmlunit.html.HtmlPageTest)14 URL (java.net.URL)14 WebElement (org.openqa.selenium.WebElement)14 BuggyWebDriver (com.gargoylesoftware.htmlunit.junit.BrowserRunner.BuggyWebDriver)11 NameValuePair (com.gargoylesoftware.htmlunit.util.NameValuePair)9 ArrayList (java.util.ArrayList)7 InputStream (java.io.InputStream)5 HtmlUnitDriver (org.openqa.selenium.htmlunit.HtmlUnitDriver)5 Method (java.lang.reflect.Method)2 HashMap (java.util.HashMap)2 Servlet (javax.servlet.Servlet)2 HttpServlet (javax.servlet.http.HttpServlet)2 Page (com.gargoylesoftware.htmlunit.Page)1 UnexpectedPage (com.gargoylesoftware.htmlunit.UnexpectedPage)1 WebWindow (com.gargoylesoftware.htmlunit.WebWindow)1 DomNode (com.gargoylesoftware.htmlunit.html.DomNode)1