停用“退出Chromium时清除Cookie和网站数据"以编程方式 [英] Disable "Clear cookies and site data when you quit Chromium" programatically
问题描述
我看到此您退出Chromium时清除cookie和网站数据"在Chrome和Chromium的设置上.
当使用Selenium启动浏览器时,我想更改为禁用它.我没有找到任何chrome选项,也找不到任何有帮助的chrome参数.
我已检查
[更新]
在评论中,我被问到我是怎么找到这个的-答案是我看了看书的来源,然后跟踪了白兔子.
我从设置文字开始.我搜索了清除Cookie和站点数据
在此文件中: settings_google_chrome_strings.grdp
我得到了这次成功:
<!-Cookie设置页面-><消息名称="IDS_SETTINGS_SITE_SETTINGS_DELETE_DATA_POST_SESSION"desc =用于复选框的标签,该复选框允许用户在浏览器会话结束时自动删除其cookie和站点数据."退出Chrome时清除Cookie和网站数据</message>
我可以看到那是不对的.因此,我搜索了设置的名称,然后在文件中找到了一个匹配项: md_settings_localized_strings_provider.cc
{"deleteDataPostSession",IDS_SETTINGS_SITE_SETTINGS_DELETE_DATA_POST_SESSION},
对于我通常坚持使用的功能来说,这看起来是正确的……剩下的只是对其进行测试-并且可以正常工作.
I see this "Clear cookies and site data when you quit Chromium" on Chrome's and Chromium's settings.
I would like to change disable it when starting browser with Selenium. I didn't find any chrome option, nor any chrome argument that would help.
I have check this code of Chromium, where are all the prefs but I didn't find anything regarding to cookies, site data, quit, exit, cleanup.
Also not finding any relevant on the chromium arguments: https://peter.sh/experiments/chromium-command-line-switches
Try using chrome capabilities:
from selenium import webdriver
caps = webdriver.DesiredCapabilities.CHROME.copy()
caps['deleteDataPostSession'] = False
driver = webdriver.Chrome(desired_capabilities=caps)
driver.get("http://www.google.com")
This toggles the setting to off me when i kick it off with python:
[update]
In the comments i was asked how i found this - answer is i looked at the source and followed the white rabbit..
I started with the text for the settings. I searched for Clear cookies and site data
In this file: settings_google_chrome_strings.grdp
i got this hit:
<!-- Cookie Settings Page -->
<message name="IDS_SETTINGS_SITE_SETTINGS_DELETE_DATA_POST_SESSION" desc="Label for the checkbox that allows the user to automatically delete their cookies and site data at the end of the browser session.">
Clear cookies and site data when you quit Chrome
</message>
I could see that wasn't quite right. So i searched for the name of the setting, and that got one hit in file: md_settings_localized_strings_provider.cc
{"deleteDataPostSession",
IDS_SETTINGS_SITE_SETTINGS_DELETE_DATA_POST_SESSION},
That looked about right for what i usually stick into capabilities... All that was left was to test it - and it worked.
这篇关于停用“退出Chromium时清除Cookie和网站数据"以编程方式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!