I am automating a scenario wherein a specific web element might or might not be displayed on the UI. If it is getting displayed, then I want to perform a specific action on it. I am using below logic for the same
try{
if(element.isDisplayed())
{
//perform action on the element if it is visible
}
}
catch(Exception e)
{
}
The code works fine whenever the element is visible on the UI. But during scenarios when the element is not displayed, then 'element.isDisplayed()' waits for the element for 10 seconds (i.e the implicit wait time which I have defined for the driver session).
I want my script to not wait for that 10 seconds for the element to appear, instead just go ahead with further actions. Any idea what approach should I go with here?
It seem like you can achieve with decrease timeout value utilize
WebDriverWait
.Try to create a boolean function to check the element presence or not with specific time.
Just call with:
The following imports:
Please delete
implicitWait
which you've declared before.