Python selenium chrome 环境配置
- Python selenium chrome 环境配置
- 一、参考文章:
- 1. 记录一下python easy_install和pip安装地址和方法
- http://heipark.iteye.com/blog/1916758
- 2. selenium + python自动化测试环境搭建
- http://www.cnblogs.com/fnng/archive/2013/05/29/3106515.html
- 3. Python-selenium-Firefox-chrome-IE问题解决方法
- http://blog.csdn.net/lcm_up/article/details/38302143
- 4. ChromeDriver - WebDriver for Chrome Getting started
- https://sites.google.com/a/chromium.org/chromedriver/getting-started
- 二、Windows PowerShell
- 1. 【win】键
- 2. 键入:Windows PowerShell + 【Enter】键
- 三、Python setuptools 18.4 安装:
- 1. download:https://pypi.python.org/pypi/setuptools
- 2. 跳到ez_setup.py所在的目录
- 3. python .\ez_setup.py
- 四、Python pip 7.1.2 安装:
- 1. download:https://pypi.python.org/pypi/pip#downloads
- 2. 跳到解压出来的目录下的setup.py所在的目录
- 3. python setup.py install
- 五、Python selenium 2.48.0 安装:
- 1. download:https://pypi.python.org/pypi/selenium
- 2. 跳到解压出来的目录下的setup.py所在的目录
- 3. python setup.py install
- 六、chrome driver
- 1. download:http://chromedriver.storage.googleapis.com/index.html?path=2.20/
- 2. 解压拷贝文件到:D:\python2_7\chromedriver_win32\chromedriver.exe
- 3. 创建一个chrome浏览器实例:
- driver = webdriver.Chrome('D:\python2_7\chromedriver_win32\chromedriver') ##可以替换为IE(), FireFox()
- 七、Test Demo(请确保能访问Google):
- #!/usr/bin/python
- # -*- coding: utf-8 -*-
- import os
- from selenium import webdriver
- from selenium.common.exceptions import TimeoutException
- from selenium.webdriver.support.ui import WebDriverWait # available since 2.4.0
- import time
- # Create a new instance of the browser driver
- driver = webdriver.Chrome('D:\python2_7\chromedriver_win32\chromedriver') ##可以替换为IE(), FireFox()
- # go to the google home page
- driver.get("http://www.google.com")
- # find the element that's name attribute is q (the google search box)
- inputElement = driver.find_element_by_name("q")
- # type in the search
- inputElement.send_keys("Cheese!")
- # submit the form. (although google automatically searches now without submitting)
- inputElement.submit()
- # the page is ajaxy so the title is originally this:
- print driver.title
- try:
- # we have to wait for the page to refresh, the last thing that seems to be updated is the title
- WebDriverWait(driver, 10).until(lambda driver : driver.title.lower().startswith("cheese!"))
- # You should see "cheese! - Google Search"
- print driver.title
- finally:
- #driver.quit() # 当前使用 driver.quit()会导致如下错误
- # Traceback (most recent call last):
- # File "E:/python/Spider/Spider.py", line 39, in <module>
- # driver.quit()
- # File "D:\python2_7\install\lib\site-packages\selenium-2.48.0-py2.7.egg\selenium\webdriver\chrome\webdriver.py", line 88, in quit
- # self.service.stop()
- # File "D:\python2_7\install\lib\site-packages\selenium-2.48.0-py2.7.egg\selenium\webdriver\chrome\service.py", line 111, in stop
- # url_request.urlopen("http://127.0.0.1:%d/shutdown" % self.port)
- # File "D:\python2_7\install\lib\urllib2.py", line 126, in urlopen
- # return _opener.open(url, data, timeout)
- # File "D:\python2_7\install\lib\urllib2.py", line 397, in open
- # response = meth(req, response)
- # File "D:\python2_7\install\lib\urllib2.py", line 510, in http_response
- # 'http', request, response, code, msg, hdrs)
- # File "D:\python2_7\install\lib\urllib2.py", line 435, in error
- # return self._call_chain(*args)
- # File "D:\python2_7\install\lib\urllib2.py", line 369, in _call_chain
- # result = func(*args)
- # File "D:\python2_7\install\lib\urllib2.py", line 518, in http_error_default
- # raise HTTPError(req.get_full_url(), code, msg, hdrs, fp)
- # urllib2.HTTPError: HTTP Error 404: Not Found
- driver.close()
Python selenium chrome 环境配置的更多相关文章
- python+selenium的环境配置
以前写过关于python和selenium加myeclipse的环境配置,但是myeclipse启动时过于费时,虽然myeclipse有很好的提示功能,但是作为初学者,我还是直接用python的idl ...
- Python——Selenium & Chrome Driver配置
1.CMD下载安装selenium pip install selenium 2.python运行: from selenium import webdriver browser = webdrive ...
- python selenium 开发环境配置
selenium是一个web测试应用框架也可以拿来做爬虫. 1.安装selenium模块 pip install -U selenium 2.安装selenium模块后需要有相应的浏览器驱动 A.使用 ...
- 【Python selenium自动化环境配置】4步搞定ChromeDriver版本选择
很多刚做自动化的小伙伴,会在ChromeDriver版本选择时犯难,看来大家都被坑过,真正掌握独门绝技,都不是难事儿. 看好了主要步骤就4部 1.确定谷歌浏览器版本 2.找到谷歌浏览器版本与Chrom ...
- Docker环境下运行python+selenium+chrome
Docker环境下运行python+selenium+chrome docker运行时占用的资源非常少,而且能将环境进行有效的隔离,可以快速的进行部署,因此可以将docker与selenium结合实现 ...
- Python+Selenium+webdriver环境搭建(windows)以及相关资源下载链接
今天记录一下测试小菜鸟alter在测试入门的一点关于python+Selenium+webdriver环境搭建的经历以及资源分享.欢迎交流学习,批评指正. 一.Python的下载与安装 1.pytho ...
- Selenium Java环境配置
Selenium Java环境配置 上次配置的是C#的环境,今天主要来配置一下Java环境. 首先,对于java环境配置最基础的JDK和JRE 先前我做过配置,这里就不重述了,网上的教程超级多.在基础 ...
- Python selenium chrome打包exe后禁用控制台输出滚动日志
Python selenium chrome打包exe后,在运行的过程中,如果遇到需要input()输入时,会发现被不断滚动刷新的日志把命令行输入快速顶掉了,通过查阅资料不断实践,发现以下方法有效: ...
- web端自动化——Selenium Server环境配置
Selenium Server环境配置 下面下载.配置并运行Selenium Server. ① 下载 Selenium Server. 下载地址为:https://pypi.python.or ...
随机推荐
- FM/AM收音机原理
收音机这东西很早就开始用了,但一直都没有了解过它的原理,听说是很简单.下面记录一些笔记. 1. 基本概念 收音机是一种小型的无线电接收机,主要用于接受无线电广播节目,收听无线电发射台.首先说一下收音机 ...
- 【运维技术】Zookeeper单机以及集群搭建教程
Zookeeper单机以及集群搭建教程 单机搭建 单机安装以及启动 安装zookeeper的前提是必须有java环境 # 选择目录进行下载安装 cd /app # 下载zk,可以去官方网站下载,自己上 ...
- 20155201 2016-2017-2 《Java程序设计》第三周学习总结
20155201 2016-2017-2 <Java程序设计>第三周学习总结 教材学习内容总结 - 第四章要点: 4.1类与对象 类定义时使用class关键词,基本模式为 class na ...
- 20145326 《Java程序设计》第6周学习总结
20145326 <Java程序设计>第6周学习总结 教材学习内容总结 第十章 一.使用InputStream与OutputStream 1.串流设计的概念 想活用输入/输出API,一定要 ...
- phpstorm2016.1 添加对Drupal的编程支持
一.前言 phpstorm作为目前对drupal支持最好的开发工具之一,是drupal模块开发的首选工具.今天我就来谈谈最新的phpstorm如何添加对drupal模块的支持. 相关环境:操作系统ub ...
- 嵌入式 Linux 如何操作 GPIO ?
作者:刘凯链接:https://www.zhihu.com/question/19704852/answer/19760467来源:知乎著作权归作者所有.商业转载请联系作者获得授权,非商业转载请注明出 ...
- pip安装tensorflow-gpu好慢怎么办
答:为pip换源,如换成清华源 cat ~/.pip/pip.conf(没有此文件,自行创建即可,然后加入以下内容) [global]index-url = https://pypi.tuna.tsi ...
- 【MVC - 参数原理】详解SpringMVC中Controller的方法中参数的工作原理[附带源码分析]
前言 SpringMVC是目前主流的Web MVC框架之一. 如果有同学对它不熟悉,那么请参考它的入门blog:http://www.cnblogs.com/fangjian0423/p/spring ...
- No module named import_export.admin
解决方法: pip install django-import-export
- POJ 1159 Palindrome(最长公共子序列)
http://poj.org/problem?id=1159 题意: 给出一个字符串,计算最少要插入多少个字符可以使得该串变为回文串. 思路: 计算出最长公共子序列,再用原长-LCS=所要添加的字符数 ...