如何从Chrome驱动程序中分离Chrome浏览器(Selenium Web Driver C#)

san*_*an5 6 c# selenium selenium-chromedriver selenium-webdriver

我想在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]
Run Code Online (Sandbox Code Playgroud)

我已经尝试了以下所有内容作为最后一行

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
Run Code Online (Sandbox Code Playgroud)

有任何想法吗?

Arr*_*ran 0

这根本不可能,那种分离是不存在的。

  • 有趣的是,尽管 ChromeDrive 记录了它,但我测试了“detach”并发现它不起作用。很难说我是否做错了——到目前为止还没有看到其他人在网上声称成功。 (3认同)