Skip to content

Commit

Permalink
Fixed problems with getting imageCoords in IE11 (#56)
Browse files Browse the repository at this point in the history
Fixed problems with getting imageCoords in IE11
  • Loading branch information
EvgeniyMarchenko89 authored and buresmi7 committed Jan 20, 2020
1 parent e69ace1 commit d688df7
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions module/VisualCeption.php
Original file line number Diff line number Diff line change
Expand Up @@ -308,20 +308,16 @@ private function getCoordinates($elementId)
$elementId = 'body';
}

$imageCoords = array();

$elementExists = (bool)$this->webDriver->executeScript('return document.querySelectorAll( "' . $elementId . '" ).length > 0;');

if (!$elementExists) {
throw new \Exception("The element you want to examine ('" . $elementId . "') was not found.");
}

$coords = $this->webDriver->executeScript('return document.querySelector( "' . $elementId . '" ).getBoundingClientRect();');

$imageCoords['offset_x'] = $coords['left'];
$imageCoords['offset_y'] = $coords['top'];
$imageCoords['width'] = $coords['width'];
$imageCoords['height'] = $coords['height'];
$imageCoords = $this->webDriver->executeScript('
var rect = document.querySelector( "' . $elementId . '" ).getBoundingClientRect();
return {"offset_x": rect.left, "offset_y": rect.top, "width": rect.width, "height": rect.height};
');

return $imageCoords;
}
Expand Down

0 comments on commit d688df7

Please sign in to comment.