栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 面试经验 > 面试问答

如何在pythonselenium中设置Chrome实验选项same

面试问答 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

如何在pythonselenium中设置Chrome实验选项same

在Chrome上测试:版本79.0.3945.130(正式版本)(64位)

在Python中,您可以使用以下代码

    chrome_options = webdriver.ChromeOptions()    experimentalFlags = ['same-site-by-default-cookies@1','cookies-without-same-site-must-be-secure@1']    chromeLocalStatePrefs = { 'browser.enabled_labs_experiments' : experimentalFlags}    chrome_options.add_experimental_option('localState',chromeLocalStatePrefs)    driver = webdriver.Chrome(options=chrome_options)    driver.get("https://www.bing.com")

Python Selenium客户端将发送以下功能

[1579581631.792][INFO]: Starting ChromeDriver 79.0.3945.36 (3582db32b33893869b8c1339e8f4d9ed1816f143-refs/branch-heads/3945@{#614})[1579581631.792][INFO]: Please protect ports used by ChromeDriver and related test frameworks to prevent access by malicious pre.[1579581632.264][INFO]: [f6b8433509c420fd317902f72b1d102d] COMMAND InitSession {   "capabilities": {      "alwaysMatch": {         "browserName": "chrome",         "goog:chromeOptions": { "args": [  ], "extensions": [  ], "localState": {    "browser.enabled_labs_experiments": [ "same-site-by-default-cookies@1", "cookies-without-same-site-must-be-secure@1" ] }         },         "platformName": "any"      },      "firstMatch": [ {      } ]   },   "desiredCapabilities": {      "browserName": "chrome",      "goog:chromeOptions": {         "args": [  ],         "extensions": [  ],         "localState": { "browser.enabled_labs_experiments": [ "same-site-by-default-cookies@1", "cookies-without-same-site-must-be-secure@1" ]         }      },      "platform": "ANY",      "version": ""   }}

检查它是否实际工作。转到chrome:// flags /



转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/376323.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号