18 January 2026:
Sahi Pro is an enterprise grade test automation platform which can automate web, mobile, API, windows and java based applications and SAP.
This forum is now archived and is in read-only mode. Please continue discussions on our improved new Sahi Pro Community forum.
Sahi Pro is an enterprise grade test automation platform which can automate web, mobile, API, windows and java based applications and SAP.
.parentElement TypeError
globalworming
Moderators
Hi all
When executing a test i have a code i.e
var $a=_image("xy");
_log((_image("xy").parentElement.parentElement.title);
_log($a.parentElement.parentElement.title);
in the record tab, accessing the image by $a or by name works fine. When I play back this code, the line
_log((_image("xy").parentElement.parentElement.title);
works as expected, but
_log($a.parentElement.parentElement.title);
throws an error: TypeError: Cannot read property "parentElement" from undefined.
Does anyone have an idea why this is happening. Unfortunately I m relying on refering to pictures by a varible. This code is in a for-loop and I got many pictures
Regards
Wormi
When executing a test i have a code i.e
var $a=_image("xy");
_log((_image("xy").parentElement.parentElement.title);
_log($a.parentElement.parentElement.title);
in the record tab, accessing the image by $a or by name works fine. When I play back this code, the line
_log((_image("xy").parentElement.parentElement.title);
works as expected, but
_log($a.parentElement.parentElement.title);
throws an error: TypeError: Cannot read property "parentElement" from undefined.
Does anyone have an idea why this is happening. Unfortunately I m relying on refering to pictures by a varible. This code is in a for-loop and I got many pictures
Regards
Wormi
This discussion has been closed.
Comments
var $Child = _table("/x-grid3-row-table.*/");
var $Parent = $Child.parentElement.parentElement.parentElement.parentElement;
Error displayed in log file:
"Cannot read property "parentElement" from undefined"
Please suggest a solution
Regards,
vinoth
parentNode is an API that you are looking for.
Repace parentElement with parentNode and you should be fine.
Regards.