This how-to explains how to create an Unsupported Widget action for the reference selector widget. In a standard situation, the first step is to check if ATS supports the widget.
The how-to assumes you must build your own action.
This how-to applies to all widgets like the reference selector widget, if the widget has a drop-down you can follow this how-to. Keep in mind that it might need some adjustments according to the widget!
This how-to will teach you how to do the following:
- Approach a drop-down widget that ATS must set
- Create the custom action to set the drop-down widget
Before starting this how-to, make sure you have completed the following prerequisite:
- Read General
3 Defining the User Approach
First you define the user approach and how you interact with the widget. Since you are creating an Unsupported Widget action, how you find the widget is not important. What is important is how you interact with it.
You interact with the widget by clicking it to see the options and then selecting the option you want. A user only clicks the widget to see the options it has.
This is the reference selector opened:
This is the reference selector unopened:
Most widgets that give options—like the reference selector and the drop-down—have a
select element that displays the options.
4 Creating the Action Structure
In the previous step, you wrote down the user approach for the reference selector widget. Now you will create this approach in ATS with actions.
To create the action structure, follow these steps:
Check the parent element, which is always the element with
mx-namewhen creating an unsupported widget action. If the widget does not have
mx-name, look for the highest
divelement that is still referencing to the widget. The parent element of the reference selector looks like this in the debugger:
The debugger creates the border around the selected element in the app:
The parent element is not an
inputelement. Find a child element that ATS can use to select an option. When you look at the parent element, you see it has a
selectchild element that ATS can use:
When you create a custom action for an unsupported widget action, you must use the Find Widget Child Node action. This action is a combination of the Find/Assert Widget and Find Element by Sizzle actions, combining the best of both. It is an official Mendix action, it has all the internal processes, and it uses a CSS/jQuery selector to find the child, which makes it flexible. The selector for finding the input element is an input. You use this selector in the Find Widget Child Node action to find an input element inside the text box widget.
Before you start creating the action, you need to know if ATS can find the select element within the reference selector widget. You use the debugger to simulate what ATS does. Since the Find Widget Child Node action uses
mx-nameto find the parent, you also must use
mx-namein your code. Use jQuery to find out if ATS can find the element. Enter the following code in the console of the debugger:
$( ‘.mx-name-referenceSelector1 select’ )
It can happen that the debugger does not return an element. Check if jQuery is available and if you constructed the code in the correct manner. When you enter a selector in ATS, don’t use
$( ‘….’ )or
jQuery( ‘…..’ ).
Add the Find Widget Child Node action to your action. Enter the child node selector
select, then enter the test step description and output description:
ATS has core actions for selecting an option from a select element. We use the Select Option by Text action, because you want to select the option based on text. Enter the output of test step 1 as an input and give a proper description:
The Select Option by Text action is a core action that triggers an event. Finish your custom action with a Mendix Wait action:
5 Action Parameters
Next, you need to add the action input parameters:
- Widget Name
- Search Context
Keep the guidelines for creating a custom action in mind while creating action parameters.
To add the action parameters, follow these steps:
Configure the Widget Name input parameter like this:
Configure the Value parameter like this:
Configure the Search Context input parameter like this:
For this custom action, you do not need an output parameter.
Connect the input parameters to the right actions. Start with the Widget Name and Search Context input parameters for the Find Widget Child Node action:
The last input parameter to connect is the Value parameter. Connect the input parameter to the Select Option by Text action:
There is no need to add logic to this custom action, since it is only selecting an option in the widget.
6 Final Check
Now check for the following:
- Use of the ATS naming convention for parameters
- A clear description of test steps, input parameters, output parameters, and action returns
- Interpunction usage in pieces of code (if used)
- Use of data types on the different parameters to avoid errors
After checking these items, you can run the test case that uses this action.
Congratulations! You have created your own custom action for the Mendix Reference Selector widget.