Python+Selenium环境部署步骤
1.安装Python35
2.安装pycharm2016社区版
3.导入setting-project-project interpreter安装pip,selenium,setuptools
4.在http://www.seleniumhq.org/download/网站上下载浏览器驱动;解压,将geckodriver.exe(Firefox),chromedriver.exe(chrome)文件放置Python35/Scripts路径下;
5.Python35添加到系统变量path下;出现的问题:
1.Webdriver常见问题:
1)若geckodriver.exe(Firefox),chromedriver.exe(chrome)文件未放置Python35/Scripts路径下
会导致系统报错如下:
E:\Python\Py-scripts\venv\Scripts\python.exe E:/Python/Py-scripts/WebDriverAPI/test1.py
Traceback (most recent call last):
File "E:\Python\Py-scripts\venv\lib\site-packages\selenium\webdriver\common\service.py", line 76, in start
stdin=PIPE)
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python35\lib\subprocess.py", line 950, in __init__
restore_signals, start_new_session)
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python35\lib\subprocess.py", line 1220, in _execute_child
startupinfo)
FileNotFoundError: [WinError 2] 系统找不到指定的文件。
During handling of the above exception, another exception occurredTraceback (most recent call last):
File "E:/Python/Py-scripts/WebDriverAPI/test1.py", line 3, in <module>
driver = webdriver.Chrome()
File "E:\Python\Py-scripts\venv\lib\site-packages\selenium\webdriver\chrome\webdriver.py", line 68, in __init__
self.service.start()
File "E:\Python\Py-scripts\venv\lib\site-packages\selenium\webdriver\common\service.py", line 83, in start
os.path.basename(self.path), self.start_error_message)
selenium.common.exceptions.WebDriverException: Message: 'chromedriver' executable needs to be in PATH. Please see https://sites.google.com/a/chromium.org/chromedriver/home
Process finished with exit code 1