Search in sources :

Example 56 with HtmlUnitNYI

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

the class HtmlLabelTest method clickNestedTextArea.

/**
 * @throws Exception if an error occurs
 */
@Test
@Alerts(DEFAULT = { "labelclick", "text1focus", "text1click", "labelclick" }, IE = { "labelclick", "text1click", "labelclick", "text1focus" })
@HtmlUnitNYI(IE = { "labelclick", "text1focus", "text1click", "labelclick" })
public void clickNestedTextArea() throws Exception {
    final String html = "  <label id='label1' onclick='log(\"labelclick\")' onfocus='log(\"labelfocus\")'>Click me" + // we have to add some extra text to make Selenium click the label and not the nested element
    " (we have to add some extra text to make Selenium click the label and not the nested element)\n" + "    <textarea id='text1' onclick='log(\"text1click\")' onfocus='log(\"text1focus\")'></textarea>\n" + "    <textarea id='text2' onclick='log(\"text2click\")' onfocus='log(\"text2focus\")'></textarea>\n" + "  </label>\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 57 with HtmlUnitNYI

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

the class HtmlLabelTest method clickForSelect.

/**
 * @throws Exception if an error occurs
 */
@Test
@Alerts(DEFAULT = { "labelclick", "selectfocus", "selectclick" }, IE = { "labelclick", "selectclick", "selectfocus" })
@HtmlUnitNYI(IE = { "labelclick", "selectfocus", "selectclick" })
public void clickForSelect() throws Exception {
    final String html = "  <label id='label1' for='select1' onclick='log(\"labelclick\")' " + "onfocus='log(\"labelfocus\")'>Click me</label>\n" + "  <select id='select1' onclick='log(\"selectclick\")' " + "onfocus='log(\"selectfocus\")'><option>Option</option></select>\n";
    final WebDriver driver = loadPage2(generatePage(html));
    driver.findElement(By.id("label1")).click();
    verifyTitle2(driver, getExpectedAlerts());
    assertEquals(driver.findElement(By.id("select1")), 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 58 with HtmlUnitNYI

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

the class HTMLDocumentTest method lastModified.

/**
 * Property lastModified returns the last modification date of the document.
 * @throws Exception if the test fails
 */
@Test
@Alerts({ "string", "Fri, 16 Oct 2009 13:59:47 GMT" })
@HtmlUnitNYI(IE = { "string", "Fri, 16 Oct 2009 13:59:47 GMT" })
public void lastModified() throws Exception {
    final List<NameValuePair> responseHeaders = new ArrayList<>();
    responseHeaders.add(new NameValuePair("Last-Modified", "Fri, 16 Oct 2009 13:59:47 GMT"));
    testLastModified(responseHeaders);
    // for some strange reasons, the selenium driven browser is in an invalid
    // state after this test
    releaseResources();
    shutDownAll();
}
Also used : NameValuePair(com.gargoylesoftware.htmlunit.util.NameValuePair) ArrayList(java.util.ArrayList) 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 59 with HtmlUnitNYI

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

the class HTMLIFrameElement2Test method detachAppend.

/**
 * @throws Exception if an error occurs
 */
@Test
@Alerts(DEFAULT = { "iframe script", "loaded", "null", "[object Window]", "about:blank", "iframe script", "loaded" }, IE = { "iframe script", "loaded", "null", "[object Window]", "§§URL§§", "iframe script", "loaded" })
@HtmlUnitNYI(CHROME = { "iframe script", "loaded", "null", "loaded", "[object Window]", "about:blank", "iframe script", "loaded" }, EDGE = { "iframe script", "loaded", "null", "loaded", "[object Window]", "about:blank", "iframe script", "loaded" }, FF = { "iframe script", "loaded", "null", "loaded", "[object Window]", "about:blank", "iframe script", "loaded" }, FF_ESR = { "iframe script", "loaded", "null", "loaded", "[object Window]", "about:blank", "iframe script", "loaded" }, IE = { "iframe script", "loaded", "null", "loaded", "[object Window]", "about:blank", "iframe script", "loaded" })
public void detachAppend() throws Exception {
    final String html = "<html>\n" + "<head><script>\n" + "  function log(msg) {\n" + "    var ta = document.getElementById('myTextArea');\n" + "    ta.value += msg + '; ';\n" + "  }\n" + "  function test() {\n" + "    var myFrame = document.getElementById('i');\n" + "    var parent = myFrame.parentNode;\n" + "    parent.removeChild(myFrame);\n" + "    log(myFrame.contentWindow);\n" + "    parent.appendChild(myFrame);\n" + "    log(myFrame.contentWindow);\n" + "    log(myFrame.contentWindow.location);\n" + "  }\n" + "</script></head>\n" + "  <body>\n" + "    <iframe id='i' onload='log(\"loaded\");' src='" + URL_SECOND + "'></iframe>\n" + "    <textarea id='myTextArea' cols='80' rows='30'></textarea>\n" + "    <button id='clickMe' onclick='test()'>Click Me</button>\n" + "  </body>\n" + "</html>";
    final String html2 = "<html><body>foo<script>parent.log('iframe script');</script></body></html>";
    getMockWebConnection().setResponse(URL_SECOND, html2);
    final WebDriver driver = loadPage2(html);
    Thread.sleep(DEFAULT_WAIT_TIME);
    final int start = getMockWebConnection().getRequestCount();
    driver.findElement(By.id("clickMe")).click();
    Thread.sleep(DEFAULT_WAIT_TIME);
    assertEquals(1, getMockWebConnection().getRequestCount() - start);
    expandExpectedAlertsVariables(URL_SECOND);
    final WebElement textArea = driver.findElement(By.id("myTextArea"));
    assertEquals(String.join("; ", getExpectedAlerts()) + "; ", textArea.getAttribute("value"));
}
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 60 with HtmlUnitNYI

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

the class HtmlScript2Test method deferRemovesScript.

/**
 * @throws Exception if an error occurs
 */
@Test
@Alerts(DEFAULT = { "end", "s0 6", "5", "deferred-1", "deferred-2", "deferred-3", "onload" }, IE = { "end", "s0 6", "5", "deferred-1", "deferred-2", "onload" })
@HtmlUnitNYI(IE = { "end", "s0 6", "5", "deferred-1", "deferred-2", "deferred-3", "onload" })
public void deferRemovesScript() throws Exception {
    final String html = "<html>\n" + "<head>\n" + "  <script>\n" + LOG_TITLE_FUNCTION + "  </script>\n" + "  <script defer id='s0' src='script0.js'></script>\n" + "  <script defer id='s1' src='script1.js'></script>\n" + "  <script defer id='s2' src='script2.js'></script>\n" + "  <script defer id='s3' src='script3.js'></script>\n" + "</head>\n" + "<body onload='log(\"onload\")'>\n" + "</body>\n" + "<script>log('end')</script>\n" + "</html>";
    getMockWebConnection().setResponse(new URL(URL_FIRST, "script0.js"), "log('s0 ' + document.getElementsByTagName('script').length);\n" + "var scr = document.getElementById('s3');\n" + "scr.parentNode.removeChild(scr);\n" + " log(document.getElementsByTagName('script').length);\n");
    getMockWebConnection().setResponse(new URL(URL_FIRST, "script1.js"), "log('deferred-1');");
    getMockWebConnection().setResponse(new URL(URL_FIRST, "script2.js"), "log('deferred-2');");
    getMockWebConnection().setResponse(new URL(URL_FIRST, "script3.js"), "log('deferred-3');");
    loadPageVerifyTitle2(html);
}
Also used : URL(java.net.URL) 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