我正在尝试使用配置文件运行chrome webdriver,因此我可以存储cookie和用户名/密码。但是,当我尝试将此与无头模式结合使用时,会出错:
DevTools listening on ws://127.0.0.1:63585/devtools/browser/ab7a020f-e412-4204-a53a-285e0b3a15c4
[0824/105430.911:ERROR:devtools_http_handler.cc(288)] Error writing DevTools active port to file
[0824/105430.916:ERROR:cache_util_win.cc(19)] Unable to move the cache: 3
[0824/105430.916:ERROR:cache_util.cc(135)] Unable to move cache folder cookies/PresFox1\Default\GPUCache to cookies/PresFox1\Default\old_GPUCache_000
[0824/105430.917:ERROR:disk_cache.cc(169)] Unable to create cache
[0824/105430.917:ERROR:shader_disk_cache.cc(600)] Shader Cache Creation failed: -2
代码:
public static void login(string username, string password)
{
ChromeOptions options = new ChromeOptions();
//options.AddArgument("--start-maximized");
options.AddArgument("--user-data-dir=cookies/"+username);
options.AddArgument("--headless");
IWebDriver driver = new ChromeDriver(options);
有什么主意我可以解决这个问题吗?