Skip to content

Commit

Permalink
Update Page.php
Browse files Browse the repository at this point in the history
  • Loading branch information
GrahamCampbell committed Nov 6, 2024
1 parent 1db982d commit 30f902d
Showing 1 changed file with 2 additions and 10 deletions.
12 changes: 2 additions & 10 deletions src/Page.php
Original file line number Diff line number Diff line change
Expand Up @@ -940,17 +940,9 @@ public function setHtml(string $html, int $timeout = 3000, string $eventName = s
*/
public function getHtml(?int $timeout = null): string
{
try {
return $this->evaluate('document.documentElement.outerHTML')->getReturnValue($timeout);
} catch (JavascriptException $e) {
if (0 === \strpos($e->getMessage(), 'Error during javascript evaluation: TypeError: Cannot read properties of null (reading \'outerHTML\')')) {
$this->getSession()->getConnection()->processAllEvents();

$this->getSession()->getConnection()->processAllEvents();

return $this->evaluate('document.documentElement.outerHTML')->getReturnValue($timeout);
}
throw $e;
}
return $this->evaluate('document.documentElement.outerHTML')->getReturnValue($timeout);
}

/**
Expand Down

0 comments on commit 30f902d

Please sign in to comment.