Search in sources :

Example 26 with HtmlUnitNYI

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());
}
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 27 with HtmlUnitNYI

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());
}
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 28 with HtmlUnitNYI

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());
}
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 29 with HtmlUnitNYI

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());
}
Also used : WebDriver(org.openqa.selenium.WebDriver) BuggyWebDriver(com.gargoylesoftware.htmlunit.junit.BrowserRunner.BuggyWebDriver) Test(org.junit.Test) Alerts(com.gargoylesoftware.htmlunit.junit.BrowserRunner.Alerts) HtmlUnitNYI(com.gargoylesoftware.htmlunit.junit.BrowserRunner.HtmlUnitNYI)

Example 30 with HtmlUnitNYI

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());
}
Also used : HashMap(java.util.HashMap) HttpServlet(javax.servlet.http.HttpServlet) Servlet(javax.servlet.Servlet) 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