Reputation: 4360
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?
Upvotes: 5
Views: 2150
Reputation: 4411
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()
Upvotes: 4