use of net.sourceforge.htmlunit.corejs.javascript.JavaScriptException in project selenium_tests by sergueik.
the class FirefoxPreferencesTest method testClearCacheOld.
// for Firefox version 40
@Test(enabled = false, priority = 20)
public void testClearCacheOld() {
// Arrange
driver.get("about:preferences#advanced");
// Wait page to load
wait.until(ExpectedConditions.urlContains("#advanced"));
System.err.println("Waited on URL contains: " + driver.getCurrentUrl());
// Click the "Clear Now" button under "Cached Web Content"
WebElement networkTabElement = wait.until(ExpectedConditions.visibilityOf(driver.findElement(By.id("networkTab"))));
assertThat(networkTabElement, notNullValue());
try {
highlight(networkTabElement);
} catch (JavaScriptException e) {
// org.openqa.selenium.JavascriptException: waiting for doc.body
// failed
System.err.println("Exception (ignored) " + e.toString());
}
System.err.println("Clicking on tab: " + networkTabElement.getAttribute("outerHTML"));
// TODO: figure which method is working
networkTabElement.click();
networkTabElement.sendKeys(Keys.SPACE);
actions.moveToElement(networkTabElement).click().build().perform();
WebElement clearCacheButtonElement = wait.until(ExpectedConditions.visibilityOf(driver.findElement(By.id("clearCacheButton"))));
assertThat(clearCacheButtonElement, notNullValue());
System.err.println("Clicking on button: " + clearCacheButtonElement.getAttribute("outerHTML"));
clearCacheButtonElement.click();
WebElement clearOfflineAppCacheButtonElement = wait.until(ExpectedConditions.visibilityOf(driver.findElement(By.id("clearOfflineAppCacheButton"))));
assertThat(clearOfflineAppCacheButtonElement, notNullValue());
System.err.println("Clicking on button: " + clearOfflineAppCacheButtonElement.getAttribute("outerHTML"));
clearOfflineAppCacheButtonElement.click();
// Click the "Clear All Data" button under "Site Data"
// this button is no longer shown in preferences, keep the code
WebElement clearSiteDataButtonElement = null;
try {
clearSiteDataButtonElement = wait.until(ExpectedConditions.visibilityOf(driver.findElement(By.id("clearSiteDataButton"))));
} catch (NoSuchElementException e) {
return;
}
assertThat(clearSiteDataButtonElement, notNullValue());
clearSiteDataButtonElement.click();
// and accept the alert
// TODO: Generics ?
wait.until(ExpectedConditions.alertIsPresent());
try {
alert = driver.switchTo().alert();
alert.accept();
} catch (NoAlertPresentException e) {
// Alert not present - ignore
} catch (WebDriverException e) {
System.err.println("Alert was not handled : " + e.getStackTrace().toString());
return;
}
}
use of net.sourceforge.htmlunit.corejs.javascript.JavaScriptException in project htmlunit-core-js by HtmlUnit.
the class StackTraceTest method runWithExpectedStackTrace.
private static void runWithExpectedStackTrace(final String _source, final String _expectedStackTrace) {
final ContextAction<Object> action = new ContextAction<Object>() {
@Override
public Object run(final Context cx) {
final Scriptable scope = cx.initSafeStandardObjects();
try {
cx.evaluateString(scope, _source, "test.js", 0, null);
} catch (final JavaScriptException e) {
assertEquals(_expectedStackTrace, e.getScriptStackTrace());
return null;
}
throw new RuntimeException("Exception expected!");
}
};
Utils.runWithOptimizationLevel(action, -1);
}
Aggregations