From c3ed455ec61b9f0ed36a828982096af44e3b914d Mon Sep 17 00:00:00 2001 From: Hamish Friedlander Date: Thu, 28 Jul 2016 16:51:33 +1200 Subject: [PATCH] FIX iSelectFromInputGroup not understanding bootstraps input-in-label structure --- src/SilverStripe/BehatExtension/Context/BasicContext.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/SilverStripe/BehatExtension/Context/BasicContext.php b/src/SilverStripe/BehatExtension/Context/BasicContext.php index a6a3e66..44bccd8 100644 --- a/src/SilverStripe/BehatExtension/Context/BasicContext.php +++ b/src/SilverStripe/BehatExtension/Context/BasicContext.php @@ -480,8 +480,14 @@ JS; foreach($parent->findAll('css', 'label') as $option) { if($option->getText() == $value) { + $input = null; + + // First, look for inputs referenced by the "for" element on this label $for = $option->getAttribute('for'); - $input = $parent->findById($for); + if ($for) $input = $parent->findById($for); + + // Otherwise look for inputs _inside_ the label + if (!$input) $input = $option->find('css', 'input'); if(!$input) throw new \InvalidArgumentException(sprintf('Input "%s" cannot be found', $value));