问题描述
我正在使用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缓存的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!