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
andEnabled: 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.