在Selenium IDE中清除Firefox缓存

编程入门 行业动态 更新时间:2024-10-10 03:25:10
本文介绍了在Selenium IDE中清除Firefox缓存的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正在使用Selenium IDE来测试Web应用程序.有时我的测试成功了,即使它们应该失败了.原因是浏览器碰巧从缓存中加载了页面的先前版本,而不是加载了该页面的较新版本.换句话说,我可能在没有意识到的情况下向我的应用程序引入了错误,因为在加载先前的工作版本而不是加载新的错误版本之后,测试可能会通过.

I'm using Selenium IDE to test a web application. Sometimes my tests succeed even though they should have failed. The reason is that the browser happens to load a previous version of a page from the cache instead of loading the newer version of that page. In other words, I might introduce a bug to my app without being aware of it because the tests may pass after loading a previous working version instead of loading the new buggy version.

我可能想到的最好的解决方案是在运行测试之前删除浏览器缓存.我有一个Selenium脚本,可以在运行测试之前在其中运行设置selenium命令.是否有一个硒命令来清除Firefox缓存?另外,还有另一种方法可以防止在测试期间从缓存中加载页面吗?

The best solution I could have thought of is to delete the browser cache before running the tests. I have a Selenium script in which I run set-up selenium commands before running the tests. Is there a selenium command to clear Firefox cache? Alternatively, is there another way to prevent loading pages from the cache during the tests?

推荐答案

在python中,这应禁用firefox缓存:

In python this should disable firefox cache:

profile = webdriver.FirefoxProfile() profile.set_preference("browser.cache.disk.enable", False) profile.set_preference("browser.cache.memory.enable", False) profile.set_preference("browser.cache.offline.enable", False) profile.set_preference("network.http.use-cache", False) driver = webdriver.Firefox(profile)

希望这对某人有帮助

更多推荐

在Selenium IDE中清除Firefox缓存

本文发布于:2023-11-27 17:59:46,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1639027.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:缓存   Selenium   IDE   Firefox

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!