你好在Pycharm我已经在virtualenv中安装了Selenium。我尝试执行
from selenium import webdriver
#from selenium.webdriver.firefox.firefox_binary import FirefoxBinary
#binary = FirefoxBinary('/webdriver/firefox')
browser = webdriver.Firefox()
browser.get('http://localhost:8000')
assert 'Django ' in browser.title
但我有错误
(django_env)darek @ Toshiba:〜/ PycharmProjects / Django $ python functional_tests.py Traceback(最近一次调用最后一次):文件 " functional_tests.py",第5行,in browser = webdriver.Firefox()File" /home/darek/.virtualenvs/django_env/lib/python3.5/site-packages/selenium/webdriver/firefox/webdriver.py", 第140行,在 init 中 self.service.start()File" /home/darek/.virtualenvs/django_env/lib/python3.5/site-packages/selenium/webdriver/common/service.py", 第74行,开始 stdout = self.log_file,stderr = self.log_file)文件" /usr/lib/python3.5/subprocess.py",第947行, init restore_signals,start_new_session)文件" /usr/lib/python3.5/subprocess.py",第1551行,在_execute_child中 raise child_exception_type(errno_num,err_msg)NotADirectoryError:[Errno 20]不是目录,忽略了异常:> Traceback(最近一次调用最后一次):文件 " /home/darek/.virtualenvs/django_env/lib/python3.5/site-packages/selenium/webdriver/common/service.py" ;, 第173行, del self.stop()文件" /home/darek/.virtualenvs/django_env/lib/python3.5/site-packages/selenium/webdriver/common/service.py", 第145行,在停止 如果self.process是None:AttributeError:' Service'对象没有属性' process'
我下载geckodriver ver。 11并添加到变量路径并添加到bashrc
export PYTHONPATH = $ {PYTHONPATH}:/ usr / bin export WORKON_HOME = $ HOME / .virtualenvs export PROJECT_HOME = $ HOME / MyProject export VIRTUALENVWRAPPER_PYTHON = / usr / bin / python3 source /usr/local/bin/virtualenvwrapper.sh
source django_env / bin / activate export PATH = $ PATH:/ home / darek / webdriver / firefox / geckodriver export PATH = $ PATH:/家庭/ darek / webdriver的/火狐/电线
我还能做些什么?