1

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

Community
  • 1
  • 1
Devang
  • 365
  • 2
  • 6
  • 26
  • Which `iedriverserver` are you using `64-bit` or `32-bit`?? and what happened when you are going to click using `WebElement.click()`?? is there any exception?? – Saurabh Gaur Sep 08 '16 at 07:45
  • I'm using 32-bit driver , and no exceptions are found when i use element.click() – Devang Sep 08 '16 at 07:48
  • Is this element manually clickable correctly at IE browser?? – Saurabh Gaur Sep 08 '16 at 07:53
  • @SaurabhGaur i'm using 64-bit OS , but 64-bit IEdriver was very slow and i found some solutions related to that so , currently using 32-bit driver , also tried 64-bit driver but i faced same issue. – Devang Sep 08 '16 at 07:55
  • yes, it's clickable – Devang Sep 08 '16 at 07:55
  • You are using `32-bit`, that is good, did you tried using `WebDriverWait` to wait until this visible and clickable?? or could you share your code that how to perform click on it??? – Saurabh Gaur Sep 08 '16 at 07:56
  • @SaurabhGaur while debugging i found that element was not clickable and issue was solved by setting IE capability `caps.setCapability(InternetExplorerDriver.NATIVE_EVENTS, false);`but still click() doesn't work while executing script. – Devang Sep 08 '16 at 07:59
  • @SaurabhGaur yes, element is clickable and isenable() method also return true. – Devang Sep 08 '16 at 08:00
  • Then it hard to say why is it not clickable on IE, may be its designing issue, try once using `Actions` class as `Actions::moveToElement(yourElement).click().perform();` – Saurabh Gaur Sep 08 '16 at 08:04
  • I've already tried that. – Devang Sep 08 '16 at 08:05
  • 1
    Then you can also try as an alternate solution using `JavascriptExecutor` as `((JavascriptExecutor)driver).executeScript("arguments[0].cli‌​ck()", yourElement);`.. – Saurabh Gaur Sep 08 '16 at 08:14

1 Answers1

2

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.

Saurabh Gaur
  • 23,507
  • 10
  • 54
  • 73
  • 1
    I'm able to click using JavascriptExecutor but, using this way i have to write separate click method , Because i think using JavascriptExecutor for each click is not a good way. – Devang Sep 08 '16 at 08:44
  • Yes you are right you should create separate click method as `clickByJs()`..:) – Saurabh Gaur Sep 08 '16 at 08:46