From 49b4ff0f3e52919fc6a9066963c4463a54a4e1f5 Mon Sep 17 00:00:00 2001 From: sam marshall Date: Tue, 30 Aug 2022 11:16:53 +0100 Subject: [PATCH] MDL-75608 Behat: Expand all fieldsets step fails with single fieldset --- lib/tests/behat/behat_forms.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/tests/behat/behat_forms.php b/lib/tests/behat/behat_forms.php index 62bae1615ec..33562c9a9d6 100644 --- a/lib/tests/behat/behat_forms.php +++ b/lib/tests/behat/behat_forms.php @@ -148,11 +148,14 @@ class behat_forms extends behat_base { $expandallxpath = "//div[@class='collapsible-actions']" . "//a[contains(concat(' ', @class, ' '), ' collapsed ')]" . "//span[contains(concat(' ', @class, ' '), ' expandall ')]"; - // Else, look for the first expand fieldset link. - $expandonlysection = "//legend[@class='ftoggler']" . + // Else, look for the first expand fieldset link (old theme structure). + $expandsectionold = "//legend[@class='ftoggler']" . + "//a[contains(concat(' ', @class, ' '), ' icons-collapse-expand ') and @aria-expanded = 'false']"; + // Else, look for the first expand fieldset link (current theme structure). + $expandsectioncurrent = "//legend/div[contains(concat(' ', @class, ' '), ' ftoggler ')]" . "//a[contains(concat(' ', @class, ' '), ' icons-collapse-expand ') and @aria-expanded = 'false']"; - $collapseexpandlink = $this->find('xpath', $expandallxpath . '|' . $expandonlysection, + $collapseexpandlink = $this->find('xpath', $expandallxpath . '|' . $expandsectionold . '|' . $expandsectioncurrent, false, false, behat_base::get_reduced_timeout()); $collapseexpandlink->click(); $this->wait_for_pending_js();