问题
From the C# object model, it looks like this should do the trick, but the UseInPrivateBrowsing property has no effect at my end. Just opens a regular browser session in the edge.
var options = new EdgeOptions();
options.UseInPrivateBrowsing = true;
var driver = new EdgeDriver(options);
I am using the latest Selenium.WebDriver.MicrosoftDriver.
These are the installed packages:
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="NUnit" version="3.10.1" targetFramework="net47" />
<package id="NUnit3TestAdapter" version="3.10.0" targetFramework="net47" />
<package id="Selenium.Chrome.WebDriver" version="2.40" targetFramework="net47" />
<package id="Selenium.Support" version="3.13.0" targetFramework="net47" />
<package id="Selenium.WebDriver" version="3.13.0" targetFramework="net47" />
<package id="Selenium.WebDriver.MicrosoftDriver" version="17.17134.0" targetFramework="net47" />
</packages>
How is this supposed to be done?
回答1:
The UseInPrivateBrowsing
property will only work for versions of the driver for Microsoft Edge that support the W3C WebDriver Specification. Unfortunately, these versions of the driver are only available in Windows Insider builds at the moment. Once a version of the driver is released to widely available versions of Windows 10, this property will work everywhere for Edge.
来源:https://stackoverflow.com/questions/51112482/unable-to-open-edge-in-inprivate-mode-using-selenium-web-driver