# Instructions

- Following Playwright test failed.
- Explain why, be concise, respect Playwright best practices.
- Provide a snippet of code with the fix, if possible.

# Test info

- Name: checkout-flow/uk.spec.ts >> @COF_UK PAYPAL PAYMENT >> UK - PayPal Standard - Checkout with PayPal Standard in Checkout page
- Location: tests/checkout-flow/uk.spec.ts:73:7

# Error details

```
Error: expect(locator).toBeVisible() failed

Locator: locator('//form[@class=\'cart-form rounded\']//button[@name=\'checkout\']')
Expected: visible
Timeout: 40000ms
Error: element(s) not found

Call log:
  - Expect "toBeVisible" with timeout 40000ms
  - waiting for locator('//form[@class=\'cart-form rounded\']//button[@name=\'checkout\']')

```

```yaml
- link "Skip to content":
  - /url: "#main"
- complementary:
  - paragraph:
    - link "Rated 4.7/5 ⭐️ Free shipping ⭐️ Free returns":
      - /url: /collections/our-products
- banner:
  - navigation:
    - list:
      - listitem:
        - group: Kegel Exercisers
      - listitem:
        - group: Breast Pump
  - link "Perifit (United Kingdom)":
    - /url: /
  - navigation:
    - list:
      - listitem:
        - link "FAQ & Support":
          - /url: /pages/faq-perifit
  - link "Open search":
    - /url: /search
  - link "Open cart":
    - /url: /cart
- main:
  - img "Perifit Care+ | Smart Kegel Exerciser"
  - button "Zoom"
  - img "Perifit Care+ | Smart Kegel Exerciser"
  - button "Zoom"
  - img "Perifit Care+ | Smart Kegel Exerciser"
  - button "Zoom"
  - heading "Perifit Care+ | Smart Kegel Exerciser" [level=1]
  - heading "Stop leaks in weeks with 5-min games" [level=5]
  - text: Sale price £139.00
  - button "4.81 stars": 
  - text: 3635 reviews
  - button "Add to cart"
  - iframe
  - link "More payment options":
    - /url: "#"
  - text: "In Stock: Ships today - Free delivery in 72 hours."
  - separator
  - text: 💪
  - strong: Clinically proven
  - text: to improve pelvic floor strength and reduce urine leaks 🎮
  - strong: Game-based workouts
  - text: keep you engaged 📈
  - strong: Track progress
  - text: in-app to stay motivated 🛡️
  - strong: Home-based training
  - text: that saves you from hospital visits and high costs ⚡
  - strong: Intuitive, biofeedback-powered
  - text: device + app
  - group: How it works
  - text: 100-day trial period
  - paragraph:
    - link "Free and easy":
      - /url: /policies/refund-policy
    - text: returns
  - text: Free delivery
  - paragraph: Anonymous and discreet parcel
  - paragraph: Frequently bought together
  - img "Travel Pouch for Kegel Exercisers"
  - link "Travel Pouch for Kegel Exercisers":
    - /url: /products/small-bag?pr_prod_strat=pinned&pr_rec_id=a31919200&pr_rec_pid=9117604020551&pr_ref_pid=9051893072199&pr_seq=uniform
  - paragraph: £16.99
  - button "+ Add"
  - paragraph: As simple as it gets
  - paragraph: 💡 Insert the Perifit Care+ device 🎮 Play games with your pelvic floor ✅ Detect inaccurate contractions 💪 Quickly strengthen your pelvic floor 🥳 Improve your pelvic floor
  - link "Learn How it Works":
    - /url: /pages/perifit-care-app
  - paragraph: Build body strength while protecting your pelvic floor
  - paragraph: For more durable results, Perifit Care+ exclusively offers activities designed to strengthen your abdominal and gluteal muscles while protecting your pelvic floor.
  - heading "Choose the solution that suits you best" [level=2]
  - link "#color_green":
    - /url: /products/kegel-exerciser-with-app
    - img "#color_green"
  - link "Perifit Care | Original Kegel Exerciser":
    - /url: /products/kegel-exerciser-with-app
  - text: Sale price £119.00
  - link "View":
    - /url: /products/kegel-exerciser-with-app
  - text: Current page
  - link "Perifit Care+ | Smart Kegel Exerciser":
    - /url: /products/new-kegel-exerciser-with-app-perifit-plus
    - img "Perifit Care+ | Smart Kegel Exerciser"
  - link "Perifit Care+ | Smart Kegel Exerciser":
    - /url: /products/new-kegel-exerciser-with-app-perifit-plus
  - text: Sale price £139.00
  - link "View":
    - /url: /products/new-kegel-exerciser-with-app-perifit-plus
  - text: Summary
  - paragraph: "The #1 best-selling pelvic floor trainer"
  - paragraph: The most advanced pelvic floor trainer
  - text: Comprehensive pelvic floor training
  - paragraph: ✅
  - paragraph: ✅
  - text: Small design for added comfort
  - paragraph: ❌
  - paragraph: ✅
  - text: Flexible design adapting to all anatomies
  - paragraph: ❌
  - paragraph: ✅
  - text: Position detection for more precise tracking
  - paragraph: ❌
  - paragraph: ✅
  - button "See more features"
  - button "Read more"
  - button "Read more"
  - button "Read more"
  - button "Read more"
  - button "Read more"
  - region:
    - group "Item 1 of 2":
      - paragraph: Cut out the guesswork
      - paragraph: Perifit Care+ removes uncertainty by providing real-time feedback, indicating when you're engaging your pelvic floor muscles correctly, simplifying and enhancing your journey to a stronger pelvic floor
    - group "Item 2 of 2":
      - paragraph: Monitor your technique
      - paragraph:
        - text: Without feedback, only 50% of women perform Kegels correctly, while
        - link "1/4 risk unintentional harm":
          - /url: https://pubmed.ncbi.nlm.nih.gov/25349943/
        - text: . Perifit Care's dual sensor biofeedback helps improve your technique with visual cues and protects you pelvic floor from harm.
  - text: 100-day trial
  - heading "Customer Reviews" [level=2]
  - img "Average rating is 4.81 stars":  4.81 out of 5
  - text: Based on 3635 reviews
  - button "85% (3085) reviews with 5 star rating": 
  - text: "3085"
  - button "12% (437) reviews with 4 star rating": 
  - text: "437"
  - button "2% (89) reviews with 3 star rating": 
  - text: "89"
  - button "0% (9) reviews with 2 star rating": 
  - text: "9"
  - button "0% (15) reviews with 1 star rating": 
  - text: "15"
  - textbox "Search"
  - text:  Sort by
  - combobox "Sort by ":
    - option "Most Recent" [selected]
    - option "Highest Rating"
    - option "Lowest Rating"
    - option "Only Pictures"
    - option "Pictures First"
    - option "Videos First"
    - option "Most Helpful"
  - text:     Customer Verified
  - img "4 star review": 
  - time: 09/06/2026
  - paragraph: Perifit is helping me learn the feeling of using the right muscles for contractions. It has clearly pointed out my areas of strengths and weaknesses. For instance, I have trouble relaxing the muscles. I wouldn’t have a way of know that without Perifit. I recommend the device.
  - text:    Customer Verified
  - img "5 star review": 
  - time: 31/05/2026
  - text: Fantastic!
  - paragraph: Compact, portable, easy to clean and silly fun instead of serious labor. Much more important, it works. Since using this for 15 minutes a night, I no longer have pee leaks when I need to go urgently, and I do not get up at night to pee. Even better, I discovered that flexing those same muscles without the device during the day causes a mild orgasm!
  - text:    Katherine Francis Verified
  - img "5 star review": 
  - time: 31/03/2026
  - text: It really works
  - paragraph: Ever since having my girls, I have struggled with minor stress incontinence when running. I tried everything from formal pelvic floor therapy, Pilates, doing Kegels on my own. Nothing seemed to work. I decided to try Perifit on a whim, couldn't hurt, but didn't hold out too much hope. Six week later, and the problem is gone. I can run without a worry! I couldn't be happier!
  - text:   Lucy Verified
  - img "4 star review": 
  - time: 23/07/2026
  - text: Seems to be helping
  - paragraph: The only thing I find disappointing is that the data from the games is not included in how you are getting on. The data is obviously there in the background, it could be provided separately. Other than that, it's just 10 minutes a day and really easy to use.
  - text:   Customer Verified
  - img "4 star review": 
  - time: 22/07/2026
  - text: I do like it
  - paragraph: I really do have fun with this. It can be aggravating when I don’t get the placement just right but you’ll know. My only wish is that it would offer me some feedback on how to improve or what I need to improve. Like you can be bad at it but HOW do you get better. I need feedback.
  - text:   Ann Bass Verified
  - img "5 star review": 
  - time: 21/07/2026
  - text: Great Product
  - paragraph: Just started using but very impressed so far
  - text:   Emily Nichols Verified
  - img "4 star review": 
  - time: 15/07/2026
  - text: The games are nice
  - paragraph: I think it's great. It works really well. I'd love to have a free style type game where you can test how long you can squeeze it and what levels you can hold it at and for how long.
  - paragraph: Or like an elevator type game where you can squeeze it and release.
  - text:   Cathryn Perendy Verified
  - img "5 star review": 
  - time: 14/07/2026
  - paragraph: Perifit Care+ | Smart Kegel Exerciser
  - text:   Anonymous Verified
  - img "5 star review": 
  - time: 12/07/2026
  - text: Highly recommend
  - paragraph: As I work with gynae patients, I am well aware of the importance of strong pelvic floor muscles. Personally my issue was that I felt like a tiny gremlin was using my bladder as a trampoline. I would suddenly get the sensation that I really needed to go for a wee, but when I got to the toilet, there was very little in my bladder. Perifit is easy to use and makes doing the exercises fun. The time spent exercising goes really quickly and it’s very clever how the device makes the exercises gradually harder as your strength increases. My symptoms improved within a couple of weeks. An unexpected benefit has been that I am only getting up to the toilet in the night once now, instead of 2 or 3 times, so my sleep is less disturbed.
  - text:   Sarah Thomas Verified
  - img "4 star review": 
  - time: 08/07/2026
  - text: Good once we sorted the false start
  - paragraph: My first purchase came in a broken box and the item looked damaged. It wouldn’t calibrate so I contacted perefit and after a couple of days back and for they replaced the item straight away. Since then it’s been all good. It has helped me to control my pelvic floor and has shown how little I relax… it definitely helps to focus my efforts for exercises.
  - button "Load More"
  - heading "FAQ" [level=2]
  - group: Why should I use Perifit Care or Perifit Care+?
  - group: Can I download the Perifit app for free?
  - group: How long will it take to get my order?
  - group: How to choose between Perifit Care and Care+?
  - group: What are the dimensions of Perifit probes?
  - group: For how long and how often should I use Perifit?
  - group: Are Perifit probes safe?
  - group: Are there any health effects associated with using Bluetooth technology in this device?
  - link "See more FAQs":
    - /url: /pages/faq-perifit
  - region:
    - group "Item 1 of 4":
      - paragraph: Over 10,000 5-star reviews
      - paragraph:
        - text: Top ratings on
        - link "Amazon":
          - /url: https://www.amazon.com/Perifit-Probe-Video-Games-Pelvic/dp/B09ZPX3FLH
        - text: ","
        - link "App Store":
          - /url: https://apps.apple.com/us/app/perifit/id1183437203
        - text: ", and"
        - link "Google Play.":
          - /url: https://play.google.com/store/apps/details?id=starshipproduct.perifitmainapp&hl=en&gl=US
    - group "Item 2 of 4":
      - paragraph: Free and easy product returns
      - paragraph:
        - link "Return free":
          - /url: https://uk.perifit.co/policies/refund-policy
        - text: within 100 days of purchase
    - group "Item 3 of 4":
      - paragraph: Fast and free shipping
      - paragraph:
        - text: Enjoy
        - link "free":
          - /url: https://uk.perifit.co/policies/shipping-policy
        - text: and discreet shipping on £35+ orders.
    - group "Item 4 of 4":
      - paragraph: Exceptional customer service
      - paragraph:
        - link "Expert team":
          - /url: mailto:support@perifit.co
        - text: dedicated to your journey’s success.
  - navigation "breadcrumbs":
    - list
  - paragraph: "Don’t miss out on our exclusive offers:"
  - textbox "E-mail"
  - button "Subscribe"
  - paragraph: Contact
  - list:
    - listitem:
      - link "FAQ":
        - /url: /pages/faq-perifit
    - listitem:
      - link "Blog":
        - /url: /pages/blog
    - listitem:
      - link "Contact Us":
        - /url: /pages/faq-perifit
    - listitem:
      - link "All Perifit reviews":
        - /url: /pages/all-products-reviews
    - listitem:
      - link "Health Professionals":
        - /url: https://form.typeform.com/to/VZXtjpLH
    - listitem:
      - link "Distribution & Wholesale":
        - /url: mailto:sales@perifit.co
  - paragraph: Legal Information
  - list:
    - listitem:
      - link "Terms and conditions":
        - /url: /policies/terms-of-sale
    - listitem:
      - link "Legal Notice":
        - /url: /policies/legal-notice
    - listitem:
      - link "Terms of Service":
        - /url: /policies/terms-of-service
    - listitem:
      - link "Privacy Policy":
        - /url: /policies/privacy-policy
    - listitem:
      - link "Shipping Policy":
        - /url: /policies/shipping-policy
    - listitem:
      - link "Refund Policy":
        - /url: /policies/refund-policy
  - paragraph: © 2026, Perifit all rights reserved.
```

