skyhirider · GitHub

I am testing the new method that is supposed to work with the filename - handleAttachment(Page page, String attachmentFilename) .

When I

I noticed this while looking at implementing an attachment handler that would download all attachments automatically to a temporary folder.

Are you open to adding an extra attachment handler to HtmlUnit in addition to the Collecting attachment handler? I can build one (provided the attachment handler is working correctly)

My very ugly work in progress test.

The attachment handler I am using is an empty class, but noticed the problem mentioned above while debugging.

	@Test
	public void test() throws FailingHttpStatusCodeException, MalformedURLException, IOException, InterruptedException {
		System.out.println(System.getProperty("java.io.tmpdir"));
		WebClient webClient = new WebClient(BrowserVersion.FIREFOX);
		webClient.setAttachmentHandler(new DownloadingAttachmentHandler());
		HtmlPage page = webClient.getPage("https://www.ronsplace.ca/products/ronsdataedit/download");
		HtmlAnchor anchorByHref = page.getAnchorByHref("/contentproduct/data-edit/setup.exe");
		System.out.println(anchorByHref.asXml());
		anchorByHref.click();
		Thread.sleep(100000);
	}

Read the original on github.com ↗