title: How to find if a text exists on page using selenium
body: <p>If the text exists then click on <code>xyz</code> else click on <code>abc</code>.</p>
  
  <p>I'm using the below <code>if</code> statement:  </p>
  
  <pre><code>if(driver.findElement(By.xpath("/html/body/div[2]/div/div/div/div/div/div/table/tbody/tr[6]/td[2]")).isDisplayed())
  {    
      driver.findElement(By.linkText("logout")).getAttribute("href");          
  } else {          
      driver.findElement(By.xpath("/html/body/div/div/div/a[2]")).click();
  }
  </code></pre>
  
  <p>Script fails with the following error message:</p>
  
  <pre><code>Unable to locate element: {"method":"xpath","selector":"/html/body/div[2]/div/div/div/div/div/div/table/tbody/tr[6]/td[2]"}
  </code></pre>