Python+Selenium打开火狐浏览器为啥是出现报错呢
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Python+Selenium打开火狐浏览器为啥是出现报错呢相关的知识,希望对你有一定的参考价值。
参考技术A 你需要下载一个geckodriver.exe放在python的安装目录下(和python.exe同级),geckodriver是火狐浏览器的驱动,可以去这个地址下载下载地址,根据系统版本找最新的就行python+selenium 火狐浏览器运行不行
python+selenium 火狐浏览器运行不行?Traceback (most recent call last):
File "D:\Program Files\Python35\lib\site-packages\selenium\webdriver\common\service.py", line 64, in start
stdout=self.log_file, stderr=self.log_file)
File "D:\Program Files\Python35\lib\subprocess.py", line 947, in __init__
restore_signals, start_new_session)
File "D:\Program Files\Python35\lib\subprocess.py", line 1224, in _execute_child
startupinfo)
FileNotFoundError: [WinError 2] 系统找不到指定的文件。
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "D:\workspace\Test\selenium_study\worm_1_1.py", line 7, in <module>
browser = webdriver.Firefox()
File "D:\Program Files\Python35\lib\site-packages\selenium\webdriver\firefox\webdriver.py", line 135, in __init__
self.service.start()
File "D:\Program Files\Python35\lib\site-packages\selenium\webdriver\common\service.py", line 71, in start
os.path.basename(self.path), self.start_error_message)
selenium.common.exceptions.WebDriverException: Message: 'geckodriver' executable needs to be in PATH.
Exception ignored in: <bound method Service.__del__ of <selenium.webdriver.firefox.service.Service object at 0x0000000000A44160>>
Traceback (most recent call last):
File "D:\Program Files\Python35\lib\site-packages\selenium\webdriver\common\service.py", line 163, in __del__
self.stop()
File "D:\Program Files\Python35\lib\site-packages\selenium\webdriver\common\service.py", line 135, in stop
if self.process is None:
AttributeError: 'Service' object has no attribute 'process'?
现在版本的firefox浏览器,需要下载一个geckodriver驱动放到你的python文件夹里面. 参考技术A python的配置参数是不是正确
seleninm在新版火狐下可能会有些问题,建议退回至49及以下版本安装使用。
以上是关于Python+Selenium打开火狐浏览器为啥是出现报错呢的主要内容,如果未能解决你的问题,请参考以下文章
selenium2+python自动化2-打开火狐输入百度网址