php - Behat - 检查损坏的图像链接

标签 php testing behat

是否可以通过 Behat 检查页面上是否没有链接损坏/损坏的图像?

最佳答案

我建议查找页面上的所有图像

$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);
}

关于php - Behat - 检查损坏的图像链接,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31636189/

相关文章:

ios - 检查静态库的 iOS 部署目标

ajax - 如何让 Behat 等待 Angular ajax 调用?

php - 需要帮助来克服与 PHP 5.3 设置的某些行为依赖项的不兼容性

php - Mink : Failed to execute 'evaluate' on 'Document' : The result is not a node set, 中的 XPath 错误,因此无法转换为所需的类型

php - 如何获取href属性的值?

php - 与 src 处于同一级别的文件夹的 PSR-4 命名空间约定

android - Android-Robotium 可以做哪些类型的测试

php - SQL 语法错误/查询

php - 如何使用 Doctrine 更改 mysql 表的 auto_increment

c# - 如何使用 FluentAssertions 编写 CustomAssertion?