WebClient firephoque = new WebClient(browserVersion);
firephoque.setPageCreator(new DefaultPageCreator() {
@Override
public Page createPage(WebResponse wr, WebWindow ww) throws IOException {
Page page = createHtmlPage(wr, ww);
return page;
}
});
firephoque.setThrowExceptionOnFailingStatusCode(false);
firephoque.setAlertHandler(new AlertHandler() {
public void handleAlert(Page page, String string) {
try {
Window window = (Window)page.getEnclosingWindow().getScriptObject();
window.custom_eval(
"parent.selenium.browserbot.recordedAlerts.push('" + string.replace("'", "\\'")+ "');"
);
} catch(Exception e) {
e.printStackTrace();
}
}
});
firephoque.setConfirmHandler(new ConfirmHandler() {
public boolean handleConfirm(Page page, String string) {
try {
Window window = (Window)page.getEnclosingWindow().getScriptObject();
Object result = window.custom_eval(
"parent.selenium.browserbot.recordedConfirmations.push('" + string.replace("'", "\\'")+ "');" +
"var result = parent.selenium.browserbot.nextConfirmResult;" +
"parent.selenium.browserbot.nextConfirmResult = true;" +
"result"
);
return (Boolean)result;
} catch(Exception e) {
e.printStackTrace();
return false;
}
}
});
firephoque.setPromptHandler(new PromptHandler() {
public String handlePrompt(Page page, String string) {
try {
Window window = (Window)page.getEnclosingWindow().getScriptObject();
Object result = window.custom_eval(
"parent.selenium.browserbot.recordedPrompts.push('" + string.replace("'", "\\'")+ "');" +
"var result = !parent.selenium.browserbot.nextConfirmResult ? null : parent.selenium.browserbot.nextPromptResult;" +
"parent.selenium.browserbot.nextConfirmResult = true;" +
"parent.selenium.browserbot.nextPromptResult = '';" +