About "Element Not Found" Error
The "Element not found" error is one of the most common errors during test executions.
This error message indicates that the test execution engine could not find the target HTML element that you wanted to interact with.
On this page, you'll find examples of the causes of this error, as well as links to detailed troubleshooting manuals to help resolve this issue.
Start troubleshooting by comparing screenshots
If you come across this error, your test result screen will look something like this:
To troubleshoot, the first thing you will want to do is to compare the screenshots of when this step was recorded and when the test was run.
How to check screenshots
Navigate to the step that failed with the "Element not found" error and click the thumbnail of the screenshot.
From there, you'll see the screenshots that were taken during recording and the current test run.
Check the screenshot labeled "Current result" and verify whether or not the target element is visible on the screen. You will likely encounter one of three different cases:
Case 1: The target element is displayed, and the screenshot looks the same as the one taken in a previous execution/recording
If you see the target element displayed in the "Current result" screen, but the test is failing, here are some possible causes:
- You were using a CSS selector, and the selector was incorrect.
- The attributes of the target element or the underlying structure of the page have been changed.
- Try recording the step again. If the step is still unstable, consider using a CSS selector.
- You recorded the step against the parent/ancestor element of the desired target. The green-lined highlight in the screenshot was applied to the larger area than usual. (This tends to happen in an assertion step where you are trying to check an element's text.)
- Try recording the step again. Make sure to interact with the target element at its center, not at its edge.
Case 2: The target element is displayed, but the color, styling, or text is different
If you see that the target element is displayed, but its color, styling, or text looks different from when it was recorded, the following may be the cause:
- The element displays dynamic data, and the data shown during recording is different from when the test was executed. For example, the element you are testing may display today's date. When the test was recorded, the date displayed was 01/01/2022, but when you execute the test at a later date, a different date would be displayed, such as 12/05/2022.
Case 3: The target element is not displayed
If you don't see the target element displayed in the "Current result" screen, the following could be possible causes:
- The page was still loading.
- Try adding a Sleep step before the failed step.
- The element was hidden when the step was executed. The visibility of the target element was based on certain prerequisites.
- The screenshot shows a different page. It could not navigate to the desired page/state in the preceding steps.
- Check the preceding steps and see if a disabled link/button was clicked.
If you are still having trouble...
Contact our Customer Success team anytime and we can work with you to resolve this matter. 🙂
- To learn how to edit scenarios, see Adding and Deleting Steps