If an error occurs in a JS step, the following message appears in the test result:
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 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. 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
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
null will be returned. If a
click is executed on this returned
null, an error will occur:
Please see this article 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.
Error: cannot find the element with selector/XPath
Please see this article 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.