title: webdriver modal window click() not working
body: <p>I've been browsing around trying to find a solution to this but none of the solutions have worked for me thus far.</p>
  
  <p>Here is a quick test I've thrown together where its simply trying to click the 'close' button to close a modal pop up. I can step through my test in Visual Studio and it will work fine. When I run the test in Nunit, it will error. I've tried the following based upon others issues and suggestions given to them:- </p>
  
  <ul>
  <li>putting in waits all over the place</li>
  <li>changing from the chrome driver to firefox</li>
  <li>changing to maximised window mode</li>
  <li>re-working it every which way I can think of</li>
  </ul>
  
  <p>The modal is not an iframe or anything like that. I seem to be getting the following error:</p>
  
  <p>Exception has been thrown by the target of an invocation.
    ----> System.InvalidOperationException : Element is not clickable at point (922.5, 342.0999755859375). Other element would receive the click: </p>
  
  <p>which is why I was fiddling with maximised and normal sized modes.</p>
  
  <p>Looking for any suggestions as it's got me stumped..</p>
  
  <p>Thanks</p>
  
  <pre><code>[Test(Description = "Test to check if the cancel button closes the modal window when clicked on the 'Reset Password' modal")]
      public void CheckCancelPasswordResetOnModalWorks()
      {
          bool modalFoundSuccess = false;
          bool forgotPasswordControlFound = false;
          _driver.Navigate().GoToUrl(_baseURL + "login");
  
          if (_loginPage.CheckForgotPasswordControlExists())
          {
              forgotPasswordControlFound = true;
  
              _loginPage.ClickForgotPasswordButton();
  
              if (_loginPage.CheckResetPasswordModalIsDisplayed())
              {
                  modalFoundSuccess = true;
                  _loginPage.ClickCancelResetPasswordButton();
                  if (_loginPage.CheckResetPasswordModalIsDisplayed() != true)
                  {
                      modalFoundSuccess = false;
                  }
                  Assert.IsFalse(modalFoundSuccess, "The modal window did not close when the 'cancel' button was clicked on the modal pop up");
              }
              Assert.IsTrue(forgotPasswordControlFound, "Could not find the 'Forgotten Password' Modal box on the page");
          }
          Assert.IsTrue(forgotPasswordControlFound, "Was not able to find the 'Forgot Password' button on the '/login' page.");
      }
  </code></pre>
  
  <hr>
  
  <p>Page Item</p>
  
  <pre><code>public class LoginPage : Page
  {
      private IWebDriver _driver;
      public string userNameValidationText = "Username must be filled in.";
      public string passwordValidationText = "Password must be filled in.";
      public string incorrectLoginValidationText = "The user name or password is incorrect";
  
      [FindsBy(How = How.ClassName, Using = "scfForm")]
      private IWebElement _WFFMForm;
  
      [FindsBy(How = How.XPath, Using = "//div[@class='scfSubmitButtonBorder']/input")]
      private IWebElement _loginButton;
  
      [FindsBy(How = How.XPath, Using = "//div[@class='scfSingleLineGeneralPanel']/input")]
      private IWebElement _userNameField;
  
      [FindsBy(How = How.XPath, Using = "//div[@class='scfPasswordGeneralPanel']/input")]
      private IWebElement _passwordField;
  
      [FindsBy(How = How.XPath, Using = "//div[@id='divForgotPassword']")]
      private IWebElement _resetPasswordModal;
  
      [FindsBy(How = How.XPath, Using = "//div[@id='divForgotPassword']/p/input")]
      private IWebElement _forgotPasswordEmailInputField;
  
      [FindsBy(How = How.XPath, Using = "//div[@id='divForgotPassword']/a[contains(., 'Reset My Password')]")]
      private IWebElement _resetPasswordButton;
  
      [FindsBy(How = How.XPath, Using = "//div[@id='divForgotPassword']/a[contains(., 'Cancel')]")]
      private IWebElement _cancelResetPasswordButton;
  
      [FindsBy(How = How.XPath, Using = "//div[@class='forgot-password']/a[contains(., 'Forgot Password')]")]
      private IWebElement _forgotPasswordButton;
  
      public LoginPage(IWebDriver driver)
          : base(driver)
      {
          _driver = driver;
          PageFactory.InitElements(_driver, this);
      }
  
      public void InputUserNameText(string phoneText)
      {
          _userNameField.Clear();
          _userNameField.SendKeys(phoneText);
      }
  
      public void InputPasswordText(string queryText)
      {
          _passwordField.Clear();
          _passwordField.SendKeys(queryText);
      }
  
      public void InputResetPasswordEmail(string resetEmail)
      {
          _forgotPasswordEmailInputField.Clear();
          _forgotPasswordEmailInputField.SendKeys(resetEmail);
      }
  
      public void ClickLoginButton()
      {
          _loginButton.Click();
      }
  
      public void ClickResetButton()
      {
          WebDriverWait wait = new WebDriverWait(_driver, TimeSpan.FromSeconds(10));
          wait.Until((d) =&gt; { return CheckModalHasLoaded(); });
          _resetPasswordButton.Click();
      }
  
      public void ClickCancelResetPasswordButton()
      {
          WebDriverWait wait = new WebDriverWait(_driver, TimeSpan.FromSeconds(20));
          wait.Until((d) =&gt; { return CheckModalHasLoaded(); });
          _cancelResetPasswordButton.Click();
      }
  
      public void ClickForgotPasswordButton()
      {
          _forgotPasswordButton.Click();
      }
  
      public void ClickLoginButtonForEmtpyValidation()
      {
          _loginButton.Click();
          WebDriverWait wait = new WebDriverWait(_driver, TimeSpan.FromSeconds(10));
          wait.Until((d) =&gt; { return CheckValidationTopBoxExists(); });
      }
  
      public bool CheckValidationForIncorrectLoginExists()
      {
          return Utility.IsThisElementPresent(_driver, By.XPath("//div[@class='scfSubmitSummary']/span"));
      }
  
      public bool loginFormExistsCheck()
      {
          return Utility.IsThisElementPresent(_driver, By.ClassName("scfForm"));
      }
  
      public bool CheckValidationTopBoxExists()
      {
          return Utility.IsThisElementPresent(_driver, By.ClassName("scfValidationSummary"));
      }
  
      public bool CheckResetPasswordModalIsDisplayed()
      {
          return Utility.IsThisElementPresent(_driver, By.XPath("//div[@id='divForgotPassword']"));
      }
  
      public bool CheckForgotPasswordControlExists()
      {
          return Utility.IsThisElementPresent(_driver, By.ClassName("forgot-password"));
      }
  
      public bool CheckModalHasLoaded()
      {
          return Utility.IsThisElementPresent(_driver, By.XPath("//div[@id='divForgotPassword']"));
      }
  
  }
  </code></pre>