Tech Preview, Relevant for: GUI UFT Mobile tests only
This topic describes how to install and use UFT Artificial Intelligence (AI) Features to identify objects the way a person would, enabling you to run the same test on different platforms and versions, regardless of the objects' implementation.
Install and enable UFT AI Features
To use UFT's AI features, you need to install them, and enable them in the Options dialog box:
Before installing the AI features, make sure you have the following installed:
Microsoft Visual C++ 2013 Redistributable
One of the following Windows features, depending on your Windows operating system:
Windows OS Windows Server OS Microsoft Media Feature Pack Microsoft Media Foundation
Install UFT AI Features
From the UFT DVD, run AI\setup.exe installation file and follow the on-screen instructions.
When selecting the features to install, you only need the AI Engine.
Note: The AI Codeless Testing Tool feature is not part of UFT. It is a standalone tool that lets you experiment with AI Codeless testing. Installing AI Codeless requires additional prerequisites. See the UFT AI Codeless Help Center.
Enable the UFT AI features
- Open the Options dialog box to the AI pane of the GUI Testing tab (Tools > Options > GUI Testing > AI).
- Select the AI active option.
- Restart UFT.
If you use the Generate Script option in the Options dialog box, the AI Active option is included in the script. For details, see General Pane (Options Dialog Box > GUI Testing Tab).
Add a statement to the generated script to restart UFT if this option's value is modified. For details, see the Options Object > AI Property section of the UFT Automation Object Model Reference.
Inspect your application for objects
Use the AI inspection tool in the Object Spy to identify objects in your application that you can use in your test steps.
- Make sure the Web Add-in and Mobile Add-in and installed and loaded.
- Connect to UFT Mobile and open your mobile device and the application you want to test. For details, see Open a remote access window and application manually.
Inspect your application
In UFT, click the Object Spy toolbar button to open the Object Spy.
In the Object Spy, click the AI spy .
Click on the remote access window displaying your mobile application.
The spy's AI Identification View displays an image of the application, highlighting all of the detected objects.
You can switch between By Object and By Text modes, to see either the objects that UFT detected visually, or areas of text in the application.
Help design the future of AI-based testing in UFT
Click How is the detection? Help us improve to open the Feedback Tool and send Micro Focus feedback about the object detection. For details, see AI-based testing Feedback Tool.
Add AI-based steps to your tests
You can add AI-based steps to your test in one of the following ways:
Drag and Drop the identified Object or Text from the inspection results window into your test.
The step added for each object includes any information used to identify it uniquely, such as associated text or the objects relative location on the screen. See Associating text with objects and Identifying objects by relative location.
Edit your test using the AIUtil object.
First, set the context in which to use AI. This must be a mobile Device test object that exists in your object repository.
Next, use the AIUtil object to identify the control by type, text, or a combination thereof, and to perform operations on the objects, such as Click, Type, or Search.
For details, see AI-based Testing in the UFT Object Model Reference.
The following example clicks a settings control on a mobile device and then types a user name in the appropriate field. Both controls are identified visually using AI.
Next, the Log In text is located on the screen and clicked.
After logging in, this example clicks an "ON" button. Since the application contains a few similar buttons, the example specifies that button to click is the third button from the top.
AIUtil.SetContext Device("device") 'Set the context for AI AIUTil("settings").Click AIUtil("input", "USER NAME").Type "admin" AIUtil.FindTextBlock("Log In").Click AIUtil("button", "ON", "FromTop", 3).Click
Tip: UFT generates steps that use FindTextBlock, as the spy identifies full blocks of text. When you create your own steps, consider using the FindText method, which will match the text you provide, even if it is only part of a larger text block.
Continue to the application's next screen
When you finish creating test steps for one screen in your application and you want to continue on another screen, work with your application in the remote access window or directly on the device to move to the next screen.
Then, in the spy's AI Identification View window, click Refresh to load the new application screen and re-inspect it.
Tip: If multiple remote access windows are open, the inspection session interacts with only one.
Run AI-based tests
After inspecting your application and creating test steps, run your AI-based test as you would run any other UFT test. See Run / Debug tests.
You can run the same test on different operating systems and versions, as it is not based on implementation details.