Examples of get the url within your application in Cypress, for a full reference of commands, go to docs.cypress.io
To get window.location
, use the cy.location()
command.
cy.location().should((location) => {
expect(location.hash).to.be.empty
expect(location.href).to.eq('http://localhost:8080/commands/location')
expect(location.host).to.eq('localhost:8080')
expect(location.hostname).to.eq('localhost')
expect(location.origin).to.eq('http://localhost:8080')
expect(location.pathname).to.eq('/commands/location')
expect(location.port).to.eq('8080')
expect(location.protocol).to.eq('http:')
expect(location.search).to.be.empty
})
To get the current URL, use the cy.url()
command.
cy.url().should('eq', 'http://localhost:8080/commands/location')