zoukankan      html  css  js  c++  java
  • mac 系统安装selenium注意事项

    mac最新系统:OS X EI Captian

    python: 本机自带的python2.7。 (本来想升级3.5,觉得太复杂,放弃了)

    pip: https://pypi.python.org/pypi/pip    下载版本pip 8.1.2.tar.gz (下载,解压,cd到目录,执行命令:sudo python setup.py install)

    selenium :sudo easy_install selenium     (联网安装,默认最新版,所以不用担心没有输入版本号)

    pycharm:版本2016.1   注册码如下

    http://idea.lanyus.com/    获取最新注册码 

    注意事项:

    1、使用python 的pip安装selenium报错

    chenchengdeMacBook-Pro:~ NichoC$ sudo pip install -U selenium

    Password:

    The directory '/Users/NichoC/Library/Caches/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.

    The directory '/Users/NichoC/Library/Caches/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.

    Requirement already up-to-date: selenium in /Library/Python/2.7/site-packages

    chenchengdeMacBook-Pro:~ NichoC$ 

    好像是权限不足,找了好多帖子没解决,放弃,后来换了命令sudo easy_install selenium 安装成功。

    2、本机没有安装firefox ,尝试其他浏览器的webdriver,都失败,最后下载安装firefox,不用配置path和路径直接完成

    推荐一个firefox 历史版本下载地址,selenium对最新版本的firefox 支持不好,建议下载历史版本:

    http://ftp.mozilla.org/pub/firefox/releases/        (选择版本号,选择平台MAC,选择语言zc-CN)

    3、测试selenium安装是否成功的用例(firefox弹出打开百度首页然后关闭)

    from selenium import webdriver
    browser = webdriver.Firefox()
    browser.get("http://www.baidu.com")
    browser.quit()


  • 相关阅读:
    看完让你彻底搞懂Websocket原理
    将map中的value赋值给list,list改变为什么会引起map也变呢?
    eclipse创建maven 3.1版本maven项目
    eclipse 集成mybatis-generator 生成mybatis 文件
    IDEA错误:Cannot start compilation: the output path is not specified for module "XXX".
    IDEA内存优化(秒开的快感!!)
    实体类反向生成数据库表SQL
    基于idea新建maven项目并发布tomcat
    Netty概念之 Future 和 Promise
    Java检测死锁之ThreadMXBean
  • 原文地址:https://www.cnblogs.com/nichoc/p/5543654.html
Copyright © 2011-2022 走看看