问题
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