我有一个Angular 的应用程序,我为创建 cypress E2E.
该应用程序的一个页面有一个表,其中第三列包含一个类名为‘link ng-star-Inserted’的链接,我希望测试在找到特定行后点击该链接.
实际上,我已经让测试完成了这项工作--链接实际上是被点击的.
但它不是很优雅,而且它将.Click()方法标记为错误(尽管它确实可以工作).
我正在寻找一种方法,使其不将.ick()方法标记为错误.
这是我的密码...
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());
//Yes this is kind of ugly. I tried it every other way I could think of and this is the only way it worked
let cellWithLink = $row.find('td:nth-child(3)');
cellWithLink.children().get(0).getElementsByClassName('link ng-star-inserted').item(0).click();
});
这张截图显示了IDE将Click()标记为错误的地方--尽管它确实有效.
多谢了!