始终提示:目录名称browser = webdriver.Firefox('D:\\Program Files/Firefox/fire...
始终提示:目录名称>>> browser = webdriver.Firefox('D:/Program Files/Firefox/firefox.exe')
Traceback (most recent call last):
File "<pyshell#16>", line 1, in <module>
browser = webdriver.Firefox('D:/Program Files/Firefox/firefox.exe')
File "D:\python\lib\site-packages\selenium\webdriver\firefox\webdriver.py", line 132, in __init__
firefox_profile = FirefoxProfile(firefox_profile)
File "D:\python\lib\site-packages\selenium\webdriver\firefox\firefox_profile.py", line 78, in __init__
ignore=shutil.ignore_patterns("parent.lock", "lock", ".parentlock"))
File "D:\python\lib\shutil.py", line 303, in copytree
names = os.listdir(src)
NotADirectoryError: 目录名称无效。: 'D:/Program Files/Firefox/firefox.exe'
看看这批那文章,你的指定路径有问题。http://blog.csdn.net/qiyueqinglian/article/details/47756265 :victory: 不能直接这么写的。试试这个:
firefoxBin = os.path.abspath(r"D:\Program Files\Firefox\firefox.exe")
os.environ["webdriver.firefox.bin"] = firefoxBin
driver = webdriver.Firefox() 已经找到了 解决方法,直接把路径加入到了path中。
页:
[1]