搭建好Python3.6+Firefox+Selenium环境,运行如下测试脚本:
#!/usr/bin/env python
# -*- coding:utf-8 -*-
from selenium import webdriver
browser = webdriver.Firefox()
browser.get('http://www.baidu.com')
得到如下报错:
C:\Users\Administrator\AppData\Local\Programs\Python\Python36-32\python.exe C:/Users/Administrator/PycharmProjects/WebAuto/IEAuto.py
Traceback (most recent call last):
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python36-32\lib\site-packages\selenium\webdriver\common\service.py", line 76, in start
stdin=PIPE)
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python36-32\lib\subprocess.py", line 709, in __init__
restore_signals, start_new_session)
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python36-32\lib\subprocess.py", line 997, in _execute_child
startupinfo)
FileNotFoundError: [WinError 2] 系统找不到指定的文件。
During handling of the above exception, another exception occurred:
Traceback (most

在Python3.6环境下,使用Selenium与Firefox结合进行网页自动化测试时,遇到FileNotFoundError: [WinError 2] 系统找不到指定的文件错误。该错误涉及subprocess.py文件的shell模式设置和Firefox驱动配置。通过修改subprocess.py文件,将shell=False改为shell=True,然后解决Firefox驱动问题,包括下载对应版本的geckodriver,将其解压到Python安装目录,并添加到环境变量PATH中,最终成功运行脚本。

4833

被折叠的 条评论
为什么被折叠?



