无法使用存根切换窗口,无法使用赛普拉斯监视

问题描述 投票:0回答:1

我在使用存根方法切换CRM Web应用程序中的窗口时遇到问题。出现以下错误消息

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'

下面是我的代码。

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();
    })
  })

任何人都可以提出我错过的使执行失败的内容

cypress stub
1个回答
0
投票

我也有同样的问题,单击按钮后会打开一个新窗口,我需要切换并采取措施,能为您提供帮助吗?你解决了这个问题吗?您可以切换到另一个窗口吗?

© www.soinside.com 2019 - 2024. All rights reserved.