Tell me more ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

Selenium java code for regular expression.

Xpath = "//*[@id='gritter-item-6']/div[2]/div[2]/p"

In above xpath 6 is varying, any one help me how to solve this problem

Please give me the solution for this.

share|improve this question
What are you trying to match exactly? The ids should be in the form of gritter-item- and followed by a number? – user1177636 Apr 30 at 7:32

1 Answer

Try using the below xpath where we use contains keyword.

//*[contains(@id, 'gritter-item-')]
share|improve this answer
I would be very careful with this approach because it can easily match any other ID that has the same format. And assuming this is a auto generated ID I'd say the possibilities that this is true are pretty good. – Alex Peña Apr 30 at 14:53

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.