コード例 #1
0
 /**
  * Performs click confirming the action.
  *
  * @param NodeElement $node
  * @return void
  */
 protected function click_and_confirm($node)
 {
     // Clicks to perform the action.
     $node->click();
     // Confirms the delete.
     if ($this->running_javascript()) {
         $confirmbutton = $this->get_node_in_container('button', get_string('yes'), 'dialogue', get_string('confirmation', 'admin'));
         $confirmbutton->click();
     }
 }
コード例 #2
0
ファイル: behat_navigation.php プロジェクト: evltuma/moodle
 /**
  * Helper function to get sub-navigation node.
  *
  * @throws ExpectationException if note not found.
  * @param string $nodetext node to find.
  * @param NodeElement $parentnode parent navigation node.
  * @return NodeElement.
  */
 protected function get_navigation_node($nodetext, $parentnode = null)
 {
     // Avoid problems with quotes.
     $nodetextliteral = behat_context_helper::escape($nodetext);
     $xpath = "/ul/li[contains(concat(' ', normalize-space(@class), ' '), ' contains_branch ')]" . "[child::p[contains(concat(' ', normalize-space(@class), ' '), ' branch ')]" . "/child::span[normalize-space(.)=" . $nodetextliteral . "]]";
     $node = $parentnode->find('xpath', $xpath);
     if (!$node) {
         $xpath = "/ul/li[contains(concat(' ', normalize-space(@class), ' '), ' contains_branch ')]" . "[child::p[contains(concat(' ', normalize-space(@class), ' '), ' branch ')]" . "/child::a[normalize-space(.)=" . $nodetextliteral . "]]";
         $node = $parentnode->find('xpath', $xpath);
     }
     if (!$node) {
         throw new ExpectationException('Sub-navigation node "' . $nodetext . '" not found under "' . $parentnode->getText() . '"', $this->getSession());
     }
     return $node;
 }
コード例 #3
0
 /**
  * Opens a content tree node based on the root of the tree or a given node.
  *
  * @param   string          $pathNode   The text of the node that is going to be opened
  * @param   NodeElement     $node       The base node to expand from, if null defaults to the content tree root
  * @return  NodeElement                 The node that was opened
  */
 protected function openTreeNode($pathNode, $node)
 {
     $page = $this->getSession()->getPage();
     $notFound = true;
     $subNodes = $node->findAll('css', '.ez-tree-node');
     foreach ($subNodes as $subNode) {
         $leafNode = $subNode->find('css', '.ez-tree-navigate');
         if ($leafNode->getText() == $pathNode) {
             $notFound = false;
             if ($subNode->hasClass('is-tree-node-close')) {
                 $toggleNode = $subNode->find('css', '.ez-tree-node-toggle');
                 if ($toggleNode->isVisible()) {
                     $toggleNode->click();
                 }
             }
             return $subNode;
         }
     }
     if ($notFound) {
         throw new \Exception("The path node: {$pathNode} was not found for the given path");
     }
     return $node;
 }