Rayrun
← Back to Discord Forum

Paypal payment flow

merrymary_42246posted in #help-playwright
Open in Discord
merrymary_42246

Hi guys, does anyone have any experience automating the payment flow with Paypal? It's an integrated component on UI [we can't change it internally]. The yellow checkout paypal button is inside an iframe, when clicking it, it opens a new browser window and I can't seem to find a reliable way 1) to always click on this yellow button (flaky) 2) to switch windows from the main one to this window2 to interact with paypal login. When I use a Playwright recorder, it stops recording right after the need to focus on window2.

Screen_Shot_2023-10-03_at_11.45.30_AM.png
Screen_Shot_2023-10-03_at_11.44.42_AM.png

This thread is trying to answer question "Does anyone have any experience automating the payment flow with Paypal, specifically in reliably clicking the Paypal button and switching windows to interact with the Paypal login?"

6 replies

Hi, did you figure how to test PayPal with playwright, I’m also looking for solutions, thanks

merrymary_42246
@terence1948: Yes I think I found it. There are other issues, I requested support from Chargify to clarify their paypal different flows. But for the current issue: 1) please, refer to https://github.com/paypal/react-paypal-js/issues/390 for clicking the checkout button (proper locator) 2) for switching the windows: I wrapped it into a Promise.all() and wait for the event 'page' while clicking on the locator from the above: const [newPage] = await Promise.all([ context.waitForEvent('page'), selectPlanPage.paypalFrame.click({ delay: 5000 }) ]); await newPage.bringToFront();

Yes I think I found it. There are other issues, I requested support from Chargify to clarify their paypal different flows. But for the current issue:

  1. please, refer to https://github.com/paypal/react-paypal-js/issues/390 for clicking the checkout button (proper locator)
  2. for switching the windows: I wrapped it into a Promise.all() and wait for the event 'page' while clicking on the locator from the above: const [newPage] = await Promise.all([ context.waitForEvent('page'), selectPlanPage.paypalFrame.click({ delay: 5000 }) ]); await newPage.bringToFront();
merrymary_42246
@.graff: I believe it opens a new page == new tab, not a popup, so yes, we wait for the event 'page'

I believe it opens a new page == new tab, not a popup, so yes, we wait for the event 'page'

Thanks, @merrymary_42246 , I also figured out by the pop-up suggesstion provided by @.graff

<:blobfingerguns:498891006020681748>

Related Discord Threads

TwitterGitHubLinkedIn
AboutQuestionsDiscord ForumBrowser ExtensionTagsQA Jobs

Rayrun is a community for QA engineers. I am constantly looking for new ways to add value to people learning Playwright and other browser automation frameworks. If you have feedback, email [email protected].