Element not found error in HTML for QA Automation

Modified on Tue, 28 Mar, 2023 at 4:12 PM

Error Name: Element not found


Description: The "Element not found" error occurs when the script is unable to locate an element on the page. This error can happen when automating web applications using Selenium or other similar tools.



Causes:


Cause 1: Incorrect locator used: The script may be using an incorrect or non-unique locator to find the element.


Cause 2: Page not loaded completely: The page may not have loaded completely before the script tries to find the element.


Cause 3: Element is not visible or clickable: The element may be present on the page, but it is not visible or clickable.


Checks:


  1. Check the element locator: Verify that the element locator being used is correct and matches the HTML structure. Check if the element locator is still valid or if any changes were made to the HTML that may have affected the locator.


  1. Check the page loading time: Check if the page has fully loaded before interacting with the element. Sometimes, the element may not be immediately available or may take some time to load. In such cases, it is important to add appropriate wait conditions before trying to interact with the element.



Debugs:


Debug 1: Double-check the locator used: Ensure that the locator used to find the element is unique and correct. You can try using a different locator if the current one is not working.


Debug 2: Wait for the page to load completely: Add a wait statement to the script to wait for the page to load completely before trying to find the element.


Debug 3: Ensure that the element is visible and clickable: Check the CSS properties of the element to ensure that it is visible and clickable. You can also use explicit waits to wait for the element to become clickable.


Debug 4:Check if the element is inside an iframe: If the element is inside an iframe, you will need to switch to the iframe first before trying to find the element.


Debug 5: Check the DOM structure: Check the DOM structure of the page to ensure that the element is present and has the correct attributes. You can use the browser's developer tools to inspect the DOM structure of the page.

Was this article helpful?

That’s Great!

Thank you for your feedback

Sorry! We couldn't be helpful

Thank you for your feedback

Let us know how can we improve this article!

Select at least one of the reasons
CAPTCHA verification is required.

Feedback sent

We appreciate your effort and will try to fix the article