Search in sources :

Example 11 with NotYetImplemented

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

the class HtmlImage2Test method clickWithCoordinates.

/**
 * @throws Exception if the test fails
 */
@Test
@Alerts({ "58", "29", "58", "29" })
@NotYetImplemented
public void clickWithCoordinates() throws Exception {
    try (InputStream is = getClass().getClassLoader().getResourceAsStream("testfiles/tiny-gif.img")) {
        final byte[] directBytes = IOUtils.toByteArray(is);
        final URL urlImage = new URL(URL_SECOND, "img.gif");
        final List<NameValuePair> emptyList = Collections.emptyList();
        getMockWebConnection().setResponse(urlImage, directBytes, 200, "ok", MimeType.IMAGE_GIF, emptyList);
    }
    final String html = "<html><head>\n" + "<script>\n" + LOG_TITLE_FUNCTION + "  function clickImage(event) {\n" + "    log(event.clientX);\n" + "    log(event.clientY);\n" + "    log(event.screenX);\n" + "    log(event.screenY);\n" + "  }\n" + "</script>\n" + "</head>\n" + "<body>\n" + "  <img id='myImg' src='" + URL_SECOND + "img.gif' " + "width='100px' height='42px' onclick='clickImage(event)'>\n" + "</body>\n" + "</html>";
    final WebDriver driver = loadPage2(html);
    final Actions actions = new Actions(driver);
    // this requires a webdriver change
    actions.moveToElement(driver.findElement(By.id("myImg")), 0, 0).click().build().perform();
    verifyTitle2(driver, getExpectedAlerts());
}
Also used : WebDriver(org.openqa.selenium.WebDriver) NameValuePair(com.gargoylesoftware.htmlunit.util.NameValuePair) Actions(org.openqa.selenium.interactions.Actions) InputStream(java.io.InputStream) URL(java.net.URL) NotYetImplemented(com.gargoylesoftware.htmlunit.junit.BrowserRunner.NotYetImplemented) Test(org.junit.Test) Alerts(com.gargoylesoftware.htmlunit.junit.BrowserRunner.Alerts)

Example 12 with NotYetImplemented

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

the class MalformedHtmlTest method framesetInsideForm.

/**
 * @throws Exception if an error occurs
 */
@Test
@Alerts("frame loaded")
@NotYetImplemented
public void framesetInsideForm() throws Exception {
    final String html = "<html>\n" + "<form id='tester'>\n" + "  <frameset>\n" + "    <frame name='main' src='" + URL_SECOND + "' />\n" + "  </frameset>\n" + "</form>\n" + "</html>";
    final String html2 = "<html><body>\n" + "<script>\n" + "  alert('frame loaded');\n" + "</script>\n" + "</body></html>";
    getMockWebConnection().setResponse(URL_SECOND, html2);
    final WebDriver webDriver = loadPageWithAlerts2(html);
    assertEquals(1, webDriver.findElements(By.name("main")).size());
    assertEquals(0, webDriver.findElements(By.id("tester")).size());
}
Also used : WebDriver(org.openqa.selenium.WebDriver) NotYetImplemented(com.gargoylesoftware.htmlunit.junit.BrowserRunner.NotYetImplemented) Test(org.junit.Test) Alerts(com.gargoylesoftware.htmlunit.junit.BrowserRunner.Alerts)

Example 13 with NotYetImplemented

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

the class MalformedHtmlTest method framesetInsideTable.

/**
 * @throws Exception if an error occurs
 */
@Test
@NotYetImplemented
public void framesetInsideTable() throws Exception {
    final String html = "<html>\n" + "<table id='tester'>\n" + "  <frameset>\n" + "    <frame name='main' src='" + URL_SECOND + "' />\n" + "  </frameset>\n" + "</table>\n" + "</html>";
    final String html2 = "<html><body>\n" + "<script>\n" + "  alert('frame loaded');\n" + "</script>\n" + "</body></html>";
    getMockWebConnection().setResponse(URL_SECOND, html2);
    final WebDriver webDriver = loadPageWithAlerts2(html);
    assertEquals(0, webDriver.findElements(By.name("main")).size());
    assertEquals(1, webDriver.findElements(By.id("tester")).size());
}
Also used : WebDriver(org.openqa.selenium.WebDriver) NotYetImplemented(com.gargoylesoftware.htmlunit.junit.BrowserRunner.NotYetImplemented) Test(org.junit.Test)

Example 14 with NotYetImplemented

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

the class MalformedHtmlTest method framesetInsideDiv.

