From 4f7c6ebcff7ce5c2e54896f721fd87df14172cd5 Mon Sep 17 00:00:00 2001 From: Sam Minnee Date: Thu, 13 Feb 2014 17:36:46 +1300 Subject: [PATCH] FIX: Fixed behat text selection rule, which broke some tests. The behat rule for text selection wasn't working due to the JavaScript not executing properly. I have also updated the code to traverse all childNodes, which is important if you have text like this:

text1 text2 text3

And you are trying to select 'text3' --- .../Test/Behaviour/CmsFormsContext.php | 21 ++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/tests/behat/features/bootstrap/SilverStripe/Framework/Test/Behaviour/CmsFormsContext.php b/tests/behat/features/bootstrap/SilverStripe/Framework/Test/Behaviour/CmsFormsContext.php index 5ae293d9a..459c8ebb6 100644 --- a/tests/behat/features/bootstrap/SilverStripe/Framework/Test/Behaviour/CmsFormsContext.php +++ b/tests/behat/features/bootstrap/SilverStripe/Framework/Test/Behaviour/CmsFormsContext.php @@ -184,17 +184,24 @@ var editor = jQuery('#$inputFieldId').entwine('ss').getEditor(), sel = editor.getInstance().selection, rng = document.createRange(), matched = false; + jQuery(doc).find('body *').each(function() { - if(!matched && this.firstChild && this.firstChild.nodeValue && this.firstChild.nodeValue.match('$text')) { - rng.setStart(this.firstChild, this.firstChild.nodeValue.indexOf('$text')); - rng.setEnd(this.firstChild, this.firstChild.nodeValue.indexOf('$text') + '$text'.length); - sel.setRng(rng); - editor.getInstance().nodeChanged(); - matched = true; + if(!matched) { + for(var i=0;igetSession()->evaluateScript($js); + + $this->getSession()->executeScript($js); } /**