Итак, я новичок в python и заинтересовался WebDriver и его возможными приложениями.Поэтому я написал это только для того, чтобы проверить, что все необходимые библиотеки установлены.
from selenium import webdriver
import time
driver = webdriver.Chrome(executable_path= r'chromedriver.exe')
driver.get('http://www.google.com')
И как только я напишу python3 nameOfCode.py, результатом будет ошибка, как это часто бывает.Ошибка (ы):
macs-MacBook-Pro:Desktop mac$ python3 testSelenium.py
Traceback (most recent call last):
File "testSelenium.py", line 5, in <module>
driver = webdriver.Chrome(executable_path= mac/Desktop/chromedriver.exe)
NameError: name 'mac' is not defined
macs-MacBook-Pro:Desktop mac$ python3 testSelenium.py
Traceback (most recent call last):
File "testSelenium.py", line 5, in <module>
driver = webdriver.Chrome(executable_path= Desktop/chromedriver.exe)
NameError: name 'Desktop' is not defined
macs-MacBook-Pro:Desktop mac$ python3 testSelenium.py
Traceback (most recent call last):
File "testSelenium.py", line 5, in <module>
driver = webdriver.Chrome(executable_path= chromedriver.exe)
NameError: name 'chromedriver' is not defined
macs-MacBook-Pro:Desktop mac$ python3 testSelenium.py
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/selenium/webdriver/common/service.py", line 76, in start
stdin=PIPE)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/subprocess.py", line 709, in __init__
restore_signals, start_new_session)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/subprocess.py", line 1344, in _execute_child
raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: 'chromedriver.exe': 'chromedriver.exe'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "testSelenium.py", line 5, in <module>
driver = webdriver.Chrome(executable_path= r'chromedriver.exe')
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/selenium/webdriver/chrome/webdriver.py", line 73, in __init__
self.service.start()
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/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.exe' executable needs to be in PATH. Please see https://sites.google.com/a/chromium.org/chromedriver/home
Извините, если это много :)) Дарио