Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

180
Vistas
URL is not changing. After first time login, the page is redirected to T&C page to accept

Login.spec.js

  it.only('TC02 - Login with valid data as reseller ', () => {
    const id = ut.record(testdata, 2);
    cy.login(id.username, id.password);
    cy.title().should('equal', 'Compass - Home');
    cy.visit('/users');
    cy.logout();
  });

LoginPage.js -> from POM folder

checkHome() {
  const path = '/license-agreement';

  cy.url().then(($url) => {
      if($url.includes(path)) {
          cy.log("Yes")
      } else  {
          cy.log("No")
      }
   })
}

After, login I am calling checkHome method to see if the page is redirected to home or agreement. If its on agreement page then I get accept button and click it.

But when I log url it outputs the previous page url.

Also, this is solved if I put wait in between. But I don't want to use wait and something dynamic solution to this

about 4 years ago · Juan Pablo Isaza
2 Respuestas
Responde la pregunta

0

For testing purposes, you should find a way to avoid this type of conditional testing.

If you cannot then you may want to include the code that calls the checkHome() method. However, to avoid using cy.wait(), you can either add a cy.location('pathname').should('include', '/commmon-path/') if your url's are common for the home page or agreement or query a common element in both pages and append a should (ie cy.get('.common-element-in-home-and-agreement').should('be.visible')).

about 4 years ago · Juan Pablo Isaza Denunciar

0

To wait on the url, instead of .then() try using should() with a function to handle either/or, because should will retry until condition is satisfied

cy.url().should( url => {

  // Assert the url is one of the two expected, retry until passes
  expect(url).to.satisfy(function(url) { 
    return url.includes('/license-agreement') || url.includes('/home')  
  })

  if (url.includes(path)) {
    cy.log("Yes")
  } else  {
    cy.log("No")
  }
})
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda