chromedriver.quit and chromedriver.close doesn't work

Viewed 1365

I am on an interactive prompt and I have excecute the essential commands, the minimum indispensable ones:

from selenium import webdriver
options = webdriver.ChromeOptions()
options.binary_location = '/usr/bin/google-chrome'
driver = webdriver.Chrome(executable_path='/usr/bin/chromedriver', options=options) #Chrome has opened
driver.quit #doesn't work
driver.close #doesn't work

The error messages are the following:

<bound method WebDriver.quit of <selenium.webdriver.chrome.webdriver.WebDriver (session="34e01ec73c9522d792c5b0e13797c8d4")>>

<bound method WebDriver.close of <selenium.webdriver.chrome.webdriver.WebDriver (session="34e01ec73c9522d792c5b0e13797c8d4")>>

Why?

Ubuntu 20.04 LTS 64-bit Desktop
Python 3.8.5 (default, Jan 27 2021, 15:41:15) [GCC 9.3.0] on linux
selenium 3.141.0 (installed from pip3 21.0.1)
ChromeDriver 89.0.4389.23
Google Chrome 89.0.4389.90

So everything to the latest version.

3 Answers

driver.quit() and driver.close() are methods. Call them as methods.

There's already good result above that you should use quit(), not quit, and close(), not close,

as well try to use Options() instead of ChromeOptions()

so, the code looks like that:

from selenium import webdriver
from selenium.webdriver.chrome.options import Options

options = Options()
options.binary_location = '/usr/bin/google-chrome'
driver = webdriver.Chrome(executable_path='/usr/bin/chromedriver', options=options) #Chrome has opened
driver.quit()

Looks like you are just missing ()
So just use driver.quit() and it will work correctly.

Related