Proyectos de Subversion Moodle

Rev

Rev 1 | Mostrar el archivo completo | | | Autoría | Ultima modificación | Ver Log |

Rev 1 Rev 1441
Línea 39... Línea 39...
39
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
39
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
40
 */
40
 */
41
class behat_qbank_comment extends behat_question_base {
41
class behat_qbank_comment extends behat_question_base {
Línea 42... Línea 42...
42
 
42
 
43
    /**
-
 
44
     * Looks for a table, then looks for a row that contains the given text.
-
 
45
     * Once it finds the right row, it clicks a link in that row.
-
 
46
     *
-
 
47
     * @When I click :arg1 on the row on the comments column
-
 
48
     * @param string $linkname
-
 
49
     * @param string $rowtext
-
 
50
     */
-
 
51
    public function i_click_on_the_row_containing($linkname) {
-
 
52
        $exception = new ElementNotFoundException($this->getSession(),
-
 
53
                'Cannot find any row on the page containing the text ' . $linkname);
-
 
54
        $row = $this->find('css', sprintf('table tbody tr td.commentcount a:contains("%s")', $linkname), $exception);
-
 
55
        $row->click();
-
 
56
    }
-
 
57
 
-
 
58
    /**
-
 
59
     * Looks for the appropriate comment count in the column.
-
 
60
     *
-
 
61
     * @Then I should see :arg1 on the comments column
-
 
62
     * @param string $linkdata
-
 
63
     */
-
 
64
    public function i_should_see_on_the_column($linkdata) {
-
 
65
        $exception = new ElementNotFoundException($this->getSession(),
-
 
66
                'Cannot find any row with the comment count of ' . $linkdata . ' on the column named Comments');
-
 
67
        $this->find('css', sprintf('table tbody tr td.commentcount a:contains("%s")', $linkdata), $exception);
-
 
68
    }
-
 
69
 
-
 
70
    /**
43
    /**
71
     * Adds the specified option to the question comments of the current modal.
44
     * Adds the specified option to the question comments of the current modal.
72
     *
45
     *
73
     * @Then I add :arg1 comment to question
46
     * @Then I add :arg1 comment to question
74
     * @param string $comment
47
     * @param string $comment
Línea 163... Línea 136...
163
 
136
 
164
        // Wait for the animation to finish, in theory is just 1 sec, adding 4 just in case.
137
        // Wait for the animation to finish, in theory is just 1 sec, adding 4 just in case.
165
        $this->getSession()->wait(4 * 1000);
138
        $this->getSession()->wait(4 * 1000);
Línea -... Línea 139...
-
 
139
    }
-
 
140
 
-
 
141
    /**
-
 
142
     * Define named selectors for the comments column.
-
 
143
     *
-
 
144
     * Supported selectors are:
-
 
145
     * - "qbank_comment > Comment count link" a comment count displayed as a link.
-
 
146
     * - "qbank_comment > Comment count text" a comment count displayed as un-linked text.
-
 
147
     *
-
 
148
     * @return behat_component_named_selector[]
-
 
149
     */
-
 
150
    public static function get_exact_named_selectors(): array {
-
 
151
        $commentcountxpath = "//table/tbody/tr/td[contains(@class, 'commentcount')]/%s[text() = %%locator%%]";
-
 
152
        return [
-
 
153
            new behat_component_named_selector(
-
 
154
                'Comment count link',
-
 
155
                [sprintf($commentcountxpath, 'a')]
-
 
156
            ),
-
 
157
            new behat_component_named_selector(
-
 
158
                'Comment count text',
-
 
159
                [sprintf($commentcountxpath, 'span')]
-
 
160
            ),
166
    }
161
        ];