Element not found
  • 25 Sep 2023
  • 4 Minutes to read
  • Contributors
  • Dark
    Light

Element not found

  • Dark
    Light

Article Summary

If Autify cannot find a target element during a test run, you will see the following message in the test result:

element-not-found-message

"Element not found" is one of the most common errors during test execution. On this page, you will find possible causes of this error and how to handle it.

There are two main causes of this error. First, check the screenshot of the failed step to see which of the following applies:

  • The target element does not exist on the page.
  • The target element exists on the page, but was not found.

If the target element does not exist on the page

In this case, you must determine why the target element was not present when the failed step was executed. Possible causes are listed below. Please see if any of them apply.

An unintended action was performed in a previous step

Check the steps before the failed step and see if the intended screen transition occurred. If not, it may be because Autify clicked the wrong button or a validation error occurred during form input. In this case, please fix the previous step in question.

For example, let's say you enter an email address on the trial request page, click the "Request Trial" button, and want to validate the message that appears on the thank-you page. However, if a valid email address is not entered on the trial request page, a validation error appears, so the transition to the thank you page that should occur when the button is clicked does not occur.

transition_failure

As a result, the assertion step (Step 5 in the screenshot below) failed with an "element not found" error because it didn't transition to the intended page. The cause of the error is Step 3, where the wrong email address is entered. To fix the error, we need to make sure that the correct email address is entered in Step 3.

error-in-preceding-step

No hover step

If Autify couldn't find an element that appears on mouseover, adding a hover step may solve the problem. For more information, see Actions on elements that appear on mouseover results in Fail or Review Needed.

Timezone

The timezone of Autify's test execution environment is UTC. Please check if the test involves a date/time. For example, let's say your test checks whether a specific search result appears when the creation date/time is set as the search criteria. If the result appears when the test is manually executed in a local environment but not on Autify, the error may be caused by the timezone difference between the local environment and Autify's test execution environment.

The page was loading

If Autify searched for the element while the page was still loading, add a sleep step before the failed step to wait for the the page to finish loading.

Autify Element Search

If the target element is not present on the page, Autify will continue searching for a certain amount of time. Therefore, there is no need to use a sleep step if the page loads within that time.

Other tests had an effect

For example, let's say you have the following three scenarios:

  1. Create an item
  2. Search for the item on the search page and confirm that the item exists
  3. Delete the item

For all of these scenarios to pass, the order in which they are executed is critical. If scenario 3 is executed before scenario 2, scenario 2 will fail because Autify won't be able to find the target element.

The order in which the scenarios are executed is affected by a combination of whether Parallel Test Execution is enabled or disabled in Workspace settings, how parallels are executed, and whether or not the Data feature is used. If you suspect that the order of execution is causing the error, please see this article.

If the target element exists on the page but was not found

After reviewing the screenshot, you may find that the element does exist on the page. In this case, the cause of the "Element not found" message may be one of the following.

The page was modified

Even if the characteristics of the element are not exactly the same as in the previous test run due to page changes, Autify will follow the element with the highest match. However, depending on the nature of the changes, it may not follow the correct element.

Please check the Diff tab on the test result page. If there is a difference, the page change may be the cause of the error. In this case, the test may pass if you update the element information in one of the following ways:

Little information was available to identify the element

If the target element cannot be found even though there are few or no differences between pages, it may be because there wasn't enough information to identify the element or because there is a similar element. In this case, an effective solution is to use a locator to specify the correct element.

The element's text is dynamic

One of the characteristics that Autify uses when searching for an element is its text. Therefore, if the text of the target element is different than when it was recorded, Autify may not be able to find it. If this is the case, please see How to grab an element with dynamic data.

The CSS selector / XPath set in the locator was wrong

This error occurs when the CSS selector / XPath set in the locator cannot find the element. Please read this article and check if the element can be retrieved with the CSS selector / XPath you've set.

If you are still having trouble...

Please contact us. We will work with you to resolve the issue.


Was this article helpful?

Changing your password will log you out immediately. Use the new password to log back in.
First name must have atleast 2 characters. Numbers and special characters are not allowed.
Last name must have atleast 1 characters. Numbers and special characters are not allowed.
Enter a valid email
Enter a valid password
Your profile has been successfully updated.