等到柏树初始化变量
我如何等到柏树中初始化变量?
例如,我有以下代码:
let width;
cy.get("[data-cy=foo-bar]")
.should(element => (width = element.width()))
.get("[data-cy=baz-baz]")
//some other chained Cypress operations
...;
我想要行.getcy(“ Baz-baz”)
no执行,直到设置width
。我怎么能以最清洁的方式实现这一目标?
我想保留操作的链接并避免嵌套,因为以后我可能需要多个变量,并且将所有内容都放在应该
中变得非常混乱。
How could I wait until a variable is initialized in Cypress?
E.g. I have the following code:
let width;
cy.get("[data-cy=foo-bar]")
.should(element => (width = element.width()))
.get("[data-cy=baz-baz]")
//some other chained Cypress operations
...;
I would like the line .getCy("baz-baz")
no to execute until the width
was set. How could I achieve that in the cleanest way you know?
I would like to preserve the chaining of operations and avoid nesting, since I may require more than one variable later on and it becomes quite messy to put everything inside the should
.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论