Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/powerbi/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Playframework 如何为Play Framework应用程序编写集成测试,以查看是否加载了映像?_Playframework_Playframework 2.2 - Fatal编程技术网

Playframework 如何为Play Framework应用程序编写集成测试,以查看是否加载了映像?

Playframework 如何为Play Framework应用程序编写集成测试,以查看是否加载了映像?,playframework,playframework-2.2,Playframework,Playframework 2.2,我想写一个集成测试,检查图像是否真的加载到PlayFramework应用程序页面中。映像由应用程序本身生成,如果将无效路由指定为src值,则可能会失败。 使用浏览器测试有没有一种简单的方法 @RunWith(classOf[JUnitRunner]) 类集成规范扩展了规范{ “申请”应{ 在新WithBrowser中“在frontpage中显示图像”{ browser.goTo(“http://localhost:“+端口) //这里应该编码什么来测试图像是否正确 //装载 } } } 这个测试

我想写一个集成测试,检查图像是否真的加载到PlayFramework应用程序页面中。映像由应用程序本身生成,如果将无效路由指定为src值,则可能会失败。 使用浏览器测试有没有一种简单的方法

@RunWith(classOf[JUnitRunner])
类集成规范扩展了规范{
“申请”应{
在新WithBrowser中“在frontpage中显示图像”{
browser.goTo(“http://localhost:“+端口)
//这里应该编码什么来测试图像是否正确
//装载
}
}
}

这个测试似乎对我有效:

在新浏览器中“应在frontpage中显示图像”{
browser.goTo(“http://localhost:“+端口)
val img=browser.$(“#mug_image”)
val imageUrl=img.getAttribute(“src”)
val response:response=Helpers.await(WS.url(imageUrl.get())
响应。状态必须等于(正常)
response.getahresponse.getContentType必须等于(“图像/png”)
response.GetAhresponse.getResponseBodyAsBytes.size必须大于(0)
}

如果您要访问图像的src,能否作为代理检查响应的大小?@2manyprojects这是您的意思吗
val img=browser.$(“#mug_image”)val imageUrl=img.getAttribute(“src”)val response:response=Helpers.wait(WS.url(imageUrl.get())response.status必须等于(OK)response.getahresponse.getContentType必须等于(“image/png”)response.getahresponse.getResponseBodyAsBytes.size必须开始创建一个(0)