0

So this is similar to Click() method will not always work but there are several vital differences:

  • Not a timing issue because I repeatedly try to click it until success
  • No exception is thrown, just nothing happens
  • Using a JS click on the same element works - executor.executeScript("arguments[0].click();", element);
  • Using button.SendKeys(Keys.Return) instead works.
  • Displayed: true and Enabled: true

Only button.Click() doesn't work. I've stopped the application at a breakpoint and am testing it via the Immediate Window right now. I can see how Click() has no effect and doesn't throw an exception, but javascript click() and SendKeys() work.

Some additional info:

  • I'm using InternetExplorerDriver on IE11
  • I'm running the tests on Windows Server 2012 through Remote Desktop
  • It happens only intermittently. I remember switching Alt+Tab while the tests are running whenever it's happened but I don't know if this is the reason.

Any idea what is happening?

Edit: I noticed at one point that the first click pushes down the button (visibly) but it doesn't get click. The second click succeeds, however. Earlier Click() did not succeed, no matter how many times I executed it.

Edit 2: OK, now I've nailed it - if I click on the browser window, then I click to Visual Studio, then the first Click() doesn't work. Subsequent clicks all work, even if VS is still focused. Switching from VS to notepad and then to VS does not trigger it, only switching to IE and then back to VS.

It's as if it's not the problem that IE doesn't have focus, it's about having it and then losing it, then the next Click() will fail.

sashoalm
  • 75,001
  • 122
  • 434
  • 781
  • 1
    From your description, it seems that you have already found the issue. In my opinion, I think it perhaps it also related that IE is comparatively slow compared to other browsers, so, you could try to use the [WebDriverWait methods](https://www.selenium.dev/documentation/en/) waits find the elements. So, to click a button element in IE browser, it is better to keep focus on the IE window or use JavaScript or SendKeys method to click it. – Zhi Lv Jun 29 '20 at 10:25
  • Yup, I switched to javascript for clicking and I don't have problems now. – sashoalm Jun 30 '20 at 04:00

1 Answers1

1

In my case the contol was partially overlapped with another div, and the webDriver clicked in the middle of control but hitted the div. Could you please check maybe it is your case.