Menu ▾ ▴

#1 Add facility to find a link by the Text

open
nobody
None
5
2002-09-25
2002-09-25
No

I am testing an example page set that I cannot
change. This has links that are automatically
generated and do not have 'name', 'id' or 'title'
attributes. I know what the text that will appear is
(e.g. "About Us"), and I would like to be able to find
them by this text.

I have in mind a method on Segment a bit like:

/**
Returns HTML link with specified text.
*/
public Link getLinkWithText( String title )
throws Exception
{
Element linkElem =
ParseUtils.findElementByContent( elem(), "a",
title );
return linkElem == null ? null : (Link)window
().newObject( linkElem,
Link.class );
}

but I have not added this myself as I am not
confident of the style used, and worried that this
method does not look at a segment (no start or
stop).

Could this sort of enhancement be made in the
next release, please?
Is this sort of suggestion useful?
If you want more detail or other information, please
get back to me (I am not used to posting in
SourceForge).

Discussion


Log in to post a comment.