开发者

Can I check non-html responses in geb?

Geb is a nice framework for testing web applications, as there is very direct support for checking specific DOM elements as seen by the browsing client. However, sometimes the expected result of a request is plain text (or csv, json, etc).

Is there any way to get the raw text of a result? Can I also get the response code (e.g.开发者_如何转开发 200) and the content-type?


the page source can be retrieved with the getPageSource() method on the driver:

@Grapes([
    @Grab("org.codehaus.geb:geb-core:latest.release"),
    @Grab("org.seleniumhq.selenium:selenium-firefox-driver:latest.release")
])
import geb.Browser
import geb.driver.CachingDriverFactory

Browser.drive("http://geb.codehaus.org/latest/")  {

    assert title == "Geb - Groovy Browser Automation"

    println driver.pageSource
}

CachingDriverFactory.clearCacheAndQuitDriver()
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