【问题标题】:After removing attribute _target, new url is opened under iframe去掉_target属性后,在iframe下打开新的url
【发布时间】:2021-10-09 20:00:02
【问题描述】:

技术:Cypress/Typescript

我正在尝试从 <a> 元素中删除 target _blank 并在同一选项卡中打开新的 url,但由于 <a> 在 iframe 下,新的 url 在 iframe 中打开,这个问题有什么解决办法吗?

getIframeBody()
  .find('table#emailContainer tr td a')
  .invoke('removeAttr','target')
  .click();

【问题讨论】:

  • 为什么会出现问题?

标签: typescript iframe cypress


【解决方案1】:

您如何获取 href 属性然后访问它?例如:

getIframeBody().find('table#emailContainer tr td a').invoke('attr', 'href').then((href) => {
    cy.visit(href)
    // rest of the test
})

【讨论】:

    猜你喜欢
    • 2019-09-12
    • 2014-05-20
    • 1970-01-01
    • 1970-01-01
    • 2014-02-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-02-07
    相关资源
    最近更新 更多