| Línea 76... | 
            Línea 76... | 
          
          
            | 76 | 
                 * Opens Moodle homepage.
  | 
            76 | 
                 * Opens Moodle homepage.
  | 
          
          
            | 77 | 
                 *
  | 
            77 | 
                 *
  | 
          
          
            | 78 | 
                 * @Given /^I am on homepage$/
  | 
            78 | 
                 * @Given /^I am on homepage$/
  | 
          
          
            | 79 | 
                 */
  | 
            79 | 
                 */
  | 
          
          
            | 80 | 
                public function i_am_on_homepage() {
  | 
            80 | 
                public function i_am_on_homepage() {
  | 
          
          
            | 81 | 
                    $this->execute('behat_general::i_visit', ['/']);
  | 
            81 | 
                    $this->execute([self::class, 'i_visit'], ['/']);
  | 
          
          
            | 82 | 
                }
  | 
            82 | 
                }
  | 
          
          
            | Línea 83... | 
            Línea 83... | 
          
          
            | 83 | 
             
  | 
            83 | 
             
  | 
          
          
            | 84 | 
                /**
  | 
            84 | 
                /**
  | 
          
          
            | 85 | 
                 * Opens Moodle site homepage.
  | 
            85 | 
                 * Opens Moodle site homepage.
  | 
          
          
            | 86 | 
                 *
  | 
            86 | 
                 *
  | 
          
          
            | 87 | 
                 * @Given /^I am on site homepage$/
  | 
            87 | 
                 * @Given /^I am on site homepage$/
  | 
          
          
            | 88 | 
                 */
  | 
            88 | 
                 */
  | 
          
          
            | 89 | 
                public function i_am_on_site_homepage() {
  | 
            89 | 
                public function i_am_on_site_homepage() {
  | 
          
          
            | 90 | 
                    $this->execute('behat_general::i_visit', ['/?redirect=0']);
  | 
            90 | 
                    $this->execute([self::class, 'i_visit'], ['/?redirect=0']);
  | 
          
          
            | Línea 91... | 
            Línea 91... | 
          
          
            | 91 | 
                }
  | 
            91 | 
                }
  | 
          
          
            | 92 | 
             
  | 
            92 | 
             
  | 
          
          
            | 93 | 
                /**
  | 
            93 | 
                /**
  | 
          
          
            | 94 | 
                 * Opens course index page.
  | 
            94 | 
                 * Opens course index page.
  | 
          
          
            | 95 | 
                 *
  | 
            95 | 
                 *
  | 
          
          
            | 96 | 
                 * @Given /^I am on course index$/
  | 
            96 | 
                 * @Given /^I am on course index$/
  | 
          
          
            | 97 | 
                 */
  | 
            97 | 
                 */
  | 
          
          
            | - | 
               | 
            98 | 
                public function i_am_on_course_index() {
  | 
          
          
            | - | 
               | 
            99 | 
                    $this->execute([self::class, 'i_visit'], ['/course/index.php']);
  | 
          
          
            | - | 
               | 
            100 | 
                }
  | 
          
          
            | - | 
               | 
            101 | 
             
  | 
          
          
            | - | 
               | 
            102 | 
                /**
  | 
          
          
            | - | 
               | 
            103 | 
                 * Checks, that current page PATH matches regular expression
  | 
          
          
            | - | 
               | 
            104 | 
                 *
  | 
          
          
            | - | 
               | 
            105 | 
                 * Example: Then the url should match "/course/index\.php"
  | 
          
          
            | - | 
               | 
            106 | 
                 * Example: Then the url should match "/mod/forum/view\.php\?id=[0-9]+"
  | 
          
          
            | - | 
               | 
            107 | 
                 * Example: And the url should match "^http://moodle\.org"
  | 
          
          
            | - | 
               | 
            108 | 
                 *
  | 
          
          
            | - | 
               | 
            109 | 
                 * @Then /^the url should match (?P<pattern>"(?:[^"]|\\")*")$/
  | 
          
          
            | - | 
               | 
            110 | 
                 * @param string $pattern The pattern that must match to the current url.
  | 
          
          
            | - | 
               | 
            111 | 
                 */
  | 
          
          
            | - | 
               | 
            112 | 
                public function the_url_should_match($pattern) {
  | 
          
          
            | - | 
               | 
            113 | 
                    $url = $this->getSession()->getCurrentUrl();
  | 
          
          
            | - | 
               | 
            114 | 
             
  | 
          
          
            | - | 
               | 
            115 | 
                    if (preg_match($pattern, $url) === 1) {
  | 
          
          
            | - | 
               | 
            116 | 
                        return;
  | 
          
          
            | - | 
               | 
            117 | 
                    }
  | 
          
          
            | 98 | 
                public function i_am_on_course_index() {
  | 
            118 | 
             
  | 
          
          
            | Línea 99... | 
            Línea 119... | 
          
          
            | 99 | 
                    $this->execute('behat_general::i_visit', ['/course/index.php']);
  | 
            119 | 
                    throw new ExpectationException(sprintf('The url "%s" should match with %s', $url, $pattern), $this->getSession());
  | 
          
          
            | 100 | 
                }
  | 
            120 | 
                }
  | 
          
          
            | 101 | 
             
  | 
            121 | 
             
  | 
          
          
            | Línea 132... | 
            Línea 152... | 
          
          
            | 132 | 
                    }
  | 
            152 | 
                    }
  | 
          
          
            | Línea 133... | 
            Línea 153... | 
          
          
            | 133 | 
             
  | 
            153 | 
             
  | 
          
          
            | 134 | 
                    // Getting the refresh time and the url if present.
  | 
            154 | 
                    // Getting the refresh time and the url if present.
  | 
          
          
            | Línea 135... | 
            Línea 155... | 
          
          
            | 135 | 
                    if (strstr($content, 'url') != false) {
  | 
            155 | 
                    if (strstr($content, 'url') != false) {
  | 
          
          
            | Línea 136... | 
            Línea 156... | 
          
          
            | 136 | 
             
  | 
            156 | 
             
  | 
          
          
            | 137 | 
                        list($waittime, $url) = explode(';', $content);
  | 
            157 | 
                        [$waittime, $url] = explode(';', $content);
  | 
          
          
            | Línea 138... | 
            Línea 158... | 
          
          
            | 138 | 
             
  | 
            158 | 
             
  | 
          
          
            | Línea 440... | 
            Línea 460... | 
          
          
            | 440 | 
                 * @param string $element Element we look for
  | 
            460 | 
                 * @param string $element Element we look for
  | 
          
          
            | 441 | 
                 * @param string $selectortype The type of what we look for
  | 
            461 | 
                 * @param string $selectortype The type of what we look for
  | 
          
          
            | 442 | 
                 */
  | 
            462 | 
                 */
  | 
          
          
            | 443 | 
                public function i_click_on_confirming_the_dialogue($element, $selectortype) {
  | 
            463 | 
                public function i_click_on_confirming_the_dialogue($element, $selectortype) {
  | 
          
          
            | 444 | 
                    $this->i_click_on($element, $selectortype);
  | 
            464 | 
                    $this->i_click_on($element, $selectortype);
  | 
          
          
            | 445 | 
                    $this->execute('behat_general::accept_currently_displayed_alert_dialog', []);
  | 
            465 | 
                    $this->execute([self::class, 'accept_currently_displayed_alert_dialog'], []);
  | 
          
          
            | 446 | 
                    $this->wait_until_the_page_is_ready();
  | 
            466 | 
                    $this->wait_until_the_page_is_ready();
  | 
          
          
            | 447 | 
                }
  | 
            467 | 
                }
  | 
          
          
            | Línea 448... | 
            Línea 468... | 
          
          
            | 448 | 
             
  | 
            468 | 
             
  | 
          
          
            | 449 | 
                /**
  | 
            469 | 
                /**
  | 
          
          
            | Línea 454... | 
            Línea 474... | 
          
          
            | 454 | 
                 * @param string $element Element we look for
  | 
            474 | 
                 * @param string $element Element we look for
  | 
          
          
            | 455 | 
                 * @param string $selectortype The type of what we look for
  | 
            475 | 
                 * @param string $selectortype The type of what we look for
  | 
          
          
            | 456 | 
                 */
  | 
            476 | 
                 */
  | 
          
          
            | 457 | 
                public function i_click_on_dismissing_the_dialogue($element, $selectortype) {
  | 
            477 | 
                public function i_click_on_dismissing_the_dialogue($element, $selectortype) {
  | 
          
          
            | 458 | 
                    $this->i_click_on($element, $selectortype);
  | 
            478 | 
                    $this->i_click_on($element, $selectortype);
  | 
          
          
            | 459 | 
                    $this->execute('behat_general::dismiss_currently_displayed_alert_dialog', []);
  | 
            479 | 
                    $this->execute([self::class, 'dismiss_currently_displayed_alert_dialog'], []);
  | 
          
          
            | 460 | 
                    $this->wait_until_the_page_is_ready();
  | 
            480 | 
                    $this->wait_until_the_page_is_ready();
  | 
          
          
            | 461 | 
                }
  | 
            481 | 
                }
  | 
          
          
            | Línea 462... | 
            Línea 482... | 
          
          
            | 462 | 
             
  | 
            482 | 
             
  | 
          
          
            | 463 | 
                /**
  | 
            483 | 
                /**
  | 
          
          
            | Línea 972... | 
            Línea 992... | 
          
          
            | 972 | 
                        // Get the container node.
  | 
            992 | 
                        // Get the container node.
  | 
          
          
            | 973 | 
                        $containernode = $this->get_selected_node($containerselectortype, $containerelement);
  | 
            993 | 
                        $containernode = $this->get_selected_node($containerselectortype, $containerelement);
  | 
          
          
            | 974 | 
                        $msg .= " in the '{$containerelement}' '{$containerselectortype}'";
  | 
            994 | 
                        $msg .= " in the '{$containerelement}' '{$containerselectortype}'";
  | 
          
          
            | 975 | 
                    }
  | 
            995 | 
                    }
  | 
          
          
            | Línea 976... | 
            Línea 996... | 
          
          
            | 976 | 
             
  | 
            996 | 
             
  | 
          
          
            | 977 | 
                    list($preselector, $prelocator) = $this->transform_selector($preselectortype, $preelement);
  | 
            997 | 
                    [$preselector, $prelocator] = $this->transform_selector($preselectortype, $preelement);
  | 
          
          
            | Línea 978... | 
            Línea 998... | 
          
          
            | 978 | 
                    list($postselector, $postlocator) = $this->transform_selector($postselectortype, $postelement);
  | 
            998 | 
                    [$postselector, $postlocator] = $this->transform_selector($postselectortype, $postelement);
  | 
          
          
            | 979 | 
             
  | 
            999 | 
             
  | 
          
          
            | 980 | 
                    $newlines = [
  | 
            - | 
               | 
          
          
            | 981 | 
                        "\r\n",
  | 
            - | 
               | 
          
          
            | 982 | 
                        "\r",
  | 
            1000 | 
                    $prexpath = $this->prepare_xpath_for_javascript(
  | 
          
          
            | 983 | 
                        "\n",
  | 
            1001 | 
                        $this->find($preselector, $prelocator, false, $containernode)->getXpath()
  | 
          
          
            | 984 | 
                    ];
  | 
            1002 | 
                    );
  | 
          
          
            | - | 
               | 
            1003 | 
                    $postxpath = $this->prepare_xpath_for_javascript(
  | 
          
          
            | Línea 985... | 
            Línea 1004... | 
          
          
            | 985 | 
                    $prexpath = str_replace($newlines, ' ', $this->find($preselector, $prelocator, false, $containernode)->getXpath());
  | 
            1004 | 
                        $this->find($postselector, $postlocator, false, $containernode)->getXpath()
  | 
          
          
            | 986 | 
                    $postxpath = str_replace($newlines, ' ', $this->find($postselector, $postlocator, false, $containernode)->getXpath());
  | 
            1005 | 
                    );
  | 
          
          
            | 987 | 
             
  | 
            1006 | 
             
  | 
          
          
            | 988 | 
                    if ($this->running_javascript()) {
  | 
            1007 | 
                    if ($this->running_javascript()) {
  | 
          
          
            | Línea 1144... | 
            Línea 1163... | 
          
          
            | 1144 | 
                 * This step triggers cron like a user would do going to admin/cron.php.
  | 
            1163 | 
                 * This step triggers cron like a user would do going to admin/cron.php.
  | 
          
          
            | 1145 | 
                 *
  | 
            1164 | 
                 *
  | 
          
          
            | 1146 | 
                 * @Given /^I trigger cron$/
  | 
            1165 | 
                 * @Given /^I trigger cron$/
  | 
          
          
            | 1147 | 
                 */
  | 
            1166 | 
                 */
  | 
          
          
            | 1148 | 
                public function i_trigger_cron() {
  | 
            1167 | 
                public function i_trigger_cron() {
  | 
          
          
            | 1149 | 
                    $this->execute('behat_general::i_visit', ['/admin/cron.php']);
  | 
            1168 | 
                    $this->execute([self::class, 'i_visit'], ['/admin/cron.php']);
  | 
          
          
            | 1150 | 
                }
  | 
            1169 | 
                }
  | 
          
          
            | Línea 1151... | 
            Línea 1170... | 
          
          
            | 1151 | 
             
  | 
            1170 | 
             
  | 
          
          
            | 1152 | 
                /**
  | 
            1171 | 
                /**
  | 
          
          
            | 1153 | 
                 * Runs a scheduled task immediately, given full class name.
  | 
            1172 | 
                 * Runs a scheduled task immediately, given full class name.
  | 
          
          
            | Línea 1325... | 
            Línea 1344... | 
          
          
            | 1325 | 
                 * Example: I change window size to "small" or I change window size to "1024x768"
  | 
            1344 | 
                 * Example: I change window size to "small" or I change window size to "1024x768"
  | 
          
          
            | 1326 | 
                 * or I change viewport size to "800x600". The viewport option is useful to guarantee that the
  | 
            1345 | 
                 * or I change viewport size to "800x600". The viewport option is useful to guarantee that the
  | 
          
          
            | 1327 | 
                 * browser window has same viewport size even when you run Behat on multiple operating systems.
  | 
            1346 | 
                 * browser window has same viewport size even when you run Behat on multiple operating systems.
  | 
          
          
            | 1328 | 
                 *
  | 
            1347 | 
                 *
  | 
          
          
            | 1329 | 
                 * @throws ExpectationException
  | 
            1348 | 
                 * @throws ExpectationException
  | 
          
          
            | 1330 | 
                 * @Then /^I change (window|viewport) size to "(mobile|tablet|small|medium|large|\d+x\d+)"$/
  | 
            1349 | 
                 * @Then /^I change (window|viewport) size to "(mobile|tablet|small|medium|large|\d+x\d+)"( without runtime scaling)?$/
  | 
          
          
            | 1331 | 
                 * @Then /^I change the (window|viewport) size to "(mobile|tablet|small|medium|large|\d+x\d+)"$/
  | 
            1350 | 
                 * @Then /^I change the (window|viewport) size to "(mobile|tablet|small|medium|large|\d+x\d+)"( without runtime scaling)?$/
  | 
          
          
            | - | 
               | 
            1351 | 
                 * @param string $windowviewport Whether this is a window or viewport size hcange
  | 
          
          
            | 1332 | 
                 * @param string $windowsize size of the window (mobile|tablet|small|medium|large|wxh).
  | 
            1352 | 
                 * @param string $windowsize size of the window (mobile|tablet|small|medium|large|wxh).
  | 
          
          
            | - | 
               | 
            1353 | 
                 * @param null|string $scale whether to lock runtime scaling (string) or to allow it (null)
  | 
          
          
            | 1333 | 
                 */
  | 
            1354 | 
                 */
  | 
          
          
            | 1334 | 
                public function i_change_window_size_to($windowviewport, $windowsize) {
  | 
            1355 | 
                public function i_change_window_size_to(
  | 
          
          
            | - | 
               | 
            1356 | 
                    $windowviewport,
  | 
          
          
            | - | 
               | 
            1357 | 
                    $windowsize,
  | 
          
          
            | - | 
               | 
            1358 | 
                    ?string $scale = null,
  | 
          
          
            | - | 
               | 
            1359 | 
                ): void {
  | 
          
          
            | - | 
               | 
            1360 | 
                    $this->resize_window(
  | 
          
          
            | - | 
               | 
            1361 | 
                        $windowsize,
  | 
          
          
            | 1335 | 
                    $this->resize_window($windowsize, $windowviewport === 'viewport');
  | 
            1362 | 
                        $windowviewport === 'viewport',
  | 
          
          
            | - | 
               | 
            1363 | 
                        $scale === null,
  | 
          
          
            | - | 
               | 
            1364 | 
                    );
  | 
          
          
            | 1336 | 
                }
  | 
            1365 | 
                }
  | 
          
          
            | Línea 1337... | 
            Línea 1366... | 
          
          
            | 1337 | 
             
  | 
            1366 | 
             
  | 
          
          
            | 1338 | 
                /**
  | 
            1367 | 
                /**
  | 
          
          
            | 1339 | 
                 * Checks whether there the specified attribute is set or not.
  | 
            1368 | 
                 * Checks whether there the specified attribute is set or not.
  | 
          
          
            | Línea 1437... | 
            Línea 1466... | 
          
          
            | 1437 | 
             
  | 
            1466 | 
             
  | 
          
          
            | 1438 | 
                    // Check if value exists in specific row/column.
  | 
            1467 | 
                    // Check if value exists in specific row/column.
  | 
          
          
            | 1439 | 
                    // Get row xpath.
  | 
            1468 | 
                    // Get row xpath.
  | 
          
          
            | 1440 | 
                    // Some drivers make XPath relative to the current context, so use descendant.
  | 
            1469 | 
                    // Some drivers make XPath relative to the current context, so use descendant.
  | 
          
          
            | - | 
               | 
            1470 | 
                    $rowxpath = $tablexpath . "/tbody/tr[descendant::*[@class='rowtitle'][normalize-space(.)=" . $rowliteral . "] | " . "
  | 
          
          
            | 1441 | 
                    $rowxpath = $tablexpath . "/tbody/tr[descendant::*[@class='rowtitle'][normalize-space(.)=" . $rowliteral . "] | " . "
  | 
            1471 | 
                        descendant::th[contains(normalize-space(.)," . $rowliteral . ")] | " . "
  | 
          
          
            | Línea 1442... | 
            Línea 1472... | 
          
          
            | 1442 | 
                        descendant::th[normalize-space(.)=" . $rowliteral . "] | descendant::td[normalize-space(.)=" . $rowliteral . "]]";
  | 
            1472 | 
                        descendant::td[contains(normalize-space(.)," . $rowliteral . ")]]";
  | 
          
          
            | Línea 1443... | 
            Línea 1473... | 
          
          
            | 1443 | 
             
  | 
            1473 | 
             
  | 
          
          
            | 1444 | 
                    $columnvaluexpath = $rowxpath . $columnpositionxpath . "[contains(normalize-space(.)," . $valueliteral . ")]";
  | 
            1474 | 
                    $columnvaluexpath = $rowxpath . $columnpositionxpath . "[contains(normalize-space(.)," . $valueliteral . ")]";
  | 
          
          
            | Línea 1632... | 
            Línea 1662... | 
          
          
            | 1632 | 
                }
  | 
            1662 | 
                }
  | 
          
          
            | Línea 1633... | 
            Línea 1663... | 
          
          
            | 1633 | 
             
  | 
            1663 | 
             
  | 
          
          
            | 1634 | 
                /**
  | 
            1664 | 
                /**
  | 
          
          
            | 1635 | 
                 * Given the text of a link, download the linked file and return the contents.
  | 
            1665 | 
                 * Given the text of a link, download the linked file and return the contents.
  | 
          
          
            | 1636 | 
                 *
  | 
            1666 | 
                 *
  | 
          
          
            | 1637 | 
                 * This is a helper method used by {@link following_should_download_bytes()}
  | 
            1667 | 
                 * A helper method used by the steps in {@see behat_download}, and the legacy
  | 
          
          
            | 1638 | 
                 * and {@link following_should_download_between_and_bytes()}
  | 
            1668 | 
                 * {@see following_should_download_bytes()} and {@see following_should_download_between_and_bytes()}.
  | 
          
          
            | 1639 | 
                 *
  | 
            1669 | 
                 *
  | 
          
          
            | - | 
               | 
            1670 | 
                 * @param string $link the text of the link.
  | 
          
          
            | - | 
               | 
            1671 | 
                 * @param string $containerlocator optional container element locator.
  | 
          
          
            | - | 
               | 
            1672 | 
                 * @param string $containertype optional container element selector type.
  | 
          
          
            | 1640 | 
                 * @param string $link the text of the link.
  | 
            1673 | 
                 *
  | 
          
          
            | 1641 | 
                 * @return string the content of the downloaded file.
  | 
            1674 | 
                 * @return string the content of the downloaded file.
  | 
          
          
            | 1642 | 
                 */
  | 
            1675 | 
                 */
  | 
          
          
            | - | 
               | 
            1676 | 
                public function download_file_from_link(string $link, string $containerlocator = '', string $containertype = ''): string {
  | 
          
          
            | 1643 | 
                public function download_file_from_link($link) {
  | 
            1677 | 
             
  | 
          
          
            | - | 
               | 
            1678 | 
                    // Find the link.
  | 
          
          
            | - | 
               | 
            1679 | 
                    if ($containerlocator !== '' && $containertype !== '') {
  | 
          
          
            | - | 
               | 
            1680 | 
                        $linknode = $this->get_node_in_container('link', $link, $containertype, $containerlocator);
  | 
          
          
            | 1644 | 
                    // Find the link.
  | 
            1681 | 
                    } else {
  | 
          
          
            | - | 
               | 
            1682 | 
                        $linknode = $this->find_link($link);
  | 
          
          
            | - | 
               | 
            1683 | 
                    }
  | 
          
          
            | 1645 | 
                    $linknode = $this->find_link($link);
  | 
            1684 | 
             
  | 
          
          
            | Línea 1646... | 
            Línea 1685... | 
          
          
            | 1646 | 
                    $this->ensure_node_is_visible($linknode);
  | 
            1685 | 
                    $this->ensure_node_is_visible($linknode);
  | 
          
          
            | 1647 | 
             
  | 
            1686 | 
             
  | 
          
          
            | 1648 | 
                    // Get the href and check it.
  | 
            1687 | 
                    // Get the href and check it.
  | 
          
          
            | Línea 1662... | 
            Línea 1701... | 
          
          
            | 1662 | 
                }
  | 
            1701 | 
                }
  | 
          
          
            | Línea 1663... | 
            Línea 1702... | 
          
          
            | 1663 | 
             
  | 
            1702 | 
             
  | 
          
          
            | 1664 | 
                /**
  | 
            1703 | 
                /**
  | 
          
          
            | 1665 | 
                 * Downloads the file from a link on the page and checks the size.
  | 
            1704 | 
                 * Downloads the file from a link on the page and checks the size.
  | 
          
          
            | - | 
               | 
            1705 | 
                 *
  | 
          
          
            | - | 
               | 
            1706 | 
                 * Not recommended any more. The steps in {@see behat_download} are much better!
  | 
          
          
            | 1666 | 
                 *
  | 
            1707 | 
                 *
  | 
          
          
            | 1667 | 
                 * Only works if the link has an href attribute. Javascript downloads are
  | 
            1708 | 
                 * Only works if the link has an href attribute. Javascript downloads are
  | 
          
          
            | 1668 | 
                 * not supported. Currently, the href must be an absolute URL.
  | 
            1709 | 
                 * not supported. Currently, the href must be an absolute URL.
  | 
          
          
            | 1669 | 
                 *
  | 
            1710 | 
                 *
  | 
          
          
            | 1670 | 
                 * @Then /^following "(?P<link_string>[^"]*)" should download "(?P<expected_bytes>\d+)" bytes$/
  | 
            1711 | 
                 * @Then /^following "(?P<link_string>[^"]*)" should download "(?P<expected_bytes>\d+)" bytes$/
  | 
          
          
            | Línea 1695... | 
            Línea 1736... | 
          
          
            | 1695 | 
                }
  | 
            1736 | 
                }
  | 
          
          
            | Línea 1696... | 
            Línea 1737... | 
          
          
            | 1696 | 
             
  | 
            1737 | 
             
  | 
          
          
            | 1697 | 
                /**
  | 
            1738 | 
                /**
  | 
          
          
            | 1698 | 
                 * Downloads the file from a link on the page and checks the size is in a given range.
  | 
            1739 | 
                 * Downloads the file from a link on the page and checks the size is in a given range.
  | 
          
          
            | - | 
               | 
            1740 | 
                 *
  | 
          
          
            | - | 
               | 
            1741 | 
                 * Not recommended any more. The steps in {@see behat_download} are much better!
  | 
          
          
            | 1699 | 
                 *
  | 
            1742 | 
                 *
  | 
          
          
            | 1700 | 
                 * Only works if the link has an href attribute. Javascript downloads are
  | 
            1743 | 
                 * Only works if the link has an href attribute. Javascript downloads are
  | 
          
          
            | 1701 | 
                 * not supported. Currently, the href must be an absolute URL.
  | 
            1744 | 
                 * not supported. Currently, the href must be an absolute URL.
  | 
          
          
            | 1702 | 
                 *
  | 
            1745 | 
                 *
  | 
          
          
            | 1703 | 
                 * The range includes the endpoints. That is, a 10 byte file in considered to
  | 
            1746 | 
                 * The range includes the endpoints. That is, a 10 byte file in considered to
  | 
          
          
            | 1704 | 
                 * be between "5" and "10" bytes, and between "10" and "20" bytes.
  | 
            1747 | 
                 * be between "5" and "10" bytes, and between "10" and "20" bytes.
  | 
          
          
            | 1705 | 
                 *
  | 
            1748 | 
                 *
  | 
          
          
            | 1706 | 
                 * @Then /^following "(?P<link_string>[^"]*)" should download between "(?P<min_bytes>\d+)" and "(?P<max_bytes>\d+)" bytes$/
  | 
            1749 | 
                 * @Then /^following "(?P<link_string>[^"]*)" should download between "(?P<min_bytes>\d+)" and "(?P<max_bytes>\d+)" bytes$/
  | 
          
          
            | 1707 | 
                 * @throws ExpectationException
  | 
            1750 | 
                 *
  | 
          
          
            | 1708 | 
                 * @param string $link the text of the link.
  | 
            1751 | 
                 * @param string $link the text of the link.
  | 
          
          
            | 1709 | 
                 * @param number $minexpectedsize the minimum expected file size in bytes.
  | 
            1752 | 
                 * @param number $minexpectedsize the minimum expected file size in bytes.
  | 
          
          
            | - | 
               | 
            1753 | 
                 * @param number $maxexpectedsize the maximum expected file size in bytes.
  | 
          
          
            | 1710 | 
                 * @param number $maxexpectedsize the maximum expected file size in bytes.
  | 
            1754 | 
                 * @throws ExpectationException
  | 
          
          
            | 1711 | 
                 */
  | 
            1755 | 
                 */
  | 
          
          
            | 1712 | 
                public function following_should_download_between_and_bytes($link, $minexpectedsize, $maxexpectedsize) {
  | 
            1756 | 
                public function following_should_download_between_and_bytes($link, $minexpectedsize, $maxexpectedsize) {
  | 
          
          
            | 1713 | 
                    // If the minimum is greater than the maximum then swap the values.
  | 
            1757 | 
                    // If the minimum is greater than the maximum then swap the values.
  | 
          
          
            | 1714 | 
                    if ((int)$minexpectedsize > (int)$maxexpectedsize) {
  | 
            1758 | 
                    if ((int)$minexpectedsize > (int)$maxexpectedsize) {
  | 
          
          
            | 1715 | 
                        list($minexpectedsize, $maxexpectedsize) = array($maxexpectedsize, $minexpectedsize);
  | 
            1759 | 
                        [$minexpectedsize, $maxexpectedsize] = [$maxexpectedsize, $minexpectedsize];
  | 
          
          
            | Línea 1716... | 
            Línea 1760... | 
          
          
            | 1716 | 
                    }
  | 
            1760 | 
                    }
  | 
          
          
            | Línea 1717... | 
            Línea 1761... | 
          
          
            | 1717 | 
             
  | 
            1761 | 
             
  | 
          
          
            | Línea 2074... | 
            Línea 2118... | 
          
          
            | 2074 | 
                    $node = $this->get_selected_node($selectortype, $element);
  | 
            2118 | 
                    $node = $this->get_selected_node($selectortype, $element);
  | 
          
          
            | 2075 | 
                    $modifier = null;
  | 
            2119 | 
                    $modifier = null;
  | 
          
          
            | 2076 | 
                    $validmodifiers = array('ctrl', 'alt', 'shift', 'meta');
  | 
            2120 | 
                    $validmodifiers = array('ctrl', 'alt', 'shift', 'meta');
  | 
          
          
            | 2077 | 
                    $char = $key;
  | 
            2121 | 
                    $char = $key;
  | 
          
          
            | 2078 | 
                    if (strpos($key, '-')) {
  | 
            2122 | 
                    if (strpos($key, '-')) {
  | 
          
          
            | 2079 | 
                        list($modifier, $char) = preg_split('/-/', $key, 2);
  | 
            2123 | 
                        [$modifier, $char] = preg_split('/-/', $key, 2);
  | 
          
          
            | 2080 | 
                        $modifier = strtolower($modifier);
  | 
            2124 | 
                        $modifier = strtolower($modifier);
  | 
          
          
            | 2081 | 
                        if (!in_array($modifier, $validmodifiers)) {
  | 
            2125 | 
                        if (!in_array($modifier, $validmodifiers)) {
  | 
          
          
            | 2082 | 
                            throw new ExpectationException(sprintf('Unknown key modifier: %s.', $modifier),
  | 
            2126 | 
                            throw new ExpectationException(sprintf('Unknown key modifier: %s.', $modifier),
  | 
          
          
            | 2083 | 
                                $this->getSession());
  | 
            2127 | 
                                $this->getSession());
  | 
          
          
            | 2084 | 
                        }
  | 
            2128 | 
                        }
  | 
          
          
            | Línea 2105... | 
            Línea 2149... | 
          
          
            | 2105 | 
                    if (!$this->running_javascript()) {
  | 
            2149 | 
                    if (!$this->running_javascript()) {
  | 
          
          
            | 2106 | 
                        throw new DriverException('Tab press step is not available with Javascript disabled');
  | 
            2150 | 
                        throw new DriverException('Tab press step is not available with Javascript disabled');
  | 
          
          
            | 2107 | 
                    }
  | 
            2151 | 
                    }
  | 
          
          
            | 2108 | 
                    // Gets the node based on the requested selector type and locator.
  | 
            2152 | 
                    // Gets the node based on the requested selector type and locator.
  | 
          
          
            | 2109 | 
                    $node = $this->get_selected_node($selectortype, $element);
  | 
            2153 | 
                    $node = $this->get_selected_node($selectortype, $element);
  | 
          
          
            | 2110 | 
                    $this->execute('behat_general::i_click_on', [$node, 'NodeElement']);
  | 
            2154 | 
                    $this->execute([self::class, 'i_click_on'], [$node, 'NodeElement']);
  | 
          
          
            | 2111 | 
                    $this->execute('behat_general::i_press_named_key', ['', 'tab']);
  | 
            2155 | 
                    $this->execute([self::class, 'i_press_named_key'], ['', 'tab']);
  | 
          
          
            | 2112 | 
                }
  | 
            2156 | 
                }
  | 
          
          
            | Línea 2113... | 
            Línea 2157... | 
          
          
            | 2113 | 
             
  | 
            2157 | 
             
  | 
          
          
            | 2114 | 
                /**
  | 
            2158 | 
                /**
  | 
          
          
            | 2115 | 
                 * Checks if database family used is using one of the specified, else skip. (mysql, postgres, mssql, oracle, etc.)
  | 
            2159 | 
                 * Checks if database family used is using one of the specified, else skip. (mysql, postgres, mssql, etc.)
  | 
          
          
            | 2116 | 
                 *
  | 
            2160 | 
                 *
  | 
          
          
            | 2117 | 
                 * @Given /^database family used is one of the following:$/
  | 
            2161 | 
                 * @Given /^database family used is one of the following:$/
  | 
          
          
            | 2118 | 
                 * @param TableNode $databasefamilies list of database.
  | 
            2162 | 
                 * @param TableNode $databasefamilies list of database.
  | 
          
          
            | 2119 | 
                 * @return void.
  | 
            2163 | 
                 * @return void.
  | 
          
          
            | Línea 2219... | 
            Línea 2263... | 
          
          
            | 2219 | 
                 * @param string $shift string optional step verifier
  | 
            2263 | 
                 * @param string $shift string optional step verifier
  | 
          
          
            | 2220 | 
                 * @throws DriverException
  | 
            2264 | 
                 * @throws DriverException
  | 
          
          
            | 2221 | 
                 */
  | 
            2265 | 
                 */
  | 
          
          
            | 2222 | 
                public function i_manually_press_tab($shift = '') {
  | 
            2266 | 
                public function i_manually_press_tab($shift = '') {
  | 
          
          
            | 2223 | 
                    if (empty($shift)) {
  | 
            2267 | 
                    if (empty($shift)) {
  | 
          
          
            | 2224 | 
                        $this->execute('behat_general::i_press_named_key', ['', 'tab']);
  | 
            2268 | 
                        $this->execute([self::class, 'i_press_named_key'], ['', 'tab']);
  | 
          
          
            | 2225 | 
                    } else {
  | 
            2269 | 
                    } else {
  | 
          
          
            | 2226 | 
                        $this->execute('behat_general::i_press_named_key', ['shift', 'tab']);
  | 
            2270 | 
                        $this->execute([self::class, 'i_press_named_key'], ['shift', 'tab']);
  | 
          
          
            | 2227 | 
                    }
  | 
            2271 | 
                    }
  | 
          
          
            | 2228 | 
                }
  | 
            2272 | 
                }
  | 
          
          
            | Línea 2229... | 
            Línea 2273... | 
          
          
            | 2229 | 
             
  | 
            2273 | 
             
  | 
          
          
            | 2230 | 
                /**
  | 
            2274 | 
                /**
  | 
          
          
            | Línea 2317... | 
            Línea 2361... | 
          
          
            | 2317 | 
                 *
  | 
            2361 | 
                 *
  | 
          
          
            | 2318 | 
                 * @When /^I press enter/
  | 
            2362 | 
                 * @When /^I press enter/
  | 
          
          
            | 2319 | 
                 * @throws DriverException
  | 
            2363 | 
                 * @throws DriverException
  | 
          
          
            | 2320 | 
                 */
  | 
            2364 | 
                 */
  | 
          
          
            | 2321 | 
                public function i_manually_press_enter() {
  | 
            2365 | 
                public function i_manually_press_enter() {
  | 
          
          
            | 2322 | 
                    $this->execute('behat_general::i_press_named_key', ['', 'enter']);
  | 
            2366 | 
                    $this->execute([self::class, 'i_press_named_key'], ['', 'enter']);
  | 
          
          
            | 2323 | 
                }
  | 
            2367 | 
                }
  | 
          
          
            | Línea 2324... | 
            Línea 2368... | 
          
          
            | 2324 | 
             
  | 
            2368 | 
             
  | 
          
          
            | 2325 | 
                /**
  | 
            2369 | 
                /**
  | 
          
          
            | 2326 | 
                 * Visit a local URL relative to the behat root.
  | 
            2370 | 
                 * Visit a local URL relative to the behat root.
  | 
          
          
            | Línea 2352... | 
            Línea 2396... | 
          
          
            | 2352 | 
                 *
  | 
            2396 | 
                 *
  | 
          
          
            | 2353 | 
                 * @param string $tabname
  | 
            2397 | 
                 * @param string $tabname
  | 
          
          
            | 2354 | 
                 */
  | 
            2398 | 
                 */
  | 
          
          
            | 2355 | 
                public function i_click_on_the_dynamic_tab(string $tabname): void {
  | 
            2399 | 
                public function i_click_on_the_dynamic_tab(string $tabname): void {
  | 
          
          
            | 2356 | 
                    $xpath = "//*[@id='dynamictabs-tabs'][descendant::a[contains(text(), '" . $this->escape($tabname) . "')]]";
  | 
            2400 | 
                    $xpath = "//*[@id='dynamictabs-tabs'][descendant::a[contains(text(), '" . $this->escape($tabname) . "')]]";
  | 
          
          
            | 2357 | 
                    $this->execute('behat_general::i_click_on_in_the',
  | 
            2401 | 
                    $this->execute([self::class, 'i_click_on_in_the'],
  | 
          
          
            | 2358 | 
                        [$tabname, 'link', $xpath, 'xpath_element']);
  | 
            2402 | 
                        [$tabname, 'link', $xpath, 'xpath_element']);
  | 
          
          
            | 2359 | 
                }
  | 
            2403 | 
                }
  | 
          
          
            | Línea 2360... | 
            Línea 2404... | 
          
          
            | 2360 | 
             
  | 
            2404 | 
             
  | 
          
          
            | 2361 | 
                /**
  | 
            2405 | 
                /**
  | 
          
          
            | 2362 | 
                 * Enable an specific plugin.
  | 
            2406 | 
                 * Enable an specific plugin.
  | 
          
          
            | 2363 | 
                 *
  | 
            2407 | 
                 *
  | 
          
          
            | 2364 | 
                 * @When /^I enable "(?P<plugin_string>(?:[^"]|\\")*)" "(?P<plugintype_string>[^"]*)" plugin$/
  | 
            2408 | 
                 * @When /^I enable "(?P<plugin_string>(?:[^"]|\\")*)" "(?P<plugintype_string>[^"]*)" plugin$/
  | 
          
          
            | 2365 | 
                 * @param string $plugin Plugin we look for
  | 
            2409 | 
                 * @param string $plugin Plugin we look for
  | 
          
          
            | 2366 | 
                 * @param string $plugintype The type of the plugin
  | 
            2410 | 
                 * @param string $plugintype The type of the plugin
  | 
          
          
            | - | 
               | 
            2411 | 
                 */
  | 
          
          
            | 2367 | 
                 */
  | 
            2412 | 
                #[\core\attribute\example('I enable "subsection" "mod" plugin')]
  | 
          
          
            | 2368 | 
                public function i_enable_plugin($plugin, $plugintype) {
  | 
            2413 | 
                public function i_enable_plugin($plugin, $plugintype) {
  | 
          
          
            | 2369 | 
                    $class = core_plugin_manager::resolve_plugininfo_class($plugintype);
  | 
            2414 | 
                    $class = core_plugin_manager::resolve_plugininfo_class($plugintype);
  | 
          
          
            | 2370 | 
                    $class::enable_plugin($plugin, true);
  | 
            2415 | 
                    $class::enable_plugin($plugin, true);
  | 
          
          
            | Línea 2371... | 
            Línea 2416... | 
          
          
            | 2371 | 
                }
  | 
            2416 | 
                }
  | 
          
          
            | - | 
               | 
            2417 | 
             
  | 
          
          
            | - | 
               | 
            2418 | 
                /**
  | 
          
          
            | - | 
               | 
            2419 | 
                 * Disable an specific plugin.
  | 
          
          
            | - | 
               | 
            2420 | 
                 *
  | 
          
          
            | - | 
               | 
            2421 | 
                 * @When /^I disable "(?P<plugin_string>(?:[^"]|\\")*)" "(?P<plugintype_string>[^"]*)" plugin$/
  | 
          
          
            | - | 
               | 
            2422 | 
                 * @param string $plugin Plugin we look for
  | 
          
          
            | - | 
               | 
            2423 | 
                 * @param string $plugintype The type of the plugin
  | 
          
          
            | - | 
               | 
            2424 | 
                 */
  | 
          
          
            | - | 
               | 
            2425 | 
                #[\core\attribute\example('I disable "page" "mod" plugin')]
  | 
          
          
            | - | 
               | 
            2426 | 
                public function i_disable_plugin($plugin, $plugintype) {
  | 
          
          
            | - | 
               | 
            2427 | 
                    $class = core_plugin_manager::resolve_plugininfo_class($plugintype);
  | 
          
          
            | - | 
               | 
            2428 | 
                    $class::enable_plugin($plugin, false);
  | 
          
          
            | - | 
               | 
            2429 | 
                }
  | 
          
          
            | 2372 | 
             
  | 
            2430 | 
             
  | 
          
          
            | 2373 | 
                /**
  | 
            2431 | 
                /**
  | 
          
          
            | 2374 | 
                 * Set the default text editor to the named text editor.
  | 
            2432 | 
                 * Set the default text editor to the named text editor.
  | 
          
          
            | 2375 | 
                 *
  | 
            2433 | 
                 *
  | 
          
          
            | 2376 | 
                 * @Given the default editor is set to :editor
  | 
            2434 | 
                 * @Given the default editor is set to :editor
  | 
          
          
            | Línea 2388... | 
            Línea 2446... | 
          
          
            | 2388 | 
                            $this->getSession()
  | 
            2446 | 
                            $this->getSession()
  | 
          
          
            | 2389 | 
                        );
  | 
            2447 | 
                        );
  | 
          
          
            | 2390 | 
                    }
  | 
            2448 | 
                    }
  | 
          
          
            | Línea 2391... | 
            Línea 2449... | 
          
          
            | 2391 | 
             
  | 
            2449 | 
             
  | 
          
          
            | 2392 | 
                    // Make the provided editor the default one in $CFG->texteditors by
  | 
            2450 | 
                    // Make the provided editor the default one in $CFG->texteditors by
  | 
          
          
            | 2393 | 
                    // moving it to the first [editor],atto,tiny,textarea on the list.
  | 
            2451 | 
                    // moving it to the first [editor],tiny,textarea on the list.
  | 
          
          
            | 2394 | 
                    $list = explode(',', $CFG->texteditors);
  | 
            2452 | 
                    $list = explode(',', $CFG->texteditors);
  | 
          
          
            | 2395 | 
                    array_unshift($list, $editor);
  | 
            2453 | 
                    array_unshift($list, $editor);
  | 
          
          
            | Línea 2396... | 
            Línea 2454... | 
          
          
            | 2396 | 
                    $list = array_unique($list);
  | 
            2454 | 
                    $list = array_unique($list);
  | 
          
          
            | Línea 2467... | 
            Línea 2525... | 
          
          
            | 2467 | 
                            "'$title' was not found from the current page title '$actualtitle'",
  | 
            2525 | 
                            "'$title' was not found from the current page title '$actualtitle'",
  | 
          
          
            | 2468 | 
                            $session
  | 
            2526 | 
                            $session
  | 
          
          
            | 2469 | 
                        );
  | 
            2527 | 
                        );
  | 
          
          
            | 2470 | 
                    }
  | 
            2528 | 
                    }
  | 
          
          
            | 2471 | 
                }
  | 
            2529 | 
                }
  | 
          
          
            | - | 
               | 
            2530 | 
             
  | 
          
          
            | - | 
               | 
            2531 | 
                /**
  | 
          
          
            | - | 
               | 
            2532 | 
                 * Toggles the specified admin switch.
  | 
          
          
            | - | 
               | 
            2533 | 
                 *
  | 
          
          
            | - | 
               | 
            2534 | 
                 * @When /^I toggle the "(?P<element_string>(?:[^"]|\\")*)" admin switch "(?P<state_string>on|off)"$/
  | 
          
          
            | - | 
               | 
            2535 | 
                 * @param string $element Element we look for
  | 
          
          
            | - | 
               | 
            2536 | 
                 * @param string $state The state of the switch
  | 
          
          
            | - | 
               | 
            2537 | 
                 * @throws ElementNotFoundException Thrown by behat_base::find
  | 
          
          
            | - | 
               | 
            2538 | 
                 */
  | 
          
          
            | - | 
               | 
            2539 | 
                public function i_toggle_admin_switch($element, $state) {
  | 
          
          
            | - | 
               | 
            2540 | 
                    // First check we are running Javascript, otherwise explode.
  | 
          
          
            | - | 
               | 
            2541 | 
                    if (!$this->running_javascript()) {
  | 
          
          
            | - | 
               | 
            2542 | 
                        throw new \Behat\Mink\Exception\DriverException('Switches are only available with JavaScript enabled');
  | 
          
          
            | - | 
               | 
            2543 | 
                    }
  | 
          
          
            | - | 
               | 
            2544 | 
             
  | 
          
          
            | - | 
               | 
            2545 | 
                    // Next check that the node is available.
  | 
          
          
            | - | 
               | 
            2546 | 
                    $node = $this->get_selected_node('checkbox', $element);
  | 
          
          
            | - | 
               | 
            2547 | 
                    $this->ensure_node_is_visible($node);
  | 
          
          
            | - | 
               | 
            2548 | 
             
  | 
          
          
            | - | 
               | 
            2549 | 
                    // Update the state of the switch.
  | 
          
          
            | - | 
               | 
            2550 | 
                    $field = $node->getAttribute('id');
  | 
          
          
            | - | 
               | 
            2551 | 
                    if ($state == "on") {
  | 
          
          
            | - | 
               | 
            2552 | 
                        $this->execute([behat_forms::class, 'i_set_the_field_to'], [$field, 1]);
  | 
          
          
            | - | 
               | 
            2553 | 
                    } else if ($state == "off") {
  | 
          
          
            | - | 
               | 
            2554 | 
                        $this->execute([behat_forms::class, 'i_set_the_field_to'], [$field, 0]);
  | 
          
          
            | - | 
               | 
            2555 | 
                    } else {
  | 
          
          
            | - | 
               | 
            2556 | 
                        throw new \Behat\Mink\Exception\ExpectationException('Invalid state for switch: ' . $state, $this->getSession());
  | 
          
          
            | - | 
               | 
            2557 | 
                    }
  | 
          
          
            | - | 
               | 
            2558 | 
             
  | 
          
          
            | - | 
               | 
            2559 | 
                }
  | 
          
          
            | - | 
               | 
            2560 | 
             
  | 
          
          
            | - | 
               | 
            2561 | 
                /**
  | 
          
          
            | - | 
               | 
            2562 | 
                 * Update a stored progress bar.
  | 
          
          
            | - | 
               | 
            2563 | 
                 *
  | 
          
          
            | - | 
               | 
            2564 | 
                 * @Given I set the stored progress bar :idnumber to :percent
  | 
          
          
            | - | 
               | 
            2565 | 
                 * @param string $idnumber The unique idnumber of the stored progress bar.
  | 
          
          
            | - | 
               | 
            2566 | 
                 * @param float $percent The value to update the progress bar to.
  | 
          
          
            | - | 
               | 
            2567 | 
                 */
  | 
          
          
            | - | 
               | 
            2568 | 
                public function i_set_the_stored_progress_bar_to(string $idnumber, float $percent): void {
  | 
          
          
            | - | 
               | 
            2569 | 
                    $progress = \core\output\stored_progress_bar::get_by_idnumber($idnumber);
  | 
          
          
            | - | 
               | 
            2570 | 
                    if (!$progress) {
  | 
          
          
            | - | 
               | 
            2571 | 
                        throw new invalid_parameter_exception('No progress bar with idnumber ' . $idnumber . 'found.');
  | 
          
          
            | - | 
               | 
            2572 | 
                    }
  | 
          
          
            | - | 
               | 
            2573 | 
                    $progress->auto_update(false);
  | 
          
          
            | - | 
               | 
            2574 | 
                    $progress->update_full($percent, '');
  | 
          
          
            | - | 
               | 
            2575 | 
                }
  | 
          
          
            | - | 
               | 
            2576 | 
             
  | 
          
          
            | - | 
               | 
            2577 | 
                /**
  | 
          
          
            | - | 
               | 
            2578 | 
                 * Helper that returns the dropdown node element within a particular search combo box.
  | 
          
          
            | - | 
               | 
            2579 | 
                 *
  | 
          
          
            | - | 
               | 
            2580 | 
                 * @param string $comboboxname The name (label) of the search combo box element. (e.g. "Search users", "Search groups").
  | 
          
          
            | - | 
               | 
            2581 | 
                 * @param string $itemname The name of the combo box item we are searching for. This is only used if $fieldset is set
  | 
          
          
            | - | 
               | 
            2582 | 
                 *                         to true.
  | 
          
          
            | - | 
               | 
            2583 | 
                 * @param bool $fieldset Whether to set the search field of the combo box at the same time
  | 
          
          
            | - | 
               | 
            2584 | 
                 * @return NodeElement
  | 
          
          
            | - | 
               | 
            2585 | 
                 * @throws coding_exception
  | 
          
          
            | - | 
               | 
            2586 | 
                 */
  | 
          
          
            | - | 
               | 
            2587 | 
                private function get_combobox_dropdown_node(string $comboboxname, string $itemname, bool $fieldset = true): NodeElement {
  | 
          
          
            | - | 
               | 
            2588 | 
                    $this->execute([self::class, 'wait_until_the_page_is_ready']);
  | 
          
          
            | - | 
               | 
            2589 | 
             
  | 
          
          
            | - | 
               | 
            2590 | 
                    $comboboxxpath = "//div[contains(@class, 'comboboxsearch') and .//span[text()='{$comboboxname}']]";
  | 
          
          
            | - | 
               | 
            2591 | 
                    $dropdowntriggerxpath = $comboboxxpath . "/descendant::div[contains(@class,'dropdown-toggle')]";
  | 
          
          
            | - | 
               | 
            2592 | 
                    $dropdownxpath = $comboboxxpath . "/descendant::div[contains(@class,'dropdown-menu')]";
  | 
          
          
            | - | 
               | 
            2593 | 
                    $dropdown = $this->find("xpath_element", $dropdownxpath);
  | 
          
          
            | - | 
               | 
            2594 | 
             
  | 
          
          
            | - | 
               | 
            2595 | 
                    // If the dropdown is not visible, open it. Also, ensure that a dropdown trigger element exists.
  | 
          
          
            | - | 
               | 
            2596 | 
                    if ($this->getSession()->getPage()->find('xpath', $dropdowntriggerxpath) && !$dropdown->isVisible()) {
  | 
          
          
            | - | 
               | 
            2597 | 
                        $this->execute([self::class, 'i_click_on'], [$dropdowntriggerxpath, "xpath_element"]);
  | 
          
          
            | - | 
               | 
            2598 | 
                    }
  | 
          
          
            | - | 
               | 
            2599 | 
             
  | 
          
          
            | - | 
               | 
            2600 | 
                    if ($fieldset) {
  | 
          
          
            | - | 
               | 
            2601 | 
                        $this->execute([behat_forms::class, 'set_field_value'], [$comboboxname, $itemname]);
  | 
          
          
            | - | 
               | 
            2602 | 
                        $this->execute([self::class, 'wait_until_exists'], [$itemname, "list_item"]);
  | 
          
          
            | - | 
               | 
            2603 | 
                    }
  | 
          
          
            | - | 
               | 
            2604 | 
             
  | 
          
          
            | - | 
               | 
            2605 | 
                    return $dropdown;
  | 
          
          
            | - | 
               | 
            2606 | 
                }
  | 
          
          
            | - | 
               | 
            2607 | 
             
  | 
          
          
            | - | 
               | 
            2608 | 
                /**
  | 
          
          
            | - | 
               | 
            2609 | 
                 * Confirm if a value exists within the search combo box.
  | 
          
          
            | - | 
               | 
            2610 | 
                 *
  | 
          
          
            | - | 
               | 
            2611 | 
                 * Examples:
  | 
          
          
            | - | 
               | 
            2612 | 
                 * - I confirm "User" exists in the "Search users" search combo box
  | 
          
          
            | - | 
               | 
            2613 | 
                 * - I confirm "Group" exists in the "Search groups" search combo box
  | 
          
          
            | - | 
               | 
            2614 | 
                 * - I confirm "Grade item" exists in the "Search grade items" search combo box
  | 
          
          
            | - | 
               | 
            2615 | 
                 *
  | 
          
          
            | - | 
               | 
            2616 | 
                 * @Given /^I confirm "(?P<itemname>(?:[^"]|\\")*)" exists in the "(?P<comboboxname>(?:[^"]|\\")*)" search combo box$/
  | 
          
          
            | - | 
               | 
            2617 | 
                 * @param string $itemname The name of the combo box item we are searching for. This is only used if $fieldset is set
  | 
          
          
            | - | 
               | 
            2618 | 
                 *                         to true.
  | 
          
          
            | - | 
               | 
            2619 | 
                 * @param string $comboboxname The name (label) of the search combo box element. (e.g. "Search users", "Search groups").
  | 
          
          
            | - | 
               | 
            2620 | 
                 */
  | 
          
          
            | - | 
               | 
            2621 | 
                public function i_confirm_in_search_combobox_exists(string $itemname, string $comboboxname): void {
  | 
          
          
            | - | 
               | 
            2622 | 
                    $this->execute([self::class, 'assert_element_contains_text'],
  | 
          
          
            | - | 
               | 
            2623 | 
                        [$itemname, $this->get_combobox_dropdown_node($comboboxname, $itemname, false), "NodeElement"]);
  | 
          
          
            | - | 
               | 
            2624 | 
                }
  | 
          
          
            | - | 
               | 
            2625 | 
             
  | 
          
          
            | - | 
               | 
            2626 | 
                /**
  | 
          
          
            | - | 
               | 
            2627 | 
                 * Confirm if a value does not exist within the search combo box.
  | 
          
          
            | - | 
               | 
            2628 | 
                 *
  | 
          
          
            | - | 
               | 
            2629 | 
                 * Examples:
  | 
          
          
            | - | 
               | 
            2630 | 
                 * - I confirm "User" does not exist in the "Search users" search combo box
  | 
          
          
            | - | 
               | 
            2631 | 
                 * - I confirm "Group" does not exist in the "Search groups" search combo box
  | 
          
          
            | - | 
               | 
            2632 | 
                 * - I confirm "Grade item" does not exist in the "Search grade items" search combo box
  | 
          
          
            | - | 
               | 
            2633 | 
                 *
  | 
          
          
            | - | 
               | 
            2634 | 
                 * @Given /^I confirm "(?P<itemname>(?:[^"]|\\")*)" does not exist in the "(?P<comboboxname>(?:[^"]|\\")*)" search combo box$/
  | 
          
          
            | - | 
               | 
            2635 | 
                 * @param string $itemname The name of the combo box item we are searching for. This is only used if $fieldset is set
  | 
          
          
            | - | 
               | 
            2636 | 
                 *                         to true.
  | 
          
          
            | - | 
               | 
            2637 | 
                 * @param string $comboboxname The name (label) of the search combo box element. (e.g. "Search users", "Search groups").
  | 
          
          
            | - | 
               | 
            2638 | 
                 */
  | 
          
          
            | - | 
               | 
            2639 | 
                public function i_confirm_in_search_combobox_does_not_exist(string $itemname, string $comboboxname): void {
  | 
          
          
            | - | 
               | 
            2640 | 
                    $this->execute([self::class, 'assert_element_not_contains_text'],
  | 
          
          
            | - | 
               | 
            2641 | 
                        [$itemname, $this->get_combobox_dropdown_node($comboboxname, $itemname, false), "NodeElement"]);
  | 
          
          
            | - | 
               | 
            2642 | 
                }
  | 
          
          
            | - | 
               | 
            2643 | 
             
  | 
          
          
            | - | 
               | 
            2644 | 
                /**
  | 
          
          
            | - | 
               | 
            2645 | 
                 * Clicks on an option from the specified search widget.
  | 
          
          
            | - | 
               | 
            2646 | 
                 *
  | 
          
          
            | - | 
               | 
            2647 | 
                 * Examples:
  | 
          
          
            | - | 
               | 
            2648 | 
                 * - I click on "Student" in the "Search users" search combo box
  | 
          
          
            | - | 
               | 
            2649 | 
                 * - I click on "Group" in the "Search groups" search combo box
  | 
          
          
            | - | 
               | 
            2650 | 
                 * - I click on "Grade item" in the "Search grade items" search combo box
  | 
          
          
            | - | 
               | 
            2651 | 
                 *
  | 
          
          
            | - | 
               | 
            2652 | 
                 * @Given /^I click on "(?P<itemname>(?:[^"]|\\")*)" in the "(?P<comboboxname>(?:[^"]|\\")*)" search combo box$/
  | 
          
          
            | - | 
               | 
            2653 | 
                 * @param string $itemname The name of the combo box item we are searching for. This is only used if $fieldset is set
  | 
          
          
            | - | 
               | 
            2654 | 
                 *                         to true.
  | 
          
          
            | - | 
               | 
            2655 | 
                 * @param string $comboboxname The name (label) of the search combo box element. (e.g. "Search users", "Search groups").
  | 
          
          
            | - | 
               | 
            2656 | 
                 */
  | 
          
          
            | - | 
               | 
            2657 | 
                public function i_click_on_in_search_combobox(string $itemname, string $comboboxname): void {
  | 
          
          
            | - | 
               | 
            2658 | 
                    $node = $this->get_combobox_dropdown_node($comboboxname, $itemname);
  | 
          
          
            | - | 
               | 
            2659 | 
                    $this->execute([self::class, 'i_click_on_in_the'], [
  | 
          
          
            | - | 
               | 
            2660 | 
                        $itemname, "list_item",
  | 
          
          
            | - | 
               | 
            2661 | 
                        $node, "NodeElement",
  | 
          
          
            | - | 
               | 
            2662 | 
                    ]);
  | 
          
          
            | - | 
               | 
            2663 | 
                    $this->execute([self::class, 'i_wait_to_be_redirected']);
  | 
          
          
            | - | 
               | 
            2664 | 
                }
  | 
          
          
            | - | 
               | 
            2665 | 
             
  | 
          
          
            | - | 
               | 
            2666 | 
                /**
  | 
          
          
            | - | 
               | 
            2667 | 
                 * Clicks on a specific link within a table row.
  | 
          
          
            | - | 
               | 
            2668 | 
                 * Good for clicking links on tables where links have repeated text in diiferent rows.
  | 
          
          
            | - | 
               | 
            2669 | 
                 *
  | 
          
          
            | - | 
               | 
            2670 | 
                 * Example:
  | 
          
          
            | - | 
               | 
            2671 | 
                 * - I click on the "Settings" link in the row containing "Text editor placement"
  | 
          
          
            | - | 
               | 
            2672 | 
                 *
  | 
          
          
            | - | 
               | 
            2673 | 
                 * @Given /^I click on the "(?P<linktext>(?:[^"]|\\")*)" link in the table row containing "(?P<rowtext>(?:[^"]|\\")*)"$/
  | 
          
          
            | - | 
               | 
            2674 | 
                 * @param string $linktext
  | 
          
          
            | - | 
               | 
            2675 | 
                 * @param string $rowtext
  | 
          
          
            | - | 
               | 
            2676 | 
                 */
  | 
          
          
            | - | 
               | 
            2677 | 
                public function i_click_on_the_link_in_the_table_row_containing(string $linktext, string $rowtext): void {
  | 
          
          
            | - | 
               | 
            2678 | 
                    $row = $this->getSession()->getPage()->find('xpath', "//tr[contains(., '{$rowtext}')]");
  | 
          
          
            | - | 
               | 
            2679 | 
                    if (!$row) {
  | 
          
          
            | - | 
               | 
            2680 | 
                        throw new Exception("Row containing '{$rowtext}' not found");
  | 
          
          
            | - | 
               | 
            2681 | 
                    }
  | 
          
          
            | - | 
               | 
            2682 | 
                    $link = $row->findLink($linktext);
  | 
          
          
            | - | 
               | 
            2683 | 
                    if (!$link) {
  | 
          
          
            | - | 
               | 
            2684 | 
                        throw new Exception("Link '{$linktext}' not found in the row containing '{$rowtext}'");
  | 
          
          
            | - | 
               | 
            2685 | 
                    }
  | 
          
          
            | - | 
               | 
            2686 | 
                    $link->click();
  | 
          
          
            | - | 
               | 
            2687 | 
                }
  | 
          
          
            | - | 
               | 
            2688 | 
             
  | 
          
          
            | - | 
               | 
            2689 | 
                /**
  | 
          
          
            | - | 
               | 
            2690 | 
                 * Checks if a specific text is present in a table row.
  | 
          
          
            | - | 
               | 
            2691 | 
                 * Good for checking text in tables where text is repeated in different rows.
  | 
          
          
            | - | 
               | 
            2692 | 
                 *
  | 
          
          
            | - | 
               | 
            2693 | 
                 * Example:
  | 
          
          
            | - | 
               | 
            2694 | 
                 * - I should see "This action is unavailable." in the table row containing "Generate text"
  | 
          
          
            | - | 
               | 
            2695 | 
                 *
  | 
          
          
            | - | 
               | 
            2696 | 
                 * @Then /^I should see "(?P<text>(?:[^"]|\\")*)" in the table row containing "(?P<rowtext>(?:[^"]|\\")*)"$/
  | 
          
          
            | - | 
               | 
            2697 | 
                 * @param string $text
  | 
          
          
            | - | 
               | 
            2698 | 
                 * @param string $rowtext
  | 
          
          
            | - | 
               | 
            2699 | 
                 */
  | 
          
          
            | - | 
               | 
            2700 | 
                public function i_should_see_in_the_table_row_containing(string $text, string $rowtext): void {
  | 
          
          
            | - | 
               | 
            2701 | 
                    $row = $this->getSession()->getPage()->find('xpath', "//tr[contains(., '{$rowtext}')]");
  | 
          
          
            | - | 
               | 
            2702 | 
                    if (!$row) {
  | 
          
          
            | - | 
               | 
            2703 | 
                        throw new Exception("Row containing '{$rowtext}' not found");
  | 
          
          
            | - | 
               | 
            2704 | 
                    }
  | 
          
          
            | - | 
               | 
            2705 | 
                    if (strpos($row->getText(), $text) === false) {
  | 
          
          
            | - | 
               | 
            2706 | 
                        throw new Exception("Text '{$text}' not found in the row containing '{$rowtext}'");
  | 
          
          
            | - | 
               | 
            2707 | 
                    }
  | 
          
          
            | - | 
               | 
            2708 | 
                }
  | 
          
          
            | - | 
               | 
            2709 | 
             
  | 
          
          
            | - | 
               | 
            2710 | 
                /**
  | 
          
          
            | - | 
               | 
            2711 | 
                 * Checks if a specific text is not present in a table row.
  | 
          
          
            | - | 
               | 
            2712 | 
                 * Good for checking text in tables where text is repeated in different rows.
  | 
          
          
            | - | 
               | 
            2713 | 
                 *
  | 
          
          
            | - | 
               | 
            2714 | 
                 * Example:
  | 
          
          
            | - | 
               | 
            2715 | 
                 * - I should not see "This action is unavailable." in the table row containing "Generate text"
  | 
          
          
            | - | 
               | 
            2716 | 
                 *
  | 
          
          
            | - | 
               | 
            2717 | 
                 * @Then /^I should not see "(?P<text>(?:[^"]|\\")*)" in the table row containing "(?P<rowtext>(?:[^"]|\\")*)"$/
  | 
          
          
            | - | 
               | 
            2718 | 
                 * @param string $text
  | 
          
          
            | - | 
               | 
            2719 | 
                 * @param string $rowtext
  | 
          
          
            | - | 
               | 
            2720 | 
                 */
  | 
          
          
            | - | 
               | 
            2721 | 
                public function i_should_not_see_in_the_table_row_containing(string $text, string $rowtext): void {
  | 
          
          
            | - | 
               | 
            2722 | 
                    $row = $this->getSession()->getPage()->find('xpath', "//tr[contains(., '{$rowtext}')]");
  | 
          
          
            | - | 
               | 
            2723 | 
                    if (!$row) {
  | 
          
          
            | - | 
               | 
            2724 | 
                        throw new Exception("Row containing '{$rowtext}' not found");
  | 
          
          
            | - | 
               | 
            2725 | 
                    }
  | 
          
          
            | - | 
               | 
            2726 | 
                    if (strpos($row->getText(), $text) !== false) {
  | 
          
          
            | - | 
               | 
            2727 | 
                        throw new Exception("Text '{$text}' found in the row containing '{$rowtext}'");
  | 
          
          
            | - | 
               | 
            2728 | 
                    }
  | 
          
          
            | - | 
               | 
            2729 | 
                }
  | 
          
          
            | - | 
               | 
            2730 | 
             
  | 
          
          
            | - | 
               | 
            2731 | 
                /**
  | 
          
          
            | - | 
               | 
            2732 | 
                 * Sets the current time for the remainder of this Behat test.
  | 
          
          
            | - | 
               | 
            2733 | 
                 *
  | 
          
          
            | - | 
               | 
            2734 | 
                 * This is not supported everywhere in Moodle: if code uses \core\clock through DI then
  | 
          
          
            | - | 
               | 
            2735 | 
                 * it will work, but if it just calls time() it will still get the real time.
  | 
          
          
            | - | 
               | 
            2736 | 
                 *
  | 
          
          
            | - | 
               | 
            2737 | 
                 * @Given the time is frozen at :datetime
  | 
          
          
            | - | 
               | 
            2738 | 
                 * @param string $datetime Date and time in a format that strtotime understands
  | 
          
          
            | - | 
               | 
            2739 | 
                 */
  | 
          
          
            | - | 
               | 
            2740 | 
                public function the_time_is_frozen_at(string $datetime): void {
  | 
          
          
            | - | 
               | 
            2741 | 
                    global $CFG;
  | 
          
          
            | - | 
               | 
            2742 | 
                    require_once($CFG->libdir . '/testing/classes/frozen_clock.php');
  | 
          
          
            | - | 
               | 
            2743 | 
             
  | 
          
          
            | - | 
               | 
            2744 | 
                    $timestamp = strtotime($datetime);
  | 
          
          
            | - | 
               | 
            2745 | 
                    // The config variable is used to set up a frozen clock in each Behat web request.
  | 
          
          
            | - | 
               | 
            2746 | 
                    set_config('behat_frozen_clock', $timestamp);
  | 
          
          
            | - | 
               | 
            2747 | 
                    // Simply setting a frozen clock in DI should work for future steps in Behat CLI process.
  | 
          
          
            | - | 
               | 
            2748 | 
                    \core\di::set(\core\clock::class, new \frozen_clock($timestamp));
  | 
          
          
            | - | 
               | 
            2749 | 
                }
  | 
          
          
            | - | 
               | 
            2750 | 
             
  | 
          
          
            | - | 
               | 
            2751 | 
                /**
  | 
          
          
            | - | 
               | 
            2752 | 
                 * Stops freezing time so that it goes back to real time.
  | 
          
          
            | - | 
               | 
            2753 | 
                 *
  | 
          
          
            | - | 
               | 
            2754 | 
                 * @Given the time is no longer frozen
  | 
          
          
            | - | 
               | 
            2755 | 
                 */
  | 
          
          
            | - | 
               | 
            2756 | 
                public function the_time_is_no_longer_frozen(): void {
  | 
          
          
            | - | 
               | 
            2757 | 
                    unset_config('behat_frozen_clock');
  | 
          
          
            | - | 
               | 
            2758 | 
                    \core\di::set(\core\clock::class, new \core\system_clock());
  | 
          
          
            | - | 
               | 
            2759 | 
                }
  | 
          
          
            | 2472 | 
            }
  | 
            2760 | 
            }
  |