每次我运行webdriver.Firefox.get('someurl)
代码时,都会显示一个新的Firefox驱动程序,并且它不会缓存加载的任何网页。我想让Selenium告诉每个加载的Firefox缓存网页,以便将来使用,他们不必从头加载每个网页。我怎么做呢?
def setup(self):
print 'running fp'
self.path = r'path to my profile folder'
self.profile = webdriver.FirefoxProfile(self.path)
self.web = webdriver.Firefox(self.profile)
self.cache = self.web.application_cache
如何创建一个新的Firefox 配置文件与适当的缓存设置,然后使用它与Selenium
?
看看这个:http://www.toolsqa.com/selenium-webdriver/custom-firefox-profile/
然后在你的Python
脚本:
from selenium import webdriver
firefox_profile = webdriver.FirefoxProfile('path_to_your_profile')
browser = webdriver.Firefox(firefox_profile)
cache = browser.application_cache