From 44d5af386ccaa7007395da885b955dbd2fb17c63 Mon Sep 17 00:00:00 2001 From: David Monllao Date: Tue, 26 Mar 2013 12:16:00 +0800 Subject: [PATCH] MDL-38687 behat: Add activity step modification We are only supposed to look for the activity name in @class=typename --- course/tests/behat/behat_course.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/course/tests/behat/behat_course.php b/course/tests/behat/behat_course.php index c0622e21753..2d1803cb455 100644 --- a/course/tests/behat/behat_course.php +++ b/course/tests/behat/behat_course.php @@ -61,7 +61,7 @@ class behat_course extends behat_base { /** * Adds the selected activity/resource filling the form data with the specified field/value pairs. * - * @When /^I add a "(?P(?:[^"]|\\")*)" to section "(?P\d+)" and I fill the form with:$/ + * @When /^I add a "(?P(?:[^"]|\\")*)" to section "(?P\d+)" and I fill the form with:$/ * @param string $activity The activity name * @param string $section The section number * @param TableNode $data The activity field/value data @@ -78,7 +78,7 @@ class behat_course extends behat_base { /** * Opens the activity chooser and opens the activity/resource form page. * - * @Given /^I add a "(?P(?:[^"]|\\")*)" to section "(?P\d+)"$/ + * @Given /^I add a "(?P(?:[^"]|\\")*)" to section "(?P\d+)"$/ * @throws ElementNotFoundException Thrown by behat_base::find * @param string $activity * @param string $section @@ -95,7 +95,10 @@ class behat_course extends behat_base { $sectionnode->click(); // Clicks the selected activity if it exists. - $activityxpath = ".//label[contains(.,'" . $activity . "')]/input"; + $activity = ucfirst($activity); + $activityxpath = "//div[@id='chooseform']/descendant::label +/descendant::span[contains(concat(' ', @class, ' '), ' typename ')][contains(.,'" . $activity . "')] +/parent::label/child::input"; $activitynode = $this->find('xpath', $activityxpath); $activitynode->doubleClick();