I want to use selenium with chromedriver on Mac,but I have some troubles on it.
selenium.common.exceptions.WebDriverException: Message: 'chromedriver' executable needs to be in PATH.
To launch chrome browser using ChromeDriver you need to pass executable chromedriver location with executable itself into executable_path
.
You should try as below :-
from selenium import webdriver
PROJECT_ROOT = os.path.abspath(os.path.dirname(__file__))
DRIVER_BIN = os.path.join(PROJECT_ROOT, "bin/chromedriver_for_mac")
browser = webdriver.Chrome(executable_path = DRIVER_BIN)
browser.get('http://www.baidu.com/')
Or set PATH
variable using command with executable as :-
export PATH=$PATH:/Users/wyx/project/python-scraping/se/bin/chromedriver_for_mac
Then try to Initialize ChromeDriver
as :-
from selenium import webdriver
browser = webdriver.Chrome()
browser.get('http://www.baidu.com/')