<?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="AdminAddCustomAttributeToSelectedProductActionGroup">
        <annotations>
            <description>Add the created attribute to the selected product</description>
        </annotations>
        <arguments>
            <argument name="attributeCode" type="string" defaultValue="test_attribute"/>
            <argument name="adminOption1" type="string" defaultValue="value 1 admin"/>
        </arguments>

        <click selector="{{AdminProductFormActionSection.addAttributeButton}}" stepKey="clickOnAddAttributeButton" />
        <click selector="{{AdminProductAttributeSetGridSection.searchAttributeByFilter}}" stepKey="searchAttributeByFilter" />
        <fillField selector="{{AdminProductAttributeSetGridSection.setAttributeCode}}" userInput="{{attributeCode}}" stepKey="filterAttributeCode"/>
        <click selector="{{AdminProductAttributeSetGridSection.applyFilter}}" stepKey="applyFilter" />
        <waitForPageLoad stepKey="waitForResultsToBeDisplayed"/>
        <checkOption selector="{{AdminProductAttributeSetGridSection.selectFromAttributeResult(attributeCode)}}" stepKey="selectAttributeFromDisplayedResult"/>
        <click selector="{{AdminProductAttributeSetGridSection.addSelected}}" stepKey="clickAddSelectedButton" />
        <waitForPageLoad stepKey="waitForAttributesToBeAdded"/>
        <scrollTo selector="{{AdminProductFormSection.attributeTab}}" x="0" y="-100" stepKey="scrollToAttributeTab" />
        <click selector="{{AdminProductFormSection.attributeTab}}" stepKey="expandAttributeTab" />
        <selectOption selector="{{AdminProductFormSection.customSelectField(attributeCode)}}" userInput="{{adminOption1}}" stepKey="selectAvalueFromDropdown"/>
        <click selector="{{AdminProductFormSection.save}}" stepKey="saveTheProduct" />
        <waitForPageLoad stepKey="waitForProductsToBeSaved"/>
    </actionGroup>
</actionGroups>
