title: How to check if an element is visible with WebDriver - eternal loading
body: <p>I'm testing a button that close a window. Then when I clicking in the button I need check If the Window closed.</p>
  <p>I created this method:</p>
  <pre><code>enter code here
  
  
  
  
  public boolean isElementPresent(String locatorKey) {
      try {
          driver.findElement(By.xpath(locatorKey));
          return true;
      } catch (org.openqa.selenium.NoSuchElementException e) {
          Assert.assertFalse((isElementPresent(String.valueOf(By.xpath(locatorKey)))));
          return false;
      }
  }
  
  
  
  
  
  enter code here
  </code></pre>
  <p>But it`s not working. Selenium stays loading the last step for a long time and in the end shows this error</p>
  <p>Command: [8139ce6f8c35642a752d7fbedb186ec6, findElement {using=xpath, value=By.xpath: By.xpath: By.xpath: By.xpath: By.xpath: By.xpath: By.xpath: By.xpath: By.xpath: By.xpath:</p>