use of com.gargoylesoftware.htmlunit.junit.BrowserRunner.Alerts in project htmlunit by HtmlUnit.
the class HtmlCheckBoxInput2Test method onchangeFires2.
/**
* @throws Exception if the test fails
*/
@Test
@Alerts("foo,change,boo,blur,")
public void onchangeFires2() throws Exception {
final String html = HtmlPageTest.STANDARDS_MODE_PREFIX_ + "<html><head><title>foo</title>\n" + "<script>\n" + " function debug(string) {\n" + " document.getElementById('myTextarea').value += string + ',';\n" + " }\n" + "</script>\n" + "</head><body>\n" + "<form>\n" + "<input type='checkbox' id='chkbox'" + " onChange='debug(\"foo\");debug(event.type);'" + " onBlur='debug(\"boo\");debug(event.type);'" + ">\n" + "<input type='checkbox' id='chkbox2'>\n" + "</form>\n" + "<textarea id='myTextarea'></textarea>\n" + "</body></html>";
final WebDriver driver = loadPage2(html);
driver.findElement(By.id("chkbox")).click();
driver.findElement(By.id("chkbox2")).click();
assertEquals(Arrays.asList(getExpectedAlerts()).toString(), '[' + driver.findElement(By.id("myTextarea")).getAttribute("value") + ']');
}
use of com.gargoylesoftware.htmlunit.junit.BrowserRunner.Alerts in project htmlunit by HtmlUnit.
the class HtmlCheckBoxInput2Test 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 id='myCheckbox' type='checkbox' 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("myCheckbox")).click();
assertTitle(driver, getExpectedAlerts()[0]);
}
use of com.gargoylesoftware.htmlunit.junit.BrowserRunner.Alerts in project htmlunit by HtmlUnit.
the class HtmlColorInputTest method clearInput.
/**
* Verifies clear().
* @throws Exception if the test fails
*/
@Test
@Alerts(DEFAULT = "#000000", IE = "")
public void clearInput() throws Exception {
final String htmlContent = "<html>\n" + "<head></head>\n" + "<body>\n" + "<form id='form1'>\n" + " <input type='color' name='tester' id='tester' value='#ff0000'>\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"));
}
use of com.gargoylesoftware.htmlunit.junit.BrowserRunner.Alerts in project htmlunit by HtmlUnit.
the class HtmlColorInputTest method getVisibleText.
/**
* Verifies getVisibleText().
* @throws Exception if the test fails
*/
@Test
@Alerts("")
public void getVisibleText() throws Exception {
final String htmlContent = "<html>\n" + "<head></head>\n" + "<body>\n" + "<form id='form1'>\n" + " <input type='color' name='tester' id='tester' value='#ff0000'>\n" + "</form>\n" + "</body></html>";
final WebDriver driver = loadPage2(htmlContent);
final String text = driver.findElement(By.id("tester")).getText();
assertEquals(getExpectedAlerts()[0], text);
if (driver instanceof HtmlUnitDriver) {
final HtmlPage page = (HtmlPage) getWebWindowOf((HtmlUnitDriver) driver).getEnclosedPage();
assertEquals(getExpectedAlerts()[0], page.getBody().getVisibleText());
}
}
use of com.gargoylesoftware.htmlunit.junit.BrowserRunner.Alerts in project htmlunit by HtmlUnit.
the class HtmlDateInputTest method typeInto.
/**
* @throws Exception if an error occurs
*/
@Test
@Alerts("2018-03-22")
@BuggyWebDriver(CHROME = "80322-02-01", EDGE = "80322-02-01")
public void typeInto() throws Exception {
final String html = "<html>\n" + "<head>\n" + "<script>\n" + " function test() {\n" + " var input = document.getElementById('input');\n" + " alert(input.value);\n" + " }\n" + "</script>\n" + "</head>\n" + "<body>\n" + " <input id='input' type='date'>\n" + " <button id='tester' onclick='test()'>Test</button>\n" + "</body></html>";
final WebDriver driver = loadPage2(html);
driver.findElement(By.id("input")).sendKeys("2018-03-22");
driver.findElement(By.id("tester")).click();
verifyAlerts(driver, getExpectedAlerts());
}
Aggregations