I have an HTML
IWebElement we = addToBasket.FindElement(By.Id("MyBox"));
The element is blinking because of a feature of the IE driver called "persistent hovers." This feature is of dubious value, but is required because of the brain-dead way IE (the browser, not the driver) responds to
WM_MOUSEMOVE messages when using the
You have a few options. You can turn persistent hovers off by using code like the following:
InternetExplorerOptions options = new InternetExplorerOptions(); options.EnablePersistentHover = false; IWebDriver driver = new InternetExplorerDriver(options);
InternetExplorerOptions options = new InternetExplorerOptions(); options.EnableNativeEvents = false; IWebDriver driver = new InternetExplorerDriver(options);
Finally, you could migrate from using the default
SendMessage Windows API to code that uses the more correct
SendInput API. This is done with the
RequireWindowFocus property. Its drawback is that the mouse input is injected at a very low level in the system, which requires the IE window to be the foreground window on the system.
InternetExplorerOptions options = new InternetExplorerOptions(); options.RequireWindowFocus = true; IWebDriver driver = new InternetExplorerDriver(options);
As a final note, do not attempt to set all of these properties at once; pick an approach and stick with it. Several of them are mutually exclusive, and the interaction between them is undefined.