Fix 'element not found' error | Ranorex
Help CenterUser GuideHands-on application topics

Fix ‘element not found’ error

The “element not found” error (i.e. ENF) is one of the most frequent errors that can cause a test to fail. Unfortunately, it’s often not easy to find out what caused the error, especially if you’re not that experienced in Ranorex Studio yet.

This is where this guide comes in. It will help you identify the most common causes of the error and resolve them so your test will execute successfully.

In this chapter

    Analyze report

    When you encounter the ENF error, report analysis is the first thing to do.

    ENF error in Ranorex report

    ENF error in Ranorex report

    See the report identifying a test failure
    ENF error stating that a UI-element could not be found

    Note icon

    Note

    ENF errors are often rooted in the individual characteristics of an application under test. This means that this guide can only speak in very general terms about solving such errors.

    Screenshot inspection:

    The report provides several screenshots to make it easier for you to identify what went wrong. These screenshots show what happened in the last seconds up to the error.

    Compare the screenshots and pay special attention to the UI element you wanted to find. Select corresponding to your analysis:

    1. Proceed to Step 1 if the UI-element is NOT in the screenshot
    2. Proceed to Step 2 if the UI-element is IN the screenshot

    Step 1 – UI-element is not in screenshot

    Solution approach:

    Make sure the application under test is in a correct state.

    Summary:

    If the UI-element isn’t there, it means that your application under test (AUT) wasn’t in the correct state for the UI-element to be found within the search timeout. This can have various causes. For example, a button might not appear until a certain action is completed and this action is taking longer because the system is working slower than usual. This will cause the UI-element to be there during some runs, and not during others.

    Solution:

    Ensure the application under test always reaches the correct state for Ranorex Studio to find the UI-element:

    • Check that all the actions needed to reach this state are there. For example, if a UI-element is only reachable through a context menu, make sure there is an action that opens this context menu beforehand.
    • Add validations to verify that the window, page, etc. that contains the UI-element appears during test execution.
    • Increase the search timeout on the repository item or add a WaitFor action in the action table to compensate for slowdowns of the application under test and other possible delays.

    Further reading

    The concept of test validation is introduced and explained in > Ranorex Studio fundamentals > Test validation > ⇢ Introduction.

    The search timeout of repository items can be set in the repository properties in > Ranorex Studio fundamentals > Repository > ⇢ Managing repository items.

     

    tipp icon

    Hint

    If the UI-element is still not found, proceed to Step 2.

    Step 2 – UI-element is in screenshot

    Solution approach:

    Check the RanoreXPath specification of the UI-element.

    Summary:

    If the UI-element is in the screenshot, it means that your application under test reached the correct state for the UI-element to be found within the timeout. However, Ranorex Studio still couldn’t find the UI-element, so something else must be wrong. The most likely explanation is a faulty RanoreXPath. This can have various reasons, such as changes to the GUI, dynamic parts, multilingual GUIs, or even simple typos.

    Open the UI-element in Spy

    To be able to check and edit the validity of the RanoreXPath specification it is necessary to open the UI-element in Spy.

    Opening UI-element in Spy

    Opening UI-element in Spy

    Ensure the application under test is in the same state when the ENF error occurred
    Select the repository item and click EDIT IN SPY to open it in Ranorex Spy

    Identify faulty RanoreXPath elements

    First of all, the highest faulty level in the UI-element tree browser needs to be identified for a more detailed error analysis.

    Identifying highest faulty RanoreXPath tree level

    Identifying highest faulty RanoreXPath tree level

    Identify the highest faulty tree level

    Check for RanoreXPath syntax

    Check the predicate of faulty the RanoreXPath specification for possible errors:

    • Check attributes, values, and operators
    • Look for typos, incomplete specifications and wrong values 

    Further reading

    The advanced concept of RanoreXPath is introduced and explained in > Ranorex Studio advanced > RanoreXPath > ⇢ Introduction.

    Check variables

    • Does the RanoreXPath specification contain variables?
    • Check if variables are correct and if they are bound to data sources
    • Check if the referenced values are correct

    Further reading

    The concept of variables & parameter is introduced and explained in > Ranorex Studio advanced > Variables & parameter > ⇢ Introduction.

    Re-track UI-element(s)

    Perhaps the attributes and variables are correct, but the path structure itself is faulty, resulting in the UI-element not being found. A good way to solve this problem is by re-tracking the UI-element.

    Further reading

    The tracking of UI-elements is explained in > Ranorex Studio advanced > Tracking UI-elements > ⇢ Introduction.

    Contact Ranorex support team

    If you tried everything to solve the problem, but it still remains – your challenge seems more complex. Therefore, make a snapshot of your solution and contact the Ranorex support team by means of the contact form at /support-query/.

    Further reading

    If you need to know how to create a Ranorex snapshot file, refer to > Ranorex Studio advanced > Ranorex Spy > ⇢ Snapshot files.