<?xml version="1.0" encoding="UTF-8"?>
<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
              xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
    <actionGroup name="SelectCurrencyActionGroup">
        <annotations>
            <description>Selects a currency in the Stripe currency selector iframe (adaptive pricing) and waits for the Payment Element to refresh its available payment methods.</description>
        </annotations>
        <arguments>
            <argument name="currencyCode" type="string"/>
        </arguments>

        <waitForElementVisible selector="{{StorefrontStripePaymentMethodSection.currencySelectorIframe}}" stepKey="waitForCurrencySelector" time="30"/>
        <switchToIFrame selector="{{StorefrontStripePaymentMethodSection.currencySelectorIframe}}" stepKey="switchToCurrencySelector"/>
        <waitForElementClickable selector="{{StorefrontStripePaymentMethodSection.currencySelectorOption(currencyCode)}}" stepKey="waitForCurrencyOption" time="10"/>
        <click selector="{{StorefrontStripePaymentMethodSection.currencySelectorOption(currencyCode)}}" stepKey="clickCurrencyOption"/>
        <switchToIFrame stepKey="switchToDefaultFrame"/>

        <!-- Give Stripe a few seconds to refresh the payment methods after the currency change -->
        <wait time="4" stepKey="waitForPaymentMethodsToRefresh"/>

    </actionGroup>
</actionGroups>