zxz1337 发表于 2017-5-16 17:47:48

始终提示:目录名称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'


cq520131517 发表于 2017-5-16 20:10:48

看看这批那文章,你的指定路径有问题。http://blog.csdn.net/qiyueqinglian/article/details/47756265

jingzizx 发表于 2017-5-17 08:08:39

:victory:

若尘_51 发表于 2017-5-17 11:23:08

不能直接这么写的。试试这个:
firefoxBin = os.path.abspath(r"D:\Program Files\Firefox\firefox.exe")
os.environ["webdriver.firefox.bin"] = firefoxBin
driver = webdriver.Firefox()

zxz1337 发表于 2017-10-23 16:46:47

已经找到了 解决方法,直接把路径加入到了path中。
页: [1]
查看完整版本: 始终提示:目录名称browser = webdriver.Firefox('D:\\Program Files/Firefox/fire...