Skip to content

Commit afab048

Browse files
Nils LangnerNils Langner
authored andcommitted
Added exception handling if an element does not exist
1 parent 7ae4451 commit afab048

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

module/VisualCeption.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,13 @@ private function getCoordinates ($elementId)
210210
$this->webDriver->executeScript('jQuery.noConflict();');
211211

212212
$imageCoords = array ();
213+
214+
$elementExists = (bool) $this->webDriver->executeScript('return jQuery( "' . $elementId . '" ).length > 0;');
215+
216+
if( !$elementExists) {
217+
throw new \Exception("The element you want to examine ('".$elementId."') was not found.");
218+
}
219+
213220
$imageCoords['offset_x'] = (string) $this->webDriver->executeScript('return jQuery( "' . $elementId . '" ).offset().left;');
214221
$imageCoords['offset_y'] = (string) $this->webDriver->executeScript('return jQuery( "' . $elementId . '" ).offset().top;');
215222
$imageCoords['width'] = (string) $this->webDriver->executeScript('return jQuery( "' . $elementId . '" ).width();');

0 commit comments

Comments
 (0)