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


  • 相关阅读:
    eclipse用法和技巧
    eclipse常用快捷键集锦
    移动端input的虚拟键盘影响布局
    使用github page + Hexo搭建个人博客折腾记
    javascript数组的排序(sort,冒泡)
    响应式布局与媒体查询
    css属性选择器诸如Class^=,Class*= ,Class$=释义
    怎么预览 GitHub 项目里的网页或 Demo
    常见浏览器的兼容问题(一)
    jQuery常用交互效果
  • 原文地址:https://www.cnblogs.com/nichoc/p/5543654.html
Copyright © 2011-2022 走看看