use of com.gargoylesoftware.htmlunit.junit.BrowserRunner.HtmlUnitNYI in project htmlunit by HtmlUnit.
the class HtmlLabelTest method clickForEventBubbling.
/**
* @throws Exception if an error occurs
*/
@Test
@Alerts(DEFAULT = { "labelclick:label1", "parentclick:label1", "textfocus:text1", "textclick:text1", "parentclick:text1" }, IE = { "labelclick:label1", "parentclick:label1", "textclick:text1", "parentclick:text1", "textfocus:text1" })
@HtmlUnitNYI(IE = { "labelclick:label1", "parentclick:label1", "textfocus:text1", "textclick:text1", "parentclick:text1" })
public void clickForEventBubbling() throws Exception {
final String html = " <div onclick='log(\"parentclick:\" + event.target.id)' " + "onfocus='log(\"parentfocus:\" + event.target.id)'>\n" + " <label id='label1' for='text1' onclick='log(\"labelclick:\" + event.target.id)' " + "onfocus='log(\"labelfocus:\" + event.target.id)'>Click me</label>\n" + " <input type='text' id='text1' onclick='log(\"textclick:\" + event.target.id)' " + "onfocus='log(\"textfocus:\" + event.target.id)'>\n" + " </div>\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 clickNestedEventBubbling.
/**
* @throws Exception if an error occurs
*/
@Test
@Alerts(DEFAULT = { "labelclick:label1", "parentclick:label1", "text1focus:text1", "text1click:text1", "labelclick:text1", "parentclick:text1" }, IE = { "labelclick:label1", "parentclick:label1", "text1click:text1", "labelclick:text1", "parentclick:text1", "text1focus:text1" })
@HtmlUnitNYI(IE = { "labelclick:label1", "parentclick:label1", "text1focus:text1", "text1click:text1", "labelclick:text1", "parentclick:text1" })
public void clickNestedEventBubbling() throws Exception {
final String html = " <div onclick='log(\"parentclick:\" + event.target.id)' " + "onfocus='log(\"parentfocus:\" + event.target.id)'>\n" + " <label id='label1' onclick='log(\"labelclick:\" + event.target.id)' " + "onfocus='log(\"labelfocus:\" + event.target.id)'>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" + " <input type='text' id='text1' onclick='log(\"text1click:\" + event.target.id)' " + "onfocus='log(\"text1focus:\" + event.target.id)'>\n" + " <input type='text' id='text2' onclick='log(\"text2click:\" + event.target.id)' " + "onfocus='log(\"text2focus:\" + event.target.id)'>\n" + " </label>\n" + " </div>\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 clickForNotLabelableVersusNested.
/**
* @throws Exception if an error occurs
*/
@Test
@Alerts(DEFAULT = "labelclick", IE = "labelclick;div1click")
@HtmlUnitNYI(IE = "labelclick")
public void clickForNotLabelableVersusNested() throws Exception {
final String html = " <label id='label1' for='div1' 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" + " <input type='text' id='text1' onclick='log(\"text1click\")' onfocus='log(\"text1focus\")'>\n" + " </label>\n" + " <div id='div1' onclick='log(\"div1click\")' onfocus='log(\"div1focus\")'></div>\n";
final WebDriver driver = loadPage2(generatePage(html));
driver.findElement(By.id("label1")).click();
verifyTitle2(driver, getExpectedAlerts());
assertEquals(driver.findElement(By.id("body")), driver.switchTo().activeElement());
}
use of com.gargoylesoftware.htmlunit.junit.BrowserRunner.HtmlUnitNYI in project htmlunit by HtmlUnit.
the class JavaScriptEngine2Test method onloadJavascriptFunction.
/**
* Regression test for bug https://sf.net/tracker/?func=detail&atid=448266&aid=1609944&group_id=47038.
* @throws Exception if the test fails
*/
@Test
@Alerts("0")
@HtmlUnitNYI(CHROME = "1", EDGE = "1", FF = "1", FF_ESR = "1", IE = "1")
public void onloadJavascriptFunction() throws Exception {
final String html = "<html><head>\n" + "<script>\n" + "function onload() { alert('foo'); }\n" + "</script></head>\n" + "<body>\n" + "</body></html>";
final WebDriver driver = loadPage2(html);
assertEquals(Integer.parseInt(getExpectedAlerts()[0]), getCollectedAlerts(driver, 1).size());
}
use of com.gargoylesoftware.htmlunit.junit.BrowserRunner.HtmlUnitNYI in project htmlunit by HtmlUnit.
the class XMLHttpRequestCORSTest method simpleHead.
/**
* @throws Exception if the test fails.
*/
@Test
@Alerts({ "4", "200", "null" })
@HtmlUnitNYI(CHROME = { "4", "200", "[object XMLDocument]" }, EDGE = { "4", "200", "[object XMLDocument]" }, FF = { "4", "200", "[object XMLDocument]" }, FF_ESR = { "4", "200", "[object XMLDocument]" }, IE = { "4", "200", "[object XMLDocument]" })
public void simpleHead() throws Exception {
expandExpectedAlertsVariables(new URL("http://localhost:" + PORT));
final String html = "<html><head>\n" + "<script>\n" + LOG_TITLE_FUNCTION + "var xhr = new XMLHttpRequest();\n" + "function test() {\n" + " try {\n" + " var url = 'http://' + window.location.hostname + ':" + PORT2 + "/simple2';\n" + " xhr.open('HEAD', url, false);\n" + " xhr.send();\n" + " log(xhr.readyState);\n" + " log(xhr.status);\n" + " log(xhr.responseXML);\n" + " } catch(e) { log(e) }\n" + "}\n" + "</script>\n" + "</head>\n" + "<body onload='test()'></body></html>";
SimpleServerServlet.ACCESS_CONTROL_ALLOW_ORIGIN_ = "*";
final Map<String, Class<? extends Servlet>> servlets2 = new HashMap<>();
servlets2.put("/simple2", SimpleServerServlet.class);
startWebServer2(".", null, servlets2);
loadPage2(html, new URL(URL_FIRST, "/simple1"));
verifyTitle2(getWebDriver(), getExpectedAlerts());
}
Aggregations