简体   繁体   English

Cypress,获取新窗口的实例

[英]Cypress, get instance of new window

I found this: Access a new window - cypress.io我发现了这个: 访问一个新窗口 - cypress.io

I think it is a begining of something that might solve my problem.我认为这是可能解决我的问题的事情的开始。 Though, a it doesn't solve my problem entirely.尽管如此,它并不能完全解决我的问题。

Summary:总结:

I have to run cypress test on a webapp.我必须在 webapp 上运行 cypress 测试。 This webapp behaves this way:这个 webapp 的行为是这样的:

http://urlofwebsite:1234/blabla/token -> open a new window http://urlofwebsite:1234/blabla/token -> 打开一个新窗口

New window is at http://urlofwebsite:1234/blabla/page新窗口位于http://urlofwebsite:1234/blabla/page

The thing is, if I do something like cy.visit("http://urlofwebsite:1234/blabla/page") doesn't work.问题是,如果我做类似cy.visit("http://urlofwebsite:1234/blabla/page")事情就行不通了。 It opens new window the same way it did in the previous case.它以与前一种情况相同的方式打开新窗口。

That's why, I want to get the instance of this new window to run my test.这就是为什么我想获得这个新窗口的实例来运行我的测试。

I don't know if I've been clear enough.不知道我说得够不够清楚。 Don't hesitate to question me (except Why is it made that way, because I don't know, I didn't do it).不要犹豫,问我(除了为什么要那样做,因为我不知道,我没有这样做)。

Thank you all!谢谢大家!

I found a way of doing this using Dr Gleb Bahmutov's "Cypress using child window" blog post .我使用 Gleb Bahmutov 博士的“使用子窗口Cypress”博客文章找到了一种方法。

I've extended his original helper command with some additional utilities: https://github.com/jakedowns/CypressHelpers我已经用一些额外的实用程序扩展了他的原始助手命令: https : //github.com/jakedowns/CypressHelpers

These helpers allow you to: open a new window, switch between them & test between them, close your popup windows这些助手允许您:打开一个新窗口,在它们之间切换并在它们之间进行测试,关闭弹出窗口

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM