您的位置:软件测试 > 开源软件测试 > 开源功能测试工具 >
开源自动化测试框架Tellurium
作者:网络转载 发布时间:[ 2014/3/5 10:22:14 ] 推荐标签:自动化测试 测试框架 开源 测试方案

  GoogleSearchModule.groovy是用户界面模块的谷歌搜索,它自化生成Tellurium 所需要的火狐浏览器插件TrUMP.  doGoogleSearch() 和 doImFeelingLucky() 两个方法是增加定期谷歌搜索和谷歌“手气不错”搜索。
public class GoogleSearchModule extends DslContext {
public void defineUi() {
ui.Container(uid: "Google", clocator: [tag: "table"]) {
InputBox(uid: "Input", clocator: [tag: "input", title: "Google Search", name: "q"])
SubmitButton(uid: "Search", clocator: [tag: "input", type: "submit", value: "Google Search", name: "btnG"])
SubmitButton(uid: "ImFeelingLucky", clocator: [tag: "input", type: "submit", value: "I'm Feeling Lucky", name: "btnI"])
}
}
public void doGoogleSearch(String input) {
keyType "Google.Input", input
pause 500
click "Google.Search"
waitForPageToLoad 30000
}
public void doImFeelingLucky(String input) {
type "Google.Input", input
pause 500
click "Google.ImFeelingLucky"
waitForPageToLoad 30000
}
}
  因为Tellurium只支持groovy语言,所以无groovy语言无法直接在Eclipse IDE中运行,需要Eclipse安装对groovy语言支持的插件。
  Groovy-Eclipse 2.5.· 插件下载地址:
  http://www.oschina.net/news/·9279/groovy-eclipse-25·
  当然,你也可以使用IntelliJ IDEA 工具,它同样也运行java语言非常的IDE。 而且IntelliJ IDEA本身是支持groovy语言。
  Tellurium IDE 插件
  这个同样也是基于firefox浏览器的插件有,功能与selenium IDE类似,如果你熟悉selenium IDE的话,Tellurium IDE很容易操作。
  Tellurium IDE 插件安装地址:
  https://addons.mozilla.org/en-US/firefox/addon/tellurium-ide/?src=search
  注意:本插件不支持新的firefox 9 ,firefox这小子一年换版本比翻书还快,本人使用的是firefox 3.6 版本,用firefox打开上面的链接后点击“add  to  firefox”根据提示,浏览器开始下载安装重启。
  在菜单栏---工具----Tellurium IDE打开插件。

  我们打开人人网的注册页面,填写个人信息,Tellurium IDE会自动记录我的操作。
  Record :录制按钮。打开时默认是按下的,再次点击将取消录制状态。
  Step :单步运行。点击一次,运行一步。
  Run : 运行按钮。点击之后将会把脚本从头到尾运行一遍。
  Clear : 清楚脚本。清楚录制的脚本。
  本例子录制了一个人人网的注册页面(不完整,只是填写了注册信息,并被“提交”注册)。
  我们切换到Source View标签,可查看录制的代码。
  点击菜单栏File 可选择将代码以不同的形式导出或保存到剪切版上。

  在Eclipse中运行测试代码
  我们在Eclipse中创建一个NewUiModule.groovy 的文件。并把我Tellurium IDE中录制的代码插入,内容如下:
class NewUiModule extends DslContext {
public void defineUi() {
ui.Form(uid: "Regform", clocator: [tag: "form", action: "/s-c-i-reg.do", name: "regform", id: "regform", method: "post"]){
InputBox(uid: "RegEmail", clocator: [tag: "input", type: "text", class: "inputtext", id: "regEmail", name: "regEmail"])
InputBox(uid: "Pwd", clocator: [tag: "input", type: "password", class: "inputtext", id: "pwd", name: "pwd"])
InputBox(uid: "Name", clocator: [tag: "input", type: "text", class: "inputtext", id: "name", name: "name"])
RadioButton(uid: "Female", clocator: [tag: "input", type: "radio", value: "女生", id: "female", name: "gender"])
Selector(uid: "Birth_year", clocator: [tag: "select", name: "birth_year"])
Selector(uid: "Birth_month", clocator: [tag: "select", name: "birth_month"])
Selector(uid: "Birth_day", clocator: [tag: "select", name: "birth_day"])
Selector(uid: "Stage", clocator: [tag: "select", name: "stage", id: "stage"])
InputBox(uid: "Icode", clocator: [tag: "input", type: "text", class: "inputtext validate-code", id: "icode", name: "icode"])
Container(uid: "D_email", clocator: [tag: "dl", direct: "true", id: "d_email"]){
UrlLink(uid: "Xid_reg_handle", clocator: [tag: "a", text: "帐号", id: "xid_reg_handle"])
UrlLink(uid: "A", clocator: [tag: "a", text: "手机号"])
}
Container(uid: "Dl_gender", clocator: [tag: "dl", direct: "true", class: "dl_gender"]){
RadioButton(uid: "Male", clocator: [tag: "input", type: "radio", value: "男生", id: "male", name: "gender"])
}
}
connectSeleniumServer()
connectUrl "http://reg.renren.com/xn6245.do?ss=·0··3&rt=27"
type "Regform.RegEmail", "dddd"
type "Regform.RegEmail", "chongshi"
type "Regform.Pwd", "·23456"
type "Regform.Name", "小三"
click "Regform.Female"
selectByLabel "Regform.Birth_year", "80后"
selectByLabel "Regform.Birth_month", "7"
selectByLabel "Regform.Birth_day", "8"
selectByLabel "Regform.Birth_day", "7"
selectByLabel "Regform.Stage", "已经工作了"
type "Regform.Icode", "漂亮宝贝"
}  //Add your methods here
public void searchDownload(String keyword) {
keyType "TelluriumDownload.Input", keyword
click "TelluriumDownload.Search"
waitForPageToLoad 30000
}
public String[] getAllDownloadTypes() {
return getSelectOptions("TelluriumDownload.DownloadType")
}
public void selectDownloadType(String type) {
selectByLabel "TelluriumDownload.DownloadType", type
}
}

上一页1234下一页
软件测试工具 | 联系我们 | 投诉建议 | 诚聘英才 | 申请使用列表 | 网站地图
沪ICP备07036474 2003-2017 版权所有 上海泽众软件科技有限公司 Shanghai ZeZhong Software Co.,Ltd