firephoque.getOptions().setThrowExceptionOnFailingStatusCode(false);
firephoque.setAlertHandler(new AlertHandler() {
public void handleAlert(Page page, String message) {
try {
Window window = (Window)page.getEnclosingWindow().getScriptObject();
String script = "parent.selenium.browserbot.recordedAlerts.push('" + message.replace("'", "\\'")+ "');";
window.execScript(script, "JavaScript");
} catch(Exception e) {
e.printStackTrace();
}
}
});
firephoque.setConfirmHandler(new ConfirmHandler() {
public boolean handleConfirm(Page page, String message) {
try {
Window window = (Window)page.getEnclosingWindow().getScriptObject();
String script = "parent.selenium.browserbot.recordedConfirmations.push('" + message.replace("'", "\\'")+ "');" +
"var result = parent.selenium.browserbot.nextConfirmResult;" +
"parent.selenium.browserbot.nextConfirmResult = true;" +
"result";
Object result = ScriptRuntime.evalSpecial(Context.getCurrentContext(), window, window, new Object[] {script}, null, 0);
// window.execScript(script, "JavaScript");
return (Boolean)result;
} catch(Exception e) {
e.printStackTrace();
return false;
}
}
});
firephoque.setPromptHandler(new PromptHandler() {
public String handlePrompt(Page page, String message) {
try {
Window window = (Window)page.getEnclosingWindow().getScriptObject();
String script = "parent.selenium.browserbot.recordedPrompts.push('" + message.replace("'", "\\'")+ "');" +
"var result = !parent.selenium.browserbot.nextConfirmResult ? null : parent.selenium.browserbot.nextPromptResult;" +
"parent.selenium.browserbot.nextConfirmResult = true;" +
"parent.selenium.browserbot.nextPromptResult = '';" +
"result";