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());
}
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());
}
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();
}
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"));
}
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);
}
Aggregations