每次我运行webdriver.Firefox.get(‘someurl)代码时,都会显示一个新的Firefox驱动程序,它不会缓存加载的任何网页.我想让Selenium告诉每个加载到Firefox的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
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。