首页 > 解决方案 > 当我使用自定义配置文件时,Selenium C# Firefox 不会打开 URL

问题描述

我在 C# 中的 selenium webdriver 中有这个奇怪的错误,如果我不使用配置文件,它只会打开一个 URL。下面的这段代码不起作用

FirefoxOptions options = new FirefoxOptions();
options.AddArguments("-profile", profilePath);

IWebDriver driver = new FirefoxDriver(options);
driver.Navigate().GoToUrl("https://example.com"); //Opens Firefox (with profile) but not URL, times out

同时此代码有效。

FirefoxOptions options = new FirefoxOptions();


IWebDriver driver = new FirefoxDriver(options);
driver.Navigate().GoToUrl("https://example.com"); //Opens Firefox and URL no problem.

我尝试使用 Firefox 的-url启动参数,然后它打开 URL,即使使用配置文件,但它超时并且没有完成其余代码。

标签: c#seleniumselenium-webdriverselenium-firefoxdriver

解决方案


推荐阅读