18 January 2026:
Sahi Pro is an enterprise grade test automation platform which can automate web, mobile, API, windows and java based applications and SAP.
This forum is now archived and is in read-only mode. Please continue discussions on our improved new Sahi Pro Community forum.
Sahi Pro is an enterprise grade test automation platform which can automate web, mobile, API, windows and java based applications and SAP.
How to check if element exist?
Hi All,
I don't know How to check if the page element 'select' or 'input' exist on page source and if not exist go forward with the scripts without errors, is it possible?
Example I have 2 Tags to distinguish:
document.getElementsByTagName('select')[0]
document.getElementsByTagName('input')[5]
I don't need values witch were put into those fields I only would like to know if they exist.
I don't know How to check if the page element 'select' or 'input' exist on page source and if not exist go forward with the scripts without errors, is it possible?
Example I have 2 Tags to distinguish:
document.getElementsByTagName('select')[0]
document.getElementsByTagName('input')[5]
I don't need values witch were put into those fields I only would like to know if they exist.
This discussion has been closed.
Comments
var $ctr = 0;
var $inputElement = document.getElementsByTagName('input');
for(var $i=0; $i < $inputElement.length; $i++)
$ctr++;
i dont know if this will be ok for you.....
if ($ctr == 0)
//if not exist just do something that does not affect script
else
// i dont know what you are going to do here.....
Try if this works: Regards,
Pankaj.
For input, you could either do
It works and It can be closed.