title: Selenium: How to verify whether an Element is Present
body: <p>Scenario: I have a scenario like after login to some page, a profile update button intermittently appears which i need to click on. Thing is like if that button will appear i have to click otherwise i have to leave that part and go ahead. I have written a logic to handle that scenario like below.</p>
  
  <pre><code>public boolean isElementPresent(By locatorKey) {
   try {
   getDriver().findElement(locatorKey);
   return true;
   } catch (org.openqa.selenium.NoSuchElementException e) {
   return false;
   }
   }
  </code></pre>
  
  <p>If that element will appear it will return true otherwise it will return false.. The above code is working fine...but the problem is it is taking around one min to return either true or false..suppose i have used five places in my script so unnecessarily i the script is waiting for 5 mins...I have also tried the below code </p>
  
  <pre><code>getDriver().findElement(locator).isDisplayed();
  </code></pre>
  
  <p>But the same issue i am facing ...the code is working fine but it is also taking around 1 min to return the command...</p>
  
  <p>Is there any efficient way to handle this kind of scenario without waiting one min to get the status?</p>