Selenium GeckoDriver启动Firefox浏览器的速度很慢 [英] Selenium GeckoDriver is slow to launch Firefox Browser

查看:211
本文介绍了Selenium GeckoDriver启动Firefox浏览器的速度很慢的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近一直在尝试建立Selenium环境并重新运行.一切正常,脚本执行正常,使用其他Web驱动程序等.

I have recently been trying to get a Selenium environment up and running again. Everything works as it should with scripts executing as they should, using different web drivers etc etc.

但是,每个驱动程序的初始启动需要2-5分钟才能启动.这使我的脚本开发和故障排除变得很痛苦.

However, the initial launch of each driver takes anywhere between 2-5 min to launch. This makes it a pain to develop and troubleshoot my scripts.

我将Python 3.6与PyCharm和Selenium一起安装在pip上.Python 2.7中存在相同的问题.

I use Python 3.6 with PyCharm and Selenium installed with pip. The same issue is present with Python 2.7.

到目前为止,我已经尝试过的事情(没有成功):

Things I have tried so far (without success):

  • 重新安装Python
  • 重新安装硒
  • 通过PyCharm和终端运行脚本
  • 用早期和更高版本替换了网络驱动程序.
  • 已禁用网络驱动程序的代理和javascript

这是我正在跑步的东西.这个简单的脚本最多需要5分钟才能运行,但可以正常运行,并且不返回任何警告或错误.

Here is what I am running. This simple script takes up to 5min to run, but works correctly and returns no warnings or errors.

from selenium import webdriver
import time
print(time.localtime())
browser = webdriver.Firefox()
browser.get('http://seleniumhq.org/')
print(time.localtime())

上面的代码仅运行一次即可产生以下geckodriver.log

A single run of the code above yields the following geckodriver.log

