javascript - Property of window is undefined in cypress - Stack Overflow

I am using Cypress with Meteor.I need the Meteor object on the window to call Meteor.loginWithPassword.

I am using Cypress with Meteor.

I need the Meteor object on the window to call Meteor.loginWithPassword.

I want to use this to skip using the UI for login each time. I have tried the following but Meteor is not on the window when it runs.

cy.window()
  .then((window) => {
      console.log(window.Meteor);
   });

I am using Cypress with Meteor.

I need the Meteor object on the window to call Meteor.loginWithPassword.

I want to use this to skip using the UI for login each time. I have tried the following but Meteor is not on the window when it runs.

cy.window()
  .then((window) => {
      console.log(window.Meteor);
   });
Share Improve this question asked Jul 24, 2018 at 10:31 Ozzy WalshOzzy Walsh 8879 silver badges17 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 5

Try this:

cy.window().its('Meteor');

This will wait until the Meteor property exists on the window object.


Or, if you want to do something with the Meteor property once it exists, use .then():

cy.window().its('Meteor').then(meteor => {
    console.log(meteor);
    // do things
});

.its() will attempt to get a property from the object wrapped by Cypress, in this case the window object, and will retry until the property exists or the mand times out.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745673998a4639574.html

相关推荐

  • javascript - Property of window is undefined in cypress - Stack Overflow

    I am using Cypress with Meteor.I need the Meteor object on the window to call Meteor.loginWithPassword.

    6小时前
    20

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信