I have a suite of Selenium tests. Sometimes, for example, an 'assertIsElementPresent' will fail. In certain circumstances, this may be because someone broke something and the result of the sequence of UI clicking is an error that has resulted in the site's error page being shown.
How do I check if this has happened for every single failure, without having to implement a call to the below method everwhere?
$isErrorPage = $selenium->isElementPresent("id=siteErrorPage");
if ($isErrorPage){
$html = $selenium->getHtmlSource();
//send the $html to devs, log it, etc.
}
The intention is simply to email the html source of the page that's being shown if the page has turned out to be an error page.