Search in sources :

Example 6 with NotYetImplemented

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

the class StorageTest method localStorageShouldBeShared.

/**
 * Note that this test will work only with WebDriver instances that support starting 2 instances in parallel.
 * @throws Exception if the test fails
 */
@Test
@Alerts("I was here")
@BuggyWebDriver(CHROME = "", EDGE = "", FF = "", FF_ESR = "")
// But when executed manually the LocalStorage is shared.
@NotYetImplemented
public // TODO somehow persist the LocalStorage
void localStorageShouldBeShared() throws Exception {
    final String html1 = "<html><body>\n" + "<script>\n" + LOG_TITLE_FUNCTION + "try {\n" + "  localStorage.clear();\n" + "  localStorage.setItem('hello', 'I was here');\n" + "} catch(e) { log('exception'); }\n" + "</script></body></html>";
    final WebDriver driver = loadPage2(html1);
    final List<String> alerts = getCollectedAlerts(driver);
    final String html2 = "<html><body><script>\n" + "try {\n" + "  log(localStorage.getItem('hello'));\n" + "} catch(e) { log('exception'); }\n" + "</script></body></html>";
    getMockWebConnection().setResponse(URL_FIRST, html2);
    releaseResources();
    // we have to control 2nd driver by ourself
    WebDriver driver2 = null;
    try {
        driver2 = buildWebDriver();
        driver2.get(URL_FIRST.toString());
        final List<String> newAlerts = getCollectedAlerts(driver2);
        alerts.addAll(newAlerts);
        assertEquals(getExpectedAlerts(), alerts);
    } finally {
        if (!(driver2 instanceof HtmlUnitDriver)) {
            shutDownAll();
        }
    }
}
Also used : BuggyWebDriver(com.gargoylesoftware.htmlunit.junit.BrowserRunner.BuggyWebDriver) WebDriver(org.openqa.selenium.WebDriver) HtmlUnitDriver(org.openqa.selenium.htmlunit.HtmlUnitDriver) NotYetImplemented(com.gargoylesoftware.htmlunit.junit.BrowserRunner.NotYetImplemented) Test(org.junit.Test) BuggyWebDriver(com.gargoylesoftware.htmlunit.junit.BrowserRunner.BuggyWebDriver) Alerts(com.gargoylesoftware.htmlunit.junit.BrowserRunner.Alerts)

Example 7 with NotYetImplemented

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

the class URLTest method createObjectURL.

/**
 * @throws Exception if the test fails
 */
@Test
@NotYetImplemented
public void createObjectURL() throws Exception {
    final String html = HtmlPageTest.STANDARDS_MODE_PREFIX_ + "<html>\n" + "<head>\n" + "<script>\n" + "function test() {\n" + "  if (document.testForm.fileupload.files) {\n" + "    var files = document.testForm.fileupload.files;\n" + "    var url = window.URL.createObjectURL(files[0]);\n" + "    alert(url);\n" + "    window.URL.revokeObjectURL(url);\n" + "  }\n" + "}\n" + "</script>\n" + "</head>\n" + "<body>\n" + "  <form name='testForm'>\n" + "    <input type='file' id='fileupload' name='fileupload'>\n" + "  </form>\n" + "  <button id='testBtn' onclick='test()'>Tester</button>\n" + "</body>\n" + "</html>";
    final WebDriver driver = loadPage2(html);
    final File tstFile = File.createTempFile("HtmlUnitUploadTest", ".txt");
    try {
        FileUtils.writeStringToFile(tstFile, "Hello HtmlUnit", ISO_8859_1);
        final String path = tstFile.getCanonicalPath();
        driver.findElement(By.name("fileupload")).sendKeys(path);
        driver.findElement(By.id("testBtn")).click();
        final String url = getCollectedAlerts(driver, 1).get(0);
        Assert.assertTrue(url, url.startsWith("blob:"));
    } finally {
        FileUtils.deleteQuietly(tstFile);
    }
}
Also used : WebDriver(org.openqa.selenium.WebDriver) File(java.io.File) NotYetImplemented(com.gargoylesoftware.htmlunit.junit.BrowserRunner.NotYetImplemented) HtmlPageTest(com.gargoylesoftware.htmlunit.html.HtmlPageTest) Test(org.junit.Test)

Example 8 with NotYetImplemented

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

the class HTMLInputElementTest method maxLengthJavaScript.

/**
 * @throws Exception if the test fails
 */
