GUI UFT Mobile and Web 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.
Note: In UFT 15.0, AI-based testing is supported for mobile testing only.
In UFT 15.0.1, desktop web support is added as a technical preview.
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
Install the version of AI Features that is delivered with your UFT version.
For UFT 15.0, install UFT AI Features version 2.0
For UFT versions 15.0.1 and later, the UFT AI Features version number matches the UFT version number.
You can run the installation manually, using the setup wizard or you can run it silently from a command line.
|Manual installation||Silent installation|
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.
msiexec /qn /i "<UFT DVD>\AI\AI_Installer.msi" ADDLOCAL="AI_Services"
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.
Use AI inspection to identify objects in your application that you can use in your test steps.
|If you are testing an application on a mobile device||If you are testing a desktop web application|
Supported browsers: Chrome, Chromium-based Edge, Firefox, Internet Explorer.
Headless browsers are not supported.
Access the AI Spy from within the Object Spy:
In UFT, click the Object Spy toolbar button to open the Object Spy.
In the Object Spy, click the AI spy .
Click on your mobile application in the remote access window.
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.
In the Object Spy, as you spy on objects in mobile or web applications, UFT also presents the AI object you could use to represent the same object.
Once you click on an object in the application, an AI object is suggested only for the object you clicked. AI objects are not suggested for any other objects in the hierarchy displayed in the Spy.
Drag the AI object into your test to create a step that performs an operation on that object.
To toggle off the AI suggestions, toggle off AI Auto Inspection.
Tip: This setting remains in effect in subsequent Spy sessions and subsequent UFT sessions, until you toggle it on again.
Open the AI Identification View window to inspect your application and detect all AI objects in it.
To open the window, do one of the following:
- Click the AI Identification toolbar button.
- At the bottom of the Object Spy, click INSPECT. (Available when AI Auto Inspection in the Spy is toggled on).
Click on a web application or on the remote access window displaying your mobile application.
Note: You can skip this step if you began the inspection from the Object Spy and the top-level object in the spy is a Web browser or Mobile device. UFT automatically selects that browser or device for inspection.
The AI Identification View displays an image of the application, highlighting all of the detected objects.
- You can decide whether to show Visual Element or Text, 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.
Verify support for selecting from a combo box (Optional)
Supported on UFT versions 15.0.1 and later
Selecting items from a combo box is a complex operation. UFT can perform a Select operation on a combo box identified by AI only if it can also identify this combo box as a WebList or a MobileDropDown.
When inspecting your application for objects using AI, if UFT identifies a combo box, it displays a Verify icon on the object. Click this icon to check whether UFT can run Select operations on this object before adding such steps to your test.
Tip: Try verifying more than once. Depending on various environment conditions, even if verification failed, UFT may find the necessary object on subsequent attempts.
Add AI-based steps to your tests
Set the AI context
Before you can run any AI-based steps in your test, you must set the context in which to use AI. Add a statement to your test similar to this one:
UFT 15.0: The context must be a mobile Device test object that exists in your object repository.
UFT 15.0.1 and later: The AI context can be one of the following:
A mobile Device test object stored in your object repository.
A web Browser test object stored in your object repository or described using descriptive programming.
The web Browser can run on a Desktop or Mobile device, and be opened manually or from the Record and Run settings.
Add test steps
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 Object Spy or the AI Identification View 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.
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 page or screen in your application and you want to continue on another one, navigate to the desired location in the application itself. Then, in the AI Identification View window, click REFRESH to load the new application screen and re-inspect it.
When working with a mobile application, navigate to the correct location in your application directly on the device or using the remote access window.
If multiple remote access windows or browser windows are open, the inspection session interacts with only one.
UFT 15.0.1: You can switch to inspect other browser windows or mobile devices that are open on your computer. Click CHOOSE in the AI Identification View window and select a different browser or device.
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.
AI text identification requires the Windows mediaserver.exe service to be running.
If the following occurs, open the Windows Services Manager and make sure the mediaserver.exe is running:
- AI inspection cannot find objects By Text
- All FindText and FindTextBlock steps fail to return an AITextObject when running a test