我正在Geb(WebDriver)中建立一个测试,需要提交一个表单来创建一个文件作为response。
我可以下载文件(浏览器将其自动保存到磁盘),但是我想在GEB中进行检查。
如何将文件下载到变量中?
class CSVTest extends GebReportingTest
@Test
void csvCreation() {
to CSVExport
// select entries / fill values
selectAllEntries.value(true)
//// this will do a post
//// the server will render a file and deliver it back as a result of the submit
// CORRECTLY downloads the file
submitButton.click()
// NOT WORKING
withNewWindow (submitButton.click()) {
...
}
// NOT WORKING
def csv = download(submitButton.click())
}
}
单击不幸以任何方式发布帖子的按钮后,您将无法拦截浏览器下载的文件。
您将必须使用适当的表单来合成具有正确内容的发帖请求。尽管可以使用Geb的DownloadSupport
类来做到这一点,但这将是复杂而笨拙的。最好使用以此类请求为主要功能的库,例如REST-Assured。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句