On Wed, Mar 28, 2007 at 07:44:08PM +0900, Peter S. wrote:
I wuold like to click on a link in WWW::Mechaznie, and I know only the
Hpricot XPath of the element I would like to click, nothing more. While
it’s certainly possible to look up the text of the element pointed to by
the XPath, there can be more elements with that text, but only one
element with that XPath.
Is this possible with Mechanize somehow?
Yes, this is possible. Mechanize can click an hpricot element, as long
as it has an ‘href’, or a ‘src’ attribute. For example:
page = mech.get(‘http://example.com/’)
new_page = mech.click((page/’//some/xpath/a’))
If you’ve got more questions, don’t forget about the mechanize mailing
Hope that helps!