我是在一个交互式提示符,我已经超出了基本的命令,最基本的不可缺少的命令:
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位桌面
Python 3.8.5 (默认,2021年1月27日,15:41:15) GCC 9.3.0在linux上
selenium 3.141.0 (安装自pip3 21.0.1)
ChromeDriver 89.0.4389.23
谷歌Chrome 89.0.4389.90
所以一切都是最新版本的。
发布于 2021-03-29 19:26:40
上面已经有了很好的结果,您应该使用quit()、not 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()发布于 2021-03-29 19:24:33
driver.quit()和driver.close()是两种方法。把它们称为方法。
发布于 2021-03-29 19:18:14
看来你只是错过了()
所以,只要使用driver.quit(),它就能正常工作。
https://stackoverflow.com/questions/66846321
复制相似问题