seleniu阶段入门第一篇之安装与环境配置
1.下载python:32位系统:https://www.python.org/ftp/python/3.6.1/python-3.6.1-webinstall.exe
64位系统:https://www.python.org/ftp/python/3.6.1/python-3.6.1-amd64.exe
环境变量配置:单击我的电脑-右键 选择属性-选择安全-选择配置环境-找到path:C:\Python34;C:\Python34\Scripts(python34是版本,
自己安装什么版本到对应目录复制对应路径配置环境)
2.下载火狐浏览器4.2版本:
http://ftp-idc.pconline.com.cn/0dae69cf971819827d7e8f0ae21acca3/pub/download/201010/Firefox_Setup_43.0.4_x86.exe
3.安装selenium 操作步骤:电脑-运行-cmd-python(提示python版本)-命令:pip install selenium==2.53.6 敲回车
4.启动Phon GUI
5.操作步骤:
实例一:打开百度搜索“51testing”
>>> from selenium import webdriver
>>> b = webdriver.Firefox()
>>> b.implicitly_wait(10)
>>> b.get('http://www.baidu.com')
>>> elem = b.find_element_by_id('kw')
>>> elem.send_keys('51testing')
>>> elem = b.find_element_by_id('su')
>>> elem.click()
>>> b.close()
实例二:进入51testing主页
find_element_by_partial_link_text('')
>>> fromselenium import webdriver
>>> b = webdriver.Firefox()
>>> b.implicitly_wait(10)
>>> b.get('http://www.51testing.com')
>>> ele = b.find_element_by_partial_link_text('工具')
>>> ele.click()
>>> ele = b.find_element_by_partial_link_text('测试天地')
>>> ele.click()
>>> b.back()
>>> b.back()
>>> b.maxize_window()
>>> ele = b.find_element_by_partial_link_text('管理')
>>> ele.click()
赞,支持 支持分享 支持分享!
页:
[1]