/** * Finds a hyper-link that has the specified text and whose * target URL starts with the given prefix. */ static WebLink findLink( WebConversation wc, String text, String urlPrefix ) throws ProcessingException, SAXException { WebLink[] links = wc.getCurrentPage().getLinks(); for( int i=0; i<links.length; i++ ) { if( links[i].asText().indexOf(text)==-1 ) continue; if( !links[i].getURLString().startsWith(urlPrefix)) continue; return links[i]; } throw new ProcessingException("no link found for '"+text+'\''); }