From f7b380ad8e7e6faaf544fc65c7d877b313de4809 Mon Sep 17 00:00:00 2001 From: Igor Date: Tue, 7 Apr 2015 16:24:13 +1200 Subject: [PATCH] FIX getRegionObj syntax error exception --- .../BehatExtension/Context/SilverStripeContext.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/SilverStripe/BehatExtension/Context/SilverStripeContext.php b/src/SilverStripe/BehatExtension/Context/SilverStripeContext.php index c1a917f..2e49de4 100644 --- a/src/SilverStripe/BehatExtension/Context/SilverStripeContext.php +++ b/src/SilverStripe/BehatExtension/Context/SilverStripeContext.php @@ -137,16 +137,16 @@ class SilverStripeContext extends MinkContext implements SilverStripeAwareContex * @return MinkElement|null */ public function getRegionObj($region) { - // Try to find regions directly by CSS selector. $regionObj = null; - try{ + $startsWithNumber = is_numeric(substr($region, 0, 1)); + + // Try to find regions directly by CSS selector. + if(!$startsWithNumber){ // conditional, otherwise will throw a syntax error $regionObj = $this->getSession()->getPage()->find( 'css', // Escape CSS selector (false !== strpos($region, "'")) ? str_replace("'", "\'", $region) : $region ); - }catch(Exception $e){ - // ignore syntax errors... we tried our best... } if($regionObj) { return $regionObj;