AttributeError: module 'selenium.webdriver' has no attribute 'webdriver' - python

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 webdriver.py

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

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()

Related

AttributeError: module 'selenium.webdriver.chrome.webdriver' has no attribute 'Chrome' error using Selenium ChromeDriver and Chrome

Can anyone suggest about it? I have tried reinstall of selenium pip, still the same. Below is the code and error in Pycharm:
from selenium import webdriver
from selenium.webdriver.chrome import webdriver
from selenium.webdriver.chrome.service import Service
# //Chrome driver
service_obj=Service("D:\\PYTHONWITHSELENIUMTESTING\\Chromedriver\\chromedriver.exe")
#driver = webdriver.Chrome(Service=service_obj)
#driver.get("https://www.youtube.com/")
driver = webdriver.Chrome(executable_path = service_obj)
Error:
C:\Users\scdee\AppData\Local\Programs\Python\Python310\python.exe D:/PYTHONWITHSELENIUMTESTING/PythonPrograms/ChromeTrigger.py
Traceback (most recent call last):
File "D:\PYTHONWITHSELENIUMTESTING\PythonPrograms\ChromeTrigger.py", line 11, in <module>
driver = webdriver.Chrome(executable_path = service_obj)
AttributeError: module 'selenium.webdriver.chrome.webdriver' has no attribute 'Chrome'
Process finished with exit code 1
Error snapshot:
change your chrome driver path like this
service_obj="D:/PYTHONWITHSELENIUMTESTING/Chromedriver/chromedriver.exe"
You need to pass the same Service() object which you have created within Chrome() as follows:
service_obj=Service("D:\\PYTHONWITHSELENIUMTESTING\\Chromedriver\\chromedriver.exe")
driver = webdriver.Chrome(service=service_obj)
driver.get("https://www.youtube.com/")

'WebDriver' object has no attribute 'Chrome'

I'm new here and new to coding. I'm trying to run:
wd = wd.Chrome()
wd.implicity_wait(10)
But I keep getting an error that reads
AttributeError: 'WebDriver' object has no attribute 'Chrome'
Here's a picture of what I have so far
Can anybody help me out.
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")
Or
from selenium import webdriver
driver = webdriver.Chrome()
perhaps you wanna do this instead :
from selenium import webdriver
driver = webdriver.Chrome(r'C:\\Users\\Automation\\chromedriver.exe')
or in case you want to initiate with ChromeOptions, you can do it like this
from selenium import webdriver
options = webdriver.ChromeOptions()
driver = webdriver.Chrome(r'C:\\Users\\Automation\\chromedriver.exe', options = options)
You should give your chromedriver.exe file location in place of C:\\Users\\Automation\\chromedriver.exe

TypeError: 'module' object is not callable while opening chrome browser using selenium webdriver

I am trying to open and close a chrome browser using python-selenium.webdriver, but i am getting below error, i am using ubuntu system.
I have downloaded chrome browser driver and provided same path in code
I am getting below error:
File "/home/rupesh/PycharmProjects/Selenium/selenium package/test1.py", line 3, in
driver = chrome ('/home/rupesh/Downloads/chromedriver_linux64/chromedriver')
TypeError: 'module' object is not callable
code is below :
from selenium.webdriver import chrome
driver = chrome ('/home/rupesh/Downloads/chromedriver_linux64/chromedriver')
driver.close()
The driver object begins with an uppercase Chrome :
from selenium.webdriver import Chrome
driver = Chrome('/home/rupesh/Downloads/chromedriver_linux64/chromedriver')
Root cause- 1) The driver object begins was started with lowercase "chrome"
2) chrome web driver and chrome versions were different

TypeError: 'module' object is not callable error using Selenium ChromeDriver Chrome with Python

I am creating a google form spam bot so that I can get random submission for my homework assignement;however I hav the eror: TabError: inconsistent use of tabs and spaces in indentation
note I am on Pycharm
and I am using the code in this link:(https://github.com/endeneer1/google-form-autofilling-spam-bot-using-Python-multiple-choice-questions/blob/master/google-form-spambot.py)`
I have looked on different threads but I can't find the answer.
import time
import random
from selenium import webdriver
chromedriver = r"C:\\Users\\LORD\\Desktop\\max spam shit\\chromedriver"
driver = webdriver.chrome(chromedriver)
link = 'https://docs.google.com/forms/d/1mUG-
vnGYMCyVP17chfx2bzszKkb4NHDLajrOMFbgi1I/viewform?
edit_requested=true&fbzx=1367418473376240610'
driver.get(link)
normally the bot opens a google page brings up the submission,fills it in then ,submits it rince and reapeat but It just comes with the error :C:\python\python.exe "C:/mblock python shit/gg.py"
Traceback (most recent call last):
File "C:/mblock python shit/gg.py", line 6, in
driver = webdriver.chrome(chromedriver)
TypeError: 'module' object is not callable
In the line driver = webdriver.chrome(chromedriver) chrome is a module. You should call webdriver.Chrome(chromedriver) where Chrome is a class.
This error message...
TypeError: 'module' object is not callable
...implies that the call to ChromeDriver to initiate/spawn a new WebBrowser i.e. Chrome Browser session was not valid.
Solution
You need to replace the lower-case c as in chrome with upper-case C i.e. replace:
driver = webdriver.chrome(chromedriver)
With:
driver = webdriver.Chrome(chromedriver)

Getting error "AttributeError: 'module' object has no attribute 'Chrome'"

I have written my first python script using selenium. I am using pycharm.
I got an error of chrome driver even I have downloaded chrome driver & set path in my script.
from selenium import webdriver
driver = webdriver.Chrome ("C:\chromedriver\chromedriver.exe")
driver.set_page_load_timeout(30)
driver.get("http://www.facebook.com")
driver.maximazie_window()
driver.implicitly_wait(20)
driver.get_screenshot_as_file("Facebook.png")
driver.quit()
I got an error like this
C:\Users\SapanaD\PycharmProjects\seleniumscripts\venv\Scripts\python.exe C:/Users/SapanaD/PycharmProjects/seleniumscripts/facebookpackage/Myfirstscript.py
Traceback (most recent call last):
File "C:/Users/SapanaD/PycharmProjects/seleniumscripts/facebookpackage/Myfirstscript.py",
line 4, in
driver = webdriver.Chrome ("C:\chromedriver\chromedriver.exe")
AttributeError: 'module' object has no attribute 'Chrome'
Process finished with exit code 1
I have tried double backslace"\" & install chrome driver also. I have research so many things but I cannot get proper solution.
Copy chromedriver.exe file in C:\Python27 location and after that try like as below and also if import statement is wrong then above exception will get
from selenium import webdriver
# create a new Firefox session
driver = webdriver.Chrome()
driver.implicitly_wait(30)
driver.maximize_window()
# Navigate to the application home page
driver.get("http://www.google.com")
# close the browser window
driver.quit() ```

Categories

Resources