简体   繁体   English

C# Selenium Chrome 超时

[英]C# Selenium Chrome time out

I'm trying to run Selenium in C#, but I get the following error:我正在尝试在 C# 中运行 Selenium,但出现以下错误:

DevTools listening on ws://127.0.0.1:52646/devtools/browser/0bd3a117-cf36-4bd9-9614-31ae610fc7c5
[1575911008.197][WARNING]: Timed out connecting to Chrome, retrying...

To be sure, I have installed Chromedriver version 78 and Chrome version 78 .可以肯定的是,我已经安装了Chromedriver version 78Chrome version 78 There was the possibilty that the versions were incompatible, so I installed Chromedriver version 79 and placed in the same directory.有可能版本不兼容,所以我安装了Chromedriver version 79并放在同一目录中。 Then I got a this error:然后我得到了这个错误:

Unhandled exception. System.InvalidOperationException: session not created: This version of ChromeDriver only supports Chrome version 79 (SessionNotCreated) 

After this check I knew for sure that the versions were the same(I have used selenium in the past).在这次检查之后,我确定版本是相同的(我过去使用过硒)。 The chrome browser is opening, but it stays blank. chrome 浏览器正在打开,但它保持空白。 When I try to navigate to a url, nothing happens.当我尝试导航到一个 url 时,没有任何反应。

I have read this post but no success. 我已经阅读了这篇文章,但没有成功。

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>netcoreapp3.0</TargetFramework>
  </PropertyGroup>
  <ItemGroup>
    <PackageReference Include="Selenium.WebDriver" Version="3.141.0"/>
    <PackageReference Include="NUnit" Version="3.12.0"/>
    <PackageReference Include="NUnit3TestAdapter" Version="3.15.1"/>
  </ItemGroup>
</Project>
namespace Coins
{
    class Coin
    {
        IWebDriver driver;

        [SetUp]

        public void startBrowser()
        {
            driver = new ChromeDriver(".");
        }


        [Test]
        public void test()
        {

        }

        [TearDown]

        public void closeBrowser()
        {
            driver.Close();
        }
    }
}

Please check your ".cs proj file" and ensure that there is no unwanted entry of older chromedriver.请检查您的“.cs proj 文件”并确保没有不需要的旧版 chromedriver 条目。 Remove the unwanted entry if any.删除不需要的条目(如果有)。 Clean the solution and try.清洁溶液并尝试。 Hopefully this works..希望这有效..

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

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