zoukankan      html  css  js  c++  java
  • Linux环境下搭建python+selenium+webdriver环境

    1.下载并安装python,一般安装linux系统,自带有python,则python不用安装。要下载可以在官网上下载;

    或者使用下面命令安装:

    sudo apt-get install python-virtualenv

    2.下载安装python管理工具包:pip;

    sudo apt-get install python-pip 

    3.安装setuptools:

    sudo apt-get install python-setuptools

    4.下载安装selenium:注意,使用root权限安装,否则会出现安装不上。

    参考selenium官方使用手册:http://selenium-python.readthedocs.org/en/latest/getting-started.html

    pip install -U selenium

    5. 关于Webdriver

    安装的selenium2默认支持的webdriver是Firefox浏览器,如果要使用chrome或IE等其他浏览器则需要下载相关的驱动,如chromedriver或IEdriver;

    下面使用默认的Firefox进行测试:

    from selenium import webdriver
    from selenium.webdriver.common.keys import Keys
    
    driver = webdriver.Firefox()
    driver.get("http://www.python.org")
    assert "Python" in driver.title
    elem = driver.find_element_by_name("q")
    elem.send_keys("pycon")
    elem.send_keys(Keys.RETURN)
    assert "No results found." not in driver.page_source
    driver.close()

    最后会打开python的官方网址。

    chrome浏览器的配置可参考:

    http://blog.likewise.org/2015/01/setting-up-chromedriver-and-the-selenium-webdriver-python-bindings-on-ubuntu-14-dot-04/

  • 相关阅读:
    高情商人士7大说话之道
    使用httpclient提交表单数据加号(+)会被自动替换成空格的坑
    鬼谷子的五条初世潜规则
    模型可视化工具netron
    .deb文件安装应该怎么做
    转caffe scale layer
    转Ubuntu 16.04 创建无线热点
    CNN反向传播更新权值
    tensorflow查看使用的是cpu还是gpu
    yolo进化史之yolov3
  • 原文地址:https://www.cnblogs.com/coffy/p/5416987.html
Copyright © 2011-2022 走看看