~ubuntu-branches/ubuntu/trusty/moodle/trusty-proposed

« back to all changes in this revision

Viewing changes to lib/tests/behat/behat_general.php

  • Committer: Package Import Robot
  • Author(s): Thijs Kinkhorst
  • Date: 2013-09-09 15:22:35 UTC
  • mfrom: (1.1.11)
  • Revision ID: package-import@ubuntu.com-20130909152235-d9njbvgugzm380an
Tags: 2.5.2-1
* New upstream version: 2.5.2.
  - Incorporates S3 security patch.

Show diffs side-by-side

added added

removed removed

Lines of Context:
29
29
 
30
30
use Behat\Mink\Exception\ExpectationException as ExpectationException,
31
31
    Behat\Mink\Exception\ElementNotFoundException as ElementNotFoundException,
32
 
    Behat\Mink\Exception\DriverException as DriverException;
 
32
    Behat\Mink\Exception\DriverException as DriverException,
 
33
    WebDriver\Exception\NoSuchElement as NoSuchElement,
 
34
    WebDriver\Exception\StaleElementReference as StaleElementReference;
33
35
 
34
36
/**
35
37
 * Cross component steps definitions.
78
80
            return false;
79
81
        }
80
82
 
81
 
        $content = $metarefresh->getAttribute('content');
 
83
        // Wrapped in try & catch in case the redirection has already been executed.
 
84
        try {
 
85
            $content = $metarefresh->getAttribute('content');
 
86
        } catch (NoSuchElement $e) {
 
87
            return false;
 
88
        } catch (StaleElementReference $e) {
 
89
            return false;
 
90
        }
 
91
 
 
92
        // Getting the refresh time and the url if present.
82
93
        if (strstr($content, 'url') != false) {
83
94
 
84
 
            list($waittime, $url) = explode(';', $metarefresh->getAttribute('content'));
 
95
            list($waittime, $url) = explode(';', $content);
85
96
 
86
97
            // Cleaning the URL value.
87
98
            $url = trim(substr($url, strpos($url, 'http')));
231
242
 
232
243
        // The table row container.
233
244
        $nocontainerexception = new ElementNotFoundException($this->getSession(), '"' . $tablerowtext . '" row text ');
234
 
        $tablerowtext = str_replace("'", "\'", $tablerowtext);
235
 
        $rownode = $this->find('xpath', "//tr[contains(., '" . $tablerowtext . "')]", $nocontainerexception);
 
245
        $tablerowtext = $this->getSession()->getSelectorsHandler()->xpathLiteral($tablerowtext);
 
246
        $rownode = $this->find('xpath', "//tr[contains(., $tablerowtext)]", $nocontainerexception);
236
247
 
237
248
        // Looking for the element DOM node inside the specified row.
238
249
        list($selector, $locator) = $this->transform_selector($selectortype, $element);
274
285
    public function assert_page_contains_text($text) {
275
286
 
276
287
        $xpathliteral = $this->getSession()->getSelectorsHandler()->xpathLiteral($text);
277
 
        $xpath = "/descendant::*[contains(., " . $xpathliteral. ")]";
 
288
        $xpath = "/descendant::*[contains(., $xpathliteral)]";
278
289
 
279
290
        // Wait until it finds the text, otherwise custom exception.
280
291
        try {
294
305
    public function assert_page_not_contains_text($text) {
295
306
 
296
307
        $xpathliteral = $this->getSession()->getSelectorsHandler()->xpathLiteral($text);
297
 
        $xpath = "/descendant::*[not(contains(., " . $xpathliteral. "))]";
 
308
        $xpath = "/descendant::*[not(contains(., $xpathliteral))]";
298
309
 
299
310
        // Wait until it finds the text, otherwise custom exception.
300
311
        try {