简体   繁体   English

Selenium C#-与Chrome浏览器相比,使用IE11时,FindElemnt方法的执行速度较慢

[英]Selenium c# - The FindElemnt method perform slow when working with IE11 compared to Chrome browser

In my c# code, I'm working with Selenium version 3.4. 在我的C#代码中,我正在使用Selenium 3.4版。 When working with the Chrome browser, the FindElemnt seems to be executed fast compared to IE11. 与Chrome浏览器一起使用时,与IE11相比,FindElemnt的执行速度似乎更快。 Seems that the FindElemnt method faces some slowness when working with IE11. 似乎在使用IE11时,FindElemnt方法遇到了一些问题。

Any suggestions?? 有什么建议么??

Ensure you are not using the 64-bit version of the IE WebDriver. 确保您没有使用IE WebDriver的64位版本。 It appears to be a known issue. 这似乎是一个已知问题。 Based on this question there may be some ways to speed up the 64-bit version but I personally have found the 32-bit version to be more reliable. 基于这个问题,可能有一些方法可以加快64位版本的速度,但是我个人发现32位版本更加可靠。

Info on the underlying issue can also be found in this thread 有关基本问题的信息也可以在此线程中找到

After investigation of this issue, I have been able to debug the C++ code of the 64-bit IE driver to determine the root cause. 在研究了此问题之后,我已经能够调试64位IE驱动程序的C ++代码以确定根本原因。 When you are running IE 10 or higher on a 64-bit version of Windows, by default the process which hosts the containing window that includes the browser chrome (address bar, navigation buttons, menus, etc.) is a 64-bit process. 当您在64位版本的Windows上运行IE 10或更高版本时,默认情况下,承载包含浏览器镶边的包含窗口(地址栏,导航按钮,菜单等)的进程是64位进程。

The process which hosts the window where content is actually rendered (within each tab) is a 32-bit process. 承载实际渲染内容的窗口(在每个选项卡中)的进程是一个32位进程。 By default, the IE driver attempts to use a windows hook on the content-rendering window to make sure that a key-down message is properly processed before sending a key-up message. 默认情况下,IE驱动程序尝试在内容呈现窗口上使用窗口挂钩,以确保在发送按键消息之前正确处理了按键消息。 This is where the problem is. 这就是问题所在。 The windows hook is not installed, because a 32-bit process (the content-rendering process) can't execute 64-bit code. 未安装Windows挂钩,因为32位进程(内容呈现进程)无法执行64位代码。 The only way to properly fix this will be to create a second (32-bit) executable to perform the wait for the key-down to be complete. 正确解决此问题的唯一方法是创建第二个(32位)可执行文件,以执行等待击键完成的等待。 Since this would amount to a massive rearchitecture of the IE driver's binary components, no timeline is (or will be) available for this change. 由于这将构成IE驱动程序二进制组件的大量重新架构,因此没有(或将提供)此更改的时间表。

Some notes. 一些注意事项。 Careful readers will have already realized that this means that even when you are running 64-bit Windows, you're likely using a 32-bit version of IE to render the content. 细心的读者已经意识到,这意味着即使您正在运行64位Windows,也很可能使用32位版本的IE来呈现内容。 This is a powerful argument for continuing to use the 32-bit version of the IE driver for IE 10 and above: you're not actually running against a 64-bit version of IE. 对于继续将IE驱动程序的32位版本用于IE 10及更高版本,这是一个有力的论据:您实际上并不是在64位版本的IE上运行。

If you insist that you must run the 64-bit version of IEDriverServer.exe, you have two possible workarounds. 如果您坚持必须运行IEDriverServer.exe的64位版本,则有两种可能的解决方法。 First, you can disable native events by setting the "nativeEvents" capability to false using whatever mechanism your language binding provides for this. 首先,可以使用语言绑定为此提供的任何机制,通过将“ nativeEvents”功能设置为false来禁用本地事件。 A more accurate workaround from an input simulation perspective would be to enable the "requireWindowFocus" capability, though this also has a windows hook dependency, which may manifest in other ways. 从输入仿真的角度来看,更准确的解决方法是启用“ requireWindowFocus”功能,尽管这也具有Windows钩子依赖关系,这可能会以其他方式体现出来。

by james.h.evans.jr on 2014-01-31 19:23:06 由james.h.evans.jr于2014-01-31 19:23:06

Even using the 32-bit version, the IE driver is still significantly slower running the same tests as a Chromium based browser. 即使使用32位版本,IE驱动程序在运行与基于Chromium的浏览器相同的测试时仍然明显较慢。 I have had to add Waits due to the longer page load times using the IE Driver. 由于使用IE驱动程序的页面加载时间较长,我不得不添加“等待”。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM