Skip to content

Commit 06ba45a

Browse files
committed
Fix behat test with two file uploads
1 parent ca6ada0 commit 06ba45a

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

tests/behat/behat_mod_questionnaire.php

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -623,16 +623,27 @@ protected function open_add_file_window($filemanagernode, $repositoryname) {
623623
$repositoryname = behat_context_helper::escape($repositoryname);
624624

625625
// Here we don't need to look inside the selected element because there can only be one modal window.
626-
$repositorylink = $this->find(
626+
// Apparently there are some of these repo elements. So if the first one is not visible, check out
627+
// the next one.
628+
$repositorylinks = $this->find_all(
627629
'xpath',
628630
"//div[contains(concat(' ', normalize-space(@class), ' '), ' fp-repo-area ')]" .
629631
"//descendant::span[contains(concat(' ', normalize-space(@class), ' '), ' fp-repo-name ')]" .
630632
"[normalize-space(.)=$repositoryname]",
631633
$repoexception
632634
);
633635

636+
foreach ($repositorylinks as $repositorylink) {
637+
try {
638+
$this->ensure_node_is_visible($repositorylink);
639+
} catch (Exception $exception) {
640+
$repositorylink = $exception;
641+
}
642+
}
643+
if ($repositorylink instanceof \Exception) {
644+
throw new $repositorylink;
645+
}
634646
// Selecting the repo.
635-
$this->ensure_node_is_visible($repositorylink);
636647
if (!$repositorylink->getParent()->getParent()->hasClass('active')) {
637648
// If the repository link is active, then the repository is already loaded.
638649
// Clicking it while it's active causes issues, so only click it when it isn't (see MDL-51014).

0 commit comments

Comments
 (0)