mirror of
https://github.com/moodle/moodle.git
synced 2025-08-04 16:36:37 +02:00
MDL-72593 behat: Improve behat handling of file manager buttons
When using a try/catch for a find if the first match is not met then we have an implicit 6 second delay waiting for the search to time out. We can avoid this by combining the searches in a comma-separated selection. I have also taken the opportunity to convert the use of ->click() to the i_click_on function which has the benefit of supporting wait for pendingJS.
This commit is contained in:
parent
bbf30c6751
commit
6138b34e01
1 changed files with 5 additions and 11 deletions
|
@ -177,20 +177,14 @@ trait core_behat_file_helper {
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
protected function open_add_file_window($filemanagernode, $repositoryname) {
|
protected function open_add_file_window($filemanagernode, $repositoryname) {
|
||||||
|
|
||||||
$exception = new ExpectationException('No files can be added to the specified filemanager', $this->getSession());
|
$exception = new ExpectationException('No files can be added to the specified filemanager', $this->getSession());
|
||||||
|
|
||||||
// We should deal with single-file and multiple-file filemanagers,
|
// We should deal with single-file and multiple-file filemanagers,
|
||||||
// catching the exception thrown by behat_base::find() in case is not multiple
|
// catching the exception thrown by behat_base::find() in case is not multiple
|
||||||
try {
|
$this->execute('behat_general::i_click_on_in_the', [
|
||||||
// Looking for the add button inside the specified filemanager.
|
'div.fp-btn-add a, input.fp-btn-choose', 'css_element',
|
||||||
$add = $this->find('css', 'div.fp-btn-add a', $exception, $filemanagernode);
|
$filemanagernode, 'NodeElement'
|
||||||
} catch (Exception $e) {
|
]);
|
||||||
// Otherwise should be a single-file filepicker form element.
|
|
||||||
$add = $this->find('css', 'input.fp-btn-choose', $exception, $filemanagernode);
|
|
||||||
}
|
|
||||||
$this->ensure_node_is_visible($add);
|
|
||||||
$add->click();
|
|
||||||
|
|
||||||
// Wait for the default repository (if any) to load. This checks that
|
// Wait for the default repository (if any) to load. This checks that
|
||||||
// the relevant div exists and that it does not include the loading image.
|
// the relevant div exists and that it does not include the loading image.
|
||||||
|
@ -220,7 +214,7 @@ trait core_behat_file_helper {
|
||||||
if (!$repositorylink->getParent()->getParent()->hasClass('active')) {
|
if (!$repositorylink->getParent()->getParent()->hasClass('active')) {
|
||||||
// If the repository link is active, then the repository is already loaded.
|
// If the repository link is active, then the repository is already loaded.
|
||||||
// Clicking it while it's active causes issues, so only click it when it isn't (see MDL-51014).
|
// Clicking it while it's active causes issues, so only click it when it isn't (see MDL-51014).
|
||||||
$repositorylink->click();
|
$this->execute('behat_general::i_click_on', [$repositorylink, 'NodeElement']);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue