title: Cypress redirects automatically to the new URL
body: <p>I wrote some test scenarios of one of the webpage and I still face problem during automatic redirection to the login page for one specific ng-container. I have 3 test scenarios and doesnt matter in witch order I run them - always after first or during the second cookie containing login data is deleted and user redirected to the login page. Is any method to prevent redirecting to the another page and deleting cookie?</p>
  
  <pre><code>import LoginPage from "xxx/LoginPage.spec.js";
  import CreateUser from "xxx/CreateUser.spec.js";
  import Functions from "Cxxx/Functions.spec.js";
  
  describe('Check role selector', () =&gt; {
  
      const login = new LoginPage();
      const register = new CreateUser();
      const functions = new Functions();
  
      var usernameCreatedUser = functions.createUsernameAndNick();
      var nickCreatedUser = functions.createUsernameAndNick();
  
      before(() =&gt; {
          cy.visit('login')
          login.fillUsername(Cypress.env('correctUsername'))
          login.fillPassword(Cypress.env('correctPassword'))
          login.checkButtonLogin().should('be.enabled')
              .click()
          login.fillSMScode(Cypress.env('correctSMScode'))
          login.checkButtonLogin().should('be.enabled')
              .click()
          cy.visit('/control-panel/users/add')
          register.fillUsername(usernameCreatedUser)
          register.fillNick(nickCreatedUser)
          register.fillPassword(functions.createPassword())
          register.fillDivision(0)
          register.fillRole(0)
      })
  
  
  
      it('empty', () =&gt; {
          register.clearDivision()
          register.getButtonSave().should('be.disabled')
      })
  
      it('correct - select 2 divisions - only second is selected', () =&gt; {
          register.clearDivision()
          register.fillDivision(0)
          register.fillDivision(1)
          register.getDivision("Gdańsk", "Warszawa")
          register.fillDivision(1)
          register.getButtonSave().should('be.enabled')
          debugger 
      })
  
      it('correct - select 1 division', () =&gt; {        
          register.clearDivision()
          register.fillDivision(0)
          register.getDivision("Warszawa", "Gdańsk")
          register.getButtonSave().should('be.enabled')
          debugger
      })
  
  })
  
  
  class RegisterPage {
  
    fillDivision(value) {
      cy.get('[formcontrolname="divisionId"]').click()
      cy.get('[class="ng-option-label"]')
        .eq(value)
        .click()
    }
  
    clearDivision(){
      cy.get('[title="Clear all"]').eq(0)
      .should('be.visible')
      .click()
      cy.get('[formcontrolname="divisionId"]').contains('Wybierz')
      this.getDivisionError()
    }
  
    getDivision(value1, value2){
      cy.get('[role="combobox"]').contains(value1).should("have.not.value", value2)
    }
  
    getButtonSave() {
      return cy.get('button').contains('Zapisz')
    }
  }
  export default RegisterPage;
  
  
  Console:
  
  cypress_runner.js:174498 console.clear() was prevented due to 'Preserve log'
  cypress_runner.js:174490 Command:   get
  cypress_runner.js:174490 Yielded:   
  (2) [span.ng-clear-wrapper, span.ng-clear-wrapper]
  cypress_runner.js:174490 Elements:  2
  cypress_runner.js:174490 Selector:  [title="Clear all"]
  [Violation] 'click' handler took 213ms
  cypress_runner.js:174498 console.clear() was prevented due to 'Preserve log'
  cypress_runner.js:174490 Command:     eq
  cypress_runner.js:174490 Selector:    0
  cypress_runner.js:174490 Applied To:  
  (2) [span.ng-clear-wrapper, span.ng-clear-wrapper]
  cypress_runner.js:174490 Yielded:     
  cypress_runner.js:174490 Elements:    1
  [Violation] 'click' handler took 191ms
  VM561 login:1 [DOM] Input elements should have autocomplete attributes (suggested: "current-password"): 
  cypress_runner.js:174498 console.clear() was prevented due to 'Preserve log'
  cypress_runner.js:174490 Command:  assert
  cypress_runner.js:174490 Subject:  
  jQuery.fn.init [span.ng-clear-wrapper, selector: "0", context: document]
  cypress_runner.js:174490 Message:  expected &lt;span.ng-clear-wrapper&gt; to be visible
  [Violation] 'click' handler took 227ms
  cypress_runner.js:174498 console.clear() was prevented due to 'Preserve log'
  cypress_runner.js:174490 Command:     click
  cypress_runner.js:174490 Applied To:  
  cypress_runner.js:174490 Elements:    1
  cypress_runner.js:174490 Coords:      
  {x: 867, y: 370}
  cypress_runner.js:174542 MouseDown
  [Violation] 'click' handler took 231ms
  cypress_runner.js:174498 console.clear() was prevented due to 'Preserve log'
  cypress_runner.js:174490 Event:        xhr
  cypress_runner.js:174490 Method:       GET
  cypress_runner.js:174490 URL:          https://xxx/admin-api/division-managed-objects
  cypress_runner.js:174490 Status:       401 (Unauthorized)
  cypress_runner.js:174490 Duration:     86
  cypress_runner.js:174490 Stubbed:      No
  cypress_runner.js:174490 Request:      
  {headers: {…}, body: null}
  cypress_runner.js:174490 Response:     
  {headers: {…}, body: 401}
  cypress_runner.js:174490 XHR:          
  XMLHttpRequest {method: "GET", url: "https:/xxx/admin-api/division-managed-objects", id: "xhr330", __zone_symbol__ON_PROPERTYreadystatechange: ƒ, __zone_symbol__readystatechangefalse: Array(1), …}
  cypress_runner.js:174498 console.clear() was prevented due to 'Preserve log'
  cypress_runner.js:174490 Event:           new url
  cypress_runner.js:174490 New Url:         https:/xxx/login
  cypress_runner.js:174490 Url Updated By:  pushState
  cypress_runner.js:174490 Args:            
  (3) [{…}, "", "/login"]
  cypress_runner.js:174498 console.clear() was prevented due to 'Preserve log'
  cypress_runner.js:174490 Command:   get
  cypress_runner.js:174490 Elements:  0
  cypress_runner.js:174490 Selector:  [formcontrolname="divisionId"]
  cypress_runner.js:174490 Error:     CypressError: Timed out retrying: Expected to find element: '[formcontrolname="divisionId"]', but never found it.
  ﻿
  </code></pre>