使用selenium-on-rails的一些讨论 2]清理缓存
2. selenium-on-rails 清理cache
并没有提供这个功能,但是在测试开始时确实需要,方案在Align书的"基于时间的缓存失效策略"里描述了,就是删除文件夹tmp/cache
这里直接清理tmp文件夹
在测试文件中调用
并没有提供这个功能,但是在测试开始时确实需要,方案在Align书的"基于时间的缓存失效策略"里描述了,就是删除文件夹tmp/cache
这里直接清理tmp文件夹
# selenium-on-rails/lib/selenium-on-rails/paths.rb
def tmp_path
File.expand_path File.join(RAILS_ROOT,'tmp')
end
# selenium-on-rails/lib/controllers/selenium-controller.rb
def tmp_clear ## tachikoma add
FileUtils.rm_r Dir.glob(tmp_path+"/*")
RAILS_DEFAULT_LOGGER.info("Tmp directory fully sweeped.")
render :file => view_path('tmp_clear.rhtml')
end
另外做一个tmp_clear.rhtml就可以了def tmp_path
File.expand_path File.join(RAILS_ROOT,'tmp')
end
# selenium-on-rails/lib/controllers/selenium-controller.rb
def tmp_clear ## tachikoma add
FileUtils.rm_r Dir.glob(tmp_path+"/*")
RAILS_DEFAULT_LOGGER.info("Tmp directory fully sweeped.")
render :file => view_path('tmp_clear.rhtml')
end
在测试文件中调用
open '/selenium/tmp_clear"
就OK