@Test
@Alerts(DEFAULT = "§§URL§§?myName=abcdefg", IE = "§§URL§§")
@NotYetImplemented(IE)
public void maxLengthJavaScript() throws Exception {
    final String html = HtmlPageTest.STANDARDS_MODE_PREFIX_ + "<html><head><script>\n" + "function updateValue() {\n" + "  document.getElementById('myInput').value = 'abcdefg';\n" + "}\n" + "</script></head>\n" + "<body>\n" + "  <form>\n" + "    <input id='myInput' name='myName' maxlength='2'>\n" + "    <input id='mySubmit' type='submit'>\n" + "  </form>\n" + "  <button id='myButton' onclick='updateValue()'>Update Value</button>\n" + "</body></html>";
    final WebDriver driver = loadPage2(html);
    driver.findElement(By.id("myButton")).click();
    assertEquals("abcdefg", driver.findElement(By.id("myInput")).getAttribute("value"));
    driver.findElement(By.id("mySubmit")).click();
    expandExpectedAlertsVariables(URL_FIRST);
    assertEquals(getExpectedAlerts()[0], driver.getCurrentUrl());
}
Also used : WebDriver(org.openqa.selenium.WebDriver) NotYetImplemented(com.gargoylesoftware.htmlunit.junit.BrowserRunner.NotYetImplemented) HtmlPageTest(com.gargoylesoftware.htmlunit.html.HtmlPageTest) Test(org.junit.Test) Alerts(com.gargoylesoftware.htmlunit.junit.BrowserRunner.Alerts)

Example 9 with NotYetImplemented

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

the class HtmlImageInputTest method click_NoPosition.

/**
 * @throws Exception if the test fails
 */
@Test
@Alerts(DEFAULT = "§§URL§§?button.x=0&button.y=0", CHROME = "§§URL§§?button.x=16&button.y=8", EDGE = "§§URL§§?button.x=16&button.y=8", IE = "§§URL§§?button.x=14&button.y=15")
@NotYetImplemented({ CHROME, EDGE, IE })
public void click_NoPosition() throws Exception {
    final String html = "<html><head><title>foo</title></head><body>\n" + "<form id='form1'>\n" + "  <input type='image' name='aButton' value='foo'/>\n" + "  <input type='image' name='button' value='foo'/>\n" + "  <input type='image' name='anotherButton' value='foo'/>\n" + "</form></body></html>";
    final WebDriver webDriver = loadPage2(html);
    webDriver.findElement(By.name("button")).click();
    expandExpectedAlertsVariables(URL_FIRST);
    assertEquals(getExpectedAlerts()[0], webDriver.getCurrentUrl());
}
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 10 with NotYetImplemented

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

the class HtmlElement2Test method addRemove.

/**
 * Another nasty trick from one of these trackers.
 *
 * @throws Exception on test failure
 */
@Test
@Alerts({ "before appendChild;after appendChild;image onload;after removeChild;", "2" })
// node is appended and fails
@NotYetImplemented
public void addRemove() throws Exception {
    try (InputStream is = getClass().getClassLoader().getResourceAsStream("testfiles/tiny-jpg.img")) {
        final byte[] directBytes = IOUtils.toByteArray(is);
        final URL urlImage = new URL(URL_FIRST, "img.jpg");
        final List<NameValuePair> emptyList = Collections.emptyList();
        getMockWebConnection().setResponse(urlImage, directBytes, 200, "ok", "image/jpg", emptyList);
    }
    final String html = HtmlPageTest.STANDARDS_MODE_PREFIX_ + "<html>\n" + "<head>\n" + "<script>\n" + "function test() {\n" + "  var elem = document.createElement('img');\n" + "  elem.setAttribute('alt', '');\n" + "  elem.setAttribute('src', 'img.jpg');\n" + "  elem.style.display = 'none';\n" + "  elem.onload = function() {\n" + "      document.title += 'image onload;';" + "      document.body.removeChild(elem);\n" + "      document.title += 'after removeChild;';" + "    }\n" + "  document.title += 'before appendChild;';" + "  document.body.appendChild(elem);\n" + "  document.title += 'after appendChild;';" + "}\n" + "</script>\n" + "</head>\n" + "<body onload='test()'>\n" + "</body></html>";
    final int count = getMockWebConnection().getRequestCount();
    final WebDriver driver = getWebDriver();
    if (driver instanceof HtmlUnitDriver) {
        ((HtmlUnitDriver) driver).setDownloadImages(true);
    }
    loadPage2(html);
    assertTitle(driver, getExpectedAlerts()[0]);
    assertEquals(Integer.parseInt(getExpectedAlerts()[1]), getMockWebConnection().getRequestCount() - count);
}
Also used : WebDriver(org.openqa.selenium.WebDriver) BuggyWebDriver(com.gargoylesoftware.htmlunit.junit.BrowserRunner.BuggyWebDriver) NameValuePair(com.gargoylesoftware.htmlunit.util.NameValuePair) InputStream(java.io.InputStream) URL(java.net.URL) 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