use of com.gargoylesoftware.htmlunit.junit.BrowserRunner.BuggyWebDriver in project htmlunit by HtmlUnit.
the class MutationObserverTest method attributeValue2.
/**
* @throws Exception if an error occurs
*/
@Test
@Alerts("[object HTMLHeadingElement]-attributes")
@BuggyWebDriver(FF = "[object HTMLInputElement]-attributes\n" + "[object HTMLInputElement]-attributes\n" + "[object HTMLInputElement]-attributes\n" + "[object HTMLInputElement]-attributes\n" + "[object HTMLHeadingElement]-attributes", FF_ESR = "[object HTMLInputElement]-attributes\n" + "[object HTMLInputElement]-attributes\n" + "[object HTMLInputElement]-attributes\n" + "[object HTMLInputElement]-attributes\n" + "[object HTMLHeadingElement]-attributes")
public void attributeValue2() throws Exception {
final String html = "<html><head><script>\n" + " function makeRed() {\n" + " document.getElementById('headline').setAttribute('style', 'color: red');\n" + " }\n" + " function print(mutation) {\n" + " log(mutation.target + '-' + mutation.type);\n" + " }\n" + " function log(x) {\n" + " document.getElementById('log').value += x + '\\n';\n" + " }\n" + " function test() {\n" + " var mobs = new MutationObserver(function(mutations) {\n" + " mutations.forEach(print)\n" + " });\n" + " mobs.observe(document.getElementById('container'), {\n" + " attributes: true,\n" + " childList: true,\n" + " characterData: true,\n" + " subtree: true\n" + " });\n" + " document.addEventListener('beforeunload', function() {\n" + " mobs.disconnect();\n" + " });\n" + " }\n" + "</script></head><body onload='test()'>\n" + " <div id='container'>\n" + " <h1 id='headline' style='font-style: italic'>Some headline</h1>\n" + " <input id='id1' type='button' onclick='makeRed()' value='Make Red'>\n" + " </div>\n" + " <textarea id='log' cols='80' rows='40'></textarea>\n" + "</body></html>\n";
final WebDriver driver = loadPage2(html);
driver.findElement(By.id("id1")).click();
final String text = driver.findElement(By.id("log")).getAttribute("value").trim().replaceAll("\r", "");
assertEquals(String.join("\n", getExpectedAlerts()), text);
}
use of com.gargoylesoftware.htmlunit.junit.BrowserRunner.BuggyWebDriver in project htmlunit by HtmlUnit.
the class BrowserVersionClassRunner method setAlerts.
private void setAlerts(final WebTestCase testCase, final Method method) {
final Alerts alerts = method.getAnnotation(Alerts.class);
String[] expectedAlerts = {};
if (alerts != null) {
expectedAlerts = NO_ALERTS_DEFINED;
if (isDefined(alerts.value())) {
expectedAlerts = alerts.value();
} else {
if (browserVersion_ == BrowserVersion.INTERNET_EXPLORER) {
expectedAlerts = firstDefined(alerts.IE(), alerts.DEFAULT());
} else if (browserVersion_ == BrowserVersion.EDGE) {
expectedAlerts = firstDefined(alerts.EDGE(), alerts.DEFAULT());
} else if (browserVersion_ == BrowserVersion.FIREFOX_ESR) {
expectedAlerts = firstDefined(alerts.FF_ESR(), alerts.DEFAULT());
} else if (browserVersion_ == BrowserVersion.FIREFOX) {
expectedAlerts = firstDefined(alerts.FF(), alerts.DEFAULT());
} else if (browserVersion_ == BrowserVersion.CHROME) {
expectedAlerts = firstDefined(alerts.CHROME(), alerts.DEFAULT());
}
}
}
if (isRealBrowser()) {
final BuggyWebDriver buggyWebDriver = method.getAnnotation(BuggyWebDriver.class);
if (buggyWebDriver != null) {
if (isDefined(buggyWebDriver.value())) {
expectedAlerts = buggyWebDriver.value();
} else {
if (browserVersion_ == BrowserVersion.INTERNET_EXPLORER) {
expectedAlerts = firstDefinedOrGiven(expectedAlerts, buggyWebDriver.IE(), buggyWebDriver.DEFAULT());
} else if (browserVersion_ == BrowserVersion.EDGE) {
expectedAlerts = firstDefinedOrGiven(expectedAlerts, buggyWebDriver.EDGE(), buggyWebDriver.DEFAULT());
} else if (browserVersion_ == BrowserVersion.FIREFOX_ESR) {
expectedAlerts = firstDefinedOrGiven(expectedAlerts, buggyWebDriver.FF_ESR(), buggyWebDriver.DEFAULT());
} else if (browserVersion_ == BrowserVersion.FIREFOX) {
expectedAlerts = firstDefinedOrGiven(expectedAlerts, buggyWebDriver.FF(), buggyWebDriver.DEFAULT());
} else if (browserVersion_ == BrowserVersion.CHROME) {
expectedAlerts = firstDefinedOrGiven(expectedAlerts, buggyWebDriver.CHROME(), buggyWebDriver.DEFAULT());
}
}
}
} else {
final HtmlUnitNYI htmlUnitNYI = method.getAnnotation(HtmlUnitNYI.class);
if (htmlUnitNYI != null) {
if (browserVersion_ == BrowserVersion.INTERNET_EXPLORER) {
expectedAlerts = firstDefinedOrGiven(expectedAlerts, htmlUnitNYI.IE());
} else if (browserVersion_ == BrowserVersion.EDGE) {
expectedAlerts = firstDefinedOrGiven(expectedAlerts, htmlUnitNYI.EDGE());
} else if (browserVersion_ == BrowserVersion.FIREFOX_ESR) {
expectedAlerts = firstDefinedOrGiven(expectedAlerts, htmlUnitNYI.FF_ESR());
} else if (browserVersion_ == BrowserVersion.FIREFOX) {
expectedAlerts = firstDefinedOrGiven(expectedAlerts, htmlUnitNYI.FF());
} else if (browserVersion_ == BrowserVersion.CHROME) {
expectedAlerts = firstDefinedOrGiven(expectedAlerts, htmlUnitNYI.CHROME());
}
}
}
testCase.setExpectedAlerts(expectedAlerts);
}
use of com.gargoylesoftware.htmlunit.junit.BrowserRunner.BuggyWebDriver in project htmlunit by HtmlUnit.
the class ExtJS22Test method debug_console.
/**
* @throws Exception if an error occurs
*/
@Test
@Alerts("Hello from the Ext console.")
@BuggyWebDriver(IE = "Todo")
public void debug_console() throws Exception {
final WebDriver driver = getPage("debug", "debug-console");
final List<WebElement> anchors = driver.findElements(By.xpath("//a"));
assertEquals(2, anchors.size());
anchors.get(1).click();
assertEquals(getExpectedAlerts()[0], driver.findElement(By.xpath("//div[starts-with(text(), 'Hello')][1]")).getText());
}
Aggregations