启动selenium时出错:无法启动驱动程序服务



我正试图在电脑上使用selenium启动浏览器。有一个代码是这样的:

IWebDriver driver = new FirefoxDriver(FirefoxDriverService.CreateDefaultService(@"F:FirefoxPortable"));
driver.Navigate().GoToUrl("https://www.google.com/");

控制台窗口启动。然后我得到一个错误:

无法在http://localhost:52200/上启动驱动程序服务

我已经在寻找这样一个错误的原因,但我无法战胜它。请帮我找出可能的原因。

FirefoxDriverService.CreateDefaultService(@"F:FirefoxPortable")
  1. 如果不使用,请检查本地计算机上是否存在此路径
string path = @"F:FirefoxPortable";
if (Directory.Exists(path))
{
Console.WriteLine("That path exists already.");
return;
}
// Try to create the directory.
DirectoryInfo di = Directory.CreateDirectory(path);
  1. 检查端口是否被其他进程使用https://www.alphr.com/how-to-check-which-ports-open-windows-10-pc/

最新更新