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,运行,通过。

  • 相关阅读:
    angular9的学习(十)
    本周学习总结
    本周学习总结
    angular9的学习(九)
    本周学习总结
    Web地图呈现原理
    小程序Canvas性能优化实战
    地图SDK全新版本v4.3.0上线
    硬核干货来了!手把手教你实现热力图!
    地图SDK全面升级 – 数十项新功能及优化等你来体验
  • 原文地址:https://www.cnblogs.com/insist8089/p/9212710.html
Copyright © 2011-2022 走看看