/**
 * @throws Exception if an error occurs
 */
@Test
@Alerts("frame loaded")
@NotYetImplemented
public void framesetInsideDiv() throws Exception {
    final String html = "<html>\n" + "<div id='tester'>\n" + "  <frameset>\n" + "    <frame name='main' src='" + URL_SECOND + "' />\n" + "  </frameset>\n" + "</div>\n" + "</html>";
    final String html2 = "<html><body>\n" + "<script>\n" + "  alert('frame loaded');\n" + "</script>\n" + "</body></html>";
    getMockWebConnection().setResponse(URL_SECOND, html2);
    final WebDriver webDriver = loadPageWithAlerts2(html);
    assertEquals(1, webDriver.findElements(By.name("main")).size());
    assertEquals(0, webDriver.findElements(By.id("tester")).size());
}
Also used : WebDriver(org.openqa.selenium.WebDriver) NotYetImplemented(com.gargoylesoftware.htmlunit.junit.BrowserRunner.NotYetImplemented) Test(org.junit.Test) Alerts(com.gargoylesoftware.htmlunit.junit.BrowserRunner.Alerts)

Example 15 with NotYetImplemented

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

the class HtmlTextArea2Test method getVisibleTextValueChangedFromJs.

/**
 * @throws Exception if the test fails
 */
@Test
@Alerts(DEFAULT = "Hello World", IE = "HtmlUnit")
@NotYetImplemented(IE)
public void getVisibleTextValueChangedFromJs() throws Exception {
    final String html = "<html>" + "<head>\n" + "<script>\n" + "  function test() {\n" + "    document.getElementById('tester').value = 'HtmlUnit';\n" + "  }\n" + "</script>\n" + "</head>\n" + "<body onload='test()'>\n" + "<form id='form1'>\n" + "<textarea id='tester'>Hello World</textarea>\n" + "</form>\n" + "</body></html>";
    final WebDriver driver = loadPage2(html);
    final String text = driver.findElement(By.id("tester")).getText();
    assertEquals(getExpectedAlerts()[0], text);
    if (driver instanceof HtmlUnitDriver) {
        final HtmlPage page = (HtmlPage) getWebWindowOf((HtmlUnitDriver) driver).getEnclosedPage();
        assertEquals(getExpectedAlerts()[0], page.getElementById("tester").getVisibleText());
    }
}
Also used : WebDriver(org.openqa.selenium.WebDriver) HtmlUnitDriver(org.openqa.selenium.htmlunit.HtmlUnitDriver) NotYetImplemented(com.gargoylesoftware.htmlunit.junit.BrowserRunner.NotYetImplemented) Test(org.junit.Test) Alerts(com.gargoylesoftware.htmlunit.junit.BrowserRunner.Alerts)

Aggregations

NotYetImplemented (com.gargoylesoftware.htmlunit.junit.BrowserRunner.NotYetImplemented)66 Test (org.junit.Test)65 Alerts (com.gargoylesoftware.htmlunit.junit.BrowserRunner.Alerts)54 WebDriver (org.openqa.selenium.WebDriver)54 HtmlPageTest (com.gargoylesoftware.htmlunit.html.HtmlPageTest)16 URL (java.net.URL)15 BuggyWebDriver (com.gargoylesoftware.htmlunit.junit.BrowserRunner.BuggyWebDriver)12 WebElement (org.openqa.selenium.WebElement)11 ArrayList (java.util.ArrayList)6 HtmlPage (com.gargoylesoftware.htmlunit.html.HtmlPage)5 HtmlUnitDriver (org.openqa.selenium.htmlunit.HtmlUnitDriver)5 MockWebConnection (com.gargoylesoftware.htmlunit.MockWebConnection)4 MSXMLTestHelper.callLoadXMLDOMDocumentFromString (com.gargoylesoftware.htmlunit.activex.javascript.msxml.MSXMLTestHelper.callLoadXMLDOMDocumentFromString)4 NameValuePair (com.gargoylesoftware.htmlunit.util.NameValuePair)4 WebClient (com.gargoylesoftware.htmlunit.WebClient)3 InputStream (java.io.InputStream)3 CollectingAlertHandler (com.gargoylesoftware.htmlunit.CollectingAlertHandler)2 MSXMLTestHelper.callSerializeXMLDOMDocumentToString (com.gargoylesoftware.htmlunit.activex.javascript.msxml.MSXMLTestHelper.callSerializeXMLDOMDocumentToString)2 HtmlElement (com.gargoylesoftware.htmlunit.html.HtmlElement)2 File (java.io.File)2