Re: I can not open many websites

"Wolfgang Fahl" <[email protected]>
Newsgroups gmane.comp.web.httpunit.devel
Organization BITPlan GmbH
Message-ID <[email protected]>
Dear Jiangfan,

you might want to try out what you are testing manually 
before you expect the code to do it. If I understand 
your code right you are opening www.google.com and 
expect to see a link for httpunit there. If you don't 
enter any thing for search the google main page will 
most probably not display any httpunit link.

A question like this seems IMHO more suitable for the 
new httpunit users list.

Yours
  Wolfgang
> 
> 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
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.