相关疑难解决方法(0)

如何在python selenium中设置Chrome实验选项same-site-by-default-cookie

我想这应该有效:

from selenium import webdriver
options = webdriver.ChromeOptions()
options.add_experimental_option('same-site-by-default-cookies', 'true')
driver = webdriver.Chrome(chrome_options=options)
Run Code Online (Sandbox Code Playgroud)

启用为未来 chrome 版本计划的相同站点 cookie 限制。不是,有错误:

selenium.common.exceptions.InvalidArgumentException: 
Message: invalid argument: cannot parse capability: goog:chromeOptions
from invalid argument: unrecognized chrome option: same-site-by-default-cookies
Run Code Online (Sandbox Code Playgroud)

我可以使用 chrome://flags 手动更改选项并查看它是否正常工作。但是我想自动化它并运行测试脚本来查看它。

这里有 java 代码:https : //groups.google.com/forum/#!topic/ chromedriver-users/ cI8hj7eihRo 可以做到,但我不确定如何将其传输到 python。

是否有任何参考资料可以帮助我设置此选项或其他选项?

selenium google-chrome python-3.x selenium-chromedriver samesite

2
推荐指数
1
解决办法
6598
查看次数