Re: I can not open many websites
Russell Gold <[email protected]>
| Newsgroups | gmane.comp.web.httpunit.devel |
|---|---|
| Message-ID | <[email protected]> |
On Apr 16, 2008, at 8:47 PM, real self wrote:
> I attached the exceptions next. And maybe I found my mistake here.
> The reason is that by calling " WebLink httpunitLink =
> response.getFirstMatchingLink( WebLink.MATCH_CONTAINED_TEXT,
> "Adver" ); ", the httpunitLink does not have a full and complete
> URL, instead it is a partial URL. More specifically httpunitLink
> has the /intl/en/ads as its URL instead of http://www.google.com/intl/en/ads
> .
>
> How can I add the base URL to make it a complete URL?
No, actually, that's not the problem. HttpUnit should handle that
part. The problem is a Javascript error. The Google site tends to use
some fairly sophisticated Javascript that we are clearly not handling
properly. We are working on this, but are not there yet.
>
>
> Thanks.
>
> Jiangfan
>
> The exceptions are following:
>
> ConversionError: The undefined value has no properties. (httpunit;
> line 4)
> at
> org.mozilla.javascript.NativeGlobal.constructError(NativeGlobal.java:
> 597)
> at
> org.mozilla.javascript.NativeGlobal.constructError(NativeGlobal.java:
> 557)
> at
> org.mozilla.javascript.ScriptRuntime.getProp(ScriptRuntime.java:712)
> at org.mozilla.javascript.Interpreter.interpret(Interpreter.java:
> 2035)
> at org.mozilla.javascript.Interpreter.interpret(Interpreter.java:
> 2163)
> at
> org.mozilla.javascript.InterpretedScript.call(InterpretedScript.java:
> 62)
> at
> org.mozilla.javascript.InterpretedScript.exec(InterpretedScript.java:
> 55)
> at org.mozilla.javascript.Context.evaluateReader(Context.java:820)
> at org.mozilla.javascript.Context.evaluateString(Context.java:784)
> at com.meterware.httpunit.javascript.JavaScript
> $JavaScriptEngine.executeScript(JavaScript.java:132)
> at
> com
> .meterware
> .httpunit
> .scripting.ScriptableDelegate.runScript(ScriptableDelegate.java:65)
> at
> com
> .meterware
> .httpunit.parsing.ScriptFilter.getTranslatedScript(ScriptFilter.java:
> 151)
> at
> com
> .meterware
> .httpunit.parsing.ScriptFilter.endElement(ScriptFilter.java:131)
> at org.cyberneko.html.filters.DefaultFilter.endElement(Unknown
> Source)
> at org.cyberneko.html.filters.NamespaceBinder.endElement(Unknown
> Source)
> at org.cyberneko.html.HTMLTagBalancer.callEndElement(Unknown
> Source)
> at org.cyberneko.html.HTMLTagBalancer.endElement(Unknown Source)
> at org.cyberneko.html.HTMLScanner$SpecialScanner.scan(Unknown
> Source)
> at org.cyberneko.html.HTMLScanner.scanDocument(Unknown Source)
> at org.cyberneko.html.HTMLConfiguration.parse(Unknown Source)
> at org.cyberneko.html.HTMLConfiguration.parse(Unknown Source)
> at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
> at org.apache.xerces.parsers.DOMParser.parse(Unknown Source)
> at
> com
> .meterware.httpunit.parsing.NekoHTMLParser.parse(NekoHTMLParser.java:
> 41)
> at com.meterware.httpunit.HTMLPage.parse(HTMLPage.java:255)
> at
> com.meterware.httpunit.WebResponse.getReceivedPage(WebResponse.java:
> 1109)
> at com.meterware.httpunit.WebResponse.getFrames(WebResponse.java:
> 1098)
> at
> com.meterware.httpunit.WebResponse.getFrameRequests(WebResponse.java:
> 875)
> at
> com.meterware.httpunit.FrameHolder.updateFrames(FrameHolder.java:179)
> at
> com.meterware.httpunit.WebWindow.updateFrameContents(WebWindow.java:
> 252)
> at
> com.meterware.httpunit.WebClient.updateFrameContents(WebClient.java:
> 485)
> at com.meterware.httpunit.WebWindow.updateWindow(WebWindow.java:
> 146)
> at
> com.meterware.httpunit.WebWindow.getSubframeResponse(WebWindow.java:
> 130)
> at com.meterware.httpunit.WebWindow.getResponse(WebWindow.java:
> 121)
> at com.meterware.httpunit.WebWindow.sendRequest(WebWindow.java:
> 110)
> at
> com
> .meterware
> .httpunit.WebRequestSource.submitRequest(WebRequestSource.java:253)
> at
> com
> .meterware
> .httpunit.WebRequestSource.submitRequest(WebRequestSource.java:232)
> at com.meterware.httpunit.WebLink.click(WebLink.java:98)
> at jfshi.Googlemaps.main(Googlemaps.java:23)
> Exception: com.meterware.httpunit.ScriptException: Script
> '(function(){var h = document.location.hash;for(var i=0;i<h.length;i+
> +){if('<>&\'"'.indexOf(h.charAt(i))>=0)
> {document.location=document.location.href.split('#')[0]}}})();var
> _udn, _uhash, _utimeout, _utcp;(function(){if(!_udn)_udn="auto";if(!
> _uhash)_uhash="on";if(!_utcp)_utcp="/";if(!
> _utimeout)_utimeout="1800";function n(){if(!_udn||_udn==""||
> _udn=="none"){_udn="";return 1}if(_udn=="auto"){var
> f=document.domain;if(f.substring(0,4)=="www.")
> {f=f.substring(4,f.length)}_udn=f}if(_uhash=="off"){return 1}if(!
> _udn||_udn==""){return 1}var b=0,g=0;for(var
> h=_udn.length-1;h>=0;h--){var i=parseInt(_udn.charCodeAt(h),0);
> b=(b<<6&268435455)+i+(i<<14);if((g=b&266338304)!=0)b=b^g>>21}return
> b}function k(f,b,g){b=n()+"."+b;if(_udn&&_udn!=""){b
> +=";domain="+_udn}b+=";path="+_utcp;if(g==0&&_utimeout&&_utimeout!
> =""){g=_utimeout}if(g>0){b+=";expires="+(new Date((new
> Date).getTime()+g*1000)).toGMTString()}document.cookie=f
> +"="+b}k('__utmx','',63072000);k('__utmxx','',63072000)})();function
> utmx_section(n){return utmx("section",n)}function utmx(n,k,f,b)
> {function g(m,c,e){function l(A,B,j,s,C,t){var u=new
> String(B),v=u.indexOf(s);if(v>=0){var w=t?u.indexOf(t,v):-1;if(w<0)
> {w=u.length}var x=u.substring(v+1,w),p=j.indexOf(s);if(p<0){p=0}var
> q=t?j.indexOf(t,p):-1;if(q<0){q=j.length}j=A?j.substring(0,p?p:q)+(x?
> s+x:"")+j.substring(q):j.substring(0,q)+(p?C:s)+x
> +j.substring(q)}return j}if(!c){c=0}var d=i(m);if(!d){return
> true}var a=d.contents,y=d.index;if(c!=y)
> {a
> =
> l
> (false
> ,document
> .location,a,"?","&","#");a=l(true,document.location,a,"#",";");var
> r=0;while(a.charAt(r)==" ")r+
> +;if(r>0)a=a.substring(r);if(a.substring(0,7).toLowerCase()!
> ="http://"&&a.substring(0,8).toLowerCase()!
> ="https://")a="http://"+a;if(e){d.contents=a;var z=[d];a=e(z)}if(a)
> {document.location.replace(a)}}return true}function h(m){var
> c=i(m);if(c&&c.index>
> 0){document.write(c.contents+"<nosc"+"ript>")}return true}function
> i(m){return utmx_global_vd[m]}var o;switch(n){case
> "section":o=h(k);break;case "url":o=g(k,f,b);break;case
> "variation":o=i(k);break;case "combination":o= 0;break}return o}var
> utmx_global_vd={'Body':{index:0,contents:''}};' failed:
> ConversionError: The undefined value has no properties. (httpunit;
> line 4)
>
>
>
>
>
>
> On Wed, Apr 16, 2008 at 3:50 PM, Russell Gold
> <[email protected]> wrote:
> What exceptions did you get?
>
> On Apr 16, 2008, at 10:14 AM, real self wrote:
>> Dear Wolfgang,
>>
>> Thanks for your response.
>>
>> If I understand your code right you are opening www.google.com and
>> expect to see a link for httpunit there.
>>
>> There is a link named "Advertising Programs" in
>> the .www.google.com. I use the following statement to find it.
>>
>> WebLink httpunitLink =
>> response.getFirstMatchingLink( WebLink.MATCH_CONTAINED_TEXT,
>> "Adver" );
>>
>> Then I use the statement " response = httpunitLink.click();//"
>> which gives me an exception there.
>>
>> I also try other websites, such as mapquest.com, but the error
>> happens every time. I do run your example successfully.
>>
>>
>>
>>
>> A question like this seems IMHO more suitable for the new httpunit
>> users list.
>>
>> I have thought to send an email to the user list, as I did it in
>> other groups. But it seems that the user list is not active. I
>> found there was no archive in the httpunit-user maillist in your
>> sourceforge website.
>>
>> If you think someone will response in the user list, I will do that
>> next time.
>>
>> Thanks again.
>>
>> Sincerely Yours.
>> Jiangfan
>>
>>
>> >
>> > Hi, All,
>> >
>> > I could not open many websites, but I could run your example for
>> the
>> > http://www.meterware.com.
>> >
>> > I must make some mistakes somewhere. Could you please be nice to
>> point
>> > it out for me? Thanks.
>> >
>> > The problem is the statement " response = httpunitLink.click()";
>> >
>> > Thanks.
>> >
>> > Jiangfan
>> >
>> >
>> > My code:
>> > -------------------Begin--------------
>> >
>> > package jfshi;
>> >
>> > import com.meterware.httpunit.GetMethodWebRequest;
>> > import com.meterware.httpunit.WebConversation;
>> > import com.meterware.httpunit.WebLink;
>> > import com.meterware.httpunit.WebRequest;
>> > import com.meterware.httpunit.WebResponse;
>> >
>> > public class Googlemaps {
>> > public static void main( String[] params ) {
>> > try {
>> > // create the conversation object which will maintain
>> > state for us
>> > WebConversation wc = new WebConversation();
>> >
>> > // Obtain the main page on the maps google web site
>> > WebRequest request = new GetMethodWebRequest(
>> > "http://www.google.com" );
>> > WebResponse response = wc.getResponse( request );
>> >
>> > // find the link which contains the string "HttpUnit" and
>> > click it
>> > WebLink httpunitLink = response.getFirstMatchingLink(
>> > WebLink.MATCH_CONTAINED_TEXT, "Adver" );
>> > System.out.println(httpunitLink.getURLString().toString())
>> > ;
>> >
>> > response = httpunitLink.click();//
>> > <==========================SOME EXCEPTIONS HAPPEND HERE.
>> >
>> >
>> > for(int i=0;i<response.getLinks().length;i++){
>> > WebLink tmp=response.getLinks()[i];
>> > System.out.println(tmp.getText().toString());
>> > }
>> >
>> > } catch (Exception e) {
>> > System.err.println( "Exception: " + e );
>> > System.out.println("wrong!!");
>> > }
>> > }
>> > }
>> > ------------------Over---------------------------
>> >
>> >
>> >
>>
>>
>>
>> BITPlan - smart solutions
>> Pater-Delp-Str. 1, D-47877 Willich Schiefbahn
>> Tel. +49 1805 - BITPLAN / +49 1805 248 752, Fax +49 2154 811-481
>> Web: http://www.bitplan.de
>> bitplan GmbH, Willich - HRB 6820 Krefeld, VAT-ID: 10258040548,
>> Geschäftsführer: Wolfgang Fahl
>>
>>
>> -------------------------------------------------------------------------
>> This SF.net email is sponsored by the 2008 JavaOne(SM) Conference
>> Don't miss this year's exciting event. There's still time to save
>> $100.
>> Use priority code J8TL2D2.
>> http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
>> _______________________________________________
>> Httpunit-develop mailing list
>> [email protected]
>> https://lists.sourceforge.net/lists/listinfo/httpunit-develop
>>
>>
>> -------------------------------------------------------------------------
>> This SF.net email is sponsored by the 2008 JavaOne(SM) Conference
>> Don't miss this year's exciting event. There's still time to save
>> $100.
>> Use priority code J8TL2D2.
>> http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone_______________________________________________
>> Httpunit-develop mailing list
>> [email protected]
>> https://lists.sourceforge.net/lists/listinfo/httpunit-develop
>
>
> -------------------------------------------------------------------------
> This SF.net email is sponsored by the 2008 JavaOne(SM) Conference
> Don't miss this year's exciting event. There's still time to save
> $100.
> Use priority code J8TL2D2.
> http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
> _______________________________________________
> Httpunit-develop mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/httpunit-develop
>
>
> -------------------------------------------------------------------------
> This SF.net email is sponsored by the 2008 JavaOne(SM) Conference
> Don't miss this year's exciting event. There's still time to save
> $100.
> Use priority code J8TL2D2.
> http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone_______________________________________________
> Httpunit-develop mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/httpunit-develop
-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference
Don't miss this year's exciting event. There's still time to save $100.
Use priority code J8TL2D2.
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
_______________________________________________
Httpunit-develop mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/httpunit-develop