繁体   English   中英

Selenium C# 4.7.0 在尝试使用 chromedriver 时抛出 System.ComponentModel.Win32Exception

[英]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");
    }
}

尝试用 Firefox / Safari / Edge 替换 chrome,效果非常好。 但仅对于 Chrome,它会抛出

控制台 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

结果消息:

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

您需要将 chromedriver.exe 放在 Selenium 可以“找到”它的地方。 一种方法是将 chromedriver.exe 放在与调用程序相同的文件夹中。 另一种方法是调用 ChromeDriver 构造函数,它将 chromedriver.exe 的路径作为参数。

暂无
暂无

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

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