
从Selenium开始,对Firefox 使用的RAM数量几乎没有控制权。至于你提到的浏览器客户端,即Mozilla的推移 来回用户配置文件和通知页面之间的Instagram的和 不基于它找到什么太宽泛,单任务的用例。因此, 首要的任务是打破了无限循环属于 你的用例为更小的测试。
time.sleep()
Inducing
time.sleep()virtually puts a blanket over the underlying issue.
However while using Selenium and
WebDriver
to execute tests through your Automation
framework, using
time.sleep()
without any specific condition defeats the purpose of automation and should
be avoided at any cost. As per the documentation:
time.sleep(secs)
suspends the execution of the current thread for the given number of
seconds. The argument may be a floating point number to indicate a more
precise sleep time. The actual suspension time may be less than that
requested because any caught signal will terminate the sleep() following
execution of that signal’s catching routine. Also, the suspension time may
be longer than requested by an arbitrary amount because of the scheduling of
other activity in the system.
Analysis
在以前的情况下,Firefox消耗了大约80%的RAM。
Firefox_RAM
但是,根据此讨论,一些用户认为使用
的内存越多越好,因为这意味着您不会浪费RAM。Firefox使用RAM来
提高其处理速度,因为应用程序数据在
RAM中的传输速度更快。
解
您可以执行以下一个/所有通用/特定步骤:
将Selenium升级到当前版本3.141.59。
升级GeckoDriver到GeckoDriver v0.24.0水平。
将Firefox版本升级到Firefox v65.0.2级别。
清理你的项目工作,通过你的IDE和重建仅需要依赖你的项目。
如果您的基本Web客户端版本太旧,则将其卸载并安装最新的GA和Web客户端的发行版本。
某些扩展允许您阻止此类不必要的内容,例如:
from selenium import webdriver profile = webdriver.FirefoxProfile() profile.add_extension(extension='extension_name.xpi') driver = webdriver.Firefox(firefox_profile=profile, executable_path=r'C:pathtogeckodriver.exe')
配置文件= webdriver.FirefoxProfile()profile.add_extension(扩展名’extension_name.xpi’)驱动程序= webdriver.Firefox(firefox_profile = profile,executable_path = r’C: path to geckodriver.exe’)
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)