问题
Following code worked well in the past. After some days, I try to run it again but it throws such error.
using OpenQA.Selenium;
using OpenQA.Selenium.Chrome;
using OpenQA.Selenium.Support.UI;
public static ChromeDriver driver;
protected void initDriver(string userDataPath) {
var driverService = ChromeDriverService.CreateDefaultService(AppDomain.CurrentDomain.BaseDirectory);
ChromeOptions options = new ChromeOptions();
driverService.HideCommandPromptWindow = true;
//options.AddArguments("--headless");
options.AddArguments("--no-sandbox");
options.AddArguments("disable-extensions");
options.AddArguments("--start-minimized");
driver = new ChromeDriver(driverService, options, TimeSpan.FromSeconds(10*60));
}
Error:
OpenQA.Selenium.WebDriverException: 'Cannot start the driver service on http://localhost:60623/'
回答1:
When the service start the only things executed are a process with the driver service and an api call to that service.
The problems that can rise could be:
- you can't execute the process, because the executable is not reachable
- executable not there
- wrong permissions
- some configurations are preventing you from executing successfully the api call and reach http://localhost:60623/
- proxy settings (adding
NO_PROXY
environment variable excludinglocalhost
might help) - firewall settings
- port already used
- proxy settings (adding
来源:https://stackoverflow.com/questions/56712777/openqa-selenium-webdriverexception-cannot-start-the-driver-service-on-http-l