简体   繁体   中英

Selenium C# 4.7.0 throws System.ComponentModel.Win32Exception when tried to use the chromedriver

public class Tests
{
    [Test]
    public void Test1()
    {
        var d = new ChromeDriver();
        d.Navigate().GoToUrl("https://www.google.com");
        TestContext.WriteLine("Opened successfully");
    }
}

Tried replacing the chrome with Firefox / Safari / Edge it works perfectly fine. But for Chrome alone it throws

Console output:

System.ComponentModel.Win32Exception : An error occurred trying to start process '/usr/local/bin/chromedriver' with working directory '/Users/testuser/Documents/SeleniumCSharp/DemoSelenium/DemoSelenium/bin/Debug/net6.0'. No such file or directory

Result message:

System.ComponentModel.Win32Exception : An error occurred trying to start process '/usr/local/bin/chromedriver' with working directory '/Users/testuser/Documents/SeleniumCSharp/DemoSelenium/DemoSelenium/bin/Debug/net6.0'. No such file or directory

You need to place chromedriver.exe where Selenium can "find" it. One way is to place chromedriver.exe in the same folder as your calling program. Another way is to call a ChromeDriver constructor which takes the path to chromedriver.exe as a parameter.

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