报错:AttributeError: module 'selenium.webdriver' has no attribute 'Chrome'
脚本开头部分:
# coding = utf-8
import time
from selenium import webdriver
option = webdriver.ChromeOptions()
option.add_argument('disable-infobars')
driver = webdriver.Chrome(chrome_options = option)
driver.maximize_window()
driver.get("https://www.baidu.com")
time.sleep(2)
……
……
问题描述:在sublime中能够正常执行,在PyCharm中则一直提示:AttributeError: module 'selenium.webdriver' has no attribute XXXX
解决方法:
尝试:考虑到在sublime中执行的脚本所在路径,有 chromedriver; 然后把chromedriver copy 到PyCharm中的脚本所在路径,并在PyCharm中安装i,安装完成后,运行,提示:
raise RuntimeError('This package supports only Linux, MacOSX or Windows platforms')
RuntimeError: This package supports only Linux, MacOSX or Windows platforms
失败;
尝试:给Chrome浏览器配置 chromedriver,同时改了脚本名称,注释其中几行,运行脚本,失败
import time
# import chromedriver as chromedriver
from selenium import webdriver
class BaiduSearch(object):
# option = webdriver.ChromeOptions()
# option.add_argument('disable-infobars')
driver = webdriver.Chrome()
driver.maximize_window()
driver.implicitly_wait(10)
提示: AttributeError: module 'selenium.webdriver' has no attribute 'Chrome'
尝试: 添加外部库,在pycharm-setting-project Interpreter中手动添加了selenium。添加成功后,代码没有改动,再重启pycharm,运行,通过。