Python chromedriver.quit和chromedriver.close不';行不通

Python chromedriver.quit和chromedriver.close不';行不通,python,selenium,selenium-chromedriver,python-3.8,ubuntu-20.04,Python,Selenium,Selenium Chromedriver,Python 3.8,Ubuntu 20.04,我在一个交互式提示上,我有一些基本的命令,这些命令是最基本的: 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 open

我在一个交互式提示上,我有一些基本的命令,这些命令是最基本的:

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
错误消息如下所示:

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

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

为什么?

Ubuntu 20.04 LTS 64位桌面
linux上的Python 3.8.5(默认值,2021年1月27日,15:41:15)[GCC 9.3.0] selenium 3.141.0(从pip3 21.0.1安装)
ChromeDriver 89.0.4389.23
谷歌浏览器89.0.4389.90


所以所有内容都是最新版本。

看起来您只是缺少了
()


所以只要使用
driver.quit()
,它就会正常工作。

看起来您只是缺少
()


所以只要使用
driver.quit()
,它就会正常工作。

driver.quit()
driver.close()
都是方法。将它们作为方法调用。

driver.quit()
driver.close()
是方法。将它们作为方法调用。

上面已经有一个很好的结果,您应该使用quit(),而不是quit,以及close(),而不是close

还可以尝试使用Options()而不是ChromeOptions()

代码如下所示:

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

上面已经有一个很好的结果,您应该使用quit(),not quit,和close(),not close

还可以尝试使用Options()而不是ChromeOptions()

代码如下所示:

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

.quit()和.close()错过了()。哦,对不起,我真是个傻瓜。quit()和.close()错过了()。哦,对不起,我真是个傻瓜。