I am currently in the process of developing Cypress E2E tests for my Angular application.
One specific page in the app features a table with a link in the third column that is identified by the class name 'link ng-star-inserted'. My goal is to have the test locate a particular row and click on this link.
After some trial and error, I managed to achieve this functionality - the test successfully clicks on the desired link.
However, the implementation feels less than elegant and the .click() method triggers an error (despite functioning correctly).
I am seeking a solution to prevent the .click() method from being flagged as an error.
Below is the code snippet in question...
cy.get(SELECTOR.dataTableBody).should('be.visible')
.contains('tr', 'Text I am looking for in the row I want')
.then($row => {
cy.log('found it');
cy.log('on row ' + $row.index());
//Though not ideal, this approach works. I exhausted all other possibilities.
let cellWithLink = $row.find('td:nth-child(3)');
cellWithLink.children().get(0).getElementsByClassName('link ng-star-inserted').item(0).click();
});
The following image illustrates where the IDE flags the click() method as an error, despite its functionality.
https://i.sstatic.net/xRjxP.png
Thank you in advance!