简体   繁体   中英

C# Selenium Chrome time out

I'm trying to run Selenium in C#, but I get the following error:

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 . There was the possibilty that the versions were incompatible, so I installed Chromedriver version 79 and placed in the same directory. 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. When I try to navigate to a url, nothing happens.

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. Remove the unwanted entry if any. Clean the solution and try. Hopefully this works..

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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