2013-04-26 46 views
3

我使用geb進行測試,我遇到了問題。我需要保存/打印當前頁面的地址(功能SaveUrl())。使用geb保存當前網址

斯波克測試:

class TestSpec extends GebReportingSpec { 
def "Google"() { 
    given: "go to google.com" 
    to GooglePage 

    when: "we at Google home page" 
    at GooglePage 

    then: "Search Yahoo" 
    Search("Yahoo") 
    SaveUrl() 
    } 
} 

GooglePage:

class GooglePage extends Page { 
    static url = "http://www.google.by" 
    static at = { $("title").text() == "Google"} 
    static content = { 
     theModule { module SearchModule } 
    } 

def Search(String arg0) { 
    theModule.field.value(arg0) 
    theModule.search.click() 
    } 

def SaveUrl() { 
    // need implement 
    } 
} 

Modile:

class SearchModule extends Module { 
static content = { 
    field { $("input", name: "q") } 
    search { $("input", name: "btnK") } 
    } 
} 

請幫助保存/打印當前網址。
謝謝!

回答