Search in sources :

Example 61 with Alerts

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

the class HtmlDateTimeInputTest method clearInput.

/**
 * Verifies clear().
 * @throws Exception if the test fails
 */
@Test
@Alerts("")
public void clearInput() throws Exception {
    final String htmlContent = "<html>\n" + "<head></head>\n" + "<body>\n" + "<form id='form1'>\n" + "  <input type='datetime' name='tester' id='tester' value='2018-06-12'>\n" + "</form>\n" + "</body></html>";
    final WebDriver driver = loadPage2(htmlContent);
    final WebElement element = driver.findElement(By.id("tester"));
    element.clear();
    assertEquals(getExpectedAlerts()[0], element.getAttribute("value"));
}
Also used : WebDriver(org.openqa.selenium.WebDriver) WebElement(org.openqa.selenium.WebElement) Test(org.junit.Test) Alerts(com.gargoylesoftware.htmlunit.junit.BrowserRunner.Alerts)

Example 62 with Alerts

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

the class HtmlDateTimeLocalInputTest method clearInput.

/**
 * Verifies clear().
 * @throws Exception if the test fails
 */
@Test
@Alerts("")
public void clearInput() throws Exception {
    final String htmlContent = "<html>\n" + "<head></head>\n" + "<body>\n" + "<form id='form1'>\n" + "  <input type='datetime-local' name='tester' id='tester' value='2018-06-12T19:30'>\n" + "</form>\n" + "</body></html>";
    final WebDriver driver = loadPage2(htmlContent);
    final WebElement element = driver.findElement(By.id("tester"));
    element.clear();
    assertEquals(getExpectedAlerts()[0], element.getAttribute("value"));
}
Also used : WebDriver(org.openqa.selenium.WebDriver) WebElement(org.openqa.selenium.WebElement) Test(org.junit.Test) Alerts(com.gargoylesoftware.htmlunit.junit.BrowserRunner.Alerts)

Example 63 with Alerts

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

the class HtmlDefinitionListTest method simpleScriptable.

/**
 * @throws Exception if the test fails
 */
@Test
@Alerts("[object HTMLDListElement]")
public void simpleScriptable() throws Exception {
    final String html = "<html><head>\n" + "<script>\n" + LOG_TITLE_FUNCTION + "  function test() {\n" + "    log(document.getElementById('myId'));\n" + "  }\n" + "</script>\n" + "</head><body onload='test()'>\n" + "  <dl id='myId'>\n" + "    <dt>Some Term</dt>\n" + "    <dd>A description</dd>\n" + "  </dl>\n" + "</body></html>";
    final WebDriver driver = loadPageVerifyTitle2(html);
    if (driver instanceof HtmlUnitDriver) {
        final HtmlPage page = (HtmlPage) getWebWindowOf((HtmlUnitDriver) driver).getEnclosedPage();
        assertTrue(HtmlDefinitionList.class.isInstance(page.getHtmlElementById("myId")));
    }
}
Also used : WebDriver(org.openqa.selenium.WebDriver) HtmlUnitDriver(org.openqa.selenium.htmlunit.HtmlUnitDriver) Test(org.junit.Test) Alerts(com.gargoylesoftware.htmlunit.junit.BrowserRunner.Alerts)

Example 64 with Alerts

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

the class HtmlDirectoryTest method simpleScriptable.

/**
 * @throws Exception if the test fails
 */
@Test
@Alerts("[object HTMLDirectoryElement]")
public void simpleScriptable() throws Exception {
    final String html = "<html><head>\n" + "<script>\n" + LOG_TITLE_FUNCTION + "  function test() {\n" + "    log(document.getElementById('myId'));\n" + "  }\n" + "</script>\n" + "</head><body onload='test()'>\n" + "  <dir id='myId'>\n" + "    <li>First Item</li>\n" + "    <li>Secong Item</li>\n" + "  </dir>\n" + "</body></html>";
    final WebDriver driver = loadPageVerifyTitle2(html);
    if (driver instanceof HtmlUnitDriver) {
        final HtmlPage page = (HtmlPage) getWebWindowOf((HtmlUnitDriver) driver).getEnclosedPage();
        assertTrue(HtmlDirectory.class.isInstance(page.getHtmlElementById("myId")));
    }
}
Also used : WebDriver(org.openqa.selenium.WebDriver) HtmlUnitDriver(org.openqa.selenium.htmlunit.HtmlUnitDriver) Test(org.junit.Test) Alerts(com.gargoylesoftware.htmlunit.junit.BrowserRunner.Alerts)

Example 65 with Alerts

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

the class HtmlScript2Test method simpleScriptable.

/**
 * @throws Exception if the test fails
 */
@Test
@Alerts("[object HTMLScriptElement]")
public void simpleScriptable() throws Exception {
    final String html = "<html><head>\n" + "<script>\n" + LOG_TITLE_FUNCTION + "  function test() {\n" + "    log(document.getElementById('myId'));\n" + "  }\n" + "</script>\n" + "</head><body onload='test()'>\n" + "  <script id='myId'></script>\n" + "</body></html>";
    final WebDriver driver = loadPageVerifyTitle2(html);
    assertEquals("script", driver.findElement(By.id("myId")).getTagName());
}
Also used : WebDriver(org.openqa.selenium.WebDriver) Test(org.junit.Test) Alerts(com.gargoylesoftware.htmlunit.junit.BrowserRunner.Alerts)

Aggregations

Alerts (com.gargoylesoftware.htmlunit.junit.BrowserRunner.Alerts)1266 Test (org.junit.Test)1261 WebDriver (org.openqa.selenium.WebDriver)894 HtmlPageTest (com.gargoylesoftware.htmlunit.html.HtmlPageTest)398 URL (java.net.URL)238 HtmlUnitDriver (org.openqa.selenium.htmlunit.HtmlUnitDriver)206 BuggyWebDriver (com.gargoylesoftware.htmlunit.junit.BrowserRunner.BuggyWebDriver)159 WebElement (org.openqa.selenium.WebElement)146 HtmlPage (com.gargoylesoftware.htmlunit.html.HtmlPage)128 MSXMLTestHelper.callLoadXMLDOMDocumentFromString (com.gargoylesoftware.htmlunit.activex.javascript.msxml.MSXMLTestHelper.callLoadXMLDOMDocumentFromString)101 NameValuePair (com.gargoylesoftware.htmlunit.util.NameValuePair)97 ArrayList (java.util.ArrayList)90 HtmlUnitNYI (com.gargoylesoftware.htmlunit.junit.BrowserRunner.HtmlUnitNYI)72 NotYetImplemented (com.gargoylesoftware.htmlunit.junit.BrowserRunner.NotYetImplemented)54 MockWebConnection (com.gargoylesoftware.htmlunit.MockWebConnection)48 XMLDocumentTest.callLoadXMLDocumentFromString (com.gargoylesoftware.htmlunit.javascript.host.xml.XMLDocumentTest.callLoadXMLDocumentFromString)47 XMLDocumentTest.callSerializeXMLDocumentToString (com.gargoylesoftware.htmlunit.javascript.host.xml.XMLDocumentTest.callSerializeXMLDocumentToString)44 File (java.io.File)30 WebClient (com.gargoylesoftware.htmlunit.WebClient)29 InputStream (java.io.InputStream)29