# Test source

```ts
  1   | import { expect, Page } from "@playwright/test";
  2   | 
  3   | export class CartPage {
  4   |     page: Page;
  5   | 
  6   |     constructor(page: Page) {
  7   |         this.page = page;
  8   |     }
  9   | 
  10  |     defaultPaypalAccount = {
  11  |         username: "for.test.perifit@gmail.com",
  12  |         password: "Testforperifit2024"
  13  |     };
  14  | 
  15  |     defaultShopPay = {
  16  |         account: "for.test.perifit@gmail.com",
  17  |         password: "Testforperifit2024"
  18  |     }
  19  | 
  20  |     xpathBtnBuyWithShopPay = "//shop-pay-wallet-button";
  21  |     xpathBtnBuyWithPayPal = "//div[@aria-label='PayPal' and @id='buttons-container'] | //paypal-button";
  22  | 
  23  |     // PayPal
  24  |     xpathPayPalExpress = "(//div[@aria-label='PayPal' and @id='buttons-container']) | //paypal-button";
  25  |     xpathHeaderTextPayPal = "//h1[@id='headerText']";
  26  |     xpathUsernamePayPal = "//input[@id='email']";
  27  |     xpathPasswordPayPal = "//input[@id='password']";
  28  |     xpathBtnLogIn = "//button[@id='btnLogin']";
  29  |     xpathChooseAWayToPay = "//div[text()='Choose a way to pay']";
  30  |     xpathAddACreditOrPrepaidCard = "//div[text()='Add a credit or prepaid card']";
  31  |     xpathCardNumberPayPal = "//input[@id='cardNumber']";
  32  |     xpathExpirationDatePayPal = "//input[@id='cardExpiry']";
  33  |     xpathCardCVVPayPal = "//input[@id='cardCvv']";
  34  |     xpathLogoPayPal = "(//p[text()='PayPal'])[1]";
  35  | 
  36  |     // Cart Drawer
  37  | 
  38  |     // ShopPay
  39  |     xpathIframeShopPayPayment = "//iframe[@id='shop-pay-login-iframe']";
  40  |     xpathBtnChangeShopPayPayment = "//button[text()='Change']";
  41  |     xpathCheckout = "//button[@class='button button--xl w-full']"
  42  | 
  43  |     get cartLoc() {
  44  |         return {
  45  |             xpahtBtnCheckoutCartDrawer: this.page.locator("//button[@name='checkout']")
  46  |         }
  47  |     }
  48  | 
  49  | 
  50  |     async clickBtnCheckout() {
  51  |         await this.page.waitForTimeout(5_000);
> 52  |         await expect(this.page.locator("//form[@class='cart-form rounded']//button[@name='checkout']")).toBeVisible({ timeout: 40_000 });
      |                                                                                                         ^ Error: expect(locator).toBeVisible() failed
  53  |         const checkoutButton = this.page.locator("//form[@class='cart-form rounded']//button[@name='checkout']");
  54  |         if (await checkoutButton.count() > 0) {
  55  |             await checkoutButton.click();
  56  |             await this.page.waitForTimeout(5_000);
  57  |         }
  58  |     }
  59  | 
  60  |     async buyWithShopPay() {
  61  |         await this.page.waitForTimeout(3000);
  62  |         await this.page.click(this.xpathBtnBuyWithShopPay);
  63  | 
  64  |         const iframeShopPayPayment = this.page.frameLocator(this.xpathIframeShopPayPayment);
  65  |         await iframeShopPayPayment.locator("//input[@id='IdentityEmailForm-input']").fill(this.defaultShopPay.account);
  66  |         await iframeShopPayPayment.locator("//button[contains(@class,'button')]").click();
  67  |         await this.page.waitForTimeout(7000);
  68  |     }
  69  | 
  70  |     async buyWithPayPal() {
  71  |         await this.page.locator(this.xpathCheckout).waitFor({ state: 'visible', timeout: 30_000 });
  72  |         await this.page.locator(this.xpathCheckout).click();
  73  |         const iframePayPal = this.page.frameLocator("//iframe[contains(@title,'PayPal') or @id='PAYPAL_EXPRESS-iframe']").first();
  74  | 
  75  |         await expect(iframePayPal.locator(this.xpathBtnBuyWithPayPal)).toBeVisible({ timeout: 30_000 })
  76  |         await this.page.waitForTimeout(2_000);
  77  |         const [popup] = await Promise.all([this.page.waitForEvent("popup", { timeout: 20_000 }), await iframePayPal.locator(this.xpathBtnBuyWithPayPal).click({ force: true })]);
  78  |         await popup.waitForLoadState();
  79  | 
  80  |         // Just verify the popup is opened
  81  |         return true;
  82  | 
  83  |         // login
  84  |         // await popup.waitForSelector(this.xpathHeaderTextPayPal);
  85  |         // await popup.locator("//input[@id='email']").fill(this.defaultPaypalAccount.username);
  86  |         // await popup.locator("//button[contains(@class,'login-click-next')]").click();
  87  |         // await popup.waitForTimeout(6000);
  88  | 
  89  |         // if (await popup.locator(this.xpathLogoPayPal).isVisible()) {
  90  |         //     return true;
  91  |         // } else if (await popup.locator(this.xpathHeaderTextPayPal).isVisible()) {
  92  |         //     return true;
  93  |         // } else if (await popup.locator(this.xpathPasswordPayPal).isVisible()) {
  94  |         //     return true;
  95  |         // } else {
  96  |         //     return false;
  97  |         // }
  98  | 
  99  |         // await popup.waitForSelector(this.xpathHeaderTextPayPal);
  100 |         // await popup.locator(this.xpathPasswordPayPal).fill(this.defaultPaypalAccount.password);
  101 |         // await popup.locator(this.xpathBtnLogIn).click();
  102 |         // await popup.waitForSelector("//button[@id='change-shipping']");
  103 |         // // await popup.click("//button[@data-testid='submit-button-initial']");
  104 |     }
  105 | 
  106 |     async buyWithPaypalInCheckout() {
  107 |         await this.page.waitForTimeout(5_000);
  108 |         const iframePayPal = this.page.frameLocator("//iframe[contains(@title,'PayPal') or @id='PAYPAL_EXPRESS-iframe']").first();
  109 |         const [popup] = await Promise.all([this.page.waitForEvent("popup", { timeout: 40_000 }), await iframePayPal.locator(this.xpathBtnBuyWithPayPal).click()]);
  110 |         await popup.waitForLoadState();
  111 |         return true;
  112 |     }
  113 | }
```