From 648d1a0cf4c7cb659d66a35652fa84e909b1e8b7 Mon Sep 17 00:00:00 2001 From: madmatt Date: Mon, 6 Jan 2014 10:20:44 +1300 Subject: [PATCH] Allow GridFields without titles to be found. --- .../Framework/Test/Behaviour/CmsUiContext.php | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/tests/behat/features/bootstrap/SilverStripe/Framework/Test/Behaviour/CmsUiContext.php b/tests/behat/features/bootstrap/SilverStripe/Framework/Test/Behaviour/CmsUiContext.php index 41fc7e0d0..c7418590a 100644 --- a/tests/behat/features/bootstrap/SilverStripe/Framework/Test/Behaviour/CmsUiContext.php +++ b/tests/behat/features/bootstrap/SilverStripe/Framework/Test/Behaviour/CmsUiContext.php @@ -114,11 +114,20 @@ class CmsUiContext extends BehatContext { $table_element = null; foreach ($table_elements as $table) { $table_title_element = $table->find('css', '.title'); - if ($table_title_element->getText() === $title) { + if ($table_title_element && $table_title_element->getText() === $title) { $table_element = $table; break; } } + + // Some {@link GridField} tables don't have a visible title, so look for a fieldset with data-name instead + if(!$table_element) { + $fieldset = $page->findAll('xpath', "//fieldset[@data-name='$title']"); + if(is_array($fieldset) && isset($fieldset[0])) { + $table_element = $fieldset[0]->find('css', '.ss-gridfield-table'); + } + } + assertNotNull($table_element, sprintf('Table `%s` not found', $title)); return $table_element;