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

TAG: Python python

 

评分:0

我来说两句

我的栏目

日历

« 2024-05-07  
   1234
567891011
12131415161718
19202122232425
262728293031 

我的存档

数据统计

  • 访问量: 24663
  • 日志数: 5
  • 建立时间: 2016-09-18
  • 更新时间: 2016-09-21

RSS订阅

Open Toolbar