Search in sources :

Example 16 with HtmlUnitNYI

use of com.gargoylesoftware.htmlunit.junit.BrowserRunner.HtmlUnitNYI in project htmlunit by HtmlUnit.

the class HTMLDocumentTest method readyState.

/**
 * @throws Exception if the test fails
 */
@Test
@Alerts(DEFAULT = "complete,[object HTMLBodyElement]-complete,[object HTMLBodyElement]-", FF = "uninitialized,[object HTMLBodyElement]-uninitialized,[object HTMLBodyElement]-", FF_ESR = "uninitialized,[object HTMLBodyElement]-uninitialized,[object HTMLBodyElement]-", IE = "loading,[object HTMLBodyElement]-complete,[object HTMLBodyElement]-")
@HtmlUnitNYI(CHROME = "loading,[object HTMLBodyElement]-complete,[object HTMLBodyElement]-", EDGE = "loading,[object HTMLBodyElement]-complete,[object HTMLBodyElement]-", FF = "loading,[object HTMLBodyElement]-complete,[object HTMLBodyElement]-", FF_ESR = "loading,[object HTMLBodyElement]-complete,[object HTMLBodyElement]-")
public void readyState() throws Exception {
    final String html = "<html>\n" + "<head>\n" + "  <script>\n" + "  var doc;\n" + "  function test() {\n" + "    var iframe = document.createElement('iframe');\n" + "    var textarea = document.getElementById('myTextarea');\n" + "    textarea.parentNode.appendChild(iframe);\n" + "    doc = iframe.contentWindow.document;\n" + "    check();\n" + "    setTimeout(check, 100);\n" + "  }\n" + "  function check() {\n" + "    var textarea = document.getElementById('myTextarea');\n" + "    textarea.value += doc.readyState + ',' + doc.body + '-';\n" + "  }\n" + "  </script>\n" + "</head>\n" + "<body onload='test()'>\n" + "<div>\n" + "  <textarea id='myTextarea' cols='80'></textarea>\n" + "</div>\n" + "</body>\n" + "</html>";
    final WebDriver driver = loadPage2(html);
    Thread.sleep(200);
    final List<String> actual = new LinkedList<>();
    actual.add(driver.findElement(By.id("myTextarea")).getAttribute("value"));
    assertEquals(getExpectedAlerts(), actual);
}
Also used : WebDriver(org.openqa.selenium.WebDriver) BuggyWebDriver(com.gargoylesoftware.htmlunit.junit.BrowserRunner.BuggyWebDriver) LinkedList(java.util.LinkedList) HtmlPageTest(com.gargoylesoftware.htmlunit.html.HtmlPageTest) Test(org.junit.Test) Alerts(com.gargoylesoftware.htmlunit.junit.BrowserRunner.Alerts) HtmlUnitNYI(com.gargoylesoftware.htmlunit.junit.BrowserRunner.HtmlUnitNYI)

Example 17 with HtmlUnitNYI

use of com.gargoylesoftware.htmlunit.junit.BrowserRunner.HtmlUnitNYI in project htmlunit by HtmlUnit.

the class SvgScriptTest method htmlOrSvg.

/**
 * @throws Exception if the test fails
 */
@Test
@Alerts({ "[object SVGScriptElement]", "[object HTMLScriptElement]" })
@HtmlUnitNYI(CHROME = { "[object SVGScriptElement]", "[object SVGScriptElement]" }, EDGE = { "[object SVGScriptElement]", "[object SVGScriptElement]" }, FF = { "[object SVGScriptElement]", "[object SVGScriptElement]" }, FF_ESR = { "[object SVGScriptElement]", "[object SVGScriptElement]" }, IE = { "[object SVGScriptElement]", "[object SVGScriptElement]" })
public void htmlOrSvg() throws Exception {
    final String html = "<svg xmlns='http://www.w3.org/2000/svg' version='1.1'>\n" + "<script id='id1'>\n" + LOG_TITLE_FUNCTION + "  function test() {\n" + "    log(document.getElementById('id1'));\n" + "    log(document.getElementById('id2'));\n" + "  }\n" + "</script>\n" + "<body onload='test()'>\n" + "  <script id='id2'></script>\n" + "</body>\n" + "</svg>";
    final WebDriver driver = loadPageVerifyTitle2(html);
    if (driver instanceof HtmlUnitDriver) {
        final HtmlPage page = (HtmlPage) getWebWindowOf((HtmlUnitDriver) driver).getEnclosedPage();
        assertType(getExpectedAlerts()[0], page.getElementById("id1"));
        assertType(getExpectedAlerts()[1], page.getElementById("id2"));
    }
}
Also used : WebDriver(org.openqa.selenium.WebDriver) HtmlPage(com.gargoylesoftware.htmlunit.html.HtmlPage) HtmlUnitDriver(org.openqa.selenium.htmlunit.HtmlUnitDriver) HtmlPageTest(com.gargoylesoftware.htmlunit.html.HtmlPageTest) Test(org.junit.Test) Alerts(com.gargoylesoftware.htmlunit.junit.BrowserRunner.Alerts) HtmlUnitNYI(com.gargoylesoftware.htmlunit.junit.BrowserRunner.HtmlUnitNYI)

Example 18 with HtmlUnitNYI

