Search in sources :

Example 81 with Alerts

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

the class HtmlSpan2Test method simpleScriptable_others.

/**
 * Test that HTMLSpanElement is the default for other elements like 'address', 'code', 'strike', etc.
 * @throws Exception if the test fails
 */
@Test
@Alerts(DEFAULT = "[object HTMLElement]", IE = "[object HTMLBlockElement]")
public void simpleScriptable_others() 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" + "  <address id='myId'>My Address</address>\n" + "</body></html>";
    final WebDriver driver = loadPageVerifyTitle2(html);
    if (driver instanceof HtmlUnitDriver) {
        final HtmlPage page = (HtmlPage) getWebWindowOf((HtmlUnitDriver) driver).getEnclosedPage();
        assertTrue(HtmlAddress.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 82 with Alerts

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

the class HtmlStyle2Test method simpleScriptable.

/**
 * @throws Exception if the test fails
 */
@Test
@Alerts("[object HTMLStyleElement]")
public void simpleScriptable() throws Exception {
    final String html = "<html><head>\n" + "<style type='text/css' id='myId'>\n" + "img { border: 0px }\n" + "</style>\n" + "<script>\n" + LOG_TITLE_FUNCTION + "  function test() {\n" + "    log(document.getElementById('myId'));\n" + "  }\n" + "</script>\n" + "</head><body onload='test()'>\n" + "</body></html>";
    final WebDriver driver = loadPageVerifyTitle2(html);
    if (driver instanceof HtmlUnitDriver) {
        final HtmlPage page = (HtmlPage) getWebWindowOf((HtmlUnitDriver) driver).getEnclosedPage();
        assertTrue(HtmlStyle.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 83 with Alerts

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

the class HtmlSubmitInputTest method outsideForm.

/**
 * @throws Exception if the test fails
 */
@Test
@Alerts("1")
public void outsideForm() throws Exception {
    final String html = "<html><head>\n" + "<script>\n" + LOG_TITLE_FUNCTION + "</script>\n" + "</head>\n" + "<body>\n" + "<input id='myInput' type='submit' onclick='log(1)'>\n" + "</body></html>";
    final WebDriver webDriver = loadPage2(html);
    final WebElement input = webDriver.findElement(By.id("myInput"));
    input.click();
    verifyTitle2(webDriver, getExpectedAlerts());
}
Also used : WebDriver(org.openqa.selenium.WebDriver) WebElement(org.openqa.selenium.WebElement) Test(org.junit.Test) Alerts(com.gargoylesoftware.htmlunit.junit.BrowserRunner.Alerts)

Example 84 with Alerts

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

the class HtmlRadioButtonInput2Test method checkedAttribute.

/**
 * @throws Exception if the test fails
 */
@Test
@Alerts({ "true", "null", "true", "", "true", "yes" })
public void checkedAttribute() throws Exception {
    final String html = HtmlPageTest.STANDARDS_MODE_PREFIX_ + "<html><head>\n" + "<script>\n" + LOG_TITLE_FUNCTION + "  function test() {\n" + "    var checkbox = document.getElementById('r1');\n" + "    log(checkbox.checked);\n" + "    log(checkbox.getAttribute('checked'));\n" + "    checkbox = document.getElementById('r2');\n" + "    log(checkbox.checked);\n" + "    log(checkbox.getAttribute('checked'));\n" + "    checkbox = document.getElementById('r3');\n" + "    log(checkbox.checked);\n" + "    log(checkbox.getAttribute('checked'));\n" + "  }\n" + "</script>\n" + "</head><body'>\n" + "<form name='myForm'>\n" + "  <input type='radio' id='r1' name='myRadio'>\n" + "  <input type='radio' name='myRadio'>\n" + "</form>\n" + "<form name='myForm'>\n" + "  <input type='radio' id='r2' name='myRadio' checked>\n" + "  <input type='radio' name='myRadio'>\n" + "</form>\n" + "<form name='myForm'>\n" + "  <input type='radio' id='r3' name='myRadio' checked='yes'>\n" + "  <input type='radio' name='myRadio'>\n" + "</form>\n" + "  <button id='clickMe' onClick='test()'>do it</button>\n" + "</body></html>";
    final WebDriver driver = loadPage2(html);
    driver.findElement(By.id("r1")).click();
    driver.findElement(By.id("r2")).click();
    driver.findElement(By.id("r3")).click();
    driver.findElement(By.id("clickMe")).click();
    verifyTitle2(driver, getExpectedAlerts());
}
Also used : WebDriver(org.openqa.selenium.WebDriver) Test(org.junit.Test) Alerts(com.gargoylesoftware.htmlunit.junit.BrowserRunner.Alerts)

Example 85 with Alerts

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

the class HtmlRadioButtonInput2Test method setChecked2.

/**
 * @throws Exception if the test fails
 */
@Test
@Alerts("Second")
public void setChecked2() throws Exception {
    final String firstHtml = HtmlPageTest.STANDARDS_MODE_PREFIX_ + "<html><head><title>First</title></head><body>\n" + "<form>\n" + "<input type='radio' name='radioGroup' id='radio'" + " onchange=\"window.location.href='" + URL_SECOND + "'\">\n" + "<input id='myInput' type='text'>\n" + "</form>\n" + "</body></html>";
    final String secondHtml = "<html><head><title>Second</title></head><body></body></html>";
    getMockWebConnection().setDefaultResponse(secondHtml);
    final WebDriver driver = loadPage2(firstHtml);
    driver.findElement(By.id("radio")).click();
    assertTitle(driver, getExpectedAlerts()[0]);
}
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