【问题标题】:Cypress- unable to see/capture the popup赛普拉斯 - 无法查看/捕获弹出窗口
【发布时间】:2021-10-31 12:55:41
【问题描述】:

在我正在测试的网站上,我有一个链接——点击它会弹出一个弹出窗口。 我能够找到该链接,但是单击该链接会导致“未捕获的异常 TypeError:无法读取属性弹出窗口...”。如果我抑制异常测试通过但我仍然看不到弹出窗口。

我尝试过等待,但没有成功。如果有人遇到类似问题,那么想在这里检查一下吗?

弹出弹窗的链接元素在下方

<a class="locpickerSelect" data-blank="<span>Select Location</span>" data-change="<span>Change Selection</span>" href="#"><span>Select Location</span></a>

弹出窗口在源代码中添加了一个额外的 div,下面是我单击链接时在源代码中看到的内容

<div class="PopupOverlay" style="inset: 0px; position: fixed;"></div>
<div class="PopupShadow" style="width: 940px; height: 352px; top: 5px; left: 216px;"></div>
<div class="PopupFrame" style="width: 940px; height: 352px; left: 216px; top: 5px;">
<a class="ClosePopup icon cancel-circle"></a>
<iframe seamless="seamless" frameborder="0" width="100%" height="100%" src="https://<myurl>;forFeature=&amp;selectOrgId=" style="display: block; height: 352px;"></iframe>
</div>

【问题讨论】:

  • 请分享您的 cypress 代码 sn-p。
  • 不能分享太多,但这就是它的样子,我可以在 Cypress runner 中看到它能够定位元素但点击部分抛出异常`描述('popupTest',函数( ) { it('启动 ID', function(){ cy.visit("https:///") cy.get('.locpickerSelect').click({force: true}) } ) } ) `

标签: cypress ui-automation browser-automation


【解决方案1】:

“未捕获的异常 TypeError:无法读取属性弹出...”可能来自应用程序,而不是测试。

你可以把它放在测试的顶部,

Cypress.on('uncaught:exception', (err, runnable) => {
  return false
})

这将抑制应用程序中的任何异常,但理想情况下,您希望了解它发生的原因。

您显示的 HTML 中似乎没有任何可能导致它的内容。很可能是在locpickerSelect 的点击处理程序中。

【讨论】:

    猜你喜欢
    • 2020-09-14
    • 1970-01-01
    • 2020-12-23
    • 2018-09-30
    • 1970-01-01
    • 1970-01-01
    • 2022-06-10
    • 2020-09-12
    • 2021-07-07
    相关资源
    最近更新 更多