Not able to Switch Windows using stub and spy using Cypress

a 夏天 提交于 2019-12-13 03:26:01

问题


I am facing Issue in switching windows within my CRM web Application using Stub methods. Getting below error message

Timed out retrying: { [Function: open]
  callBaseMethod: 
   { [Function]
     callBaseMethod: [Circular],
     getBaseMethod: 
      { [Function]
        callBaseMethod: [Circular],
        getBaseMethod: [Circular],
 resolveInheritance: [Circular],
        registerEnum: [Circular] },
     registerEnum: [Circular] } } is not a spy or a call to a spy!
Because this error occurred during a 'before each' hook we are skipping the remaining tests in the current suite: 'window open'

Below is my code.

describe('window open', function () {
    beforeEach(function () {
      cy.visit('https://abc.in', {
        onBeforeLoad(win) {
          cy.stub(win, 'open').as('windowOpen')
        }  
      })
      cy.xpath('//span[@class="largeTextNoWrap indentNonCollapsible"]').eq(0).click();

    cy.get('#userNameInput',{timeout : 7000}).type("****").debug()

    cy.get('#passwordInput').type('***').screenshot();
    cy.get('#submitButton').click();
    cy.wait(20000);
    cy.xpath('//span[@id="advancedFindImage"]').click();
    cy.wait(20000);
    cy.window().its('open').should('be.called')
    })

    it('see window open being called with url', function () {

        cy.wait(5000);
        cy.xpath('/a[@id="Mscrm.AdvancedFind.Groups.Show.Results-Large"]').click().debug();
        cy.contains('Results').click(); 
      cy.get('@windowOpen').should('be.calledWith', '?appid=&pagetype=advancedfind#761326506').debug();
    })
  })

Can anyone suggest what I have missed in this which is making execution failed

来源:https://stackoverflow.com/questions/58328099/not-able-to-switch-windows-using-stub-and-spy-using-cypress

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!