'AttributeError Issue: module 'selenium.webdriver' has no attribute 'Chrome'
I have just started Selenium using Python. And I'm facing the Attribute error issue.
Have Installed Python 3.6.5 and installed the latest selenium packages(selenium-3.11.0)
Have also added Scripts and Python folder path in the Environment variable:PATH.
Downloaded the chromedriver.exe and have added the respective file path into the environment variable.
But while running the below code:
from selenium import webdriver
driver = webdriver.Chrome("E:\Selenium\chromedriver_win32\chromedriver.exe")
It's throwing the following error:
C:\Users\Sooraj\venv\firstpgm\Scripts\python.exe C:/Users/Sooraj/PycharmProjects/Selenium/First.py
Traceback (most recent call last):
File "C:/Users/Sooraj/PycharmProjects/Selenium/First.py", line 2, in
<module>
driver=webdriver.Chrome("E:\Selenium\chromedriver_win32\chromedriver.exe")
AttributeError: module 'selenium.webdriver' has no attribute 'Chrome'
Process finished with exit code 1
Tried all the other solutions provided here in Stack Overflow like uninstalling and reinstalling Python and upgrading the selenium.But was of no help.
The code was run using PyCharm IDE but when run using IDLE it's working fine.
Could find the folders like firefox,chrome,safari,phantomjs,android etc..under Sitepackages -> selenium -> webdriver.But not sure why it is still showing "Webdriver has no attribute chrome"
The above screenshot attached. Shows no module chrome() under webdriver
Any help would be appreciated.
Solution 1:[1]
from selenium import webdriver
driver = webdriver.Chrome()
This is the correct way how to write that code, also if u want to use firefox or something else then change chrome to firefox ... also read 1st a documentation and look for some examples, then put it here if u find nothing
Also use pip install selenium !
Solution 2:[2]
You can delete the file you recently created. I am facing same issue when i come to this thread and nothing worked for me. I just deleted my recent file and everything works fine :-)
Before creating new python file selenium work fine. it start showing this error when i create new python file in same folder. When i delete the file , everything work fine as before.
Solution 3:[3]
you should write it like this : browser = webdriver.Chrome(executable_path=r"chromedriver.exe") and please make sure that you have Google Chrome installed on your system.
Solution 4:[4]
Try using following command instead
driver = webdriver.chrome.webdriver.WebDriver(executable_path='E:\Selenium\chromedriver_win32\chromedriver.exe')
Reference: Official document https://seleniumhq.github.io/selenium/docs/api/py/webdriver_chrome/selenium.webdriver.chrome.webdriver.html#selenium.webdriver.chrome.webdriver.WebDriver
Solution 5:[5]
first check google chrome version of your system by using this in URL chrome://version/
then download chrome driver from below mention website according to chrome version https://chromedriver.chromium.org/downloads
then type this in pycharm or sublime text
import selenium
from selenium import webdriver
driver = webdriver.chrome.webdriver.WebDriver(executable_path='C:/drivers/chromedriver_win32 (1)/chromedriver.exe')
driver.get("http://www.python.org")
and RUN, surely it works
Solution 6:[6]
Windows 7: Pycharm IDE version 2018.1.2 Navigate to
Project Name->venv
Open pyenv.cfg
Change
include-system-site-packages = false
to
include-system-site-packages = true
Solution 7:[7]
please check your filename, it is not be special name. for example selectors.py
Solution 8:[8]
use this and then hit invoke
from selenium import webdriver driver = webdriver.Chrome(executable_path=yourpath\chromedriver.exe")
Solution 9:[9]
Well what you can do is to consider this official page selenium
Three Ways to Use Drivers...
The first way works well. For this you have to install webdrivermanager
pip install webdriver-manager
and then
# selenium 4
from selenium import webdriver
from selenium.webdriver.chrome.service import Service
from webdriver_manager.chrome import ChromeDriverManager
driver = webdriver.Chrome(service=Service(ChromeDriverManager().install()))
Solution 10:[10]
I had the same problem and we solved it!! I installed the newest version of python which is 3.9. I ran it and it yelled at me for selenium. So I went into command prompt and did :
pip install selenium
It installed selenium. I ran it, and it worked.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
