title: C# Selenium IF & ELSE
body: <p>For some reason my if &amp; else statement aren't working correctly, code example:</p>
  
  <pre><code>             if (driver.FindElement(By.XPath("//*[@id='gb']/div[2]/div[3]/div/div[2]/div/a")).Displayed)
          {
              driver.FindElement(By.XPath("//*[@id='gb']/div[2]/div[3]/div/div[2]/div/a")).Click();
              driver.FindElement(By.XPath("//*[@id='gb_71']")).Click();
          }
          else
          {
              Console.WriteLine("Heannaannay");
          }
  </code></pre>
  
  <p>What's suppose to happen is if</p>
  
  <pre><code>if (driver.FindElement(By.XPath("//*[@id='gb']/div[2]/div[3]/div/div[2]/div/a")).Displayed)
  </code></pre>
  
  <p>then follow through with the commands, </p>
  
  <pre><code> else
  </code></pre>
  
  <p>print ...</p>
  
  <p>but it doesn't seem to do that, it just searches for the if statement within a 10 second limit and then if the specified element isn't displayed it will throw an exception rather than producing the else statement..</p>