Search in sources :

Example 26 with NotYetImplemented

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

the class HtmlIsIndex2Test method simpleScriptable.

/**
 * @throws Exception if the test fails
 */
@Test
@Alerts(DEFAULT = "[object HTMLUnknownElement]", IE = "null")
@NotYetImplemented(IE)
public void simpleScriptable() throws Exception {
    final String html = "<html><head>\n" + "<script>\n" + LOG_TITLE_FUNCTION + "  function test() {\n" + "    log(document.getElementById('myId'));\n" + "  }\n" + "</script>\n" + "</head>\n" + "<body onload='test()'>\n" + "  <form id='form1' method='post'>\n" + "    <isindex id='myId' prompt='enterSomeText'></isindex>\n" + "  </form>\n" + "</body></html>";
    final WebDriver driver = loadPageVerifyTitle2(html);
    if (driver instanceof HtmlUnitDriver) {
        final HtmlPage page = (HtmlPage) getWebWindowOf((HtmlUnitDriver) driver).getEnclosedPage();
        assertTrue(HtmlUnknownElement.class.isInstance(page.getHtmlElementById("myId")));
    }
}
Also used : WebDriver(org.openqa.selenium.WebDriver) HtmlUnitDriver(org.openqa.selenium.htmlunit.HtmlUnitDriver) NotYetImplemented(com.gargoylesoftware.htmlunit.junit.BrowserRunner.NotYetImplemented) Test(org.junit.Test) Alerts(com.gargoylesoftware.htmlunit.junit.BrowserRunner.Alerts)

Example 27 with NotYetImplemented

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

the class Event3Test method ie_EventBubbling.

/**
 * Test for event bubbling in IE.
 * @throws Exception if the test fails
 */
@Test
// TODO: in IE no click event can be registered for the window
@NotYetImplemented
@Alerts({ "span bubbling", "div", "div bubbling" })
public void ie_EventBubbling() throws Exception {
    final String content = "<html><head><title>foo</title>\n" + "<script>\n" + "function t(_s) {\n" + "  return function() { alert(_s) };\n" + "}\n" + "function init() {\n" + "  window.attachEvent('onclick', t('window bubbling'));\n" + "  var oDiv = document.getElementById('theDiv');\n" + "  oDiv.attachEvent('onclick', t('div bubbling'));\n" + "  var oSpan = document.getElementById('theSpan');\n" + "  oSpan.attachEvent('onclick', t('span bubbling'));\n" + "}\n" + "</script>\n" + "</head><body onload='init()'>\n" + "<div onclick=\"alert('div')\" id='theDiv'>\n" + "<span id='theSpan'>blabla</span>\n" + "</div>\n" + "</body></html>";
    final List<String> collectedAlerts = new ArrayList<>();
    final HtmlPage page = loadPage(content, collectedAlerts);
    page.getHtmlElementById("theSpan").click();
    assertEquals(getExpectedAlerts(), collectedAlerts);
}
Also used : HtmlPage(com.gargoylesoftware.htmlunit.html.HtmlPage) ArrayList(java.util.ArrayList) NotYetImplemented(com.gargoylesoftware.htmlunit.junit.BrowserRunner.NotYetImplemented) Test(org.junit.Test) Alerts(com.gargoylesoftware.htmlunit.junit.BrowserRunner.Alerts)

Example 28 with NotYetImplemented

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

the class EventTest method document_focus.

/**
 * @throws Exception if the test fails
 */
@Test
@Alerts(DEFAULT = "activeElement BODY", FF = { "activeElement BODY", "focus #document", "handler: activeElement BODY" }, FF_ESR = { "activeElement BODY", "focus #document", "handler: activeElement BODY" }, IE = { "activeElement BODY", "focus BODY", "handler: activeElement BODY" })
// http://code.google.com/p/selenium/issues/detail?id=4665
@NotYetImplemented({ IE, FF, FF_ESR })
public void document_focus() throws Exception {
    final String html = "<html>\n" + "<head>\n" + "<script>\n" + "  function test() {\n" + "    handle(document);\n" + "    log('activeElement ' + document.activeElement.nodeName);\n" + "  }\n" + "  function handle(obj) {\n" + "    obj.addEventListener('focus', handler, true);\n" + "  }\n" + "  function handler(e) {\n" + "    var src = e.srcElement;\n" + "    if (!src)\n" + "      src = e.target;\n" + "    log(e.type + ' ' + src.nodeName);\n" + "    log('handler: activeElement ' + document.activeElement.nodeName);\n" + "  }\n" + "  function log(x) {\n" + "    document.getElementById('log').value += x + '\\n';\n" + "  }\n" + "</script>\n" + "</head>\n" + "<body onload='test()'>\n" + "  <textarea id='log' cols='80' rows='40'></textarea>\n" + "</body></html>";
    final WebDriver driver = loadPage2(html);
    final String text = driver.findElement(By.id("log")).getAttribute("value").trim().replaceAll("\r", "");
    assertEquals(String.join("\n", getExpectedAlerts()), text);
}
Also used : WebDriver(org.openqa.selenium.WebDriver) NotYetImplemented(com.gargoylesoftware.htmlunit.junit.BrowserRunner.NotYetImplemented) HtmlPageTest(com.gargoylesoftware.htmlunit.html.HtmlPageTest) Test(org.junit.Test) Alerts(com.gargoylesoftware.htmlunit.junit.BrowserRunner.Alerts)

