zoukankan      html  css  js  c++  java
  • 报错: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,运行,通过。

  • 相关阅读:
    c++ mvc timer的应用
    table 在网页无法顶到头部问题
    vs2008 C++ 没有找到MSVCR90D.dll 问题
    FrametSet中各frame,iframe之间dom的访问
    关于VC中的Timer
    Vc2008中如何为视图类添加消息响应
    C++ map在MFC中的应用
    解决iframe 右边有空白的问题
    poj1125 Stockbroker Grapevine *
    poj1062 昂贵的聘礼 **
  • 原文地址:https://www.cnblogs.com/insist8089/p/9212710.html
Copyright © 2011-2022 走看看