Devang
Devang

Reputation: 385

Selenium Webdriver - Click() method fails with IE driver

I'm using the IE driver with IE11, For some elements Click method will only select a element, it wont do the action of the Click(). With ChromeDriver and FirefoxDriver same script is working fine.

I've set driver capabilities as below

DesiredCapabilities caps = DesiredCapabilities.internetExplorer();
caps.setCapability(InternetExplorerDriver.INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS, true);
caps.setCapability(InternetExplorerDriver.IGNORE_ZOOM_SETTING, true);
caps.setCapability(InternetExplorerDriver.REQUIRE_WINDOW_FOCUS, false);
caps.setCapability(InternetExplorerDriver.ENABLE_PERSISTENT_HOVERING, false);
caps.setCapability(InternetExplorerDriver.NATIVE_EVENTS, false);

I found some solutions on following links but still facing same issue.

Selenium WebDriver Click issue in Internet Explorer

Selenium WebDriver on IE 9, on clicking, links are flashing as if some click event was not completely handled

Selenium 2.0b3 IE WebDriver, Click not firing

Upvotes: 1

Views: 5521

Answers (1)

Saurabh Gaur
Saurabh Gaur

Reputation: 23835

It's hard to say why is it not clickable on IE, may be its designing issue.

If you have tried all possibility, but nothing get success try using JavascriptExecutor as an alternate solution as below :-

((JavascriptExecutor)driver).executeScript("arguments[0].cli‌​ck()", yourElement);

Note :- The JavaScript injection HTMLElement.click() shouldn't be used in a testing context. It defeats the purpose of the test. First because it doesn't generate all the events like a real click (focus, blur, mousedown, mouseup...) and second because it doesn't guarantee that a real user can interact with the element. But to get rid from this issues you can consider it as an alternate solution.

Upvotes: 2

Related Questions