Request Quote

How To Use Variable in Magento Functional Testing Framework

In this article, I am going to explain how to use any value or text again in writing Test in Magento Functional Testing Framework. Suppose you have created any new customer for testing purpose in your Magento and you want to delete the same customer after completion of your test work or you have placed an order in Magento and you want to search same order again in order grids of Magento back-end then this article will be very helpful for you.

Here I will give an example of how to search same order id of your placed order again in your Magento orders grid.

Here is the example of, How to get text by using the variable :

I have taken an example from the checkout module of Magento. Magento has used it in the file: StorefrontCustomerCheckoutTest.xml

Magento has used it in placing an order and then searching same order again in the orders grid of Magento back-end.

StorefrontCustomerCheckoutTest.xml :

<grabTextFrom stepKey="s53" selector="{{CheckoutSuccessMainSection.orderNumber22}}"/>
        <see stepKey="s55" selector="{{CheckoutSuccessMainSection.success}}" userInput="Your order number is:" />
        <actionGroup ref="LoginAsAdmin" stepKey="loginAsAdmin1"/>
        <amOnPage stepKey="s67" url="{{OrdersPage.url}}"/>
        <waitForPageLoad stepKey="s75"/>
        <fillField stepKey="s77" selector="{{OrdersGridSection.search}}" userInput="{$s53}" />
        <waitForPageLoad stepKey="s78"/>
        <click stepKey="s81" selector="{{OrdersGridSection.submitSearch22}}" />

Let see above keywords explanation:
1. grabTextFrom:
It is the main part of getting a text of order id. This tag is used when we want to get a text of any place.
2. stepKey = “s53” : It is used for unique identifier but here stepKey variable name i.e. s53 is used for saving the value of order id which I have to get by using the grabTextFrom keyword.
This orderId variable is used again in userInput by $s53.
3. selector=”{{CheckoutSuccessMainSection.orderNumber22}}” : Selector I have used by using section in which you can use any by any id, CSS selector, name or by using any attribute. Its Selector  is not different than any other element selection in Magento Functional Testing Framework
4. userInput=”{$s53}”: userInput is use to provide data in Test. Here I have used userInput which I have saved earlier in stepKey.

Summary of above article: Firstly I have used grabTextFrom for getting orderId and saved it in the stepKey variable and then this stepKey variable I have used again on orders page grid by giving userInput.

How to get value by using Variable: 

grabValueFrom: For getting the value of any place, there is a keyword: grabValueFrom.

Suppose you want to get the value of any text field and you want to use that value again then you can use grabValueFrom keyword. You have to follow the same process of the above code, the only thing is you have to put grabValueFrom keyword in the place of grabTextFrom.

Thanks!

. . .

Comment

Add Your Comment

Be the first to comment.

css.php