本文介绍了无法从超时获得自动化扩展:从渲染器接收消息超时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用 Selenium Webdriver (C#) 我不时收到下一个错误:

Using Selenium Webdriver (C#) I'm getting the next error from time to time:

System.InvalidOperationException:未知错误:无法从超时获得自动化扩展:从渲染器接收消息超时:-3.959(会话信息:chrome=37.0.2062.120)(驱动程序信息:chromedriver=2.10.267521,平台=Windows NT6.2 x86_64)

这个错误出现的方式:

OpenQA.Selenium.Remote.RemoteWebDriver.UnpackAndThrowOnError(Response errorResponse) in c:ProjectswebdriverdotnetsrcwebdriverRemoteRemoteWebDriver.cs:line 1048 at OpenQA.Selenium.Remote.RemoteWebDriver.Execute(StringdriverCommandToExecute,Dictionary`2 参数)在 c:ProjectswebdriverdotnetsrcwebdriverRemoteRemoteWebDriver.cs:line 865 at AutomatedTests.DriverCover..ctor(IWebDriver driver)

所以,它发生在下一段代码中:

So, it's happening in the next piece of code:

 public class DriverCover
 {
        public DriverCover(IWebDriver driver)
        {
            _driver = driver;

            _driver.Manage().Window.Maximize(); //There is my mistake
        }

        private readonly IWebDriver _driver;
 }

我使用这个类作为 PageObject 类的基类,我使用 PageFactory 来初始化网页元素.

I use this class as a base class of PageObject classes where I use PageFactory to initialize elements of web pages.

我有 chromedriver v.2.10和 Google Chrome v. 37.0.2062.120 m

I have chromedriver v.2.10and Google Chrome v. 37.0.2062.120 m

另外:在同一行我又遇到了另一个错误:

In addition: at the same line I got another error:

OpenQA.Selenium.WebDriverException:对远程 WebDriver 服务器的 HTTP 请求 URL http://localhost:62407/session/021e05cd4c89abedb2abc77342b3bd7c/window/current/maximize 在 60 秒后超时.----> System.Net.WebException :操作在 c:ProjectswebdriverdotnetsrcwebdriverRemoteHttpCommandExecutor.cs:line 中的 OpenQA.Selenium.Remote.HttpCommandExecutor.CreateResponse(WebRequest request) 超时152 at OpenQA.Selenium.Remote.DriverServiceCommandExecutor.Execute(Command commandToExecute) in c:ProjectswebdriverdotnetsrcwebdriverRemoteDriverServiceCommandExecutor.cs:line 73 at OpenQA.Selenium.Remote.RemoteWebDriver.Execute(String driverCommandToExecute), Dictionary`2 参数)在 c:ProjectswebdriverdotnetsrcwebdriverRemoteRemoteWebDriver.cs:line 852 at AutomatedTests.DriverCover..ctor(IWebDriver driver)

推荐答案

我们在 Chrome 中看到了类似的问题,问题归结为我们在运行测试之前最大化浏览器的方式.

We were seeing something similar with Chrome and the issue came down to the way we were maximizing the browser before running the tests.

我们从这里切换:

Driver.Manage().Window.Maximize();

对此(仅适用于 Chrome):

To this (for Chrome only):

if (typeof(TWebDriver) == typeof(ChromeDriver))
{
    var options = new ChromeOptions();
    options.AddArgument("start-maximized");

    driver = new ChromeDriver(driverPath, options);
}

这篇关于无法从超时获得自动化扩展:从渲染器接收消息超时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-06 21:31
查看更多