有没有办法检查Behat,如果在页面上没有包含损坏/损坏链接的图像?
答案 0 :(得分:3)
我建议在页面上找到所有图片
$imageElements = $this->getSession()->getPage()->findAll('css','img');
foreach($imageElements as $image){
$imgUrl = $image->getAttribute('src');
$this->visit($imgUrl);
//Here should be assertion of valid img,
//F.e. if you are using goutte driver check that server response is not 500 or 404
$this->assertResponseStatusIsNot(404);
}