Firefox驱动程序不会在配置文件中保存会话和cookie

问题描述 投票:0回答:1

我正在使用firefox进行altomation,我需要保持登录始终处于活动状态,即..保持会话,cookie等。我设置selenium的默认用户不要创建临时,但似乎Firefox忽略并清除会话,cookies,历史,一切..每次终止..在Chrome驱动程序工作完美通知默认配置文件,但不幸的是我不能使用铬。

这有什么解决方案吗?

public IWebDriver StartFirefoxDriver(string url, string driverLocation, bool headless = false)
{
    var service = FirefoxDriverService.CreateDefaultService(driverLocation, "geckodriver.exe");
    service.FirefoxBinaryPath = @"C:\Program Files\Mozilla Firefox\firefox.exe";
    service.HideCommandPromptWindow = true;

    var test = new FirefoxProfile(@"C:\Users\gabriels\AppData\Local\Mozilla\Firefox\Profiles\zq9sf3jp.Whats");
    test.DeleteAfterUse = false;

    var firefoxOptions = new FirefoxOptions();

    firefoxOptions.Profile = test;

    if (headless)
        firefoxOptions.AddArgument("--headless");


    var driver = new FirefoxDriver(service, firefoxOptions);

    driver.Navigate().GoToUrl(url);



    return driver;

}
c# selenium selenium-webdriver selenium-firefoxdriver
1个回答
0
投票

我拍摄个人资料的位置不正确,对于犯同样错误的人来说,这是一个教训。

正确的位置是:

C:\用户\ Gabriels的\应用程序数据\漫游\ Mozilla的\火狐\ Profiles文件\

© www.soinside.com 2019 - 2024. All rights reserved.