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

297
Views
How can I get the url in cypress?

When I click on the button, I try to check if I'm on the right page.

Here is my code:

describe('espace_parent is functional', () => {
  it('test login parent', () => {

    cy.visit('http://localhost:3000')
    cy.contains('parent').click()
    cy.contains('Espace Parent')



    cy.get(":input[placeholder='Adresse e-mail']").type('guigui@guigui.fr')
    cy.get(":input[placeholder='Mot de passe']").type('guigui')
    cy.contains('Se connecter').click() 


    cy.log('Current URL is ')
    cy.contains("Accueil")

  })
})

On this code, I am on localhost3000, I click on the parent who has to redirect me to localhost3000/connexion/parent and I want to login but I don't know if it's functioning or not.

I already tried to do different things to print the URL, but none work.

about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

You have to use the cy.url().

  1. To print the URL you can use:
cy.url().then((url) => {
  cy.log('Current URL is: ' + url)
})
  1. If you want to validate the URL you can use:
cy.url().should('include', '/connexion/parent')
about 4 years ago · Juan Pablo Isaza Report

0

You can get the url with command cy.url() or cy.location().

You would use cy.url() like this:

// with should()
cy.url().should('eq', 'http://localhost:3000/connexion/parent');
cy.url().should('include', '/connexion/parent');
// with then()
cy.url().then(url => cy.log('Current URL is', url);
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!