Latest Inquiries - Data Extraction Software

text() of a node = text() of another node

Submitted: 5/5/2016
Hi,

Website http://www.youcanmovehere.com/wayne_walnut has a title 'Wayne Walnut Apartments' in a H2 tag who's XPATH is //DIV[@id='property-detail-nav'//H2.

When you click 'Show Available Units' on the page, I want to select all units (which are in DIV class='listing-item__body') that have the same //A text as the H2 tag I specified above.

So in this case I want to select all units that have the anchor with text 'Wayne Walnut Apartments', which is just like the title on the //H2 tag. I can easily select it like this:
//DIV[@class='listing-item__body'][//H2//A[.='Wayne Walnut Apartments']]

But instead I want to change the XPATH to be dynamic. I want it to do something like this:
//DIV[@class='listing-item__body'][//H2//A[text()=text(//DIV[@id='property-detail-nav'//H2)]
but the syntax is wrong.

How can I select the DIV where the anchor's text equals the text of a H2 node within DIV [@id='property-detail-nav']?

I attached a project file for reference. Thanks!

YouCanMoveHere.rip

Replied: 5/6/2016 7:55:41 AM

Please check the attached new project.

I created a new element called 'h2' to capture the header text, then write custom xpath function the set it in xpath comparing to current text in <a> link:

//DIV[@class='listing-item__body'][//H2//A[.=GetHeaderText()]]

You have to upgarde to use agent version 2 then use this method.

YouCanMoveHere.rip