Tellurium Automated Testing Framework(Tellurium自動測試框架)是一個新的開源項目。已經有一些用戶, 主要來自美國和印度, 國內的還是比較少。 希望這里把Tellurium介紹給國內的同行,請多多使用,多多交流。
目前,Tellurium還是建立在Selenium框架之上, 在不久的將來希望Tellurium會開發自己的測試驅動Engine來更好,更有效地支持Tellurium.
盡管Tellurium脫胎于Selenium, 但兩者在概念上是大大的不同。 打個比方,Selenium是C, 而Tellurium是C++。
首先, Selenium主要用于記錄和重播模式(Record and replay), 這是很方便,但是在比較復雜的應用中這種模式并不能很好地工作, 因為你必須記錄可能的所以的測試情況, 除此之外, Data dependency(數據的依賴性)也是個大問題。
第二, Selenium將測試的頁面表述(Locator)和測試代碼混在一起, 很難維護和重復使用(reuse)。
第三, Selenium面對的是一個個單獨的網頁元素, 而且網頁元素的Locator很難作到魯棒性(robust)。
那么Tellurium是如何克服上面的問題的呢?
第一, Tellurium不是記錄和重播模式, 而是注重網頁模塊的。 首先你必須定義網頁模塊和對模塊的方法。 以Google頁面為例, Google搜索模塊可以定義為:
ui.Container(uid: "Google", clocator: [tag: "td"], group: "true"){
InputBox(uid: "SearchBox", clocator: [title: "Google Search"])
SubmitButton(uid: "Search", clocator: [name: "btnG", value: "Google Search"])
SubmitButton(uid: "Feelinglucky", clocator: [value: "I'm Feeling Lucky"])
}
然后, 你可以定義一些對它的操作方法,
def doGoogleSearch(String input){
type "Google.SearchBox", input
pause 500
click "Google.Search"
waitForPageToLoad 30000
}
def doImFeelingLucky(String input){
type "Google.SearchBox", input
pause 500
click "Google.FeelingLucky"
waitForPageToLoad 30000
}
在此之上你可以像寫JUnit測試一樣的寫測試代碼, 例如:
public class GoogleStartPageJavaTestCase extends TelluriumJavaTestCase {
protected static NewGoogleStartPage ngsp;
@BeforeClass
public static void initUi() {
ngsp = new NewGoogleStartPage();
ngsp.defineUi();
}
原文轉自:http://www.anti-gravitydesign.com