I'm trying to understand how do i return a boolean from cypress page object?
Use case:
I am trying to check if an element is present on the page. If so, return a boolean.
Code:
class DataTable {
constructor() {
return this;
}
has(fieldName) {
// HOW DO I RETURN A BOOLEAN HERE?
return cy.get('.view-and-field-name').contains(fieldName)
}
}
Mainpage.spec.js
const dataTable = new DataTable();
expect(dataTable.has(field.fieldName)).to.be.true;
I'd appreciate some insights on what I am doing wrong.
Thank you for the time.