博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
python
阅读量:4299 次
发布时间:2019-05-27

本文共 1033 字,大约阅读时间需要 3 分钟。

网上查资料无意中看见这个东西,觉得挺好玩,原来是用来做web测试的。于是安装了个玩玩python的官网中居然有这个介绍:http://pypi.python.org/pypi/selenium

简单介绍下虚拟环境(为了方便安装各种包,又不会影响系统包)

建立虚拟环境

virtualenv example  (创建)

启用

source example/bin/activate

pip install selenium (这样就装好了)

离开

deactivate

 测试例子:

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公司的一个集成测试的强大工具。

转载地址:http://savws.baihongyu.com/

你可能感兴趣的文章
PCB反推理念
查看>>
京东技术架构(一)构建亿级前端读服务
查看>>
git 提示:error: unable to rewind rpc post data - try increasing http.postBuffer
查看>>
php 解决json_encode中文UNICODE转码问题
查看>>
LNMP 安装 thinkcmf提示404not found
查看>>
PHP empty、isset、innull的区别
查看>>
apache+nginx 实现动静分离
查看>>
通过Navicat远程连接MySQL配置
查看>>
phpstorm开发工具的设置用法
查看>>
Linux 系统挂载数据盘
查看>>
Git基础(三)--常见错误及解决方案
查看>>
Git(四) - 分支管理
查看>>
PHP Curl发送数据
查看>>
HTTP协议
查看>>
HTTPS
查看>>
git add . git add -u git add -A区别
查看>>
apache下虚拟域名配置
查看>>
session和cookie区别与联系
查看>>
PHP 实现笛卡尔积
查看>>
Laravel中的$loop
查看>>