Simple class mapping

To begin with the example, we resolve the recognition of the '-5%' button in the right bottom corner. The figure below shows our goal. On the left we find the current recording without simplification steps, on the right we see the desired recording.

Current recordingSimplified recording
Current recordingSimplified recording
Figure 49.9:  Simplification due to simple class mapping

First you should record a simple text check or a mouse click to that button. Then jump to the recorded components via »Locate component«. There you can see that you got a component of the class DIV and an empty name. The other attributes don't provide anything useful. Please note that QF-Test didn't record the actual text of '-5%' in any attribute. This means QF-Test has no good information for recognizing that component. There is just the geometry and the structure information. Now let us make this component more readable and the component recognition more robust.

WebCarConfigDiv5
Figure 49.10:  Recording of '-5%' button in "CarConfigurator Web" demo

When analyzing the recorded component more in detail we discover that there is an extra feature class with the value button. Now we can assume that a button in our project will have that particular attribute. Especially after verifying the assumption for further buttons.

So, please insert a 'Install CustomWebResolver' node below the Extras node. As we found out previously the class attribute contains the class information for QF-Test. Knowing this, we can add Button: button to the category genericClasses. The expression Button: button signifies that any component with the CSS class button will be assigned the generic class Button. This will make QF-Test record the default features for buttons when we re-record the components. Run the 'Install CustomWebResolver' node and re-record the component. You will get the following recording:

WebCarConfig5Custom2
Figure 49.11:  Recording with genericClasses in "CarConfigurator Web"

As you can see you got a click on component button-5_. When you jump to the recorded component you can see the class Button has been assigned the '-5%' for the feature as well and we even got the extra feature qfs:label with that text. This component will now be treated as button by QF-Test. Of course, you should advise the development team to assign a dedicated ID to that button as well.

This simple assignment of one value can be sufficient for lots of cases, especially for buttons, menu items or checkboxes. If your web page doesn't contain that information in the attribute class, but in the attribute role, then you need to add Button: role=button to the category genericClasses. In some cases the information about the specific class will not be part of the leaf component, but in a parent component. The next section shows how to deal with this challenge.