I am writing cypress javascript code and try to access title attribute value from and storing value into title.
When I print cy.log(“Title Attribute: “, title); It works. but i want to access another function called getdocumentTitle(). but its not printing value.
Can somebody see what I am doing wrong.
getdocumentTitle() {
cy.log("Title : ", this.titlev);
return this.titlev;
}
readDocTitleAttributeByDocumentNameFromTableColumns(value) {
let x;
// Find the rows containing the desired text
this.rowResponseSummaryTable.each(($row) => {
// Check if the row contains the desired text
cy.wrap($row)
.find("td:nth-child(5)")
.invoke("text")
.then((text) => {
if (text.trim() === value) {
cy.wrap($row)
.find("td:nth-child(2) > a")
.invoke("attr", "title")
.then((title) => {
cy.log("Title Attribute: ", title);
x = title; // Assign title to x
this.titlev = x; // Assign x to this.titlev inside the inner then block
});
}
});
});
// This log will execute before the inner Cypress commands are finished
cy.log("Title X: ", x);
// This assignment will execute before the inner Cypress commands are finished
this.titlev = x;
}