Search in sources :

Example 71 with HtmlUnitNYI

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

the class PolymerWebComponentsTest method hello.

/**
 * See https://github.com/HtmlUnit/htmlunit/issues/23.
 *
 * @throws Exception if an error occurs
 */
@Test
@Alerts("Hello Unicorn :)")
@HtmlUnitNYI(CHROME = "", EDGE = "", FF = "", FF_ESR = "", IE = "")
public void hello() throws Exception {
    final String url = URL_FIRST + "index.html";
    final WebDriver driver = getWebDriver();
    driver.get(url);
    // for real FF
    Thread.sleep(200);
    assertEquals(getExpectedAlerts()[0], driver.findElement(By.tagName("body")).getText());
}
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 72 with HtmlUnitNYI

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

the class HtmxTest method htmx.

/**
 * @throws Exception if an error occurs
 */
@Test
@Alerts(DEFAULT = "passes:412failures:0", IE = "passes:17failures:396")
@HtmlUnitNYI(CHROME = "passes:411failures:1", EDGE = "passes:411failures:1", FF = "passes:411failures:1", FF_ESR = "passes:411failures:1")
public void htmx() throws Exception {
    startWebServer("src/test/resources/libraries/htmx/htmx-1.6.1", null, null);
    final long runTime = 42 * DEFAULT_WAIT_TIME;
    final long endTime = System.currentTimeMillis() + runTime;
    try {
        final WebDriver webDriver = getWebDriver();
        if (getWebDriver() instanceof HtmlUnitDriver) {
            getWebWindowOf((HtmlUnitDriver) getWebDriver()).getWebClient().getOptions().setThrowExceptionOnScriptError(false);
        }
        final String url = URL_FIRST + "test/index.html";
        webDriver.get(url);
        String lastStats = "";
        while (lastStats.length() == 0 || !lastStats.startsWith(getExpectedAlerts()[0])) {
            Thread.sleep(100);
            if (System.currentTimeMillis() > endTime) {
                lastStats = "HtmxTest runs too long (longer than " + runTime / 1000 + "s) - " + getResultElementText(webDriver);
                break;
            }
            lastStats = getResultElementText(webDriver);
        }
        // bug hunting
        /*
            if (getWebDriver() instanceof HtmlUnitDriver) {
                final WebClient webClient = getWebWindowOf((HtmlUnitDriver) getWebDriver()).getWebClient();

                final Page page = webClient.getCurrentWindow().getEnclosedPage();
                System.out.println(((HtmlPage) page).asNormalizedText());
            }
            */
        assertTrue(lastStats + "\n\n" + getErrors(webDriver), lastStats.startsWith(getExpectedAlerts()[0]));
    } catch (final Exception e) {
        e.printStackTrace();
        Throwable t = e;
        while ((t = t.getCause()) != null) {
            t.printStackTrace();
        }
        throw e;
    }
}
Also used : WebDriver(org.openqa.selenium.WebDriver) StaleElementReferenceException(org.openqa.selenium.StaleElementReferenceException) NoSuchElementException(org.openqa.selenium.NoSuchElementException) HtmlUnitDriver(org.openqa.selenium.htmlunit.HtmlUnitDriver) 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