0

I am having errors trying to use selenium webdriver with Chrome in Windows 10.

This is my code:

import time
from selenium import webdriver

driver = webdriver.Chrome()

And this is what I get:

Traceback (most recent call last): File "C:\Users\angrypig\Desktop\Angrypig\Program Files#Projects\Python\SeleCrawler_1\SeleCrawler_1\SeleCrawler_1.py", line 10, in driver = webdriver.Chrome() AttributeError: module 'selenium.webdriver' has no attribute 'Chrome'

I already installed selenium and have chromedriver in C: but no success.

Any help please?

3
  • did you install the selenium package? Commented Aug 12, 2017 at 2:05
  • yes, I installed selenium package and chromedriver. Commented Aug 12, 2017 at 2:30
  • could you please open you python interpreter and run from selenium import webdriver and let me know if you have any errors? Commented Aug 12, 2017 at 3:05

7 Answers 7

3

It seems you haven't installed the selenium package, if so:

pip install selenium

However, it also seems you are using the wrong class, so this might solve your problem:

driver = webdriver.Chrome()

If the previous line did not work, so try this

driver = webdriver.Chrome('path/to/chromedriver')

Update:

I found here:

Ensure Chromium/Google Chrome is installed in a recognized location ChromeDriver expects you to have Chrome installed in the default location for your platform. You can also force ChromeDriver to use a custom location by setting a special capability.

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

10 Comments

yes, I installed the selenium package via pip already. And, the Chrome in lower case was just to see if that worked after webdriver.Chrom() didn't work at all. Sorry for the mistake
@angrypig7, so it seems you have a typo in the class chrome, change it to Chrome.
Yes, that was also a mistake when posting into stackoverflow. I tried that after findin out that uppercase letters also didn't work.
Just did that. Nothing seems to have changed.
The chromedriver is in C:\webdriver\chromdriver.exe Then it should be like webdriver.Chrome('C:\webdriver') right? If so, still no luck
|
0

From your error message I am guessing you are working on windows and did you install chromedriver ? If not, you can do it from here:

  • Download from here

Change chrome to Chrome. Then, this should work:

from selenium import webdriver
driver = webdriver.Chrome()

Please refer this thread as well.

1 Comment

I did download selenium and chromedriver but no luck.
0

I have run into this issue and solved it by just importing selenium, then doing:

driver = selenium.webdriver.Chrome(executable_path="PATH\TO\chromedriver.exe")

Hopefully it helps

4 Comments

Thanks for your helpt but, this is what I get - NameError: name 'selenium' is not defined
After adding "import selenium" instead of "from selenium import webdriver", I get this error: AttributeError: module 'selenium.webdriver' has no attribute 'Chrome'
This is very strange. I pasted that directly from a working module I wrote and use every day. You should try to uninstall and re-install selenium or doing an update, because something may have been corrupted when installing or something
Also, another thing that I remember using once was doing a from selenium import * before the other imports, but really don't know if this would do anything
0

It is not enough to install selenium. Have you downloaded and put the Chrome driver where it needs to be?

From here: https://sites.google.com/a/chromium.org/chromedriver/downloads

1 Comment

Have you tried to follow the steps here: github.com/SeleniumHQ/selenium/wiki/ChromeDriver ?
0

I just got an answer to this: Visual Studio was the problem. I tried PyCharm and it just works. heh

I have no idea what caused Visual Studio to put off errors.

Comments

0

I had this problem also. What ended up happening for me was when I installed selenium using pip install -U selenium in command prompt it missed putting the selenium folder in the python library.

What fixed it for me was going to https://pypi.python.org/pypi/selenium, downloading the "selenium-3.11.0.tar.gz (md5)". Unzip that and copy the selenium folder over to your python library.

This is also refreanced in part 2. Selenium installation here: https://www.kainos.pl/blog/first-test-python-webdriver-pycharm/

Comments

0

I was facing the same error AttributeError: module 'selenium.webdriver' has no attribute 'Chrome' . Earlier I just copied and pasted the selenium library in my venv libs .But the copy was not made properly. That's why it was not working well. Since I receive this error , I removed the selenium package and installed it by pip using the command pip install selenium.It worked for me .

So What I came up to is this issue is regarding the installation of selenium.if it is not working in your code also, go and try removing the package or just uninstalling the package and install it again.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.