Turn your manual testers into automation experts! Request a DemoStart testRigor Free

How do You Resolve Object Not Found Error in UFT?

In Unified Functional Testing (UFT), exceptions are events that occur during test execution. These errors are triggered when the application behaves differently than expected, leading to test script failure. So, UFT provides a mechanism to handle these exceptions so that the test execution continues even if these unexpected situations occur.

We will discuss one common exception in UFT: Object Not Found. So, let’s see how this exception is triggered and how we can resolve it.

Root Cause for Object Not Found Error

Object Not Found Exception occurs when UFT cannot locate a specific object on the application while executing test scripts. This exception is critical and common as the automation operates based on identifying and interacting with the elements. So automation may not proceed if one of the elements is not found.

This exception can happen due to various reasons:

  • Change in Object Properties: The Element properties are always dynamic and subject to change at any time by developers or design teams. Automation will fail if there is a change to the properties after creating the test script.
    • Example: Consider a button’s label was “Submit” while creating a test script and later changed to “Order Submit.” So UFT won’t be able to find the element with the name Submit, and this exception will be raised.
  • Dynamic Object Properties: For applications created using React, etc., the class names will mostly load dynamically every time. So, the automation scripts designed based on these class names may fail as they are highly unstable.
    • Example: A web element might have a class name like “button12345”, where “12345” is a session-specific identifier that changes with each session.
  • Synchronization Issues: If UFT tries to interact with the element even before the component is fully loaded, it can raise this exception.
    • Example: Clicking an element just after the page loads, but the element is not rendered fully, can cause the exception.
  • Incorrect Object Repository Entries: If the object properties stored in the UFT Object Repository are wrong, then UFT won’t be able to find this element. This can happen due to some error while capturing the element properties.
  • Frame or Window Not Set: UFT might look for the object in the wrong frame or window in applications with multiple frames or windows. For instance, trying to interact with a control inside an iframe without first switching the focus to that iframe.
  • Application Changes: Updates or changes in the application’s UI can lead to objects not being found. For example, if a new application version changes the layout, particular objects might be relocated or removed.
  • Incorrect Identification Settings: UFT has various settings for object identification, like Smart Identification and Ordinal Identifiers. If these are not configured correctly, UFT might fail to recognize objects. For instance, relying solely on index-based identification when the order of elements changes.
  • Environmental Issues: Differences in screen resolution, browser version, or other environmental factors can affect object recognition. An identifiable object on a development machine might not be found in a different testing environment.

Resolving Object Not Found Exception

  • Update Object Repository: Ensure that the objects in the UFT Object Repository match the current state of the application. This might involve re-identifying objects or modifying their properties.
  • Synchronization: Add synchronization points in your script to wait for objects to load.
    Browser("title:=MyApp").Page("title:=MyApp").Sync
    ' or
    Browser("title:=MyApp").Page("title:=MyApp").WebElement("html tag:=INPUT", "name:=Submit").WaitProperty "visible", True, 10000
  • Descriptive Programming: Directly code the object properties in the script, bypassing the Object Repository.
    Browser("title:=.*MyApp.*").Page("title:=.*MyPage.*").WebElement("html tag:=INPUT", "name:=Submit").Click
  • Dynamic Properties Handling: Use regular expressions or variable data for dynamic properties.
    Browser("title:=.*MyApp.*").Page("title:=.*").WebElement("html tag:=INPUT", "name:=regexp:Submit.*").Click
  • Check Object State: Before interacting with an object, ensure it is in an interactable state.
    ' Check if an object exists
    If Browser("title:=My Application").Page("title:=My Application").WebButton("name:=Submit").Exist(5) Then
      ' Object exists, perform actions
    Else
      ' Handle the case where the object does not exist
    End If
  • Smart Identification: Enable and configure Smart Identification in UFT. This allows UFT to identify an object even if some of its properties have changed.
  • Error Handling: Implement error handling to manage exceptions gracefully.
    On Error Resume Next ' Ignore runtime errors
    ' Attempt to click a button
    Browser("title:=My Application").Page("title:=My Application").WebButton("name:=Submit").Click
    If Err.Number <> 0 Then
      ' Error occurred, handle it
      MsgBox "Error in clicking Submit button: " & Err.Description
      Err.Clear
    End If
    On Error GoTo 0 ' Reset error handling

Using testRigor to Overcome Error: Object Not Found

UFT has been a popular tool for a long time, but it still uses the conventional method of identifying elements. This traditional method using DOM element properties like ID, Class Name, and XPath is flaky and can change anytime, leading to false positive bugs. So, the team needs to spend more hours debugging and capturing the element locators whenever a change occurs.

That’s where testRigor brings in the big difference through generative AI. It doesn’t rely on these flaky element identifiers; instead, it uses its own testRigor locators. We can mention the text as we see on the UI screen to identify elements, and testRigor, with its AI algorithms, can capture the element easily. With testRigor locators, script maintenance becomes easy as it is powered by self-healing.

Also, to add another point, testRigor doesn’t depend on any programming languages; instead, testRigor helps to write test scripts in plain English, allowing everyone to create or edit new test cases, thereby increasing the test coverage.

Let’s see an example of a test script in testRigor:
click "cart"
click on the 3rd "hello" 5 times
click on the "Cancel" to the right of "Submit"

The above example shows how easy it is to create test scripts and use the testRigor locators as plain English text. We discussed a few features of testRigor, and you can read more exciting top features here.

EndNotes

If we compare the current market demand with past years, we can see how fast it’s changing. Hence, the tools associated with the software development lifecycle also need to change. Here, testing plays a crucial role, and if the testing tool is not intelligent enough to meet the current market demand, it will fail to meet the testing goals effectively.

With minimum effort and time consumption, we need automation tools to produce more significant results. testRigor promises that it helps you utilize your quality time creating new robust test scripts rather than debugging your old code. Sign up to experience the testRigor features and save effort, time, and cost.

You're 15 Minutes Away From Automated Test Maintenance and Fewer Bugs in Production
Simply fill out your information and create your first test suite in seconds, with AI to help you do it easily and quickly.
Achieve More Than 90% Test Automation
Step by Step Walkthroughs and Help
14 Day Free Trial, Cancel Anytime
“We spent so much time on maintenance when using Selenium, and we spend nearly zero time with maintenance using testRigor.”
Keith Powe VP Of Engineering - IDT
Related Articles

SAP Concur Testing

Concur Technologies, now SAP Concur, is an American software-as-a-service (SaaS) company providing travel and expense management ...

Authorize.net Testing

You need a payment gateway in several scenarios, especially when you are running a business that requires secure, efficient, and ...
On our website, we utilize cookies to ensure that your browsing experience is tailored to your preferences and needs. By clicking "Accept," you agree to the use of all cookies. Learn more.
Cookie settings
Privacy Overview
This site utilizes cookies to enhance your browsing experience. Among these, essential cookies are stored on your browser as they are necessary for ...
Read more
Strictly Necessary CookiesAlways Enabled
Essential cookies are crucial for the proper functioning and security of the website.
Non-NecessaryEnabled
Cookies that are not essential for the website's functionality but are employed to gather additional data. You can choose to opt out by using this toggle switch. These cookies gather data for analytics and performance tracking purposes.