descargar archivos detrás del botón javascript con htmlunit

Estoy tratando de descargar algo adjunto detrás de un botón de JavaScript con HtmlUnit. Realizar otras tareas funciona muy bien (por ejemplo, navegación, inicio de sesión). Verifiqué la prueba de la unidad de conexión pero no me ayudó.

final WebClient webClient = new WebClient(BrowserVersion.FIREFOX_24);
final HtmlPage page1 = webClient.getPage( loginUrl );
final HtmlTextInput textField =  page1.getElementByName(user);
final HtmlPasswordInput pwd =  page1.getElementByName(pwd);  
textField.setValueAttribute(User.getUsername());
pwd.setValueAttribute(User.getPassword());   

final HtmlSubmitInput button =  page1.getElementByName(login);
final HtmlPage page2 =  button.click();

String buttonJavaScript = "window.location='"+folder+filename + ....... ";
ScriptResult result = page2.executeJavaScript(buttonJavaScript);
webClient.waitForBackgroundJavaScript(2000);    

InputStream is = result.getNewPage().getWebResponse().getContentAsStream();
try {
    File f = new File("filename.extension");
    OutputStream os = new FileOutputStream(f);
    byte[] bytes = new byte[1024];
    while (read == is.read(bytes)) {
        os.write(bytes, 0, read);
    }
    os.close();
    is.close();
} catch (IOException ex) {
    // Exception handling
}

Sin embargo, se detiene con:

runtimeError: message=[No node attached to this object] sourceName=[http://pagead2.googlesyndication.com/pagead/osd.js] line=[7] lineSource=[null] lineOffset=[0]

El archivo creado es de tamaño 0. ¿Debe haber una manera de llegar al archivo real adjunto?

Gracias de antemano

Respuestas a la pregunta(1)

Su respuesta a la pregunta