C# 为什么 Selenium InternetExplorerDriver Webdriver 在调试模式下非常慢(visual studio 2010 和 IE9)

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/8850211/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-09 04:47:06  来源:igfitidea点击:

Why is Selenium InternetExplorerDriver Webdriver very slow in debug mode (visual studio 2010 and IE9)

c#visual-studio-2010seleniumwebdriver

提问by Jon Spokes

I'm using the example code from the SeleniumHq site - but in debug mode the performance is awful.

我正在使用来自 SeleniumHq 站点的示例代码 - 但在调试模式下,性能很糟糕。

In release mode the entire test takes about 6 seconds (including launching and closing IE) In Debug mode it takes 65 seconds ?

在发布模式下,整个测试大约需要 6 秒(包括启动和关闭 IE) 在调试模式下需要 65 秒?

The sample code is just :

示例代码只是:

    [Test]
    public void testBrowser()
    {
        // Do something here
        IWebDriver driver = new InternetExplorerDriver();
        //Notice navigation is slightly different than the Java version
        //This is because 'get' is a keyword in C#
        driver.Navigate().GoToUrl("http://www.google.com");
        IWebElement query = driver.FindElement(By.Name("q"));
        query.SendKeys("Cheese");
        System.Console.WriteLine("Page title is: " + driver.Title);
        // TODO add wait
        driver.Quit();

    }

I've tried it in ie8 and have the same performance. Firefox is fine - but my clients use IE so I'm stuck with testing against it. Also - I don't have the same issues if I use Selenium RC.

我已经在 ie8 中尝试过并且具有相同的性能。Firefox 很好 - 但我的客户使用 IE,所以我坚持对它进行测试。另外 - 如果我使用 Selenium RC,我不会遇到同样的问题。

NB - I'm using .Net 4 and the latest version (2.16) of the webDriver.dll (running on a 64bit windows 7 box)

注意 - 我正在使用 .Net 4 和 webDriver.dll 的最新版本 (2.16)(在 64 位 Windows 7 机器上运行)

回答by Jules

check 'prefer 32 bit' is not checked in your build properties. If it is and you are using the 64 bit IE driver it will run like an asthmatic snail.

检查“首选 32 位”未在您的构建属性中选中。如果是,并且您使用的是 64 位 IE 驱动程序,它将像哮喘蜗牛一样运行。

回答by slavikko

For me, the fix was to switch to the 32 bit version of InternetExplorerDriver.exefrom https://code.google.com/p/selenium/downloads/list

对我来说,修复是InternetExplorerDriver.exehttps://code.google.com/p/selenium/downloads/list切换到 32 位版本

Seemingly named IEDriverServernowadays, but works if you just rename it to InternetExplorerDriver.exe.

IEDriverServer如今看似已命名,但如果您只是将其重命名为InternetExplorerDriver.exe.

回答by domehead100

Using the C#, NUnit, C# webdriver client and IEDriverServer, I originally had the problem with slow input (e.g., sending keys to an input box would take about 5 seconds between keys, or clicking on a button same kind of delay).

使用 C#、NUnit、C# webdriver 客户端和 IEDriverServer,我最初遇到了输入缓慢的问题(例如,将键发送到输入框在键之间需要大约 5 秒,或者单击按钮会出现同样的延迟)。

Then, after reading this thread, I switched to the 32-bit IEDriverServer, and that seemed to solve the problem.

然后,在阅读此线程后,我切换到 32 位 IEDriverServer,这似乎解决了问题。

But today I was experimenting with the InternetExplorerOptions object in order to set some options on IE according to this documentation:

但是今天我正在尝试使用 InternetExplorerOptions 对象,以便根据此文档在 IE 上设置一些选项:

https://code.google.com/p/selenium/wiki/InternetExplorerDriver

https://code.google.com/p/selenium/wiki/InternetExplorerDriver

Per the documentation, I created the registry value HKCU\Software\Microsoft\Internet Explorer\Main\TabProcGrowth with a value of 0 in order to use ForceCreateProcessApi = true and BrowserCommandLineArguments = "-private."

根据文档,我创建了值为 0 的注册表值 HKCU\Software\Microsoft\Internet Explorer\Main\TabProcGrowth,以便使用 ForceCreateProcessApi = true 和 BrowserCommandLineArguments = "-private"。

After doing this, I noticed that the slow-input problem was back. I had made several changes to my code, but after rolling all of them back, the problem still persisted. When I removed the aforementioned registry key, however, the input was back to full speed (no delay).

这样做之后,我注意到输入慢的问题又回来了。我对我的代码进行了几次更改,但是在将所有更改回滚后,问题仍然存在。但是,当我删除上述注册表项时,输入又恢复到全速(无延迟)。