From: Marc G. <mgu...@ya...> - 2005-07-15 09:03:58
|
Hi, I don't use htmlunit through a proxy but I think that you have to use the WebClient c'tor with 3 args: http://htmlunit.sourceforge.net/apidocs/com/gargoylesoftware/htmlunit/WebClient.html#WebClient(com.gargoylesoftware.htmlunit.BrowserVersion,%20java.lang.String,%20int) Marc. Javier G wrote: > Hello, I´m a novice in htmlunit, trying to using it through a > corporative proxy. > it´s the same error as if proxy authentication were not used. > This is the code i´m using, but it always throws UnknowHostException. > > Thanks in advance! > > import com.gargoylesoftware.htmlunit.*; > import com.gargoylesoftware.htmlunit.html.*; > import junit.framework.Assert; > import java.net.*; > import org.apache.commons.httpclient.auth.CredentialsProvider; > import com.gargoylesoftware.htmlunit.DefaultCredentialsProvider; > > ... > > public void test_auHomePage() throws Exception { > final WebClient webClient = new WebClient(); > final DefaultCredentialsProvider scp = new DefaultCredentialsProvider(); > scp.addProxyCredentials("user", "password","corporative.proxy",8080); > webClient.setCredentialsProvider(scp); > > final URL url = new URL("http://htmlunit.sourceforge.net"); > final HtmlPage page = (HtmlPage)webClient.getPage(url); > Assert.assertEquals( "htmlunit - Welcome to HtmlUnit", > page.getTitleText() ); > > > ------------------------------------------------------------------------ > > Correo Yahoo! > Comprueba qué es nuevo, aquí > <http://us.rd.yahoo.com/mail/es/whatsnew/*http://es.whatsnew.mail.yahoo.com/> > http://correo.yahoo.es |