--- title: "Troubleshooting 'Javascript Error' in Autify | Autify Guide" slug: "javascript-error" description: "Fix 'Javascript Error' Issues in Autify. Start your Free Trial!" updated: 2024-07-17T06:26:40Z published: 2024-07-17T06:26:40Z canonical: "help.autify.com/javascript-error" --- > ## Documentation Index > Fetch the complete documentation index at: https://help.autify.com/llms.txt > Use this file to discover all available pages before exploring further. # JavaScript Error If an error occurs in a JS step, the following message appears in the test result: ![js_error_en](https://cdn.document360.io/a099d8a2-cfd2-42ca-9906-68b4a337f4a5/Images/Documentation/js_error_en.png?sv=2026-02-06&spr=https&st=2026-11-11T14%3A10%3A47Z&se=2026-11-11T15%3A10%3A47Z&sr=c&sp=r&sig=VVYc6%2BaJX5Wod9wjh8BTi0XWMG21l6XpRR8EWu1TFXI%3D) The message after "JavaScript error: " gives you a clue as to what the issue is. Here are some possible causes of JS Step errors and how to fix them. ## The JS Step was executed before the page load was complete JS Steps are executed without waiting for the page to load. For example, if it's a JS Step that clicks on an element found by a CSS Selector, the step will fail if it's executed before the page has finished loading, since the CSS Selector can't find the element. Review the screenshots and [video logs](/docs/en/video-logs-for-test-results) of the test results. If you see a loading screen or the page is incomplete, it's possible that the JS Step was executed before the page was fully loaded. In this case, the solution is to add a [sleep step](/docs/en/sleep-step). Insert a sleep step before the JS Step so that it waits a few seconds for the page to load. ## Causes of Error Messages and Fixes Next, let's take a look at some common error messages. ### Cannot read properties of null This error message appears when you try to access a property of an object and the object is `null`. For example, suppose you want to click on an element selected by a CSS selector. If there is no element available in the CSS selector specified in `document.querySelector()`, `null` will be returned. If a `click` is executed on this returned `null`, an error will occur: ![cannot_read_properties_of_null](https://cdn.document360.io/a099d8a2-cfd2-42ca-9906-68b4a337f4a5/Images/Documentation/cannot_read_properties_of_null.png?sv=2026-02-06&spr=https&st=2026-11-11T14%3A10%3A47Z&se=2026-11-11T15%3A10%3A47Z&sr=c&sp=r&sig=VVYc6%2BaJX5Wod9wjh8BTi0XWMG21l6XpRR8EWu1TFXI%3D) Please see [this article](/docs/how-to-get-css-selectors#how-to-validate-css-selector-xpath) to check if the specified CSS selector can select the correct element. ### xxx is not defined This error occurs if you try to reference an undefined variable or function. Please ensure that the variable or function is defined. ![is_not_defined](https://cdn.document360.io/a099d8a2-cfd2-42ca-9906-68b4a337f4a5/Images/Documentation/is_not_defined.png?sv=2026-02-06&spr=https&st=2026-11-11T14%3A10%3A47Z&se=2026-11-11T15%3A10%3A47Z&sr=c&sp=r&sig=VVYc6%2BaJX5Wod9wjh8BTi0XWMG21l6XpRR8EWu1TFXI%3D) ### Error: cannot find the element with selector/XPath Some snippets in [Autify JavaScript Snippets](https://javascript-snippets.autify.com/) use a CSS selector/XPath to select the element before clicking on it. If the specified CSS selector/XPath is incorrect, or if the CSS selector contains dynamic values that change each time the test is run, the element cannot be selected and an error occurs: ![cannot_find_the_element_with](https://cdn.document360.io/a099d8a2-cfd2-42ca-9906-68b4a337f4a5/Images/Documentation/cannot_find_the_element_with.png?sv=2026-02-06&spr=https&st=2026-11-11T14%3A10%3A47Z&se=2026-11-11T15%3A10%3A47Z&sr=c&sp=r&sig=VVYc6%2BaJX5Wod9wjh8BTi0XWMG21l6XpRR8EWu1TFXI%3D) Please see [this article](/docs/how-to-get-css-selectors#how-to-validate-css-selector-xpath) and make sure the specified CSS selector / XPath can select the correct element. ## If you are still having trouble... Please contact our Customer Support team. We will help resolve the issue. ## Related articles - [How to get CSS selectors / XPath](/docs/how-to-get-css-selectors) - [Using CSS selectors effectively](/docs/how-to-use-css-selectors-effectively)