Intercepting external redirections with Cypress

914 views Asked by At

Here is my test scenario:

The user opens a page in my application, fills in some details in a form, and then clicks the button in the form.

A third-party library triggers a redirect to an external website to validate some information. After the validation is complete (this validation takes place in a single page), the script on the external site redirects the user back to my application with a custom URL.

I know that what I described above is similar to an oauth flow, but for something different.

So I know that it is not possible to test external websites with Cypress. As a workaround, I am thinking of intercepting the redirect that is triggered by the button click and manually processing the external site with cy.request. But I am getting nowhere with intercepting the redirect after the button click event. How can I use cy.intercept to get the URL that is requested after the button is clicked?

The second question is that the page I will be working on with 'cy.request' redirects to my app with a custom URL. So I need to intercept this redirect as well to continue testing with the relevant page in my app.

0

There are 0 answers