I am using selenium web driver and appium as this is mobile application automation,
I am trying to check that if element is there or not and based on that I have put conditions.
long starttime = System.currentTimeMillis();
long endtime = starttime + 60*1000; // 60 seconds * 1000 ms/sec;
while(System.currentTimeMillis() < endtime)
{
notcount = driver.findElement(By.id(AppConstants.notificationcount));
}
if(notcount.equals(null))
{
System.out.println("No Element found");
}
else
{
//SOME ANOTHER STEPS
}
Here issue is when element is not there , instead to redirect to ELSE part , selenium stops execution and throwing exception.
I do not want to use List -findelements here as that is taking long time to find element.
Source: Read More