realtebo
realtebo

Reputation: 25699

Codeception: how to test if an image is loaded?

I'm trying to do this

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

to check if the images with the Verisign logo is loaded, but the test passes even if the image is not loaded (for a 404 if the file name of the source is wrong).

What's the right way to check for image loaded?

Upvotes: 2

Views: 614

Answers (1)

Florent B.
Florent B.

Reputation: 42538

You can check the naturalHeight to validate that the image correctly loaded:

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

Upvotes: 2

Related Questions