I need to check if a form element exists in my current web page with selenium.
Does anybody know how to do?
I need to check if a form element exists in my current web page
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
There are two ways to do this. Either use lefthandedgoat’s version catching an exception, or use the FindElements method and check it’s size, so something like (in C# using LINQ):
Either option will work fine, there is not really much different. I personally use the other way, but wanted to make sure you knew there are generally two ways to do this. You didn’t mention a language, so let us know if there is a specific language you are using.
It is worth noting that underneath, when you do a FindElement() in Selenium, it is performing this method.