Create and use parameterized selectors in the Magento Functional Testing Framework

Setting up a selector in section

In a <section></section>, create a new <element/>.

Create a new element

Add the attribute parameterized="true" to the <element/>.

Set parameterized flag

In the selector="" attribute add your selector.

Specify your selector

Selector with single variable

For the parameterized part of the selector, add {{var1}} to represent the first piece of data that you want to replace.

Add a parameter to substitute

Enter a descriptive name into the name="" attribute.

Add a name for the element

Enter the type of UI element that the <element/> represents.

Enter the type

Selector with multiple variables

For the parameterized part of the selector, add {{var1}}, {{var2}}, ..., {{varN}} for each parameter that you need to pass in.

Add var2

Add var3

Using a parameterized selector in a test

Create a new test in a cest.

Create a test

Add an action.

Add action

In the selector="" attribute, enter "{{}}".

Add braces to selector

Inside the {{}}, make a reference to the section that the element is assigned to.

Reference section

Make a reference to the section

Inside the {{}}, add name of a parameterized element separated by "."

Add the reference element

Inside the {{}}, add a set of "()" following the parameterized element.

Add parentheses

Inside of the (), add the first parameter that you’d like to pass to the selector.

Add the first parameter

Add the 2nd/3rd parameters that you’d like to pass to the selector separated by ,

Add other parameters

Any data can be used in parameterized elements as well as entered in test actions like so:

  • _defaultCategory.is_active is a reference to <data key="is_active"> in <entity name="_defaultCategory" ... ></entity> in the corresponding …/Data/*.xml
  • stringLiteral is a literal
  • $$ is a reference to persisted data created in the SampleCest1 within action with stepKey="createDataKey"
  • {$variable} is a reference to data returned by a test action, like <grabValueFrom>.