最近,我一直试图让Selenium环境重新启动并运行。所有的工作,它应该与脚本执行他们应该,使用不同的网络驱动等。
然而,每个驱动程序的初始发射需要2-5分钟才能启动。这使得开发和排除我的脚本变得很痛苦。
我在PyCharm中使用Python3.6,在pip中安装Selenium。Python2.7也存在同样的问题。
到目前为止,我尝试过的事情(没有成功):
这是我要跑的东西。这个简单的脚本需要5分钟才能运行,但工作正常,不返回警告或错误。
from selenium import webdriver
import time
print(time.localtime())
browser = webdriver.Firefox()
browser.get('http://seleniumhq.org/')
print(time.localtime())编辑:上面的代码只运行一次就会产生以下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发布于 2018-06-04 13:04:29
这些错误信息..。
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...implies表示有几次尝试读取现有的VR Path Registry from C:\Users\victorsk\AppData\Local\openvr\openvrpaths.vrpath。
您的主要问题是系统中存在os杂务。
解决方案
要加快操作,请执行以下步骤:
Test。tearDown(){}方法中调用tearDown(){}来关闭和销毁WebDriver和WebDriver实例。注意事项:不要禁用JavaScript。禁用 JavaScript 可能会导致网页加载不完整,因为所有网页设计人员/开发人员都认为JavaScript在每个浏览器中都是可用的,而且最近的所有浏览器功能和效果都是使用JavaScript实现的。
https://stackoverflow.com/questions/50679623
复制相似问题