https://cypress.io logo
Hi everyone Does Cypress support
# general-chat
c
Hi everyone. Does Cypress support navigating to third party pages? On my project, Strype payment is used (after clicking the Pay button), a transition is made to the payment page. My existing tests no longer open the next page after clicking on the Pay button. Thank you in advance for answers
d
If we are talking about multiple domains, then it is best to use the
cy.origin()
command. All the necessary information is here: https://docs.cypress.io/api/commands/origin#docusaurus_skipToContent_fallback
This article by Cypress Ambassador @careful-insurance-62240 may also be helpful: https://kailash-pathak.medium.com/how-to-run-cypress-test-cases-across-multiple-domains-eaba82eab753
c
@dazzling-thailand-9844 Thanks a lot
Hi, @dazzling-thailand-9844 Can I ask you please to help?
I'm using "cy.origin" in the following way cy.origin ('https://checkout.stripe.com/c/pay/', () => { cy.visit ("/*")
But I catch a problem here. After the user is redirected to the payment page - https://checkout.stripe.com/c/pay/ (after the last slash is generated a unique code. It looks like "https://checkout.stripe.com/c/pay/cs_test_a1y0BN8BzJY7VsZL4Jkwa6eJMCuLUZy1xwVxHrkoUZ7Q4ju1aB3DdD0jnp#fi")) How to tell Cypress to "pick up" what's after / Thank you in advance for helping
d
If I understand the question correctly, you can grab the whole url with cy.url() and then separate the desired piece of unique enpoint with split() for example and assign it to some variable. In other words, add something like this on line 27:
Copy code
cy.url().then((url) => {
  const uniqueEndpoint = url.split("someRegEx")[1];
  // do anything with the unique endpoint
});
c
Hi @dazzling-thailand-9844 . To be on one line, I've created a short video, with question. When you will have time, could you please take a look?
Thank you
p
if you need just to check is code 200 you can use this, but I assume that you need to check something else too, so just ignore my comment if that is case. So add this in commands.js file
Cypress.Commands.add('checkValidURL', (urlToCheck) => { cy.request({ url: urlToCheck, followRedirect: true, failOnStatusCode: false, }).then((resp) => { expect(resp.status).to.be(200); }); });
and then just call this on the following way from everywhere
cy.get(loc) .should('have.attr', 'href') .then((href) => { cy.checkValidURL(href).wait(100); });
c
Hi @powerful-journalist-49461 Will this help solve the problem with cy.origin()?
p
Depends what you want to do >>> if you want just to check is response code of your link 200 than answer is YES, if you want to check elements on page that's coming after click than answer is NO, you need to use cy.origin 🙂
c
@powerful-journalist-49461 I need help with resolving this issue https://drive.google.com/file/d/1FqRcQP_UG4GofLWbCN_muDhsPAf0rQ1s/view
Guys, if in short: After clicking on the "MakePayment" button, the user is redirected to the page "https://checkout.stripe.com/c/pay/cs_test_a1E8WaWpykZA5UJXYg81r3YzULc1a1nnnEHsIOn" where "cs_test_a1E8WaWpykZA5UJXYg81r3YzULc1a1nnnEHsIOn" by the system, each time we press the "MakePayment" button, a unique value that is generated by the system is generated How to tell Cypress to "pick up" what's after https://checkout.stripe.com/c/pay/ ->> ?
d
@curved-pager-86474 I've sent you DM
s
Hi everyone, if anyone knows on how to handle iframe with different origin than document please advise. The iframe element is being identified but the 0.contentDocument.body is giving an error that not found. Parent site-> Click Pay-> redirects to different domain-> has credit card payment details embedded in iFrame with a different url. cy.origin('https://somesite.com/',()=>{ const pymnt= Cypress.require("../../PageObjects/Pages/DraftRegApp_Pymnt.js") cy.get("main[role='main'] div h1") .should("be.visible"); cy.wait(5000) cy.get('iframe#monerisCheckout-Frame') .its('0.contentDocument.body') .should('be.visible') .then(cy.wrap) })
3 Views