From: David D. K. <ddk...@ki...> - 2005-07-15 14:54:13
|
It's probably a missing (or misimplemented) JavaScript feature in Htmlunit. Have you tried using a different browser type by passing in a constant to the WebClient constructor to make it look like a different browser? The default is MSIE 6, I believe. Try the Mozilla 1.0 browser to see if it behaves differently. For example, Google's home page returns different JavaScript depending on the browser type. Htmlunit has a "sanity test" as part of its unit tests that hits the home pages of a variety of external web sites. I would recommend filing a bug on SourceForge about this since it seems to be another good external web site to hit. Dave On Jul 11, 2005, at 1:02 AM, John Smith wrote: > I don't have a specific question per se. However, I am concerned > about HTMLUnit's behavior when I attempt to access ebay.com: > > Code > ------------------ > import java.net.URL; > import com.gargoylesoftware.htmlunit.WebClient; > import com.gargoylesoftware.htmlunit.html.HtmlPage; > > public class Test { > > public static void main( String[] args ) { > > try { > > WebClient webClient = new WebClient(); > webClient.setRedirectEnabled( true ); > > HtmlPage page = ( HtmlPage ) webClient.getPage( new URL( > "http://www.ebay.com" ) ); > > if ( page != null ) { > > System.out.println( page.asXml() ); > } > > } catch ( Exception e ) { > > System.err.println( "Exception: " + e.getMessage() ); > e.printStackTrace(); > } > } > } > > Output > ------------------ > >> java Test >> > Jul 11, 2005 1:51:59 AM > com.gargoylesoftware.htmlunit.javascript.host.Document jsxSet_cookie > INFO: Added cookie: ebay=%5Edv%3D42d208ff%5E > Jul 11, 2005 1:52:00 AM > com.gargoylesoftware.htmlunit.javascript.host.Document jsxSet_cookie > INFO: Added cookie: ebay=%5Edv%3D42d20900%5E > Jul 11, 2005 1:52:04 AM > com.gargoylesoftware.htmlunit.javascript.host.Document jsxSet_cookie > INFO: Added cookie: lucky9=626637 > Exception in thread "main" java.lang.StackOverflowError > at java.net.URLStreamHandler.parseURL(Unknown Source) > at sun.net.www.protocol.file.Handler.parseURL(Unknown Source) > at java.net.URL.<init>(Unknown Source) > at java.net.URL.<init>(Unknown Source) > at sun.misc.URLClassPath$FileLoader.getResource(Unknown > Source) > at sun.misc.URLClassPath$FileLoader.findResource(Unknown > Source) > at sun.misc.URLClassPath.findResource(Unknown Source) > at java.net.URLClassLoader$2.run(Unknown Source) > at java.security.AccessController.doPrivileged(Native Method) > at java.net.URLClassLoader.findResource(Unknown Source) > at java.lang.ClassLoader.getResource(Unknown Source) > at java.lang.ClassLoader.getResourceAsStream(Unknown Source) > at java.util.ResourceBundle$1.run(Unknown Source) > at java.security.AccessController.doPrivileged(Native Method) > at java.util.ResourceBundle.loadBundle(Unknown Source) > at java.util.ResourceBundle.findBundle(Unknown Source) > at java.util.ResourceBundle.getBundleImpl(Unknown Source) > at java.util.ResourceBundle.getBundle(Unknown Source) > at java.util.logging.Level.getLocalizedName(Unknown Source) > at java.util.logging.SimpleFormatter.format(Unknown Source) > at java.util.logging.StreamHandler.publish(Unknown Source) > at java.util.logging.ConsoleHandler.publish(Unknown Source) > at java.util.logging.Logger.log(Unknown Source) > at java.util.logging.Logger.doLog(Unknown Source) > at java.util.logging.Logger.logp(Unknown Source) > at org.apache.commons.logging.impl.Jdk14Logger.log > (Jdk14Logger.java:91) > at org.apache.commons.logging.impl.Jdk14Logger.error > (Jdk14Logger.java:119) > at > com.gargoylesoftware.htmlunit.javascript.StrictErrorReporter.runtimeEr > ror(StrictErrorReporter.java:113) > at org.mozilla.javascript.Context.reportRuntimeError > (Context.java:1054) > at org.mozilla.javascript.Parser.parse(Parser.java:354) > at org.mozilla.javascript.Parser.parse(Parser.java:287) > at org.mozilla.javascript.Context.compileImpl(Context.java: > 2349) > at org.mozilla.javascript.Context.compileString > (Context.java:1372) > at org.mozilla.javascript.ScriptRuntime.evalSpecial > (ScriptRuntime.java:2202) > at org.mozilla.javascript.ScriptRuntime.callSpecial > (ScriptRuntime.java:2071) > at org.mozilla.javascript.Interpreter.interpret > (Interpreter.java:2922) > at org.mozilla.javascript.Interpreter.interpret > (Interpreter.java:2164) > at org.mozilla.javascript.InterpretedFunction.call > (InterpretedFunction.java:140) > at org.mozilla.javascript.ScriptRuntime.evalSpecial > (ScriptRuntime.java:2217) > at org.mozilla.javascript.ScriptRuntime.callSpecial > (ScriptRuntime.java:2071) > at org.mozilla.javascript.Interpreter.interpret > (Interpreter.java:2922) > at org.mozilla.javascript.Interpreter.interpret > (Interpreter.java:2164) > at org.mozilla.javascript.InterpretedFunction.call > (InterpretedFunction.java:140) > at org.mozilla.javascript.ScriptRuntime.evalSpecial > (ScriptRuntime.java:2217) > at org.mozilla.javascript.ScriptRuntime.callSpecial > (ScriptRuntime.java:2071) > at org.mozilla.javascript.Interpreter.interpret > (Interpreter.java:2922) > at org.mozilla.javascript.Interpreter.interpret > (Interpreter.java:2164) > at org.mozilla.javascript.InterpretedFunction.call > (InterpretedFunction.java:140) > at org.mozilla.javascript.ScriptRuntime.evalSpecial > (ScriptRuntime.java:2217) > at org.mozilla.javascript.ScriptRuntime.callSpecial > (ScriptRuntime.java:2071) > at org.mozilla.javascript.Interpreter.interpret > (Interpreter.java:2922) > at org.mozilla.javascript.Interpreter.interpret > (Interpreter.java:2164) > at org.mozilla.javascript.InterpretedFunction.call > (InterpretedFunction.java:140) > at org.mozilla.javascript.ScriptRuntime.evalSpecial > (ScriptRuntime.java:2217) > at org.mozilla.javascript.ScriptRuntime.callSpecial > (ScriptRuntime.java:2071) > at org.mozilla.javascript.Interpreter.interpret > (Interpreter.java:2922) > at org.mozilla.javascript.Interpreter.interpret > (Interpreter.java:2164) > at org.mozilla.javascript.InterpretedFunction.call > (InterpretedFunction.java:140) > at org.mozilla.javascript.ScriptRuntime.evalSpecial > (ScriptRuntime.java:2217) > at org.mozilla.javascript.ScriptRuntime.callSpecial > (ScriptRuntime.java:2071) > at org.mozilla.javascript.Interpreter.interpret > (Interpreter.java:2922) > at org.mozilla.javascript.Interpreter.interpret > (Interpreter.java:2164) > at org.mozilla.javascript.InterpretedFunction.call > (InterpretedFunction.java:140) > at org.mozilla.javascript.ScriptRuntime.evalSpecial > (ScriptRuntime.java:2217) > ... > > * Note: The last five stack trace lines keep repeating (hence the ...) > > Does anyone have any suggestions or explanations? Thanks. > |