【问题标题】:Selenium Webdriver - disabling browser cookieSelenium Webdriver - 禁用浏览器 cookie
【发布时间】:2013-07-25 05:29:30
【问题描述】:

我需要在 Firefox 中禁用浏览器 cookie。

我正在使用 selenium - webdriver 2.32。

【问题讨论】:

    标签: cookies selenium-webdriver


    【解决方案1】:

    为了实现这一点,您必须首先调整配置文件首选项。执行以下操作:

    require 'selenium-webdriver'
    
    profile = Selenium::WebDriver::Firefox::Profile.new
    profile['network.cookie.cookieBehavior'] = 2 # disables all kind of cookies
    
    driver = Selenium::WebDriver.for :firefox, :profile => profile
    

    当您打开工具 -> 选项 -> 浏览器隐私(由 driver = Selenium::WebDriver.for :firefox, :profile => profile 打开)时,您会看到如下图,确保cookie 已被禁用:

    【讨论】:

    • 这确实有效,但代码示例有一个错字,stackoverflow 不会让我修复它(禁止编辑少于 6 个字符,愚蠢的规则)。将 network.cookie.cookieBehvior 更改为 network.cookie.cookieBehavior
    猜你喜欢
    • 2010-11-10
    • 2016-05-26
    • 1970-01-01
    • 1970-01-01
    • 2015-01-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-02-03
    相关资源
    最近更新 更多