2

I've installed Selenium correctly as well as the Chromium webdriver for Selenium, and I keep getting the following error:

    Traceback (most recent call last):
  File "C:/Users/Turtle/PycharmProjects/SpotifyWebscraper/seleniumTest.py", line 3, in <module>
    driver = webdriver.chrome()
TypeError: 'module' object is not callable

Here is my code:

from selenium import webdriver

driver = webdriver.chrome()
driver.get("htts://www.google.com")

print(driver.title)
print(driver.current_url)

driver.quit

I've checked in the folders correctly and the files seem to be in the right positions:

C:\Users\Turtle\AppData\Local\Programs\Python\Python38\Lib\site-packages\selenium-4.0.0a3-py3.8.egg\selenium\webdriver\chromium

contains file webdriver.py.

2 Answers 2

3

If you look at the way Selenium imports the various flavours of webdriver to selenium.webdriver you can see that the import you want is Chrome

from .firefox.webdriver import WebDriver as Firefox  # noqa
from .chrome.webdriver import WebDriver as Chrome  # noqa

So you would do driver = webdriver.Chrome() or if you want Firefox, webdriver.Firefox()

By doing webdriver.chrome() you're importing & calling the actual chrome module

In terms of your new error, you need to download the chromedriver executable and make sure it's in a folder which is available to python (included in your PATH). You can download chromedriver here; https://sites.google.com/a/chromium.org/chromedriver/downloads

Sign up to request clarification or add additional context in comments.

6 Comments

another commenter noticed this. I have thus fixed the code but now i'm getting a whole different slew of errors: cdn.discordapp.com/attachments/526891145733603339/…
@ThomasScheer you actually need to download chromedriver. I've added a link to my answer.
yes, I have already downloaded the chromedriver thank you. I have also created a path to it but the error persists. here is proof: cdn.discordapp.com/attachments/526891145733603339/…
@ThomasScheer The python3.8 path which you've got selenium installed to isn't listed in those paths. Perhaps that's your issue. If you need further reading on windows path then check this; computerhope.com/issues/ch000549.htm
I just remembered that I updated my python and didn't reset the path. this was the answer. Thanks Mark. this has me a lot of headaches
|
1

The error in your title is different than the one in your post.

TypeError: 'module' object is not callable

chrome should be capitalized in webdriver.chrome():

driver = webdriver.Chrome() # .Chrome(), not .chrome()

4 Comments

I see. I capitalized the driver and now i'm getting a whole new slew of error.
Looks like you're missing the chromedriver chromedriver.chromium.org/downloads
hi Ismael, I am positive that I am not missing the chromedriver. thank you for your input, however.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.