How to find a node(or element) in XPath, when the path to that node is always different
So I'm trying to check the XPath of a block of text to verify that th开发者_开发百科e 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)?
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...)
精彩评论