即时通讯使用pycharm和我的pythn
版本3.6.7 pip 9.0.1
和硒版硒-3.141.0 urllib3-1.24.1
我使用这个命令安装selenium
pip3 install selenium
然后我这样编码
from selenium import webdriver
driver = webdriver.Firefox("/home/ghost/automation/pwd/geckodriver")
driver.set_page_load_timeout(30)
driver.get("https://www.google.com/")
driver.maximize_window()
driver.implicitly_wait(120)
driver.get_screenshot_as_file("google.png")
driver.quit()
**当我运行这个我得到这个错误**
/home/ghost/PycharmProjects/try/venv/bin/python /home/ghost/PycharmProjects/try/open/testcas1.py
Traceback (most recent call last):
File "/home/ghost/PycharmProjects/try/open/testcas1.py", line 3, in <module>
driver = webdriver.Firefox("/home/ghost/automation/pwd/geckodriver")
File "/home/ghost/PycharmProjects/try/venv/lib/python3.6/site-packages/selenium/webdriver/firefox/webdriver.py", line 151, in __init__
firefox_profile = FirefoxProfile(firefox_profile)
File "/home/ghost/PycharmProjects/try/venv/lib/python3.6/site-packages/selenium/webdriver/firefox/firefox_profile.py", line 80, in __init__
ignore=shutil.ignore_patterns("parent.lock", "lock", ".parentlock"))
File "/usr/lib/python3.6/shutil.py", line 309, in copytree
names = os.listdir(src)
NotADirectoryError: [Errno 20] Not a directory: '/home/ghost/automation/pwd/geckodriver'
Process finished with exit code 1
并在此行driver = webdriver.Firefox(“/ home / ghost / automation / pwd / geckodriver”)其正确的路径我的geckodriver和我的geckodriver
版本是0.23.0
这些答案对我没有帮助
https://stackoverflow.com/a/40399367/8337986
https://stackoverflow.com/a/42945346/8337986
解决方法:
在使用GeckoDriver,Firefox和Selenium时,您需要使用Key executable_path和Value设置为单引号内GeckoDriver的绝对路径,即带有正斜杠的’…’,即/作为路径分隔符,如下所示:
driver = webdriver.Firefox(executable_path='/home/ghost/automation/pwd/geckodriver')
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。