python中使用selenium
来源:互联网 发布:加工中心打孔编程格式 编辑:程序博客网 时间:2024/05/18 18:47
网上查资料无意中看见这个东西,觉得挺好玩,原来是用来做web测试的。于是安装了个玩玩python的官网中居然有这个介绍:http://pypi.python.org/pypi/selenium
下载python版本的python包,放入到python的lib下面,然后下载selenium的jar。
启动使用java -jar selenium-server-standalone-2.0b3.jar
测试例子:
from selenium import webdriverfrom selenium.common.exceptions import NoSuchElementExceptionfrom selenium.webdriver.common.keys import Keysimport timebrowser = webdriver.Firefox() # Get local session of firefoxbrowser.get("http://www.yahoo.com") # Load pageassert "Yahoo!" in browser.titleelem = browser.find_element_by_name("p") # Find the query boxelem.send_keys("seleniumhq" + Keys.RETURN)time.sleep(0.2) # Let the page load, will be added to the APItry: browser.find_element_by_xpath("//a[contains(@href,'http://seleniumhq.org')]")except NoSuchElementException: assert 0, "can't find seleniumhq"browser.close()
运行的结果是打开雅虎浏览器搜素seleniuhq,然后查找http://seleniumhq.org
http://www.ltesting.net/ceshi/open/kygncsgj/selenium/
再补充下介绍,要下班了,明天慢慢看
Selenium (SeleniumHQ) 是 thoughtworks公司的一个集成测试的强大工具。
一、Selenium 的版本
Selenium 现在存在2个版本,一个叫 selenium-core, 一个叫selenium-rc 。
selenium-core 是使用HTML的方式来编写测试脚本,你也可以使用 Selenium-IDE来录制脚本,但是目前Selenium-IDE只有 FireFox 版本。
Selenium-RC 是 selenium-remote control 缩写,是使用具体的语言来编写测试类。
selenium-rc 支持的语言非常多,这里我们着重关注java的方式。这里讲的也主要是 selenium-rc,因为个人还是喜欢这种方式.
下图是Selenium IDE的运行界面截图:
- python中使用selenium
- python中selenium升级
- python selenium使用demo
- Python使用selenium出错
- Python Selenium使用IE
- Python爬虫Selenium使用
- python+selenium使用
- Python selenium使用总结
- 使用python+selenium自动上传exel表中bug
- Python中使用 Selenium 实现网页截图实例
- 如何在Python-Selenium中使用PhantomJS加载cookies
- python中使用selenium的一些注意点
- python中使用selenium的一些注意点2
- python使用selenium爬取InCites中journal数据
- python+selenium在Pycharm中使用alert报错问题解决
- Selenium中使用XPath
- selenium python中引用js
- python selenium expected_conditions使用实例
- mysql中ip地址转换
- man page分类
- 深入理解C语言
- perl 中hash表的清空操作
- Navicat 8 中文乱码问题
- python中使用selenium
- java的List、Set等分析
- Flex 加载进度条
- AwesomePlayer 源代码分析
- ORACLE 多表删除
- ADW_Launcher源码学习地址
- Oracle BIEE 11.1.1.5.0 问题汇总
- Omnet++4.0安装过程
- 关于INDEXTOSTATEIMAGEMASK