我有一个测试用例,其中我有一个链接在新选项卡中打开,并且由于cypress不支持多选项卡,我想获得该链接的href属性然后在同一个选项卡中打开它,我试图这样做,但由于某种原因,它不起作用.
it('Advertise link should refer to Contact page', () => {
var link = document.querySelector("div.footer-nav > ul > li:nth-child(2) > a").href;
cy.visit(link);
cy.title().should('include', 'Text');
});
Run Code Online (Sandbox Code Playgroud)