htmlunit

How to click on a javascript button in htmlunit

假如想象 提交于 2019-12-06 23:04:23
问题 I'm trying to click on a search button in this website: http://www.amadeusepower.com/trek/portals/trek/default.aspx?Culture=en-US The button is in here somewhere <table cellpadding="0" cellspacing="0" class="QuickSearchFormFlightModuleButtonsTable" width="100%"> <tr> <td class="cell1"> <a id="ctl00_ctl00_ctl00_cph1_cph1_QuickSearchAll1_QuickFlightSearchControl1_hlFlightDetailedSearch" href="javascript:if(typeof notRedirectToTop == 'undefined'){document.forms[0].target = '_top';}__doPostBack(

How to ignore HTMLUnit warnings/errors related to jQuery?

青春壹個敷衍的年華 提交于 2019-12-06 17:43:02
问题 Is it possible to teach HTMLUnit to ignore certain javascript scripts/files on a web page? Some of them are just out of my control (like jQuery) and I can't do anything with them. Warnings are annoying, for example: [WARN] com.gargoylesoftware.htmlunit.javascript.host.html.HTMLDocument: getElementById(script1299254732492) did a getElementByName for Internet Explorer Actually I'm using JSFUnit and HTMLUnit works under it. 回答1: If you want to avoid exceptions because of any JavaScript errors:

How to enable Flash to HTMLUnit?

久未见 提交于 2019-12-06 15:50:05
I'm trying to grab html contents by HTMLUnit. Everything went nice, but couldn't get Flash contents those are visible as <img> where its actually in <object> , i have webClient.getOptions().setJavaScriptEnabled(true); webClient.getOptions().setActiveXNative(true); webClient.getOptions().setAppletEnabled(true); webClient.getOptions().setCssEnabled(true); In SO some places i found someone saying HTMLUnit won't support Flash, but those answers seems old, so am raising this question. Someone please help. Thanks. I found it with the help for this i have downgrade my HTMLUnit version from 2.15 to 2

“Run” HTMLUnit with PHP

徘徊边缘 提交于 2019-12-06 15:49:42
So I have installed Java on my CentOS server. I now want to be able to use PHP to run HTMLUnit to get a fully rendered webpage and then return the results to the user. I see the "simple" example on HTMLUnit but I know next to nothing about Java and don't know where that needs to go or be ran to even get the test case working (i.e. getting Google's homepage). public void getURL() throws Exception { final WebClient webClient = new WebClient(); final HtmlPage page = webClient.getPage("http://google.com"); // Pass in URL // RETURN "page" } Once the test is working I would need to be able to "pass"

HtmlUnit 2.9 jar execute JavaScript

痞子三分冷 提交于 2019-12-06 13:09:17
I am trying this code: import com.gargoylesoftware.htmlunit.BrowserVersion; import com.gargoylesoftware.htmlunit.JavaScriptPage; import com.gargoylesoftware.htmlunit.ScriptResult; import com.gargoylesoftware.htmlunit.WebClient; import com.gargoylesoftware.htmlunit.WebRequest; import com.gargoylesoftware.htmlunit.WebResponse; import com.gargoylesoftware.htmlunit.WebWindow; import com.gargoylesoftware.htmlunit.html.HtmlPage; import com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine; import com.gargoylesoftware.htmlunit.javascript.host.html.HTMLScriptElement; import java.net.URL; import

Getting HtmlUnit to run under Android

浪尽此生 提交于 2019-12-06 08:18:53
问题 I was wondering if anyone was able to make HtmlUnit run under Android? I have a site which I am scraping using Jsoup (this works well). However, one of the sections contains more than 2 pages. The site uses ASP.NET and they are using a Javascript postback for the link that leads to the next page. As a result I need to somehow execute that Javascript to get the next page's content. This is where my attempts at HtmlUnit comes in. The following code worked perfectly on Java: WebClient webClient

HtmlUnit Android problem with WebClient

笑着哭i 提交于 2019-12-06 08:01:29
问题 HtmlUnit is amazing, in Java at least I have had no problems with it. Unfortunately when switching the code over to the Android platform, it is giving me errors when I try to create a web-client. import android.app.Activity; import android.os.Bundle; import com.gargoylesoftware.htmlunit.WebClient; public class AndroidTestActivity extends Activity { /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState);

Using Webdriver for PrimeFaces file upload

妖精的绣舞 提交于 2019-12-06 07:54:55
I've got a problem writing a test using Webdriver and HTMLUnit for my Primefaces page. What I've done is to add a simple Primefaces fileupload to the page, which will take a CSV file (no validation as yet), like this: <p:fileUpload id="listFileUpload" mode="simple" value="#{fileImportView.file}" /> This will indeed make an UploadedFile object available to my listener method when used from Firefox. However, when the same listener is called through the test the resulting UploadedFile is null. To give the fileupload field a value before submitting the form, I use sendKeys like this: WebElement

HtmlUnit WebClient Timeout

主宰稳场 提交于 2019-12-06 07:20:18
问题 In my previous questions about HtmlUnit Skip particular Javascript execution in HTML unit and Fetch Page source using HtmlUnit : URL got stuck I had mentioned that URL is getting stuck. I also found out that it is getting stuck due to one of the methods(parse) in HtmlUnit library is not coming out of execution. I did further work on this. I wrote code to get out of the method if it takes more than specified time-out seconds to complete. import java.io.IOException; import java.net

is it possible to load a HtmlPage from a string?

谁说我不能喝 提交于 2019-12-06 04:53:07
问题 I have stored a webpage's HTML in the database. I want to take advantage of HtmlUnit's ability to find/reference DOM elements. Is it possible to load the HtmlPage object from a string (via a database column)? 回答1: StringWebResponse may help. Edit: example: URL url = new URL("http://www.example.com"); StringWebResponse response = new StringWebResponse("<html><head><title>Test</title></head><body></body></html>", url); HtmlPage page = HTMLParser.parseHtml(response, new TopLevelWindow("top", new