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.
_parent dom relation
Why doesn't a DOM relation
Ideally, it would look something like this. To get the first DIV that is a parent of a TABLE called "myTable" and where the DIV has the class "container", I would do:
As a side note, you can implement something to achieve similar functionality (but unfortunately, a less convenient interface since it's not really a DOM relation) by doing the following:
And using the above like so:
Furthermore, I'm aware that while my temporary solution works, you could likely achieve a much more efficient version by writing it in the API itself.
_parent
exist in the API? This would only search against elements which are parents of the provided element. This would add functionality because currently, using
_parentNode
, you can only specify a tag type and an occurrence index (and it's not a DOM relation, it's an accessor).Ideally, it would look something like this. To get the first DIV that is a parent of a TABLE called "myTable" and where the DIV has the class "container", I would do:
var $firstDiv = _div(0, {className: "container"}, _parent(_table({id:"myTable"})));
As a side note, you can implement something to achieve similar functionality (but unfortunately, a less convenient interface since it's not really a DOM relation) by doing the following:
function findParent($apiType, $tagName, $identifier, $childNode){
//start search on the first parent
var $parent = _parentNode($childNode, $tagName);
do{
//getting reference to old parent
var $child = $parent;
//setting parent to parent of old parent
$parent = _parentNode($parent, $tagName);
//getting all children of the new parent that match the identifier
var $children = _collect($apiType, $identifier, _in($parent));
//checking each match to see if they are a parent of the original childNode
for(var $index in $children){
//if element matches and is a parent, we can return the previous parent
//in other words, ($children[$index] === $child) at this point
if(_contains($children[$index], $childNode)){
return $child;
}
}
} while($parent != null);
return null;
}
And using the above like so:
var $firstDiv = findParent("_div","DIV",{className:"container"},_table({id:"myTable"}));
Furthermore, I'm aware that while my temporary solution works, you could likely achieve a much more efficient version by writing it in the API itself.