'WebDriver' object has no attribute 'Chrome' - python

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

Related

Error in python selenium 3 Edge web driver

I am a complete beginner to selenium and I wrote my first program just to connect to Google.
from selenium import webdriver
path = "C:\\Users\\Home\\Documents\\Python37-32\\Scripts\\Code\\msedgedriver.exe"
driver = webdriver.Edge(path)
driver.get("https://google.com")
print(driver.title)"
My web driver version is 88.0.705.50 (Official build) (64-bit)
I use selenium 3 and I am getting this error while running the code. Also it is opening "data:," for a few seconds then opening Google. Lastly the browser doesn't stay open.
Declare path on a separate line from the import statement
Use raw string in path or double escapes
Code:
from selenium import webdriver
path = r"C:\Users\Home\Documents\Python37-32\Scripts\Code\msedgedriver.exe"
driver = webdriver.Edge(path)
driver.get("https://google.com")
print(driver.title)
What error do you get? It's the default behavior that the browser opens with data:,, then it will direct to the website you want. The browser doesn't stay opened may because the error breaks it.
You can refer to the following steps to automate Edge in python selenium:
Make sure the WebDriver version is the same as the Edge version.
Install the MS Edge Selenium tools using command below:
pip install msedge-selenium-tools selenium==3.141
Sample code:
from msedge.selenium_tools import Edge, EdgeOptions
options = EdgeOptions()
options.use_chromium = True
driver = Edge(executable_path = r"C:\Users\Home\Documents\Python37-32\Scripts\Code\msedgedriver.exe", options = options)
driver.get("https://google.com")
print(driver.title)

Python, Selenium. Successfully initialized webdriver but couldn't open a web page because "there is no attribute called get"

I imported selenium
from selenium import webdriver
Initialized chrome webdriver as browser
browser = webdriver.chrome
But when I try to open a new tab I get a error
Error
Help?
you haven't created the browser object use below code:
from selenium import webdriver
driver =webdriver.Chrome(r"C:\Users\Downloads\chromedriver.exe")
driver.get("https://www.google.com")
you just referenced the method you should trigger and call it by passing arguments

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

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

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

Python Selenium show geckodriver version

How can I find out which version of geckodriver I use?
from selenium import webdriver
driver = webdriver.Firefox()
Not sure if the new one is used or the old one when I use:
sys.path.append(self.driver_dir)
Thanks in advance
http://selenium-python.readthedocs.io/api.html
You can get capabilities of driver by below code:
from selenium import webdriver
driver = webdriver.Firefox()
print driver.capabilities
It will print driver related info in dictionary form, which would also have info about driver version.

Categories

Resources