From 3a34c204c191310c9f6d2d478a4cb902e49790a0 Mon Sep 17 00:00:00 2001 From: Ingo Schommer Date: Tue, 9 Apr 2013 11:32:43 +0200 Subject: [PATCH] Generalized and fixed UploadField handling in behat --- .../BehatExtension/Context/BasicContext.php | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/SilverStripe/BehatExtension/Context/BasicContext.php b/src/SilverStripe/BehatExtension/Context/BasicContext.php index 6e22856..9540554 100644 --- a/src/SilverStripe/BehatExtension/Context/BasicContext.php +++ b/src/SilverStripe/BehatExtension/Context/BasicContext.php @@ -319,15 +319,20 @@ JS; } /** - * @Given /^(I attach the file .*) with HTML5$/ + * @Given /^(?:|I )attach the file "(?P[^"]*)" to "(?P(?:[^"]|\\")*)" with HTML5$/ */ - public function iAttachTheFileTo($step) + public function iAttachTheFileTo($field, $path) { - $this->getSession()->evaluateScript("jQuery('.ss-uploadfield-editandorganize').show()"); - $this->getSession()->evaluateScript("jQuery('[name=\"AssetUploadField\"]').css({opacity:1,visibility:'visible',height:'1px',width:'1px'})"); - $this->getSession()->evaluateScript("jQuery('[name=\"files[]\"]').css({opacity:1,visibility:'visible',height:'1px',width:'1px'})"); + // Remove wrapped button styling to make input field accessible to Selenium + $js = <<getSession()->evaluateScript($js); $this->getSession()->wait(1000); - return new Step\Given($step); + return new Step\Given(sprintf('I attach the file "%s" to "%s"', $path, $field)); } }