Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AttributeError Issue: module 'selenium.webdriver' has no attribute 'Chrome'

there is no chrome module present under webdriverI 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.

like image 830
Stk Avatar asked Jul 21 '26 16:07

Stk


2 Answers

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 !

like image 91
StyleZ_but_alt Avatar answered Jul 23 '26 07:07

StyleZ_but_alt


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.

like image 42
Sanaa Ullah Avatar answered Jul 23 '26 07:07

Sanaa Ullah



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!