I am navigating to this website https://www.twitch.tv/
and to register a new user.
I am performing those steps:
I am trying to get this window but my application does not recognize the page and I am getting an error. please mind the image attached:
this is my code:
describe('RegisterTwitchTv', function() {
it('Register New User', function() {
cy.visit('')
cy.title().should('eq', 'Twitch')
cy.get('button[data-a-target="signup-button"]').click()
// cy.on('window:confirm', ($alertElement) => {
// expect($alertElement).to.equal('Log in')
// }).click
cy.contains('Log in').click()
cy.window().then((win) => {
cy.get('button[class~="tw-pd-x-1"]').click()
})
})
})
but my code does not recognize the new window which is the one I want to handle.
Unfortunately accessing new windows via Cypress is not possible in its current version.
I would be a good practice to test this functionality using two isolated tests:
describe('RegisterTwitchTv', () => {
// Check the popup is opened
it('Register New User popup is opened', () => {
cy.visit('', {
onBeforeLoad(win) {
cy.stub(win, 'open');
}
});
cy.title().should('eq', 'Twitch')
cy.get('button[data-a-target="signup-button"]').click();
cy.contains('Log in').click();
cy.window()
.its('open')
.should('be.called');
});
// Check the login works
it('Register New User2 login', () => {
cy.visit('/login?popup=true');
cy.get('button[class~="tw-pd-x-1"]').click()
cy.get('#signup-username').type('[email protected]');
...
...
});
});