0

I have created xpath on chrome as :

"//a[@href[contains(.,'moduleCode=MASTER')]]"
This xpath is working fine for chromedriver. However, when the same Xpath is being executed for IEDriverServer it throws error as below:
org.openqa.selenium.ElementNotVisibleException: Cannot click on element (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 0 milliseconds
Build info: version: '3.10.0', revision: '176b4a9', time: '2018-03-02T19:03:16.397Z'

But another xpath:

 "//a[contains(@href,'moduleCode=MASTER')]"
works for both the ChromeDriver and IEDriverServer.

Not able to figure out why is there such difference in both the xpaths and why one of the xpath is not supported for IEDriverServer.

Capabilities used are as follows:

    
capabilities.setCapability(CapabilityType.ACCEPT_SSL_CERTS, true);
             capabilities.setCapability(InternetExplorerDriver.INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS,true);
             capabilities.setCapability(InternetExplorerDriver.ENABLE_ELEMENT_CACHE_CLEANUP, true);
             capabilities.setCapability(InternetExplorerDriver.REQUIRE_WINDOW_FOCUS, true);
             capabilities.setCapability(InternetExplorerDriver.NATIVE_EVENTS, true);
Lokesh Singh
  • 33
  • 1
  • 5
  • 1
    Is your IE driver updated ? What is the version of it ? Anyway, IE doesn't have any native way to read Xpath, that has to read from 3rd party. Xpath is highly unstable for IE. Try to switch to css selector if possible. – cruisepandey Apr 30 '19 at 10:49

2 Answers2

0

As mentioned in the Selenium Documentation,

At a high level, WebDriver uses a browser’s native XPath capabilities wherever possible. On those browsers that don’t have native XPath support, we have provided our own implementation. This can lead to some unexpected behaviour unless you are aware of the differences in the various XPath engines.

S Ahmed
  • 1,454
  • 1
  • 8
  • 14
0

Taking a leaf out from @JimEvans's answer in this discussion:

The driver implementations for Firefox and Chrome are developed and maintained by the vendors for those browsers (Mozilla and Google) and those drivers have access to internals of the browser in ways that the IEDriverServer does not (and likely never will) have.

So there are some difference in the way driver implementations ideantify and click on elements.


Solution

While using IEDriverServer and Internet Explorer 11 Ensure that the nativeEvents capability is set to true.

capabilities.setCapability("nativeEvents", true);
undetected Selenium
  • 183,867
  • 41
  • 278
  • 352