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() ```
Related
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/")
Whenever I type the following code, it throws an error and I am not able to connect to my driver window:
driver = webdriver.Chrome("chromedriver.exe")
Error message: InvalidArgumentException
Download chromedriver.exe
Set executable_path to the location where your chromedriver is located.
replace driver = webdriver.Chrome("chromedriver.exe") to
driver = webdriver.Chrome()
Chekc It will work or not.
for more info check below link
https://stackoverflow.com/a/42478941/6559285
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()
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
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)