use of com.gargoylesoftware.htmlunit.junit.BrowserRunner.NotYetImplemented in project htmlunit by HtmlUnit.
the class HtmlElement2Test method removeParentOfActiveElement.
/**
* @throws Exception on test failure
*/
@Test
@Alerts(DEFAULT = "[object HTMLInputElement] [object HTMLBodyElement]", CHROME = "[object HTMLInputElement] onblur1 onfocusout1 [object HTMLBodyElement]", EDGE = "[object HTMLInputElement] onblur1 onfocusout1 [object HTMLBodyElement]", IE = "[object HTMLInputElement] null")
@NotYetImplemented(IE)
public void removeParentOfActiveElement() throws Exception {
final String html = HtmlPageTest.STANDARDS_MODE_PREFIX_ + "<html>\n" + "<head>\n" + "<script>\n" + "function test() {\n" + " var elem = document.getElementById('text1');\n" + " elem.focus();\n" + " document.title += ' ' + document.activeElement;\n" + " var elem = document.getElementById('parent');\n" + " elem.parentNode.removeChild(elem);\n" + " document.title += ' ' + document.activeElement;\n" + "}\n" + "</script>\n" + "</head>\n" + "<body onload='test()'>\n" + "<form name='form1'>\n" + " <div id='parent'>\n" + " <input id='text1' onblur='document.title += \" onblur1\"' " + "onfocusout='document.title += \" onfocusout1\"'>\n" + " <input id='text2' onblur='document.title += \" onblur2\"' " + "onfocusout='document.title += \" onfocusout2\"'>\n" + " </div>\n" + "</form>\n" + "</body></html>";
final WebDriver driver = loadPage2(html);
assertTitle(driver, getExpectedAlerts()[0]);
}
use of com.gargoylesoftware.htmlunit.junit.BrowserRunner.NotYetImplemented in project htmlunit by HtmlUnit.
the class HtmlElement2Test method removeActiveElement.
/**
* @throws Exception on test failure
*/
@Test
@Alerts(DEFAULT = "[object HTMLInputElement] [object HTMLBodyElement]", CHROME = "[object HTMLInputElement] onblur onfocusout [object HTMLBodyElement]", EDGE = "[object HTMLInputElement] onblur onfocusout [object HTMLBodyElement]", IE = "[object HTMLInputElement] null")
@NotYetImplemented(IE)
public void removeActiveElement() throws Exception {
final String html = HtmlPageTest.STANDARDS_MODE_PREFIX_ + "<html>\n" + "<head>\n" + "<script>\n" + "function test() {\n" + " var elem = document.getElementById('text1');\n" + " elem.focus();\n" + " document.title += ' ' + document.activeElement;\n" + " elem.parentNode.removeChild(elem);\n" + " document.title += ' ' + document.activeElement;\n" + "}\n" + "</script>\n" + "</head>\n" + "<body onload='test()'>\n" + "<form name='form1'>\n" + " <input id='text1' onblur='document.title += \" onblur\"' " + "onfocusout='document.title += \" onfocusout\"'>\n" + "</form>\n" + "</body></html>";
final WebDriver driver = loadPage2(html);
assertTitle(driver, getExpectedAlerts()[0]);
}
use of com.gargoylesoftware.htmlunit.junit.BrowserRunner.NotYetImplemented in project htmlunit by HtmlUnit.
the class HtmlForm2Test method inputTypeImageWithFormTarget.
/**
* @throws Exception if the test fails
*/
@Test
@Alerts(DEFAULT = "2", IE = "1")
@NotYetImplemented(IE)
public void inputTypeImageWithFormTarget() throws Exception {
final String html = "<!DOCTYPE html>\n" + "<html><head></head>\n" + "<body>\n" + " <p>hello world</p>\n" + " <form id='myForm' action='" + URL_SECOND + "' target='_self'>\n" + " <input id='myButton' type='image' alt='Submit' formtarget='_blank' />\n" + " </form>\n" + "</body></html>";
final String secondContent = "second content";
getMockWebConnection().setResponse(URL_SECOND, secondContent);
final WebDriver driver = loadPage2(html);
// check that initially we have one window
assertEquals("Incorrect number of openned window", 1, driver.getWindowHandles().size());
final String firstWindowId = driver.getWindowHandle();
driver.findElement(By.id("myButton")).click();
// check that after submit we have a new window
assertEquals("Incorrect number of openned window", Integer.parseInt(getExpectedAlerts()[0]), driver.getWindowHandles().size());
String newWindowId = "";
for (final String id : driver.getWindowHandles()) {
if (!firstWindowId.equals(id)) {
newWindowId = id;
break;
}
}
// switch to the new window and check its content
driver.switchTo().window(newWindowId);
assertTrue("Incorrect conent of new window", driver.getPageSource().contains(secondContent));
driver.close();
}
use of com.gargoylesoftware.htmlunit.junit.BrowserRunner.NotYetImplemented in project htmlunit by HtmlUnit.
the class WindowTest method showModalDialogWithButton.
/**
* Test for the <tt>showModalDialog</tt> method.
* This tests blocking until the window gets closed.
* Can not currently be tested with WebDriver
* https://github.com/seleniumhq/selenium-google-code-issue-archive/issues/284
*
* To fix this, we need to allow user to interact with the opened dialog before showModalDialog() returns
* @throws Exception if an error occurs
*/
@Test
@Alerts(DEFAULT = { "undefined", "result", "finished" }, CHROME = { "undefined", "not available" }, EDGE = { "undefined", "not available" }, FF = { "undefined", "not available" }, FF_ESR = { "undefined", "not available" })
@NotYetImplemented(IE)
public void showModalDialogWithButton() throws Exception {
final String html1 = "<html><head>\n" + " <script>\n" + " function test() {\n" + " alert(window.returnValue);\n" + " if (!window.showModalDialog) {alert('not available'); return; }\n" + " var res = showModalDialog('myDialog.html', null, 'dialogHeight:300px; dialogLeft:200px;');\n" + " alert(res);\n" + " alert('finished');\n" + " }\n" + " </script>\n" + "</head>\n" + "<body>\n" + " <button onclick='test()' id='openDlg'>Test</button>\n" + "</body></html>";
final String html2 = "<html><head>\n" + "</head>\n" + "<body>\n" + " <button id='closeDlg' onclick='window.returnValue = \"result\"; window.close();'></button>\n" + "</body>\n" + "</html>";
final WebClient client = getWebClient();
final List<String> actual = new ArrayList<>();
client.setAlertHandler(new CollectingAlertHandler(actual));
final MockWebConnection conn = new MockWebConnection();
conn.setResponse(URL_FIRST, html1);
conn.setResponse(new URL(URL_FIRST, "myDialog.html"), html2);
client.setWebConnection(conn);
final HtmlPage page = getWebClient().getPage(URL_FIRST);
final HtmlElement button = page.getHtmlElementById("openDlg");
button.click();
// TODO: <button id='closeDlg'> should be clicked
assertEquals(getExpectedAlerts(), actual);
}
use of com.gargoylesoftware.htmlunit.junit.BrowserRunner.NotYetImplemented in project htmlunit by HtmlUnit.
the class CSSStyleSheetTest method hrefWrongContentType.
/**
* @throws Exception if an error occurs
*/
@Test
@Alerts(DEFAULT = { "8", "§§URL§§style1.css 1", "§§URL§§style2.css 0", "§§URL§§style3.css 0", "§§URL§§style4.css 1", "§§URL§§style5.css 1", "§§URL§§style6.css 0", "§§URL§§style7.css 0", "§§URL§§style8.css 1" }, IE = { "2", "§§URL§§style1.css 1", "§§URL§§style5.css 1" })
@NotYetImplemented(IE)
public void hrefWrongContentType() throws Exception {
final String html = HtmlPageTest.STANDARDS_MODE_PREFIX_ + "<html>\n" + " <head>\n" + " <link href='" + URL_FIRST + "style1.css' rel='stylesheet' type='text/css'></link>\n" + " <link href='" + URL_FIRST + "style2.css' rel='stylesheet' type='text/css'></link>\n" + " <link href='" + URL_FIRST + "style3.css' rel='stylesheet' type='text/css'></link>\n" + " <link href='" + URL_FIRST + "style4.css' rel='stylesheet' type='text/css'></link>\n" + " <link href='" + URL_FIRST + "style5.css' rel='stylesheet' ></link>\n" + " <link href='" + URL_FIRST + "style6.css' rel='stylesheet' ></link>\n" + " <link href='" + URL_FIRST + "style7.css' rel='stylesheet' ></link>\n" + " <link href='" + URL_FIRST + "style8.css' rel='stylesheet' ></link>\n" + " </head>\n" + " <body>\n" + " <script>\n" + LOG_TITLE_FUNCTION + " log(document.styleSheets.length);\n" + " for (i = 0; i < document.styleSheets.length; i++) {\n" + " var sheet = document.styleSheets[i];\n" + " log(sheet.href + ' ' + sheet.cssRules.length);\n" + " }\n" + " </script>\n" + " </body>\n" + "</html>";
final MockWebConnection conn = getMockWebConnection();
conn.setResponse(new URL(URL_FIRST, "style1.css"), "div { color: red; }", MimeType.TEXT_CSS);
conn.setResponse(new URL(URL_FIRST, "style2.css"), "div { color: red; }", MimeType.TEXT_HTML);
conn.setResponse(new URL(URL_FIRST, "style3.css"), "div { color: red; }", MimeType.TEXT_PLAIN);
conn.setResponse(new URL(URL_FIRST, "style4.css"), "div { color: red; }", "");
conn.setResponse(new URL(URL_FIRST, "style5.css"), "div { color: red; }", MimeType.TEXT_CSS);
conn.setResponse(new URL(URL_FIRST, "style6.css"), "div { color: red; }", MimeType.TEXT_HTML);
conn.setResponse(new URL(URL_FIRST, "style7.css"), "div { color: red; }", MimeType.TEXT_PLAIN);
conn.setResponse(new URL(URL_FIRST, "style8.css"), "div { color: red; }", "");
expandExpectedAlertsVariables(URL_FIRST);
loadPageVerifyTitle2(html);
}
Aggregations