Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions tests/behat/behat_wiris_page.php
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,7 @@ public function i_press_in_field_in_tiny_editor($button, $field) {
"General feedback" => "fitem_id_generalfeedback",
"Feedback" => "fitem_id_feedback_0",
"Message" => "fitem_id_message",
"Text Block" => "fitem_id_config_text",
];
if (empty($sectionarray[$field])) {
throw new ExpectationException($field . " field not registered.", $this->getSession());
Expand All @@ -335,18 +336,18 @@ public function i_press_in_field_in_tiny_editor($button, $field) {
throw new ExpectationException($button . " button not registered.", $this->getSession());
}
$session = $this->getSession();
$component = $session->getPage()->find('xpath', '//div[@id="' . $sectionarray[$field] . '"]
$component = $session->getPage()->find('xpath', '//div[contains(@id,"' . $sectionarray[$field] . '")]
//*[contains(@title,\'' . $buttonarray[$button] . '\')]');

// In Moodle 4.4 the button has change from "More.." to "Reveal or hide..."
if ($button == 'Toggle' && $CFG->version >= 2024042202.02) {
$component = $session->getPage()->find('xpath', '//div[@id="' . $sectionarray[$field] . '"]
$component = $session->getPage()->find('xpath', '//div[contains(@id,"' . $sectionarray[$field] . '")]
//*[contains(@aria-label,"Reveal or hide")]');
}

// From 4.5, the button is not found via id but via data-mce-name //TODO verify if 4.x may always work like this
if ($button != 'Toggle' && $CFG->version >= 2024092400) {
$component = $session->getPage()->find('xpath', '//div[@id="' . $sectionarray[$field] . '"]
$component = $session->getPage()->find('xpath', '//div[contains(@id,"' . $sectionarray[$field] . '")]
//*[contains(@aria-label,"' . $buttonarray[$button] . '")]');
}

Expand Down Expand Up @@ -613,16 +614,18 @@ public function i_click_on_in_tinymce_6_editor_toolbar($button) {
global $CFG;
$buttonarray = [
"More options" => "More...",
"Align left" => "Align left"
];
if (empty($buttonarray[$button])) {
throw new ExpectationException($button . " button not registered.");
}
$session = $this->getSession();
$component = $session->getPage()->find('xpath', '//button[@title="' . $buttonarray[$button] . '"]');
if ($CFG->version >= 2024042202.02) {
$component = $session->getPage()->find('xpath', '//*[contains(@aria-label,"Reveal or hide")]');
$buttonarray["More options"] = "Reveal or hide"; // In Moodle 4.4 the button has change from "More.." to "Reveal or hide"
echo '//*[contains(@aria-label,"' . $buttonarray[$button] . '")]';
$component = $session->getPage()->find('xpath', '//*[contains(@aria-label,"' . $buttonarray[$button] . '")]');
}

if (empty($component)) {
throw new ExpectationException($button . " button not correctly recognized.", $this->getSession());
}
Expand Down
Loading