How To Submit File In Form With HtmlUnit September 27, 2022 Post a Comment I have a problem with this form Solution 1: The code is working, the overload goes. But I ran the tests in the spring container, and for some reason I got this error. @RunWith(SpringRunner.class) @SpringBootTest Copy If you run without springs everything works. htmlForm.<HtmlFileInput>getInputByName("filename").setValueAttribute(model); htmlForm.<HtmlFileInput>getInputByName("filename").setContentType("multipart/form-data"); HtmlPage restore = htmlForm.getInputByName("Restore").click(); Copy Refresh The problem is - "Target server failed to respond exception." I avoid this across webClient.getOptions().setTimeout(20000); webClient.getOptions().setThrowExceptionOnScriptError(false); webClient.getOptions().setThrowExceptionOnFailingStatusCode(false); webClient.getOptions().setCssEnabled(false); webClient.getOptions().setJavaScriptEnabled(true); webClient.getOptions().setUseInsecureSSL(true); webClient.getOptions().setRedirectEnabled(true); Copy Decided Share Post a Comment for "How To Submit File In Form With HtmlUnit"