• <ruby id="5koa6"></ruby>
    <ruby id="5koa6"><option id="5koa6"><thead id="5koa6"></thead></option></ruby>

    <progress id="5koa6"></progress>

  • <strong id="5koa6"></strong>
    • 軟件測試技術
    • 軟件測試博客
    • 軟件測試視頻
    • 開源軟件測試技術
    • 軟件測試論壇
    • 軟件測試沙龍
    • 軟件測試資料下載
    • 軟件測試雜志
    • 軟件測試人才招聘
      暫時沒有公告

    字號: | 推薦給好友 上一篇 | 下一篇

    自動測試工具Tellurium快速上手指南

    發布: 2009-6-16 13:10 | 作者: 網絡轉載 | 來源: 領測軟件測試網采編 | 查看: 178次 | 進入軟件測試論壇討論

    領測軟件測試網

    Locator

    Locator是用來定位一個元素在網頁DOM中的位置,Tellurium支持兩種Locator, 一種叫 Base Locator , 用“locator”標識,它是一個相對的XPath. 如:

    InputBox(uid: "SearchBox", locator: "http://input[@title='Google Search']")

    另一個是 Composite Locator , 用“clocator”來標識,它是由一組屬性構成,如

    InputBox(uid: "SearchBox", clocator: [title: "Google Search"])

    Composite Locator 是Tellurium的缺省Locator, 它容易寫,表敘性好,方便動態生成Runtime Locator.

    UI模塊

    UI模塊是一個復合的Tellurium物件,它是由一些單個Tellurium物件嵌套構成。一個UI模塊往往代表DOM的一個子樹。比如Google首頁搜索模塊就可以表敘為

    ui.Container(uid: "GoogleSearchModule", clocator: [tag: "td"], group: "true"){
       
    InputBox(uid: "Input", clocator: [title: "Google Search"],respond: ["focus", "mouseOver"])
       
    SubmitButton(uid: "Search", clocator: [name: "btnG", value: "Google Search"])
       
    SubmitButton(uid: "ImFeelingLucky", clocator: [value: "I'm Feeling Lucky"])
    }

    UI模塊的最外層元素以定要以"ui."開始。這里group為“true”表示Tellurium用利用UI元素之間的關系來協助它們在網頁DOM中的定位。respond屬性定義了InputBox需要觸發“focus”和“mouseOver”事件,Tellurium會自動觸發這些事件的。

    測試案例>Tellurium測試案例

    Tellurium測試代碼可以用Java, Groovy, 或純DSL腳本來寫。無論哪種方法,Tellurium要求你定義獨立的UI模塊,使之和測試代碼分離,以便于維護。UI模塊必須繼承Tellurium的DslContext class, 一般你還需定義對UI模塊的操作方法。例如:

    class GoogleSearchModule extends DslContext{

       
    public void defineUi() {
             ui
    .Container(uid: "google_start_page", clocator: [tag: "td"], group: "true"){
               
    InputBox(uid: "searchbox", clocator: [title: "Google Search"])
               
    SubmitButton(uid: "googlesearch", clocator: [name: "btnG", value: "Google Search"])
               
    SubmitButton(uid: "Imfeelinglucky", clocator: [value: "I'm Feeling Lucky"])
           
    }
       
    }

       
    def doGoogleSearch(String input){
            keyType
    "searchbox", input
            pause
    500
            click
    "googlesearch"
            waitForPageToLoad
    30000
       
    }

       
    def doImFeelingLucky(String input){
            type
    "searchbox", input
            pause
    500
            click
    "Imfeelinglucky"
            waitForPageToLoad
    30000
       
    }
    }

    如果你的測試案例用JUnit來寫,你需要繼承TelluriumJavaTestCase.

    public class GoogleSearchTestCase extends TelluriumJavaTestCase {
       
    private static GoogleSearchModule gsm;
       
       
    @BeforeClass
       
    public static void initUi() {
            gsm
    = new GoogleSearchModule();
            gsm
    .defineUi();
       
    }

       
    @Before
       
    public void connectToGoogle() {

            connectUrl
    ("http://www.google.com");
       
    }

       
    @Test
       
    public void testGoogleSearch() {
            gsm
    .doGoogleSearch("tellurium . ( Groovy ) Test");
       
    }

       
    @Test
       
    public void testGoogleSearchFeelingLucky() {
            gsm
    .doImFeelingLucky("tellurium automated Testing");
       
    }
    }

    TestNG的案例類似,除了你要繼承TelluriumTestNGTestCase。如果用Groovy, 你需要繼承TelluriumGroovyTestCase.

    Tellurium配置

    Tellurium用一個配置文件TelluriumConfig.groovy來配置系統。它包括對Selenium服務器和Tellurium框架本身的配置,如:

    tellurium{
       
    //embedded selenium server configuration
        embeddedserver
    {
           
    //port number
            port
    = "4445"
           
    //whether to use multiple windows
            useMultiWindows
    = false
            runInternally
    = true
            profile
    = ""
       
    }
       
    //event handler
        eventhandler
    {
           
    //whether we should check if the UI element is presented
            checkElement
    = true
           
    //wether we add additional events like "mouse over"
            extraEvent
    = true
       
    }
       
    //data accessor
        accessor
    {
           
    //whether we should check if the UI element is presented
            checkElement
    = false
       
    }
        connector
    {
           
    //selenium server host
           
    //please change the host if you run the Selenium server remotely
            serverHost
    = "localhost"
           
    //server port number the client needs to connect
            port
    = "4445"
           
    //base URL
            baseUrl
    = "http://localhost:8080"
           
    //Browser setting, valid options are
           
    //  *firefox [absolute path]
           
    //  *iexplore [absolute path]
           
    //  *chrome
           
    //   *iehta

            browser
    = "*chrome"
       
    }
        datadriven
    {
            dataprovider
    {
                reader
    = "PipeFileReader"
           
    }
       
    }
        test
    {
            result
    {
                reporter
    = "XMLResultReporter"
                output
    = "Console"
                filename
    = "TestResult.output"
           
    }
            exception
    {
                captureScreenshot
    = true
                filenamePattern
    = "Screenshot?.png"
           
    }
       
    }
        uiobject
    {
            builder
    {
               
    //example:
               
    SelectMenu="org.tellurium.builder.SelectMenuBuilder"
           
    }
       
    }
        widget
    {
           
    module{
               
    //define your widget modules here, for example Dojo or ExtJs
                included
    =""
           
    }
       
    }
    }

    此外,Tellurium還提供了方法讓用戶來覆蓋Tellurium中的配置,

    public class GoogleSearchModuleTestCase extends TelluriumJavaTestCase
    {
       
    static{
           setCustomConfig
    (true, 5555, "*chrome", true, null);
       
    }

    ...

    }

    延伸閱讀

    文章來源于領測軟件測試網 http://www.kjueaiud.com/

    32/3<123>

    關于領測軟件測試網 | 領測軟件測試網合作伙伴 | 廣告服務 | 投稿指南 | 聯系我們 | 網站地圖 | 友情鏈接
    版權所有(C) 2003-2010 TestAge(領測軟件測試網)|領測國際科技(北京)有限公司|軟件測試工程師培訓網 All Rights Reserved
    北京市海淀區中關村南大街9號北京理工科技大廈1402室 京ICP備2023014753號-2
    技術支持和業務聯系:info@testage.com.cn 電話:010-51297073

    軟件測試 | 領測國際ISTQBISTQB官網TMMiTMMi認證國際軟件測試工程師認證領測軟件測試網

    老湿亚洲永久精品ww47香蕉图片_日韩欧美中文字幕北美法律_国产AV永久无码天堂影院_久久婷婷综合色丁香五月

  • <ruby id="5koa6"></ruby>
    <ruby id="5koa6"><option id="5koa6"><thead id="5koa6"></thead></option></ruby>

    <progress id="5koa6"></progress>

  • <strong id="5koa6"></strong>