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

  • 相关阅读:
    DataInputStream与DataOutputStream类
    BluetoothChat例程分析
    Android中的Handler机制
    我的IT之路2012(二)
    菜鸟学Java(二)——Filter解决中文乱码问题
    菜鸟学Java(一)——Ajax异步检查用户名是否存在
    FTP文件操作之创建目录
    FTP文件操作之获取文件列表
    使用powershell计算性能计数器的均值
    收缩临时库 shrink tempdb
  • 原文地址:https://www.cnblogs.com/insist8089/p/9212710.html
Copyright © 2011-2022 走看看