Hi Tarun,
I am facing the problem with isElementPresent() method. Indeed when the locator is not found this method has to return false. But it is throwing exception and coming out of the loop. Please find the scenario
1. I am trying to validate the error message for an invalid data to a field
2. I am giving Invalid data to that field, then only it populates the error message.
3. I am checking whether the error message is present or not using isElementPresent()
4. Since I am looping this logic, whenever i give valid data, the error message will not populates
5. Then also i am checking whether the error message is present or not by using isElementPresent()
6. Since there is no error message for valid data, the corresponding 'if' loop will not execute indeed.
7. But my script is throwing to exception saying that locator not found instead of returning false
I opened firebug and find some text.
The general xpath for an invalid error message is like
//*[@id='registrationContent']/div[20]/div[2]/span/spanBut when there is no validation message, the text for the second span disappears in the firebug.
Please find the attachment for before and after validation messages.
Xpath.jpg