<?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="ClickThreeDSecureActionGroup">
        <annotations>
            <description>Clicks a button inside the 3D Secure modal.</description>
        </annotations>
        <arguments>
            <argument name="ButtonToClick" defaultValue="{{StorefrontCheckoutThreeDSecureSection.completeAuthenticationButton}}" type="string"/>
        </arguments>

        <!-- We don't want to wait for a page load because a spinner is running behind the 3DS modal -->
        <wait time="5" stepKey="waitFor3DSModalToRender"/>

        <waitForElementVisible selector="{{StorefrontCheckoutThreeDSecureSection.overlayIframe}}" time="30" stepKey="waitForOverlayIframe"/>
        <switchToIFrame selector="{{StorefrontCheckoutThreeDSecureSection.overlayIframe}}" stepKey="switchToOverlayIframe"/>
        <waitForElementVisible selector="{{StorefrontCheckoutThreeDSecureSection.challengeIframe}}" time="10" stepKey="waitForChallengeIframe"/>
        <switchToIFrame selector="{{StorefrontCheckoutThreeDSecureSection.challengeIframe}}" stepKey="switchToChallengeIframe"/>
        <!--<waitForElement selector="{{StorefrontCheckoutThreeDSecureSection.fullScreenIframe}}" time="10" stepKey="waitForFullScreenIframe"/>
        <switchToIFrame selector="{{StorefrontCheckoutThreeDSecureSection.fullScreenIframe}}" stepKey="switchToFullScreenIframe"/>-->

        <waitForElementVisible selector="{{ButtonToClick}}" time="60" stepKey="waitForButton"/>
        <waitForElementClickable selector="{{ButtonToClick}}" time="60" stepKey="waitForButtonClickable"/>
        <wait time="1" stepKey="waitForUIToRender"/>
        <click selector="{{ButtonToClick}}" stepKey="clickButton"/>
        <waitForElementNotVisible selector="{{ButtonToClick}}" time="60" stepKey="waitForButtonNotVisible"/>

        <waitForElementNotVisible selector="{{StorefrontCheckoutThreeDSecureSection.fullScreenIframe}}" stepKey="waitForfullScreenIframeNotVisible"/>
        <switchToIFrame stepKey="switchOutOfFullScreenIframe"/>
        <waitForElementNotVisible selector="{{StorefrontCheckoutThreeDSecureSection.challengeIframe}}" stepKey="waitForChallengeNotVisible"/>
        <switchToIFrame stepKey="switchOutOfChallengeIframe"/>
        <!--<waitForElementNotVisible selector="{{StorefrontCheckoutThreeDSecureSection.overlayIframe}}" stepKey="waitForOverlayIframeNotVisible"/>
        <switchToIFrame stepKey="switchOutOfOverlayIframe"/>-->

        <wait time="5" stepKey="waitForTokenGeneration" />

    </actionGroup>
</actionGroups>
