2013-04-26 83 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") } 
    } 
} 

请帮助保存/打印当前网址。
谢谢!

回答