Upon further investigation:
- It appears that without the "requireWindowFocus" capability clicks still always work IF the MSIE window has focus, whether there is a remote desktop connection or not
- It appears that, if the machine is untouched (including the case when the remote desktop connection is disconnected), once the window is focused, it stays focused for the rest of the test suite until one closes the driver - at which point the window is closed as expected. There is a point of possible failure, though - when the driver starts MSIE, MSIE sometimes does not get focus.This only happened once in a significant number of runs, so I'm not sure if I can reproduce it.
- It appears that, unfortunately, even without "requireWindowFocus" I get consistent failures (on the second if not the first click) if I run MSIE tests under Jenkins slave as a Windows service. Is this simply impossible?
- Also it turns out I have described the failure wrongly - the WebElement.click() method simply does not cause a click. And then I get an exception because the code is looking for a page that appears after the click. Which is of course not there.
So - trying to guess here - I might just need to run the Jenkins slave in a displayed way, not as a Windows service, and also somehow to ensure that MSIE gets focus every time? Is there a way for me to ensure MSIE gets focus? I tried VBscript but it fails when there is no Remote Desktop connection. Or do I need to do something else entirely?
(Or should MSIE always get focus, and what I encountered was a random glitch?)