htmlunit

loading elements with <object> tag in HtmlUnit

时间秒杀一切 提交于 2019-12-12 02:17:30
问题 I am loading a webpage which has lots of flash/gif elements embedded within object tags. I can see those elements in my browser, but I cannot reach them in HtmlUnit. page.getByXPath("//object"); //gives empty result waitForBackgroundJavaScript() doesn't help either. Anyone had the same problem before? Thanks!! 来源: https://stackoverflow.com/questions/23661147/loading-elements-with-object-tag-in-htmlunit

Blacklist and whitelist URLs in HtmlUnitDriver

烈酒焚心 提交于 2019-12-12 01:21:41
问题 Blacklisting URLs in PhantomJS and GhostDriver is pretty straightforward. First initialize the driver with a handler: PhantomJSDriver driver = new PhantomJSDriver(); driver.executePhantomJS(loadFile("/phantomjs/handlers.js")) And configure the handler: this.onResourceRequested = function (requestData, networkRequest) { var allowedUrls = [ /https?:\/\/localhost.*/, /https?:\/\/.*\.example.com\/?.*/ ]; var disallowedUrls = [ /https?:\/\/nonono.com.*/ ]; function isUrlAllowed(url) { function

(java) Listen to websocket messages with HtmlUnit

蓝咒 提交于 2019-12-12 00:52:59
问题 I am trying to listen to websocket messages on a particular page. It seems like HtmlUnit has support for WebSockets, but I can't find any documentation/tutorial or even an answer to: " is it possible to intercept websocket data with htmlUnit "? What I already tried: try (final WebClient webClient = new WebClient(BrowserVersion.CHROME)) { webClient.getOptions().setJavaScriptEnabled(true); webClient.getOptions().setCssEnabled(false); webClient.setAjaxController(new

login to vbulletin forums using htmlunit

旧时模样 提交于 2019-12-11 23:45:36
问题 i am trying to login vbulletins forum using htmlunit i can connect to my forum and set my username and password but when click in login button i can not login into my user this is my code : try{ final WebClient webClient = new WebClient(); webClient.getOptions().setJavaScriptEnabled(false); webClient.getOptions().setCssEnabled(false); final HtmlPage page1 =(HtmlPage) webClient.getPage("http://mysite.com/forum.php"); final HtmlForm form1 = (HtmlForm) page1.getElementById("navbar_loginform");

Unable to login to WSJ using HtmlUnit/HttpClient

余生长醉 提交于 2019-12-11 19:19:36
问题 I am a paid member of WSJ. I want to login to WSJ using HtmlUnit, but am unable to do so. Following is my code : WebClient webClient = new WebClient(BrowserVersion.FIREFOX_24); webClient.getOptions().setJavaScriptEnabled(true); webClient.getOptions().setCssEnabled(false); webClient.getOptions().setRedirectEnabled(true); webClient.getOptions().setThrowExceptionOnScriptError(false); webClient.setAjaxController(new NicelyResynchronizingAjaxController()); webClient.getCookieManager()

HTMLUnit with FIddler and SSL

久未见 提交于 2019-12-11 19:15:42
问题 I configured HTMLUnit so it uses Fiddler as a proxy. But when Fiddler is capturing traffic and I browse a site which has ssl(https) I get the following error in Java "javax.net.ssl.SSLPeerUnverifiedException: peer not authenticated" Is there anyway fix around this? I want to see all SSL traffic in Fiddler. Regards! 回答1: You need to configure Java to trust Fiddler's root certificate, which you can export from Fiddler using the Tools > Fiddler Options > HTTPS > Export Root Certificate button.

Use HtmlUnit to search google

∥☆過路亽.° 提交于 2019-12-11 18:08:57
问题 The following code is an attempt to search google, and return the results as text or html. The code was almost entirely copied directly from code snippets online, and i see no reason for it to not return results from the search. How do you return google search results, using htmlunit to submit the search query, without a browser? import com.gargoylesoftware.htmlunit.WebClient; import java.io.*; import com.gargoylesoftware.htmlunit.html.HtmlPage; import com.gargoylesoftware.htmlunit.html

Can't log in to Google using HtmlUnit - Can't advance to web page for entering password

梦想的初衷 提交于 2019-12-11 13:59:24
问题 Has anyone successfully logged into Google using HtmlUnit recently? I used to be able to, but since upgrading the BrowserVersion my WebClient uses, I am locked out. Many thanks if you can help me as I am really stuck! I have been using BrowserVersion.CHROME from HtmlUnit-2.18. Login is a two-step process involving two forms. The first form has just the email field and the ‘Next’ button. After entering an email address and clicking ‘Next’, the second form displays. This form has the password

HtmlUnit Google Login

和自甴很熟 提交于 2019-12-11 13:56:50
问题 I want to automated the google login and accept oauth to get the authentication code. I get a NullPointerExeption by nextButton.click(), I can't find the "next" Button. WebClient webClient = new WebClient(); //BrowserVersion.FIREFOX_38 HtmlPage page = webClient.getPage("https://accounts.google.com/o/oauth2/auth?"); HtmlTextInput email = (HtmlTextInput)page.getElementById("Email"); email.setValueAttribute(emailAddress); HtmlSubmitInput nextButton = (HtmlSubmitInput)page.getElementById("next");

HTMLUnit : Determine if the “login” was successful

有些话、适合烂在心里 提交于 2019-12-11 12:41:59
问题 I have developed a script whose sole purpose is to check if the website/service is up and running. The way it does that is ,it connects to the page using its url and logs in to the site using the user credentials. If the login is successful then the service is running fine. This script has been written in Java and uses HTMLUnit. Here lies my problem. How do i ensure the HTML page returned after logging in(clicking the login/sign in button after filling out the form) is the post-login "Account