From: Marc G. <mgu...@ya...> - 2005-06-02 10:27:46
|
can you try to minimze the page to get the absolute smallest html code that break. I don't have unpayed time to look at your special problem, but if it is small enough the chance is bigger that I - or someone else - can find time to look at it. Marc. SALL Ousmane wrote: > I try to process localy this page: > http://www.washingtonpost.com/wp-dyn/content/article/2005/05/08/AR2005050800802.html. > So i save it on my hard drive, and i call htmlunit > like this: > > WebClient webClient = new > WebClient(BrowserVersion.INTERNET_EXPLORER_6_0); > String webPagecode = doc.getAsString(); // the content > of local file > > MockWebConnection webConnection = new > MockWebConnection(webClient); > webConnection.setDefaultResponse(webPagecode); > webClient.setWebConnection(webConnection); > > HtmlPage = (HtmlPage) webClient.getPage(URL); > > Doing this, the exception come during getPage() > process. > > If i delete any javascript source like this: > var adCode = "" ; > adCode += ('<script language="JavaScript1.1" > src="http://ad.doubleclick.net/adj/'+keyvalues+'">'); > adCode += ('</script>'); > document.write(adCode); > > getPage() work well. > --- Marc Guillemot <mgu...@ya...> a écrit : > > >>Hi Sall, >> >>I don't fully understand the problem. Can your >>provide a minimal unit case illustrating it? >> >>Marc. >> >>SALL Ousmane wrote: >> >>>Hi, >>>Thanks, It work now if I dont use a >> >>MockWebConnection. >> >>>But when I use it I dont have any stacktrace, but >> >>only >> >>>an OutOfMemory error due to a line of code like : >>> var adCode = "" ; >>> adCode += ('<script language="JavaScript1.1" >>> >> > src="http://ad.doubleclick.net/adj/'+keyvalues+'">'); > >>> adCode += ('</script>'); >>> document.write(adCode); >>> >>>Maybe HtmlUnit is trying to load external URL but >> >>with >> >>>MockWebConnection it fail? >>> >>>Is there any way to avoid this external call, or >> >>maybe >> >>>made a pre-process to import remote javascript >> >>source >> >>>before apply htmlJUnit MockWebConnection ? >>>thank in advance for any help! >>>---- >>>SALL Ousmane >>>Hi, >>> >>> in the first case, I can imagine that the url is >> >>not >> >>>correctly resolved (what would explain >>>the long time before the >>> exeception). I can"t say more without stacktrace >> >>and >> >>>example of the failing code. >>> >>> In the second case, it looks like a classpath >> >>issue. >> >>>Are your sure to use the lib provided >>>with htmlunit and only these >>> libs? >>> >>> Marc. >>> >>> SALL Ousmane wrote: >>> > Hi there >>> > Currently i"am working with html unit on local >> >>page >> >>>in >>> > order to handle javascript redirection. >>> > It"s s >>>eems to work well, but i have 2 cases that >>> > generate exception: >>> > I load my local page like this: >>> > ----------------- >>> > WebClient client = new >>> > WebClient(BrowserVersion.MOZILLA_1_0); >>> > MockWebConnection cnx = new >>>MockWebConnection(client); >>> > >>> > cnx.setDefaultResponse(st); >>> > client.setWebConnection(cnx); >>> > >>> > HtmlPage page = (HtmlPage) client.getPage(new >>> > URL(url)); >>> > ----------------- >>> > >>> > >>> > And when i have some direct redirection in >>>javascript >>> > source, like: >>> > >>> > ---------------- >>> > <SCRIPT language="javascript"> >>> > >>> > window.open("misc/popup/popup_head.htm","","height=360,width=550"); > >>> > </SCRIPT> >>> > <HTML> >>> > <HEAD> >>> > ---------------- >>> > >>> > my application generate an exception, after a >> >>long >> >>> > time of exectution >>> > (maybe stackoverflow or time out ?) >>> > >>> > >>> > And when i have some javascript include by >>>javascript, >>> > like: >>> > ---------------- >>> > >>> > <SCRIPT language="JavaScript"> >>> > <!-- >>> > document.write("<script language="JavaScript" >>> > src="lib-load.js"></scr"+"ipt>") >>> > //--> >>> > </SCRIPT> >>> > ---------------- >>> > >>> > the generated exception is: >>> > >>> > java.lang.NoSuchMethodError: >>> > >>> > org.apache.commons.httpclient.util.EncodingUtil.getString([BIILjava/lang/StringLjava/lang/String; > >>> > at >>> > >>> > com.gargoylesoftware.htmlunit.html.HtmlPage.loadJavaScriptFromUrl(HtmlPage.java:842) > >>> > >>> > So, maybe it can be possible to pre-parse >>>javascript >>> > code in order to find that >>> > document.write will make a javascript >> >>inclusion? >> >>> > >>> > thank in advance for any help! >>> > >>> > >>> > >>> > >>> > >>> > >>> > >>> > _____________________________________________________________________________ > >>> > Découvrez le nouveau Yahoo! Mail : 1 Go >> >>d"espace de >> >>>stockage pour vos mails, photos et >>>vidéos ! >>> > Créez votre Yahoo! Mail sur >>>http://fr.mail.yahoo.com >>> > >>> > >>> > >>> > ------------------------------------------------------- > >>> > This SF.Net email is sponsored by Yahoo. >>> > Introducing Yahoo! Search Developer Network - >>>Create apps using Yahoo! >>> > Search APIs Find out how you can build Yahoo! >>>directly into your own >>> > Applications - visit >>> >> > http://developer.yahoo.net/?fr=offad-ysdn-ostg-q22005 > >>> > _______________________________________________ >>> > Htmlunit-user mailing list >>> > Htmlunit-user@li... >>> > >>> > https://lists.sourceforge.net/lists/listinfo/htmlunit-user > >>> > >>> >>> >>> >>> >>> >>> >>> >>> >> > _____________________________________________________________________________ > >>>Découvrez le nouveau Yahoo! Mail : 1 Go d'espace >> >>de stockage pour vos mails, photos et vidéos ! >> >>>Créez votre Yahoo! Mail sur >> >>http://fr.mail.yahoo.com >> >>> >>> > ------------------------------------------------------- > >>>This SF.Net email is sponsored by Yahoo. >>>Introducing Yahoo! Search Developer Network - >> >>Create apps using Yahoo! >> >>>Search APIs Find out how you can build Yahoo! >> >>directly into your own >> >>>Applications - visit >> > http://developer.yahoo.net/?fr=offad-ysdn-ostg-q22005 > >>>_______________________________________________ >>>Htmlunit-user mailing list >>>Htm...@li... >>> >> > https://lists.sourceforge.net/lists/listinfo/htmlunit-user > >> >> >> > ------------------------------------------------------- > >>This SF.Net email is sponsored by Yahoo. >>Introducing Yahoo! Search Developer Network - Create >>apps using Yahoo! >>Search APIs Find out how you can build Yahoo! >>directly > > === message truncated === > > > > > > > > _____________________________________________________________________________ > Découvrez le nouveau Yahoo! Mail : 1 Go d'espace de stockage pour vos mails, photos et vidéos ! > Créez votre Yahoo! Mail sur http://fr.mail.yahoo.com > > > ------------------------------------------------------- > This SF.Net email is sponsored by Yahoo. > Introducing Yahoo! Search Developer Network - Create apps using Yahoo! > Search APIs Find out how you can build Yahoo! directly into your own > Applications - visit http://developer.yahoo.net/?fr=offad-ysdn-ostg-q22005 > _______________________________________________ > Htmlunit-user mailing list > Htm...@li... > https://lists.sourceforge.net/lists/listinfo/htmlunit-user > |