Reputation: 224
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('[email protected]')
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.
Upvotes: 7
Views: 18558
Reputation: 1780
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);
Upvotes: 2
Reputation: 18650
You have to use the cy.url()
.
cy.url().then((url) => {
cy.log('Current URL is: ' + url)
})
cy.url().should('include', '/connexion/parent')
Upvotes: 10