Example 29 with NotYetImplemented

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

the class XMLDocumentTest method svg.

/**
 * @throws Exception if the test fails
 */
@Test
@Alerts(DEFAULT = "[object XMLDocument]", IE = "[object Document]")
@NotYetImplemented
public void svg() throws Exception {
    final String svg = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n" + "<svg xmlns=\"http://www.w3.org/2000/svg\">\n" + "  <rect id=\"rect\" width=\"50\" height=\"50\" fill=\"green\" onclick=\"alert(document)\"/>\n" + "</svg>";
    final WebDriver driver = loadPage2(svg, URL_FIRST, MimeType.TEXT_XML, ISO_8859_1);
    driver.findElement(By.id("rect")).click();
    verifyAlerts(driver, getExpectedAlerts());
}
Also used : WebDriver(org.openqa.selenium.WebDriver) NotYetImplemented(com.gargoylesoftware.htmlunit.junit.BrowserRunner.NotYetImplemented) Test(org.junit.Test) Alerts(com.gargoylesoftware.htmlunit.junit.BrowserRunner.Alerts)

Example 30 with NotYetImplemented

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

the class XMLHttpRequest3Test method streaming.

/**
 * Regression test for bug 1209686 (onreadystatechange not called with partial data when emulating FF).
 * @throws Exception if an error occurs
 */
@Test
@NotYetImplemented
public void streaming() throws Exception {
    final Map<String, Class<? extends Servlet>> servlets = new HashMap<>();
    servlets.put("/test", StreamingServlet.class);
    final String resourceBase = "./src/test/resources/com/gargoylesoftware/htmlunit/javascript/host";
    startWebServer(resourceBase, null, servlets);
    final WebClient client = getWebClient();
    final HtmlPage page = client.getPage(URL_FIRST + "XMLHttpRequestTest_streaming.html");
    assertEquals(0, client.waitForBackgroundJavaScriptStartingBefore(1000));
    final HtmlElement body = page.getBody();
    assertEquals(10, body.asNormalizedText().split("\n").length);
}
Also used : HashMap(java.util.HashMap) HtmlPage(com.gargoylesoftware.htmlunit.html.HtmlPage) HtmlElement(com.gargoylesoftware.htmlunit.html.HtmlElement) StreamingServlet(com.gargoylesoftware.htmlunit.javascript.host.xml.XMLHttpRequestTest.StreamingServlet) HttpServlet(javax.servlet.http.HttpServlet) Servlet(javax.servlet.Servlet) WebClient(com.gargoylesoftware.htmlunit.WebClient) NotYetImplemented(com.gargoylesoftware.htmlunit.junit.BrowserRunner.NotYetImplemented) Test(org.junit.Test)

Aggregations

NotYetImplemented (com.gargoylesoftware.htmlunit.junit.BrowserRunner.NotYetImplemented)66 Test (org.junit.Test)65 Alerts (com.gargoylesoftware.htmlunit.junit.BrowserRunner.Alerts)54 WebDriver (org.openqa.selenium.WebDriver)54 HtmlPageTest (com.gargoylesoftware.htmlunit.html.HtmlPageTest)16 URL (java.net.URL)15 BuggyWebDriver (com.gargoylesoftware.htmlunit.junit.BrowserRunner.BuggyWebDriver)12 WebElement (org.openqa.selenium.WebElement)11 ArrayList (java.util.ArrayList)6 HtmlPage (com.gargoylesoftware.htmlunit.html.HtmlPage)5 HtmlUnitDriver (org.openqa.selenium.htmlunit.HtmlUnitDriver)5 MockWebConnection (com.gargoylesoftware.htmlunit.MockWebConnection)4 MSXMLTestHelper.callLoadXMLDOMDocumentFromString (com.gargoylesoftware.htmlunit.activex.javascript.msxml.MSXMLTestHelper.callLoadXMLDOMDocumentFromString)4 NameValuePair (com.gargoylesoftware.htmlunit.util.NameValuePair)4 WebClient (com.gargoylesoftware.htmlunit.WebClient)3 InputStream (java.io.InputStream)3 CollectingAlertHandler (com.gargoylesoftware.htmlunit.CollectingAlertHandler)2 MSXMLTestHelper.callSerializeXMLDOMDocumentToString (com.gargoylesoftware.htmlunit.activex.javascript.msxml.MSXMLTestHelper.callSerializeXMLDOMDocumentToString)2 HtmlElement (com.gargoylesoftware.htmlunit.html.HtmlElement)2 File (java.io.File)2