Frage

I'm setting up a load of automated testing for our in house CMS.

At this moment in time, I want to be able to test that our test page has certain images in it.

I can check for the caption which will be displayed if the image exists...

$I->see('Image Caption');

...but I really want to actually be able to check for the presence of the image itself...

$I->seeImage('/path_to/image_file.jpg'); // I MADE THAT METHOD UP

...or at least the img tag...

$I->seeSourceCode('<img src="/path_to/image_file.jpg"'); // I MADE THAT METHOD UP TOO

Does anyone know how to do this?

War es hilfreich?

Lösung

seeElement() may fit your need, for instance:
$I->seeElement('//img[@src="/pixel.jpg"]');
please do see doc
and, in order to make test more readable, I'd recommend to wrap the actual call to seeElement() in helper and in test have something like this
$I->seeImageWithSource('/pixel.jpg')

public function seeImageWithSource($image_url)
{
    $phpBrowser = $this->getModule('PhpBrowser');
    $phpBrowser->seeElement('//img[@src="'.$image_url.'"]');
}
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top