diff --git a/lib/tests/behat/behat_general.php b/lib/tests/behat/behat_general.php index 04398d7b3c8..bd0d4ff3a2a 100644 --- a/lib/tests/behat/behat_general.php +++ b/lib/tests/behat/behat_general.php @@ -411,6 +411,15 @@ class behat_general extends behat_base { list($containerselector, $containerlocator) = $this->transform_selector($containerselectortype, $containerelement); $destinationxpath = $this->getSession()->getSelectorsHandler()->selectorToXpath($containerselector, $containerlocator); + $node = $this->get_selected_node("xpath_element", $sourcexpath); + if (!$node->isVisible()) { + throw new ExpectationException('"' . $sourcexpath . '" "xpath_element" is not visible', $this->getSession()); + } + $node = $this->get_selected_node("xpath_element", $destinationxpath); + if (!$node->isVisible()) { + throw new ExpectationException('"' . $destinationxpath . '" "xpath_element" is not visible', $this->getSession()); + } + $this->getSession()->getDriver()->dragTo($sourcexpath, $destinationxpath); } diff --git a/question/type/ddimageortext/tests/behat/behat_qtype_ddimageortext.php b/question/type/ddimageortext/tests/behat/behat_qtype_ddimageortext.php index b5b3e947d79..879b665f212 100644 --- a/question/type/ddimageortext/tests/behat/behat_qtype_ddimageortext.php +++ b/question/type/ddimageortext/tests/behat/behat_qtype_ddimageortext.php @@ -60,7 +60,6 @@ class behat_qtype_ddimageortext extends behat_base { * @param int $placenumber the number of the place to drop into. * * @Given /^I drag "(?P[^"]*)" to place "(?P\d+)" in the drag and drop onto image question$/ - * */ public function i_drag_to_place_in_the_drag_and_drop_onto_image_question($dragitem, $placenumber) { $generalcontext = behat_context_helper::get('behat_general'); diff --git a/question/type/ddmarker/tests/behat/behat_qtype_ddmarker.php b/question/type/ddmarker/tests/behat/behat_qtype_ddmarker.php index cb800ccaa94..23ec698251d 100644 --- a/question/type/ddmarker/tests/behat/behat_qtype_ddmarker.php +++ b/question/type/ddmarker/tests/behat/behat_qtype_ddmarker.php @@ -71,7 +71,6 @@ class behat_qtype_ddmarker extends behat_base { // DOM node so that its centre is over the centre of anothe DOM node. // Therefore to make it drag to the specified place, we have to add // a target div. - $style = $session = $this->getSession(); $session->evaluateScript(" (function() { @@ -88,8 +87,8 @@ class behat_qtype_ddmarker extends behat_base { target.style.setProperty('position', 'absolute'); target.style.setProperty('left', xadjusted + 'px'); target.style.setProperty('top', '{$y}px'); - target.style.setProperty('width', '0'); - target.style.setProperty('height', '0'); + target.style.setProperty('width', '1px'); + target.style.setProperty('height', '1px'); }())"); $generalcontext = behat_context_helper::get('behat_general');