我想在 VS 2010 C# 中使用 Selenium Web Driver 打开 Chrome 浏览器,导航到某个网页,然后关闭驱动程序但保持浏览器打开。我意识到之后我将不得不手动关闭浏览器,我可以接受。
到目前为止,我有:
DriverService service = ChromeDriverService.CreateDefaultService();
ChromeOptions options = new ChromeOptions();
options.AddAdditionalCapability("chrome.detach",true);
m_driver = new ChromeDriver(service, options, TimeSpan.FromMilliseconds(1000));
[m_driver does stuff like navigate page, double click stuff, etc]
[last line: try to close driver but not browser]
我已经尝试了以下所有作为最后一行
m_driver.Dispose(); // closes both browser and driver
m_driver.Close(); //closes just the browser and not the driver
m_driver.Quit(); // closes both browser and driver
service.Dispose(); // closes both browser and driver
有任何想法吗?