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")));
}
}
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")));
}
}
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());
}
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());
}
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]);
}
Aggregations