selenium+python(环境配置)
上一篇 /
下一篇 2016-09-18 17:25:23
/ 个人分类:selenium+python
在配置之前我们需要下载以下工具:
1、pip管理工具,可以通过官网下载:https://pypi.python.org/pypi/pip
2、下载Pycharm
3、下载chrome、Firefox
安装:
1、安装pip,解压出来之后使用终端运行
sudo python setup.py install(要在对于的目录中运行)
2、执行sudo easy_install pip
3、联网执行sudo pip install -U selenium(下载并安装selenium的插件)
4、安装Pycharm,直接执行其安装包
使用以下数据可验证配置环境是否正常:
fromseleniumimportwebdriver
browser = webdriver.Firefox()
inporthttp =raw_input("please input one the one the add.")
browser.get(inporthttp)
print("this steep")
browser.find_element_by_id("kw").send_keys("selenium")
print("this steep")
browser.find_element_by_id("su").click()
print("this steep")
browser.quit()
chrome配置:
下载chrome driver
解压完成以后,放到自己固有的目录下面(任意目录都可以)
配置环境变量:
vim ~/.bash_profile
export PATH=$PATH:/Users/samuel.c.ouyang/SDK(我已将chromedriver放到该目录下面)
注销用户
运行如下数据验证配置环境是否成功:
fromseleniumimportwebdriver
browser = webdriver.Chrome()
inporthttp =raw_input("please input one the one the add.")
browser.get(inporthttp)
print("this steep")
browser.find_element_by_id("kw").send_keys("selenium")
print("this steep")
browser.find_element_by_id("su").click()
print("this steep")
browser.quit()
相关阅读:
- Python安装模块出错(ImportError: No module named setuptools)解决方法 (xuquan, 2016-8-26)
- Python非常详细编程笔记 (zaza9084, 2016-8-29)
- python基础入门 (launcelot, 2016-8-29)
- python进阶教程 (launcelot, 2016-8-29)
- python深入教程 (launcelot, 2016-8-29)
- 基于Python的程序设计思想与方法 (zaza9084, 2016-9-01)
- Mock在Python单元测试中的使用 (zaza9084, 2016-9-02)
- python跨路径调用的三种方法 (lgrytdwtla, 2016-9-09)
- python学习-day1-2016.9.12 (测试大大, 2016-9-12)
- Windows下Python的环境安装 (彩蝶不哭, 2016-9-17)
收藏
举报
TAG:
Python
python