diff --git a/module/VuFind/tests/integration-tests/src/VuFindTest/Mink/RecordCoverImageTest.php b/module/VuFind/tests/integration-tests/src/VuFindTest/Mink/RecordCoverImageTest.php index caca6faeacb..1ee34f6fcd4 100644 --- a/module/VuFind/tests/integration-tests/src/VuFindTest/Mink/RecordCoverImageTest.php +++ b/module/VuFind/tests/integration-tests/src/VuFindTest/Mink/RecordCoverImageTest.php @@ -165,9 +165,10 @@ public function testCoverLoading( $session->visit($url); $page = $session->getPage(); $this->waitForPageLoad($page); + $coverSelector = 'img.recordcover'; $session->wait( $this->getDefaultTimeout(), - 'document.querySelector("img.recordcover").dataset.loaded !== undefined' + "document.querySelector('$coverSelector').dataset.loaded !== undefined" ); // Verify the expected backlink (or lack thereof): $backlinkSelector = 'p.cover-source'; @@ -185,10 +186,13 @@ public function testCoverLoading( $expectedClasses = 'recordcover' . ($ajaxcovers ? ' ajax' : '') . (empty($noCoverAvailableImage) ? ' hidden' : ''); - $coverImage = $this->findCss($page, 'img.recordcover'); + $coverImage = $this->findCss($page, $coverSelector); + $width = $session->evaluateScript("document.querySelector('$coverSelector').getBoundingClientRect().width"); + $height = $session->evaluateScript("document.querySelector('$coverSelector').getBoundingClientRect().height"); $this->assertEquals( $expectedClasses, - $coverImage?->getAttribute('class') + $coverImage?->getAttribute('class'), + "Unexpected classes on image of dimensions $width x $height" ); // Verify the expected image URL: