简体   繁体   English

将ChromeDriver与Chrome和IEDriverServer与Internet Explorer 11一起使用时,Click方法的行为会有所不同

[英]Click method behaves differently when using ChromeDriver with Chrome and IEDriverServer with Internet Explorer 11

I have created xpath on chrome as : 我在chrome上创建了xpath:

"//a[@href[contains(.,'moduleCode=MASTER')]]"
This xpath is working fine for chromedriver. 这个xpath适用于chromedriver。 However, when the same Xpath is being executed for IEDriverServer it throws error as below: 但是,当为IEDriverServer执行相同的Xpath时,它会抛出错误,如下所示:

\norg.openqa.selenium.ElementNotVisibleException: Cannot click on element (WARNING: The server did not provide any stacktrace information) org.openqa.selenium.ElementNotVisibleException:无法单击元素(警告:服务器未提供任何堆栈跟踪信息)\nCommand duration or timeout: 0 milliseconds 命令持续时间或超时:0毫秒\nBuild info: version: '3.10.0', revision: '176b4a9', time: '2018-03-02T19:03:16.397Z' 构建信息:版本:'3.10.0',修订版:'176b4a9',时间:'2018-03-02T19:03:16.397Z' 

But another xpath: 但另一个xpath:

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);
works for both the ChromeDriver and IEDriverServer. 适用于ChromeDriver和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. 无法弄清楚为什么在xpath中存在这样的差异以及为什么IEDriverServer不支持其中一个xpath。

Capabilities used are as follows: 使用的能力如下:

    \ncapabilities.setCapability(CapabilityType.ACCEPT_SSL_CERTS, true); capabilities.setCapability(CapabilityType.ACCEPT_SSL_CERTS,true);\n             capabilities.setCapability(InternetExplorerDriver.INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS,true); capabilities.setCapability(InternetExplorerDriver.INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS,TRUE);\n             capabilities.setCapability(InternetExplorerDriver.ENABLE_ELEMENT_CACHE_CLEANUP, true); capabilities.setCapability(InternetExplorerDriver.ENABLE_ELEMENT_CACHE_CLEANUP,true);\n             capabilities.setCapability(InternetExplorerDriver.REQUIRE_WINDOW_FOCUS, true); capabilities.setCapability(InternetExplorerDriver.REQUIRE_WINDOW_FOCUS,true);\n             capabilities.setCapability(InternetExplorerDriver.NATIVE_EVENTS, true); capabilities.setCapability(InternetExplorerDriver.NATIVE_EVENTS,true); 

As mentioned in the Selenium Documentation , Selenium文档中所述

At a high level, WebDriver uses a browser's native XPath capabilities wherever possible. 在较高的层面上,WebDriver尽可能使用浏览器的本机XPath功能。 On those browsers that don't have native XPath support, we have provided our own implementation. 在那些没有本机XPath支持的浏览器上,我们提供了自己的实现。 This can lead to some unexpected behaviour unless you are aware of the differences in the various XPath engines. 除非您了解各种XPath引擎中的差异,否则这可能会导致一些意外行为。

Taking a leaf out from @JimEvans's answer in this discussion : 本次讨论中从@ JimEvans的答案中摘出一个词:

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. FirefoxChrome的驱动程序实现由供应商为这些浏览器( MozillaGoogle )开发和维护,并且这些驱动程序可以通过IEDriverServer没有(也可能永远不会)的方式访问浏览器的内部。

So there are some difference in the way driver implementations ideantify and click on elements. 因此,驱动程序实现ideantify和单击元素的方式有所不同。


Solution

While using IEDriverServer and Internet Explorer 11 Ensure that the nativeEvents capability is set to true . 使用IEDriverServerInternet Explorer 11时确保将nativeEvents功能设置为true

capabilities.setCapability("nativeEvents", true);

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Internet Explorer 11在通过IEDriverServer和Selenium执行测试时被随机卡住 - Internet Explorer 11 getting stuck randomly while executing tests through IEDriverServer and Selenium 在Internet Explorer 11中使用Codeception / Selenium时,将引发WebDriverException - WebDriverException throws when using Codeception / Selenium with Internet Explorer 11 Selenium单击不适用于Internet Explorer 11 - Selenium click not working on Internet Explorer 11 Xunit 上的 Inte.net Explorer 11 单击问题 - Internet Explorer 11 Click problem on Xunit 通过 Selenium 和 Java 使用 IEDriverServer 和 Internet Explorer 在 Microsoft Dynamics CRM 中出现 XPathEvaluator 未定义脚本错误 - XPathEvaluator is undefined’ script error in Microsoft Dynamics CRM using IEDriverServer and Internet Explorer through Selenium and Java org.openqa.selenium.NoSuchWindowException:尝试通过 Selenium 和 IEDriverServer 打开 Internet Explorer 11 时无法获取浏览器 - org.openqa.selenium.NoSuchWindowException: Unable to get browser while trying to open Internet Explorer 11 through Selenium and IEDriverServer Selenium WebDriver Internet Explorer IEDriverServer阻止模态对话框 - Selenium WebDriver Internet Explorer IEDriverServer Blocks Modal Dialog 启动 Internet Explorer 时出现意外错误。 IELaunchURL() 使用 IEDriverServer v3.150.1 返回 HRESULT 80070005(“访问被拒绝。”) - Unexpected error launching Internet Explorer. IELaunchURL() returned HRESULT 80070005 ('Access is denied.') using IEDriverServer v3.150.1 selenium.common.exceptions.TimeoutException:消息:通过 Selenium 使用 IEDriverServer 和 Internet Explorer 等待页面加载超时 - selenium.common.exceptions.TimeoutException: Message: Timed out waiting for page to load using IEDriverServer and Internet Explorer through Selenium 在 Windows10 环境中使用 RemoteWebDriver 和 Inte.net Explorer 11 时无效 HTML (Selenium/Java) - Invalid HTML when using RemoteWebDriver and Internet Explorer 11 in a Windows10 environment (Selenium/Java)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM