mirror of
https://github.com/moodle/moodle.git
synced 2025-03-14 04:30:15 +01:00
MDL-46572 behat: extended table head look up to check if header is link
Header can be a link, this step will now look if header has a text or header link has the text Part of MDL-46191
This commit is contained in:
parent
1446e02f69
commit
3c7bfae29c
@ -1000,9 +1000,14 @@ class behat_general extends behat_base {
|
||||
$tablenode = $this->get_selected_node('table', $table);
|
||||
$tablexpath = $tablenode->getXpath();
|
||||
|
||||
// Check if column exists, it can be in thead or tbody first row.
|
||||
$columnheaderxpath = $tablexpath . "[thead/tr/th[normalize-space(.)='$column'] | "
|
||||
. "tbody/tr[1]/th[normalize-space(.)='" . $column . "']]";
|
||||
// Header can be in thead or tbody (first row), following xpath should work.
|
||||
$theadheaderxpath = "thead/tr[1]/th[(normalize-space(.)='" . $column . "' or a[normalize-space(text())='" .
|
||||
$column . "'])]";
|
||||
$tbodyheaderxpath = "tbody/tr[1]/td[(normalize-space(.)='" . $column . "' or a[normalize-space(text())='" .
|
||||
$column . "'])]";
|
||||
|
||||
// Check if column exists.
|
||||
$columnheaderxpath = $tablexpath . "[" . $theadheaderxpath . " | " . $tbodyheaderxpath . "]";
|
||||
$columnheader = $this->getSession()->getDriver()->find($columnheaderxpath);
|
||||
if (empty($columnheader)) {
|
||||
$columnexceptionmsg = $column . '" in table "' . $table . '"';
|
||||
@ -1016,17 +1021,16 @@ class behat_general extends behat_base {
|
||||
// Following conditions were considered before finding column count.
|
||||
// 1. Table header can be in thead/tr/th or tbody/tr/td[1].
|
||||
// 2. First column can have th (Gradebook -> user report), so having lenient sibling check.
|
||||
$columnpositionxpath = "/child::*[position() = count(" . $tablexpath . "/thead/tr[1]/th[normalize-space(.)='" .
|
||||
$column . "']/preceding-sibling::*) + 1]";
|
||||
$columnvaluexpath = $rowxpath . $columnpositionxpath . "[text()[contains(normalize-space(.),'" . $value . "')]]";
|
||||
|
||||
$columnpositionxpath = "/child::*[position() = count(" . $tablexpath . "/" . $theadheaderxpath .
|
||||
"/preceding-sibling::*) + 1]";
|
||||
$columnvaluexpath = $rowxpath . $columnpositionxpath . "[contains(normalize-space(.),'" . $value . "')]";
|
||||
// Looks for the requested node inside the container node.
|
||||
$coumnnode = $this->getSession()->getDriver()->find($columnvaluexpath);
|
||||
if (empty($coumnnode)) {
|
||||
// Check if tbody/tr[1] contains header selector.
|
||||
$columnpositionxpath = "/child::*[position() = count(" . $tablexpath . "/tbody/tr[1]/td[normalize-space(.)='" .
|
||||
$column . "']/preceding-sibling::*) + 1]";
|
||||
$columnvaluexpath = $rowxpath . $columnpositionxpath . "[text()[contains(normalize-space(.),'" . $value . "')]]";
|
||||
$columnpositionxpath = "/child::*[position() = count(" . $tablexpath . "/" . $tbodyheaderxpath .
|
||||
"/preceding-sibling::*) + 1]";
|
||||
$columnvaluexpath = $rowxpath . $columnpositionxpath . "[contains(normalize-space(.),'" . $value . "')]";
|
||||
$coumnnode = $this->getSession()->getDriver()->find($columnvaluexpath);
|
||||
if (empty($coumnnode)) {
|
||||
$locatorexceptionmsg = $value . '" in "' . $row . '" row with column "' . $column;
|
||||
|
Loading…
x
Reference in New Issue
Block a user