diff --git a/src/SilverStripe/BehatExtension/Context/BasicContext.php b/src/SilverStripe/BehatExtension/Context/BasicContext.php index fbe8d26..aee797c 100644 --- a/src/SilverStripe/BehatExtension/Context/BasicContext.php +++ b/src/SilverStripe/BehatExtension/Context/BasicContext.php @@ -605,13 +605,25 @@ JS; if(trim($negate)) { if (preg_match($regex, $actual)) { - $message = sprintf('The text "%s" was found in the text of the "%s" region.', $text, $region); - throw new \Exception($message, $this->getSession()); + $message = sprintf( + 'The text "%s" was found in the text of the "%s" region on the page %s.', + $text, + $region, + $this->getSession()->getCurrentUrl() + ); + + throw new \Exception($message); } } else { if (!preg_match($regex, $actual)) { - $message = sprintf('The text "%s" was not found anywhere in the text of the "%s" region.', $text, $region); - throw new \Exception($message, $this->getSession()); + $message = sprintf( + 'The text "%s" was not found anywhere in the text of the "%s" region on the page %s.', + $text, + $region, + $this->getSession()->getCurrentUrl() + ); + + throw new \Exception($message); } }