use of com.gargoylesoftware.htmlunit.junit.BrowserRunner.HtmlUnitNYI in project htmlunit by HtmlUnit.

the class HtmlLabelTest method clickForInput.

/**
 * @throws Exception if an error occurs
 */
@Test
@Alerts(DEFAULT = { "labelclick", "textfocus", "textclick" }, IE = { "labelclick", "textclick", "textfocus" })
@HtmlUnitNYI(IE = { "labelclick", "textfocus", "textclick" })
public void clickForInput() throws Exception {
    final String html = "  <label id='label1' for='text1' onclick='log(\"labelclick\")' " + "onfocus='log(\"labelfocus\")'>Click me</label>\n" + "  <input type='text' id='text1' onclick='log(\"textclick\")' " + "onfocus='log(\"textfocus\")'>\n";
    final WebDriver driver = loadPage2(generatePage(html));
    driver.findElement(By.id("label1")).click();
    verifyTitle2(driver, getExpectedAlerts());
    assertEquals(driver.findElement(By.id("text1")), driver.switchTo().activeElement());
}
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)

Example 19 with HtmlUnitNYI

use of com.gargoylesoftware.htmlunit.junit.BrowserRunner.HtmlUnitNYI in project htmlunit by HtmlUnit.

the class HtmlOption2Test method getVisibleText.

/**
 * Verifies getVisibleText().
 * @throws Exception if the test fails
 */
@Test
@Alerts(DEFAULT = { "option1", "", "Number Three", "Number 4", "option1\nNumber Three\nNumber 4" }, CHROME = { "option1", "", "Number Three", "Number 4", "      option1\n       Number Three\n      Number 4\n    " }, EDGE = { "option1", "", "Number Three", "Number 4", "      option1\n       Number Three\n      Number 4\n    " }, IE = { "option1", "", "Number Three", "Number 4", "option1 Number Three Number 4" })
@HtmlUnitNYI(CHROME = { "option1", "", "Number Three", "Number 4", "option1\nNumber Three\nNumber 4" }, EDGE = { "option1", "", "Number Three", "Number 4", "option1\nNumber Three\nNumber 4" }, IE = { "option1", "", "Number Three", "Number 4", "option1\nNumber Three\nNumber 4" })
public void getVisibleText() throws Exception {
    final String htmlContent = "<html>\n" + "<head></head>\n" + "<body id='tester'>\n" + "  <form>\n" + "    <select>\n" + "      <option id='option1'>option1</option>\n" + "      <option id='option2' label='Number Two'/>\n" + "      <option id='option3' label='overridden'>Number Three</option>\n" + "      <option id='option4'>Number&nbsp;4</option>\n" + "    </select>\n" + "  </form>\n" + "</body></html>";
    final WebDriver driver = loadPage2(htmlContent);
    String text = driver.findElement(By.id("option1")).getText();
    assertEquals(getExpectedAlerts()[0], text);
    text = driver.findElement(By.id("option2")).getText();
    assertEquals(getExpectedAlerts()[1], text);
    text = driver.findElement(By.id("option3")).getText();
    assertEquals(getExpectedAlerts()[2], text);
    text = driver.findElement(By.id("option4")).getText();
    assertEquals(getExpectedAlerts()[3], text);
    text = driver.findElement(By.id("tester")).getText();
    assertEquals(getExpectedAlerts()[4], text);
    if (driver instanceof HtmlUnitDriver) {
        final HtmlPage page = (HtmlPage) getWebWindowOf((HtmlUnitDriver) driver).getEnclosedPage();
        assertEquals(getExpectedAlerts()[4], page.getElementById("tester").getVisibleText());
    }
}
Also used : WebDriver(org.openqa.selenium.WebDriver) BuggyWebDriver(com.gargoylesoftware.htmlunit.junit.BrowserRunner.BuggyWebDriver) HtmlUnitDriver(org.openqa.selenium.htmlunit.HtmlUnitDriver) Test(org.junit.Test) Alerts(com.gargoylesoftware.htmlunit.junit.BrowserRunner.Alerts) HtmlUnitNYI(com.gargoylesoftware.htmlunit.junit.BrowserRunner.HtmlUnitNYI)

Example 20 with HtmlUnitNYI

use of com.gargoylesoftware.htmlunit.junit.BrowserRunner.HtmlUnitNYI in project htmlunit by HtmlUnit.

the class HtmlNumberInputTest method typeIntegerNegativeValid.

/**
 * @throws Exception if the test fails
 */
@Test
@Alerts(DEFAULT = { "", "--null-false", "-12", "-12--null-true", "-123", "-123--null-false" }, IE = { "", "--null-true", "12", "12--null-true", "123", "123--null-true" })
@HtmlUnitNYI(CHROME = { "-", "--null-false", "-12", "-12--null-true", "-123", "-123--null-false" }, EDGE = { "-", "--null-false", "-12", "-12--null-true", "-123", "-123--null-false" }, FF = { "-", "--null-false", "-12", "-12--null-true", "-123", "-123--null-false" }, FF_ESR = { "-", "--null-false", "-12", "-12--null-true", "-123", "-123--null-false" }, IE = { "-", "--null-false", "-12", "-12--null-true", "-123", "-123--null-false" })
public void typeIntegerNegativeValid() 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='-42' 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());
    input.sendKeys("3");
    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)

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