Reputation: 4439
how do I get "Div/yield" value from here? i've tried //td[node()='Div/yield'
and //td[text()='Div/yield'
.
and //td[@data-snapfield='latest_dividend-dividend_yield']/following-sibling::td
Upvotes: 1
Views: 433
Reputation: 373
@sideshowbarker is correct in that there's a newline at the end so looking for an element with the exact text would return 0 results. Another way to do this (one is through @sideshowbarker's answer) is to look for an element that contains this text. So the first step is:
//td[contains(text(),'Div/yield')]
But you don't need this. Your last answer is on the right track. You've identified the element that you're after, but I think you're looking for the text. So you need to add text()
at the end:
//td[@data-snapfield='latest_dividend-dividend_yield']/following-sibling::td/text()
But if you want to use the field name, so you could use the xpath for the other fields as well, then just combine these:
//td[contains(text(),'Field name')]/following-sibling::td/text()
Now just replace Field name with the field you're after..
e.g. 'Div/yield': //td[contains(text(),'Div/yield')]/following-sibling::td/text()
Upvotes: 2