1528112695159   geckodriver INFO    geckodriver 0.19.1
1528112695168   geckodriver INFO    Listening on 127.0.0.1:3148
1528112747876   mozrunner::runner   INFO    Running command: "C:\\Program Files (x86)\\Mozilla Firefox\\firefox.exe" "-marionette" "-profile" "C:\\Users\\victorsk\\AppData\\Local\\Temp\\rust_mozprofile.ULuflXGoq9rE"
Unable to read VR Path Registry from C:\Users\victorsk\AppData\Local\openvr\openvrpaths.vrpath
Unable to read VR Path Registry from C:\Users\victorsk\AppData\Local\openvr\openvrpaths.vrpath
Unable to read VR Path Registry from C:\Users\victorsk\AppData\Local\openvr\openvrpaths.vrpath
Unable to read VR Path Registry from C:\Users\victorsk\AppData\Local\openvr\openvrpaths.vrpath
Unable to read VR Path Registry from C:\Users\victorsk\AppData\Local\openvr\openvrpaths.vrpath
1528112791808   Marionette  INFO    Listening on port 3158
1528112792599   Marionette  WARN    TLS certificate errors will be ignored for this session
[Parent 36664, Gecko_IOThread] WARNING: pipe error: 109: file z:/build/build/src/ipc/chromium/src/chrome/common/ipc_channel_win.cc, line 346
[Parent 36664, Gecko_IOThread] WARNING: pipe error: 109: file z:/build/build/src/ipc/chromium/src/chrome/common/ipc_channel_win.cc, line 346
[Child 22672, Chrome_ChildThread] WARNING: pipe error: 109: file z:/build/build/src/ipc/chromium/src/chrome/common/ipc_channel_win.cc, line 346
[Child 22672, Chrome_ChildThread] WARNING: pipe error: 109: file z:/build/build/sr[Parent 36664, Gecko_IOThread] WARNING: pipe error: 109: file z:/build/build/src/ipc/chromium/src/chrome/common/ipc_channel_win.cc, line 346
[Child 25068, Chrome_ChildThread] WARNING: pipe error: 109: file z:/build/build/src/ipc/chromium/src/chrome/common/ipc_channel_win.cc, line 346
[Child 25068, C*** UTM:SVC TimerManager:registerTimer called after profile-before-change notification. Ignoring timer registration for id: telemetry_modules_ping

推荐答案

这些错误消息...

Unable to read VR Path Registry from C:\Users\victorsk\AppData\Local\openvr\openvrpaths.vrpath
Unable to read VR Path Registry from C:\Users\victorsk\AppData\Local\openvr\openvrpaths.vrpath
Unable to read VR Path Registry from C:\Users\victorsk\AppData\Local\openvr\openvrpaths.vrpath
Unable to read VR Path Registry from C:\Users\victorsk\AppData\Local\openvr\openvrpaths.vrpath
Unable to read VR Path Registry from C:\Users\victorsk\AppData\Local\openvr\openvrpaths.vrpath

...表示有几次尝试从C:\ Users \ victorsk \ AppData \ Local \ openvr \ openvrpaths.vrpath 读取现有的 VR路径注册表.

...implies that there were several attempts to read the existing VR Path Registry from C:\Users\victorsk\AppData\Local\openvr\openvrpaths.vrpath.

您的主要问题是系统中存在杂务.

Your main issue is the presence of os chores within your system.

  • 您的 Selenium Client 版本对我们未知.
  • 您的 GeckoDriver 版本是 v0.19.1 .
  • 您的 Firefox 版本对我们来说是未知.
  • Your Selenium Client version is unknown to us.
  • Your GeckoDriver version is v0.19.1.
  • Your Firefox version is unknown to us.

要加快操作速度,请按以下步骤操作:

To speed up the operation follow the steps:

  • 升级到当前级别 版本3.12.0 > .
  • GeckoDriver 升级到 GeckoDriver v0.20.1 级.
  • 确保在指定位置存在 GeckoDriver 二进制文件.
  • 确保 GeckoDriver 具有非root用户的可执行权限.
  • Firefox 版本升级到 Firefox v60.0.1 级别.
  • 通过 IDE
  • 清理您的项目工作区重建您的项目,并且仅具有必需的依赖项.
  • 使用 CCleaner 工具清除之前和之后的所有操作系统杂项在您执行 Test Suite 之后.
  • 如果您的基本 Web客户端版本太旧,请通过来卸载. Revo Uninstaller 并安装最新版本的 Web客户端 GA和发行版.
  • 进行系统重启.
  • 以非root用户身份执行 Test .
  • 始终在 tearDown(){} 方法中调用 driver.quit()以关闭&优雅地销毁 WebDriver Web Client 实例.
  • Upgrade Selenium to current levels Version 3.12.0.
  • Upgrade GeckoDriver to GeckoDriver v0.20.1 level.
  • Ensure GeckoDriver binary is present in the specified location.
  • Ensure GeckoDriver is having executable permission for non-root users.
  • Upgrade Firefox version to Firefox v60.0.1 levels.
  • Clean your Project Workspace through your IDE and Rebuild your project with required dependencies only.
  • Use CCleaner tool to wipe off all the OS chores before and after the execution of your Test Suite.
  • If your base Web Client version is too old, then uninstall it through Revo Uninstaller and install a recent GA and released version of Web Client.
  • Take a System Reboot.
  • Execute your Test as a non-root user.
  • Always invoke driver.quit() within tearDown(){} method to close & destroy the WebDriver and Web Client instances gracefully.

注意:请勿禁用 JavaScript .禁用 JavaScript 可能会导致网页加载不完整,因为所有Web设计人员/开发人员都认为 JavaScript 在每种浏览器中都可用,并且所有最近的浏览器功能和效果都使用 JavaScript .

Note: Do not disable JavaScript. Disabling JavaScript might lead to a incomplete loading of the webpage as all the web designers/developers believes JavaScript is available in every browser and all the recent browser features and effects are implemented using JavaScript.

这篇关于Selenium GeckoDriver启动Firefox浏览器的速度很慢的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