6 min read time

Creating robust tests with Micro Focus LeanFT’s Object Identification Center

by   in DevOps Cloud (ADM)

One of the most common tasks in functional test automation is creating unique identifications for your application’s UI objects.  These identifications should be created in a way that will enable identifying the objects in different environments and under different conditions.

The Object Identification Center (OIC) is a Micro Focus Lean Functional Testing (LeanFT) tool that is available from the LeanFT IDE plugin or as a standalone tool. It enables creating unique and robust object identifications easily and efficiently.

In this blog we will see how to use the Object Identification Center.

 

Use Case

Let’s assume we want to create a test that verifies the existence of a certain product in the Speakers section of the  Advantage Online Shopping website:

1.jpg

The first step in our script will take care of starting the process by clicking the “Speakers” link (highlighted above). Clicking the link requires us to first create identification code for this link. Let’s see how we do this using the Object Identification Center.

Note: While this demonstration is on a Web application, the Object Identification Center can be used similarly for applications of other technologies that are supported by LeanFT, such as the think client and mobile applications.

 

Creating object identification code

Assuming our testing project is already open in the IDE, let’s launch our browser and navigate to the website. We will then open the Object Identification Center from the IDE’s toolbar:

2.png

The following window opens:

3.png

Now, let’s identify the Speakers link and then click on it. To begin, we’ll click the large image at the center of the Object Identification Center (1) or the button in the lower right corner (2).

This enables us to hover over the objects in the website (with a pointing hand cursor) and see their properties. When we finally hover over the object we want, we click on it to select the object.

 

Tip: You can press and hold the keyboard’s Ctrl key while spying, so that mouse clicks are not captured by the Object Identification Center, but are used normally by the operating system.

 

When we click the object, we see the following in the Object Identification Center:        

  • The hierarchy of the clicked object and the object’s type (3).
  • The properties of the clicked object, based on its type (4).

 

 4.png

Notice how the Object Identification Center presents the hierarchy of the clicked object as well as a comprehensive list of properties that can be used to identify the object. In addition, the Object Identification Center provides a recommendation for a unique identification of the object. The recommended hierarchy and properties are marked with a star. In this screenshot we see only some of the recommended properties—just because not all of them are currently visible. To see them, we can scroll down, or even simpler – we can sort the properties by Recommended (5) to view them first (6):

5.png

If we are not satisfied with the identification recommendation, we can customize the identification by switching to the “Edit Mode” view. To do this we should click the “Switch to edit mode” button (7) in the Object Identification Center’s title bar.

In Edit Mode, check boxes appear adjacent to each object of the hierarchy (8) and adjacent to the properties (9) of the object.

 6.png

We will select the objects and properties to participate in the object’s identification, as well as edit the values of the properties (10) if needed. Let’s check only the TagName property and then click the Highlight button (11). This highlights the objects that the selected hierarchy and properties describe.

 If the identification is not unique, like in this example, we’ll get a notification about how many objects were found:

7.png

In this case, we’ll select more properties to make the identification unique, and then try to highlight again.

If we select ClassName and InnerText in addition to TagName and try to highlight, we’ll see the following:

8.png

Now the object is highlighted in the AUT, and we are notified that one matching object was found.

Tip: We could also identify the object by XPath, CSS, and Attributes which are specific to the Web technology, and can be very useful.

If there are problems identifying the object under several conditions, we can provide a regular expression for the values of the properties and click the asterisk (*) adjacent to the value of the property (12).

Once the object is identified correctly, we can use it in our test. We can manually write the identification code in our test based on the identification properties, or we could use the Generate code to clipboard feature.

Let’s click Generate code to clipboard (13). This generates descriptive code to identify the object, and copies the generated code to the clipboard.

In our example, the code is generated in Java because we are using the Object Identification Center from Eclipse. If we had launched it from Visual Studio, the code would have been generated in C#.

In addition, it is possible to configure the Object Identification Center to generate a JavaScript code, which is useful when creating tests using the LeanFT JavsScript SDK. This is done in the Object Identification Center’s settings:

 9.png

 The generated descriptive code looks like this:

browser.describe(WebElement.class, new WebElementDescription.Builder().className("shop_now 
roboto-bold ng-binding").tagName("SPAN").innerText("SPEAKERS").build());

 

Notice that “browser” is a placeholder, and we need to replace it with the name that we gave to the browser object earlier in our script. If we did use the name “browser” for the browser object, we can use the generated code as is. We can then assign the “describe” statement to a variable (14).

The “describe” method returns a test object, which enables us to manipulate the corresponding object in the application itself using the API provided by LeanFT for test objects of this type.

In our case, because we want to click the link, we will use the click() method (15). Our code will look similar to the following:

10.png

Now we can continue with the rest of the script and include the required verifications.

 

Conclusion

To conclude, the Object Identification Center is a simple-to-use, yet powerful tool, that allows us to create robust object identifications easily and efficiently.

 

About LeanFT

Micro Focus Lean Functional Testing (LeanFT), is a functional test automation solution, which was built specifically for continuous testing and continuous integration.

LeanFT enables advanced automation engineers and dev-testers in agile teams to leverage standard development IDEs to create automated functional tests, using modern programming languages.

In addition to its SDKs, LeanFT provides plugins for these IDEs, including powerful tools like the Object Identification Center and Application Models.

You can find more information about LeanFT in the LeanFT Help Center.

 

Thanks to Yevgeny Efter from the LeanFT R&D team for providing this article!

 

Try Lean Functional Testing for yourself!

Feel free to leave a comment in the box below.

 

Labels:

Functional Testing
  • Thanks Yossi - I'd like to recommend a followup article leveraging the OIC with Application Models.  Although the OIC will generate descriptive code, I've never found this useful in cases where you're managing large sets with objects that could change frequently. 

    For instance, if this object's properties change, you now have to go update all instances of the descriptive reference for every test.  Utilizing app models, you can update the app model itself and all test references are updated by extension - this is a major selling point and would hate to see it overlooked.

    DP has it's place, but I've always encouraged utilizing OR's or App models when possible. 

    Thanks - John