title: Issues with elements that have same By locator on multiple pages
body: <p>I have 5 pages (A, B, C, D, E). A, B, C and D each contain a button with Id 'Next' which will load the next page. Now, the problem is that sometimes (not always), the 'Next' button is not clicked on each page.</p>
  
  <p>My code is supposed to do the following: we launch the browser and navigate to page A by URL. Then, we perform some logic on the page and then we click the 'Next' button. We arrive at page B and perform some logic on the page and click the 'Next' button. We arrive at page C, and immediately click the 'Next' button without doing anything else. On page D, we perform some logic and click the 'Next' button. (and so on...)</p>
  
  <p>Now, the problem is that on page C, the 'Next' button is not always clicked, but it does not throw an error for FindElement. So it tries to perform the logic on page D and the web driver crashes because it's still on page C. How can I fix this problem? Notice that I do use a dynamic webdriverWait for the element to be present on the page, but this makes so difference because the same the locator it always the same (ID = 'Next'). Also, notice I don't return my PageObjects - I'm not sure whether this is absolutely required.</p>
  
  <p>Any thoughts?</p>
  
  <p>Here is my code:</p>
  
  <pre><code>   public class Page
      {      
          public Page()
          {
              PageFactory.InitElements(SeleniumTests.driver, this);
          }       
      }
  
  public static class SeleniumTests
      {
          public static IWebDriver driver { get; set; }
      }
  
   class Page_1 : Page
      {       
          [FindsBy(How = How.Id, Using = "Next")]
          public void Continue()
          {
              btnNext.SafeClick();
          }
      }
  
  class Page_2 : Page
          {       
              [FindsBy(How = How.Id, Using = "Next")]
              public void Continue()
              {
                  btnNext.SafeClick();
              }
          }
  
  class Page_3 : Page
          {       
              [FindsBy(How = How.Id, Using = "Next")]
              public void Continue()
              {
                  btnNext.SafeClick();
              }
          }
    class Page_4 : Page
              {       
                  [FindsBy(How = How.Id, Using = "Next")]
                  public void Continue()
                  {
                      btnNext.SafeClick();
                  }
              }
    class Page_5 : Page
              {       
                  [FindsBy(How = How.Id, Using = "Next")]
                  public void Continue()
                  {
                      btnNext.SafeClick();
                  }
              }
  
     public static class SeleniumExtensionMethod
      { 
          public static WebDriverWait wait = new WebDriverWait(SeleniumTests.driver, TimeSpan.FromSeconds(15));
          public static void SafeClick(this IWebElement webElement, Double seconds = 15)
              {
                  try
                  {
                      wait.Until(ExpectedConditions.ElementToBeClickable(webElement)).Click();
                  }
                  catch (System.Reflection.TargetInvocationException ex)
                  {
                      Console.WriteLine(ex.InnerException);
                  }
              }
      }
  </code></pre>
  
  <p>And finally: </p>
  
  <pre><code> public partial class Form1 : Form
      {
          Page_1 pageA = new Page_1();
          pageA.PerformSomeLogic();
          pageA.Continue();
  
          Page_2 pageB = new Page_2();
          pageB.PerformSomeLogic();
          pageB.Continue();
  
          Page_3 pageC = new Page_3();
          // Don't do anything here, just continue.
          pageC.Continue();
  
  
          Page_4 pageD = new Page_4();
          pageD.PerformSomeLogic();// -----&gt; here is crashes, as the previous line 'pageC.Continue()' was not really executed, it seems as though the button was clicked 2 times on page B
          pageD.Continue() ;          
  
  
          Page_5 pageE = new Page_5();
          pageD.PerformSomeLogic();
          pageE.Continue();   
  }
  </code></pre>
  
  <p>Edit: what I want, ideally is to do some kind of dynamic wait which actually would work in this case. I can also use Thread.Sleep(); and this solve my problem but it's a code smell and I want to avoid it.</p>