Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

169
Views
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 answers
Answer question

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 Report

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!