代码之家  ›  专栏  ›  技术社区  ›  soccerway

如何访问Cypress中具有外部属性的动态表单url?

  •  0
  • soccerway  · 技术社区  · 6 年前

    在我的应用程序中,我需要创建一个表单,然后激活该表单,只有在激活表单后,我才会得到新的表单动态'url',它有一个属性rel=“external”。由于url是在外部选项卡/链接中打开的,因此如何删除该属性并在Cypress限制内访问url。下面的代码不起作用,

    注:

    <div id="main">
    <div id="mainid">
    <p>Live Action:
    <a href="https://sometestsite.com/form/et24yetwefff  rel="external"></a>
    </p>
    </div>
    </div>
    cy.wait(2000)
            Cypress.$('#main-inner > p > a').removeAttr("rel")
            cy.get('p > a').last()
               .should('have.attr', 'href')
                .then((href) => {
                 console.log(href);
                 cy.visit(href)
                 cy.wait(2000)
                 ........// test continues type values in text field and submit the form
              })
    
    0 回复  |  直到 6 年前