您的位置:軟件測(cè)試 > 開(kāi)源軟件測(cè)試 > 開(kāi)源功能測(cè)試工具 >
開(kāi)源自動(dòng)化測(cè)試框架Tellurium
作者:網(wǎng)絡(luò)轉(zhuǎn)載 發(fā)布時(shí)間:[ 2014/3/5 10:22:14 ] 推薦標(biāo)簽:自動(dòng)化測(cè)試 測(cè)試框架 開(kāi)源 測(cè)試方案

  GoogleSearchModule.groovy是用戶(hù)界面模塊的谷歌搜索,它自化生成Tellurium 所需要的火狐瀏覽器插件TrUMP.  doGoogleSearch() 和 doImFeelingLucky() 兩個(gè)方法是增加定期谷歌搜索和谷歌“手氣不錯(cuò)”搜索。
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
}
}
  因?yàn)門(mén)ellurium只支持groovy語(yǔ)言,所以無(wú)groovy語(yǔ)言無(wú)法直接在Eclipse IDE中運(yùn)行,需要Eclipse安裝對(duì)groovy語(yǔ)言支持的插件。
  Groovy-Eclipse 2.5.· 插件下載地址:
  http://www.oschina.net/news/·9279/groovy-eclipse-25·
  當(dāng)然,你也可以使用IntelliJ IDEA 工具,它同樣也運(yùn)行java語(yǔ)言非常的IDE。 而且IntelliJ IDEA本身是支持groovy語(yǔ)言。
  Tellurium IDE 插件
  這個(gè)同樣也是基于firefox瀏覽器的插件有,功能與selenium IDE類(lèi)似,如果你熟悉selenium IDE的話(huà),Tellurium IDE很容易操作。
  Tellurium IDE 插件安裝地址:
  https://addons.mozilla.org/en-US/firefox/addon/tellurium-ide/?src=search
  注意:本插件不支持新的firefox 9 ,firefox這小子一年換版本比翻書(shū)還快,本人使用的是firefox 3.6 版本,用firefox打開(kāi)上面的鏈接后點(diǎn)擊“add  to  firefox”根據(jù)提示,瀏覽器開(kāi)始下載安裝重啟。
  在菜單欄---工具----Tellurium IDE打開(kāi)插件。

  我們打開(kāi)人人網(wǎng)的注冊(cè)頁(yè)面,填寫(xiě)個(gè)人信息,Tellurium IDE會(huì)自動(dòng)記錄我的操作。
  Record :錄制按鈕。打開(kāi)時(shí)默認(rèn)是按下的,再次點(diǎn)擊將取消錄制狀態(tài)。
  Step :?jiǎn)尾竭\(yùn)行。點(diǎn)擊一次,運(yùn)行一步。
  Run : 運(yùn)行按鈕。點(diǎn)擊之后將會(huì)把腳本從頭到尾運(yùn)行一遍。
  Clear : 清楚腳本。清楚錄制的腳本。
  本例子錄制了一個(gè)人人網(wǎng)的注冊(cè)頁(yè)面(不完整,只是填寫(xiě)了注冊(cè)信息,并被“提交”注冊(cè))。
  我們切換到Source View標(biāo)簽,可查看錄制的代碼。
  點(diǎn)擊菜單欄File 可選擇將代碼以不同的形式導(dǎo)出或保存到剪切版上。

  在Eclipse中運(yùn)行測(cè)試代碼
  我們?cè)贓clipse中創(chuàng)建一個(gè)NewUiModule.groovy 的文件。并把我Tellurium IDE中錄制的代碼插入,內(nèi)容如下:
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: "帳號(hào)", id: "xid_reg_handle"])
UrlLink(uid: "A", clocator: [tag: "a", text: "手機(jī)號(hào)"])
}
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", "已經(jīng)工作了"
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
}
}

上一頁(yè)1234下一頁(yè)
軟件測(cè)試工具 | 聯(lián)系我們 | 投訴建議 | 誠(chéng)聘英才 | 申請(qǐng)使用列表 | 網(wǎng)站地圖
滬ICP備07036474 2003-2017 版權(quán)所有 上海澤眾軟件科技有限公司 Shanghai ZeZhong Software Co.,Ltd