selenium - Codeception:如何测试图像是否已加载?

标签 selenium codeception facebook-php-webdriver

我正在尝试这样做

$I->seeElement('DIV#security IMG.verisign'); 

检查是否加载了带有 Verisign Logo 的图像,但即使未加载图像,测试也会通过(如果文件名为 404,则返回 404)来源错误)。

检查图像加载的正确方法是什么?

最佳答案

您可以查看 naturalHeight验证图像是否正确加载:

$this->assertGreaterThan($element->getAttribute('naturalHeight'), 1);

关于selenium - Codeception:如何测试图像是否已加载?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47133761/

相关文章:

xslt - 我们如何使用 jenkins 控制台日志通过和失败计数生成 html 报告?

selenium - 使用 Selenium 服务在 Gitlab CI 上测试 Codeception

php - 测试PDF文件Codeception

selenium-webdriver - 如何从 WebDriver 的本地缓存中保存图像?

javascript - Dropzone.js : Upload file without Browse dialog in php-webdriver integration tests

python - 遍历一列

java - org.openqa.selenium.ElementClickInterceptedException : element click intercepted error using Selenium and Java in headless mode

grails - 在 grails geb 中通过数字 id 进行选择

css - codeception 无法点击 xpath,因为它无法定位 CSS 或 Xpath