Selenium网格无法使其正常工作

时间:2017-08-02 17:15:19

标签: selenium-chromedriver selenium-grid

我在windows命令提示符中执行了以下hub和node命令。我可以看到这在浏览http://localhost:4441/grid/console

时我得到了网格控制台
C:\seleniumserver\java -jar selenium-server-standalone-3.4.0.jar -role hub -port 4441

C:\seleniumserver\java -jar selenium-server-standalone-3.4.0.ja -role wd -hub http://localhost:4441/grid/register

我的自动化代码包含以下C#代码。

C#代码段

var capabilities = DesiredCapabilities.Chrome();
capabilities.Platform = Platform.CurrentPlatform;
IWebDriver driver = new RemoteWebDriver(new Uri("http://localhost:4444/wd/hub"), capabilities);

当我运行自动化时,我收到以下错误消息

收到错误讯息

An exception of type 'OpenQA.Selenium.WebDriverException' occurred in WebDriver.dll but was not handled in user code

Additional information: The HTTP request to the remote WebDriver server for URL http://localhost:4444/wd/hub/session timed out after 60 seconds.

有什么建议我做错了吗?第一次设置

非常感谢,

评论后更新

进行了以下更改

        var capabilities = DesiredCapabilities.Chrome();
        capabilities.Platform = Platform.CurrentPlatform;
        IWebDriver driver = new RemoteWebDriver(new Uri("http://localhost:4441/wd/hub"), capabilities);

错误消息

at OpenQA.Selenium.Remote.RemoteWebDriver.UnpackAndThrowOnError(Response errorResponse)at OpenQA.Selenium.Remote.RemoteWebDriver.Execute(String driverCommandToExecute,Dictionary`2参数在OpenQA.Selenium.Remote.RemoteWebDriver.StartSession(ICapabilities desiredCapabilities)at at at OpenQA.Selenium.Remote.RemoteWebDriver..ctor(ICommandExecutor commandExecutor,ICapabilities desiredCapabilities)位于C:\ Projects \ UAT Automation \中myfile.ctor()的OpenQA.Selenium.Remote.RemoteWebDriver..ctor(Uri remoteAddress,ICapabilities desiredCapabilities) myfile.cs:第43行在.... ctor()C:\ Projects \ UAT Automation ... cs:第21行

1 个答案:

答案 0 :(得分:1)

您正在端口4441中启动集线器但是您尝试使用

连接到4444

IWebDriver driver = new RemoteWebDriver(new Uri("http://localhost:4444/wd/hub"), capabilities);

请将您的实例化代码更改为

IWebDriver driver = new RemoteWebDriver(new Uri("http://localhost:4441/wd/hub"), capabilities);

再试一次。