title: Element not found - Selenium
body: <p>I have written a piece of code to login into an application which is working fine. Now I have to click an add button, and I have tried it by Id, <code>XPath</code>, <code>ClassName</code> but it just gives me the exception of element not found. I thought I should apply an explicit wait, but it also did not work. Please check my code below:</p>
  
  <pre><code>public static void Login()
  
  {
      Browser.Url = "http://example.com";
      _username = Browser.FindElement(By.Id("UserName"));
      var password = Browser.FindElement(By.Id("Password"));
      var loginbtn = Browser.FindElement(By.ClassName("btn-primary"));
  
      _username.SendKeys("admin");
      password.SendKeys("123");
      loginbtn.Click();
  
      var supplierTab = Browser.FindElement(By.Id("mainSupplier"));
      supplierTab.Click();
  
      WebDriverWait wait = new WebDriverWait(Browser, TimeSpan.FromSeconds(20));
      IWebElement myDynamicElement = wait.Until&lt;IWebElement&gt;((d) =&gt;
      {
         try
          {
              return d.FindElement(By.Id("btnAddSupplier_SupplierForm"));
          }
          catch
          {
              return null;
          }
      });
  
      var addbtn = Browser.FindElement(By.Id("btnAddSupplier_SupplierForm"));
      addbtn.Click();
  
  }
  </code></pre>
  
  <p>This always gives an exception on the second last line of code that element not found.</p>
  
  <p>Here is the HTML:</p>
  
  <p><img src="https://i.stack.imgur.com/g4dIG.png" alt="enter image description here"></p>