Question

So I'm trying to check the XPath of a block of text to verify that the correct page has been returned. However, for the several sites and designs I'm testing(with Selenium 2), the block of text I'm searching for is always the same, but the XPath to it is always different(the block of text has no defining ID or Class, so I need to check the text). Is there a simple way to scan for the particular text, without having to write logic that will try node after node until it finds the text(or just fails)?

Was it helpful?

Solution

How about something like this:

//*[contains(text(), 'text you want to find')]

(I assume you have to use XPath? Personally I prefer LINQ to XML where it's feasible, but presumably you're giving the XPath expression to Selenium...)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top