D0nKEYKon9
D0nKEYKon9

Reputation: 47

Cypress: How do I visit, or type a generated URL into the Cypress browser

I currently have an email SMTP server that sends an email, that generates a URL.

I am able to get the contents of the URL from the email, but I want to then visit, or type this URL into the current Cypress address bar. Cypress Runner Log - URL Example

The code I have in Cypress looks like this. CypressExample.js

And the line of code related in the feature file looks like this. CypressExample.feature

When I run the Cypress code is get this error. CypressError

Is there anyway I can use this generated URL and insert it into the Cypress address bar?

Upvotes: 1

Views: 486

Answers (1)

Fody
Fody

Reputation: 32034

The property you need is .href rather than .value

cy.mailosaurGetMessage(serverId, {
  sentTo: testEmail
}).then(email => {
  cy.visit(email.text.links[0].href)
})

Upvotes: 1

Related Questions