这是我的与Firefox兼容的代码。为什么我使用硒时不保存数据?下面是我使用的代码。
public void Add()
{
FirefoxDriverService service = FirefoxDriverService.CreateDefaultService(AppDomain.CurrentDomain.BaseDirectory, "geckodriver.exe");
string path = @"D:\C# Project\FirefoxPortal tesst\FirefoxPortal tesst\bin\Debug\FirefoxPortable\Data\profile1";
options.Profile = new FirefoxProfile(@"D:\C# Project\FirefoxPortal tesst\FirefoxPortal tesst\bin\Debug\FirefoxPortable\Data\profile1");
options.BrowserExecutableLocation = @"D:\C# Project\FirefoxPortal tesst\FirefoxPortal tesst\bin\Debug\FirefoxPortable\App\firefox64\firefox.exe";
options.SetPreference("media.peerconnection.enabled", false);
options.SetPreference("media.navigator.permission.disabled", true);
options.SetPreference("browser.cache.disk.enable", true);
options.SetPreference("browser.cache.memory.enable", true);
options.SetPreference("browser.cache.offline.enable", true);
options.SetPreference("network.http.use-cache", true);
options.SetPreference("browser.cache.disk.parent_directory", path);
options.SetPreference("browser.cache.offline.parent_directory",path);
options.SetPreference("permissions.default.microphone", 1);
options.SetPreference("permissions.default.camera", 1);
options.SetPreference("dom.webnotifications.enabled", false);
driver = new FirefoxDriver(service, options);
driver.Navigate().GoToUrl("https://mbasic.facebook.com");
Thread.Sleep(TimeSpan.FromSeconds(30));
driver.Quit();
}