其他测试框架 cypress 如何操作新的选项卡

马可菠菠仔 · 2020年10月28日 · 最后由 啃包菜的猫 回复于 2020年10月28日 · 2178 次阅读

目前遇到的问题是,点击页面按键后打开了新的选项卡页面,想要做的是新页面元素的断言和截图,但是发现定位不到新页面的元素且不能截图,观察发现 cy 的操作区域还是在老页面上,请问 cypress 框架本身是否支持这种场景

共收到 1 条回复 时间 点赞
马可菠菠仔 关闭了讨论 10月30日 12:42

cypress 并不支持多 tab 切换,它的文档里已经说了:https://docs.cypress.io/guides/references/trade-offs.html#Permanent-trade-offs-1

  • Cypress is not a general purpose automation tool.
  • Cypress commands run inside of a browser.
  • There will never be support for multiple browser tabs.
  • You cannot use Cypress to drive two browsers at the same time.
  • Each test is bound to a single origin.

不过它提供了解决类似问题的方案:
https://github.com/cypress-io/cypress-example-recipes/blob/master/examples/testing-dom__tab-handling-links/cypress/integration/tab_handling_anchor_links_spec.js

需要 登录 后方可回复, 如果你还没有账号请点击这里 注册