Edit in GitHubLog an issue

Parameterized selectors

Use the following examples to create and use parameterized selectors in the MFTF.

Set up a selector in section

Create a new <element/> in a <section></section>, :

Copied to your clipboard
<section name="SampleSection">
<element name="" type="" selector=""/>
</section>

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

Copied to your clipboard
<section name="SampleSection">
<element name="" type="" selector="" parameterized="true"/>
</section>

Add your selector in the selector="" attribute:

Copied to your clipboard
<section name="SampleSection">
<element name="" type="" selector="#element" parameterized="true"/>
</section>

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:

Copied to your clipboard
<section name="SampleSection">
<element name="" type="" selector="#element .{{var1}}" parameterized="true"/>
</section>

Add a descriptive name in the name="" attribute:

Copied to your clipboard
<section name="SampleSection">
<element name="oneParamElement" type="" selector="#element .{{var1}}" parameterized="true"/>
</section>

Add the type of UI element that the <element/> represents in type:

Copied to your clipboard
<section name="SampleSection">
<element name="oneParamElement" type="text" selector="#element .{{var1}}" parameterized="true"/>
</section>

Selector with multiple variables

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

Copied to your clipboard
<section name="SampleSection">
<element name="threeParamElement" type="text" selector="#element .{{var1}} .{{var2}}" parameterized="true"/>
</section>
Copied to your clipboard
<section name="SampleSection">
<element name="threeParamElement" type="text" selector="#element .{{var1}} .{{var2}}-{{var3}}" parameterized="true"/>
</section>

Use a parameterized selector in a test

Create a new test:

Copied to your clipboard
<test name="SampleTest">
</test>

Add an action:

Copied to your clipboard
<test name="SampleTest">
<click selector="" stepKey="click1"/>
</test>

Enter "{{}}" in the selector="" attribute:

Copied to your clipboard
<test name="SampleTest">
<click selector="{{}}" stepKey="click1"/>
</test>

Make a reference to the section that the element is assigned to inside the {{}}:

Copied to your clipboard
<test name="SampleTest">
<click selector="{{SampleSection}}" stepKey="click1"/>
</test>

Add name of a parameterized element, separated by ".", inside the {{}}:

Copied to your clipboard
<test name="SampleTest">
<click selector="{{SampleSection.threeParamElement}}" stepKey="click1"/>
</test>

Add a set of "()" following the parameterized element inside the {{}}:

Copied to your clipboard
<test name="SampleTest">
<click selector="{{SampleSection.threeParamElement()}}" stepKey="click1"/>
</test>

Add the first parameter, that you would like to pass to the selector, inside of the ():

Copied to your clipboard
<test name="SampleTest">
<click selector="{{SampleSection.threeParamElement(_defaultCategory.is_active)}}" stepKey="click1"/>
</test>

Add the second or third parameters, that you'd like to pass to the selector, separated by ,:

Copied to your clipboard
<test name="SampleTest">
<click selector="{{SampleSection.threeParamElement(_defaultCategory.is_active,'StringLiteral',$createDataKey.id$)}}" stepKey="click1"/>
</test>

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

  • _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.
  • $createDataKey.id$ is a reference to persisted data created in the SampleTest1 within the stepKey="createDataKey" action.
  • {$variable} is a reference to data returned by a test action, like <grabValueFrom>.
  • Privacy
  • Terms of Use
  • Do not sell or share my personal information
  • AdChoices
Copyright © 2024 Adobe. All rights reserved.