Reading list Switch to dark mode

    How to Attach a File in Magento Functional Testing Framework (MFTF)

    Updated 2 November 2018

    Magento has been introduced their inbuild automation framework. Which is based on Codeception. It’s really useful for both QA and Developer for the acceptance Testing.

    The process of using attachments is very simple. Here I’ll give you an example of adding an image. I have used it to automate one of our modules. Where in the backend I need to add an image.

    First, you need to go inside your MagentoRoot/dev/tests/acceptance/tests/_data and upload an image name 1.jpeg. You can upload the image/file of whatever name or extension you want to use. I have used 1.jpeg just for an example.

    Now I’ll explain you the code I have Written related to it.

    Searching for an experienced
    Magento 2 Company ?
    Find out More

    Code which is written in ModuleSection.xml File-

    <element name="labelImage" type="file" selector="#shippinglabel_filename"/>

    Code which is written in ModuleData.xml File-

    <data key="label_image">1.jpeg</data>

    Code which is written in ModuleActionGroup.xml or you can write it directly in ModuleTest.xml file-

    <attachFile userInput="{{AdminRmaShippingLabelData.label_image}}" selector="{{AdminRmaShippingLabelCreateSection.labelImage}}" stepKey="fillLabeluploadImage"/>

    Use <attachFile/> node to attach a file/image.

    Here,

    AdminRmaShippingLabelData is the entity name of ModuleData.xml file.

    AdminRmaShippingLabelCreateSection is the section name of ModuleSection.xml file.

    In case of any doubt please leave a message here.

    Thanks! 🙂

    . . .

    Leave a Comment

    Your email address will not be published. Required fields are marked*


    Be the first to comment.

    Back to Top

    Message Sent!

    If you have more details or questions, you can reply to the received confirmation email.

    Back to Home