【问题标题】:Clearing browser cache with Selenium使用 Selenium 清除浏览器缓存
【发布时间】:2011-10-23 02:00:26
【问题描述】:

我一直在使用 Ruby selenium-webdriver gem 在工作中的 Web 应用程序上执行一些测试。一件很棒的事情是能够在执行定时页面加载等之前以编程方式清除浏览器缓存,但我似乎在文档中找不到任何内容。

有谁知道是否有一种简单的方法可以用 gem 做到这一点?

【问题讨论】:

  • selenium 真的缓存了什么吗?
  • 我不确定,但我认为它控制的浏览器会缓存。

标签: ruby testing selenium web-testing


【解决方案1】:

我没有足够的声誉来评论 jacksparrow007 的答案,但在 Ruby Selenium 中,他的建议可以编码为:

profile = Selenium::WebDriver::Firefox::Profile.new
profile['browser.cache.disk.enable'] = false
profile['browser.cache.memory.enable'] = false
profile['browser.cache.offline.enable'] = false
profile['network.http.use-cache'] = false
Selenium::WebDriver.for :firefox, :profile => profile

【讨论】:

    【解决方案2】:

    希望这会有所帮助!

    @driver.manage.delete_all_cookies
    

    【讨论】:

      【解决方案3】:

      我认为您可以通过制作自定义的 firefox 配置文件然后告诉您的驱动程序使用它来做到这一点。检查this

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2018-07-27
        • 2020-02-29
        • 2019-11-07
        • 2012-03-22
        • 2016-02-18
        相关资源
        最近更新 更多