diff --git a/grade/edit/tree/lib.php b/grade/edit/tree/lib.php index e97966395d1..ca2cba26c6c 100644 --- a/grade/edit/tree/lib.php +++ b/grade/edit/tree/lib.php @@ -835,16 +835,8 @@ class grade_edit_tree_column_name extends grade_edit_tree_column { $itemicon = \html_writer::div($params['icon'], 'mr-1'); $itemtype = \html_writer::span($params['type'], 'd-block text-uppercase small dimmed_text'); - - // Generate the content for a cell that represents a grade item. - // If a behat test site is running avoid outputting the information about the type of the grade item. - // This additional information causes issues in behat particularly with the existing xpath used to - // interact with table elements. - if (!defined('BEHAT_SITE_RUNNING')) { - $content = \html_writer::div($itemtype . $params['name']); - } else { - $content = \html_writer::div($params['name']); - } + $itemtitle = html_writer::div($params['name'], 'rowtitle'); + $content = \html_writer::div($itemtype . $itemtitle); $moveaction = isset($params['moveaction']) ? $params['moveaction'] : ''; diff --git a/grade/report/singleview/classes/local/screen/user.php b/grade/report/singleview/classes/local/screen/user.php index 95416709580..e0e93349059 100644 --- a/grade/report/singleview/classes/local/screen/user.php +++ b/grade/report/singleview/classes/local/screen/user.php @@ -190,14 +190,9 @@ class user extends tablelike implements selectable_items { $itemicon = html_writer::div($this->format_icon($item), 'mr-1'); $itemtype = \html_writer::span($this->structure->get_element_type_string($gradetreeitem), 'd-block text-uppercase small dimmed_text'); - // If a behat test site is running avoid outputting the information about the type of the grade item. - // This additional information currently causes issues in behat particularly with the existing xpath used to - // interact with table elements. - if (!defined('BEHAT_SITE_RUNNING')) { - $itemcontent = html_writer::div($itemtype . $itemname); - } else { - $itemcontent = html_writer::div($itemname); - } + + $itemtitle = html_writer::div($itemname, 'rowtitle'); + $itemcontent = html_writer::div($itemtype . $itemtitle); $line = [ html_writer::div($itemicon . $itemcontent . $lockicon, "{$type} d-flex align-items-center"), diff --git a/grade/report/user/classes/report/user.php b/grade/report/user/classes/report/user.php index aea37871b20..56367a5c85b 100644 --- a/grade/report/user/classes/report/user.php +++ b/grade/report/user/classes/report/user.php @@ -551,14 +551,8 @@ class user extends grade_report { } // Generate the content for a cell that represents a grade item. - // If a behat test site is running avoid outputting the information about the type of the grade item. - // This additional information causes issues in behat particularly with the existing xpath used to - // interact with table elements. - if (!defined('BEHAT_SITE_RUNNING')) { - $content = \html_writer::div($itemtype . $fullname); - } else { - $content = \html_writer::div($fullname); - } + $itemtitle = \html_writer::div($fullname, 'rowtitle'); + $content = \html_writer::div($itemtype . $itemtitle); // Name. $data['itemname']['content'] = \html_writer::div($itemicon . $content, "{$type} d-flex align-items-center"); diff --git a/lib/tests/behat/behat_general.php b/lib/tests/behat/behat_general.php index 9833b2356ab..86698bbedce 100644 --- a/lib/tests/behat/behat_general.php +++ b/lib/tests/behat/behat_general.php @@ -1456,8 +1456,8 @@ EOF; // Check if value exists in specific row/column. // Get row xpath. // GoutteDriver uses DomCrawler\Crawler and it is making XPath relative to the current context, so use descendant. - $rowxpath = $tablexpath."/tbody/tr[descendant::th[normalize-space(.)=" . $rowliteral . - "] | descendant::td[normalize-space(.)=" . $rowliteral . "]]"; + $rowxpath = $tablexpath . "/tbody/tr[descendant::*[@class='rowtitle'][normalize-space(.)=" . $rowliteral . "] | " . " + descendant::th[normalize-space(.)=" . $rowliteral . "] | descendant::td[normalize-space(.)=" . $rowliteral . "]]"; $columnvaluexpath = $rowxpath . $columnpositionxpath . "[contains(normalize-space(.)," . $valueliteral . ")]";