question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Cypress vanishes when redirecting to site that breaks out of iframe

See original GitHub issue
  • Operating System: Windows 10
  • Cypress Version: 2.1.0
  • Browser Version: Chrome 65.0.3325.181 (Official Build) (64-bit)

Is this a Feature or Bug?

Bug or potentially a feature request

Current behavior:

We integrate with Paypal as part of our checkout journey. We need to be able to redirect from our site to Paypal, enter some test credentials, and verify that we get redirected back to the payment complete page on our site. However, when we reach Paypal, they have some code that breaks their page out of the iframe, and Cypress vanishes altogether and the tests stop.

Desired behavior:

Paypal should not be able to break out of the iframe and the tests should continue to run

How to reproduce:

Clone this repo (the smallest I could get it): https://github.com/jpreecedev/cypress-paypal-scratch

run yarn install then yarn start and yarn test in seperate command windows.

Test code:

describe('Kitchen Sink', function() {
  it('.should() - assert that <title> is correct', function() {
    // https://on.cypress.io/visit
    cy.visit('http://localhost:8080/')

    cy.get('button').click()
  })
})

Additional Info (images, stack traces, etc)

In this repo I don’t redirect to Paypal but another page hosted on my server that basically does the same thing, The file is in the repo and is called breakout.html. Here is the code

<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>Document</title>
</head>

<body>
  <script>
    debugger
    if (top.location != self.location) {
      top.location = self.location.href;
    }
  </script>
</body>

</html>

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:8
  • Comments:19 (2 by maintainers)

github_iconTop GitHub Comments

21reactions
mikobcommented, May 27, 2020

@brian-mann

I want to chime in saying that this would be useful. If we’re making a truly E2E test, then checking out via PayPal/Stripe or doing other things on a 3rd party site may be a critical step in the process. At least with Stripe, they provide a dedicated test sandbox specifically designed for this sort of thing so the points about being blocked due to detected automated activity are not always valid.

I was using webdriverio before, and had a truly E2E test including the checkout with stripe. Sad to see that this isn’t possible with Cypress? Is there no way around it?

15reactions
sosnetcommented, Oct 5, 2021

Three years later I am here, migrating my webdriver tests to cypress and figuring out, that I can’t simulate a checkout with paypal due to the design of cypress? Come on, I am not testing the paypal page, I am testing our checkout-flow. If I can’t test the most critical function of a webshop, what else should I use cypress for? It should be my decision if my tests depend on an external page, but blocking it by default does not sound right to me.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to avoid that tested page exits iframe in Cypress after ...
Our test application requires a login of the user. After login he/she is redirected to the application page itself (a React application).
Read more >
Working with iframes in Cypress
In this blog post I will show how to interact with DOM elements inside an iframe (even if the iframe is served from...
Read more >
Handling stripe payments checkout with cypress - Questions
Cypress runner vanishes when redirects to Stripe for payments checkout. Has anyone faced this issue? Any idea how to handle it. 2 Likes....
Read more >
Using Cypress Intercept to Fix a Cross-Domain Test
Adding MFA added another redirect to our login process and this time, it required going out to an external site rather than a...
Read more >
cypress-io/cypress - Gitter
The iframes are created by javascript after the page is loaded. ... enterBtn and click on a delete button which then redirects to...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found