Search code examples
pythonseleniumselenium-webdriverwebdriverselenium-chromedriver

Cant get this code using selenium and chromedriver to work in pycahrm


Been working on this for a while so help would be appreciated. The code I'm on rn is:

from selenium import webdriver

PATH = "C:\\Program Files (x86)\\Chromedriver.exe"

driver = webdriver.Chrome(PATH)

driver.get("https://www.youtube.com/")

error code:

C:\Users\noahr\.virtualenvs\pythonProject-ME1SVWk8\Scripts\python.exe C:/Users/noahr/PycharmProjects/pythonProject/main.py
Traceback (most recent call last):
  File "C:\Users\noahr\PycharmProjects\pythonProject\main.py", line 3, in <module>
    driver = webdriver.chrome()
TypeError: 'module' object is not callable

Process finished with exit code 1

Solution

  • Looking at your code there seems to be no issue which was confirmed when I was able to execute your code on my machine (except for changing the chromedriver path).

    However when I look at your logs, it mentions driver = webdriver.chrome(). If this is exactly what you have in your code, then it should be driver = webdriver.Chrome(PATH) - please note the capital "C" for Chrome as well the Path parameter.