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()


  • 相关阅读:
    bzoj1014: [JSOI2008]火星人prefix
    bzoj1934: [Shoi2007]Vote 善意的投票&&bzoj2768:[JLOI2010]冠军调查
    bzoj2705: [SDOI2012]Longge的问题
    bzoj4653: [Noi2016]区间
    bzoj2456: mode
    bzoj5018: [Snoi2017]英雄联盟
    关于树论【左偏树】
    caioj1522: [NOIP提高组2005]过河
    caioj1421&&hdu2167: [视频]【状态压缩】选数
    Linux下全局安装composer方法
  • 原文地址:https://www.cnblogs.com/nichoc/p/5543654.html
Copyright © 2011-2022 走看看