<?xml version="1.0" encoding="UTF-8"?>
<!--
 /**
  * Copyright © Magento, Inc. All rights reserved.
  * See COPYING.txt for license details.
  */
-->

<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
              xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
    <actionGroup name="StorefrontAddConfigurableProductToTheCartActionGroup">
        <annotations>
            <description>Goes to the provided Storefront URL. Selects the provided Product Option under the Product Attribute. Fills in the provided Quantity. Clicks Add to Cart. Validates that the Success Message is present.</description>
        </annotations>
        <arguments>
            <argument name="urlKey" type="string"/>
            <argument name="productAttribute" type="string"/>
            <argument name="productOption" type="string"/>
            <argument name="qty" type="string"/>
        </arguments>

        <amOnPage url="{{urlKey}}.html" stepKey="goToStorefrontPage"/>
        <waitForPageLoad stepKey="waitForProductFrontPageToLoad"/>
        <waitForElementVisible selector="{{StorefrontProductInfoMainSection.productOptionSelect(productAttribute)}}" stepKey="waitForOptions"/>
        <selectOption selector="{{StorefrontProductInfoMainSection.productOptionSelect(productAttribute)}}" userInput="{{productOption}}" stepKey="selectOption1"/>
        <fillField selector="{{StorefrontProductPageSection.qtyInput}}" userInput="{{qty}}" stepKey="fillProductQuantity"/>
        <waitForElementNotVisible selector="{{StorefrontProductActionSection.addToCartDisabled}}" stepKey="waitForAddToCartButtonToRemoveDisabledState"/>
        <waitForElementClickable selector="{{StorefrontProductActionSection.addToCart}}" stepKey="waitForAddToCartButton"/>
        <click selector="{{StorefrontProductActionSection.addToCart}}" stepKey="clickOnAddToCartButton"/>
        <waitForPageLoad stepKey="waitForProductToAddInCart"/>
        <waitForElementVisible selector="{{StorefrontMessagesSection.success}}" stepKey="waitForSuccessMessage"/>
        <seeElement selector="{{StorefrontProductPageSection.successMsg}}" stepKey="seeSuccessSaveMessage"/>
    </actionGroup>
</actionGroups>
