美文网首页selenium+python
mac基于 python3.6+selenium3.6.0自动化

mac基于 python3.6+selenium3.6.0自动化

作者: 草中人 | 来源:发表于2017-10-12 15:34 被阅读0次

    mac系统下操作

    1,安装python3.6

    在终端中,安装最新的python(当前最新是python3.6)

    brew install python3

    2.更改调用最新python

    默认的python调用的是2.7版本,需要更改当前安装版本

    安装python3.6时默认路径为

    /usr/local/Cellar/python3

    在~/.bash_profile里添加

    alias python="/usr/local/Cellar/python3/3.6.2/bin/python3.6"

    source ~/.bash_profile

    退出当前终端   #必须退出重新 打开一个终端,要不安装selenium时报错

    3.安装selenium

    python3.6中已自带pip,在新打开的终端中直接使用以下命令即可安装最新的selenium

    python -m pip install -U(大写) selenium

    4.chromedriver配置

    在以下地址中下载2.29版本(这个得谢谢网友提供的链接)

    链接:http://pan.baidu.com/s/1miBUTXA  密码:a6zs

    将下载的解压后拷贝至/usr/local/bin/目录下,写一个脚本验证是否正确调用。

    from selenium import webdriver

    driver = webdriver.Chrome()

    driver.get("http://www.baidu.com")

    driver.find_element_by_id('kw').send_keys('selenium')

    driver.find_element_by_id('su').click()

    #driver.quit()

    5.在新建项目时,需要重新导入selenium

    相关文章

      网友评论

        本文标题:mac基于 python3.6+selenium3.6.0自动化

        本文链接:https://www.haomeiwen.com/subject/wlmnyxtx.html