htmlunit

downloading files behind javascript button with htmlunit

痞子三分冷 提交于 2019-12-01 01:27:51
I am trying to download something an attachment behind a javascript button with HtmlUnit. Performing other tasks works great (eg. navigating, login). I checked out the attachment unit test but it didnt help me. 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

Process AJAX request in Htmlunit

和自甴很熟 提交于 2019-12-01 01:12:23
问题 I have a program written to scrape the source code from a webpage after a button is clicked. I am unable to scrape the right page because I believe an AJAX request is being sent, and I am not waiting for this response to take place. My code is currently: public class Htmlunitscraper { private static String s = "http://cpdocket.cp.cuyahogacounty.us/SheriffSearch/results.aspx?q=searchType%3dSaleDate%26searchString%3d10%2f21%2f2013%26foreclosureType%3d%27NONT%27%2c+%27PAR%27%2c+%27COMM%27%2c+

Java: how to setup htmlunit

廉价感情. 提交于 2019-12-01 00:45:14
问题 I'm a pretty big noob to Java, but I would like try out htmlunit. I'm using netbeans as my IDE and I've created a project folder "hu1". Here is the structure for that folder: hu1 > nbproject > src > hu1 > test Now, I download htmlunit 2.7 and unzipped the folder, which contains a "lib" folder with a bunch of jar files in it. Where do I put that lib folder in my netbeans project folder so that I can use htmlunit? Also, once I have figured that out, what paths do I use for my imports. A lot of

Fetch Page source using HtmlUnit : URL got stuck

十年热恋 提交于 2019-12-01 00:38:37
I am trying to get page source of following URL using Html-Unit get method. http://denydesigns.com/collections/barbara-sherman-fleece-throw-blanket/products/barbara-sherman-antique-fleece-throw-blanket It is getting stuck somewhere. I am trying to find out the reason but I am not getting it. I also tried to see if the Thread created by HtmlUnit is BLOCKED ar WAITING, but this is also not the case. Following is my log generated by HTML Unit. 18 Jan 2013 04:14:47,832 - main - ERROR - com.gargoylesoftware.htmlunit.javascript.StrictErrorReporter.runtimeError(StrictErrorReporter.java:79) -

struggling to click on link within htmlunit

℡╲_俬逩灬. 提交于 2019-12-01 00:15:13
I am having a problem clicking on a link within htmlunit. I went through the api on the site(which I didn't really understand well) and looked at all the sample code I could find and am still having a problem with clicking on links. Here's the top of the error messsage(its pretty large, if you want I can submit it all) "page2 = link2.click() Exception class=[net.sourceforge.htmlunit.corejs.javascript.JavaScriptException] com.gargoylesoftware.htmlunit.ScriptException: Sys.ArgumentOutOfRangeException: Sys.ArgumentOutOfRangeException: Value must be an integer. Parameter name: x Actual value was

downloading files behind javascript button with htmlunit

混江龙づ霸主 提交于 2019-11-30 20:44:59
问题 I am trying to download something an attachment behind a javascript button with HtmlUnit. Performing other tasks works great (eg. navigating, login). I checked out the attachment unit test but it didnt help me. 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

How to get a HTML page using HtmlUnit

感情迁移 提交于 2019-11-30 18:14:37
问题 I know you may think this question is stupid, but I need to use HtmlUnit. However, it returns a page either as XML or as text. I don't how to get the pure HTML (the same as the source code that browsers return) I need this, because I need to use some written modules. Any ideas? 回答1: You can use the following piece of code to achieve your goal: WebClient webClient = new WebClient(); Page page = webClient.getPage("http://example.com"); WebResponse response = page.getWebResponse(); String

HtmlUnit + Selenium within Production

♀尐吖头ヾ 提交于 2019-11-30 17:43:55
I am currently using HtmlUnit and Selenium to drive it (WebDriver) within my production code. I am scaping and interacting with various websites programmatically with these libraries and am having some success and not experiencing memory issues (ensuring sessions are always cleaned up). I am wondering if these libraries are okay for a production environment or recommended against. This is difficult to find via Google due to the enormous amount of information about automated testing rather than how I am using them. I realise this is a fairly generic question, but I am seeking advice on these

Accessing html generated by Javascript with htmlunit -Java

匆匆过客 提交于 2019-11-30 12:45:36
I am trying to be able to test a website that uses javascript to render most of the HTML. With the HTMLUNIT browser how would you be able to access the html generated by the javascript? I was looking through their documentation but wasn't sure what the best approach might be. WebClient webClient = new WebClient(); HtmlPage currentPage = webClient.getPage("some url"); String Source = currentPage.asXml(); System.out.println(Source); This is an easy way to get back the html of the page but would you use the domNode or another way to access the html generated by the javascript? You gotta give some

Can't turn off HtmlUnit logging messages

巧了我就是萌 提交于 2019-11-30 12:08:14
问题 I'm using HtmlUnit to interact with a web page that interacts with the server via Ajax. Soon after the Ajax code starts, HtmlUnit produces these two log messages: WARNING: Ignoring XMLHttpRequest.setRequestHeader for Content-length: it is a restricted header Mar 3, 2011 3:32:47 PM com.gargoylesoftware.htmlunit.javascript.host.xml.XMLHttpRequest jsxFunction_setRequestHeader WARNING: Ignoring XMLHttpRequest.setRequestHeader for Connection: it is a restricted header Mar 3, 2011 3:32:47 PM com