MCPcopy Create free account
hub / github.com/InverseUI/InverseUI-Recorder / buildPath

Function buildPath

util/xpath_utils.js:122–143  ·  view source on GitHub ↗
(element, useAttributes)

Source from the content-addressed store, hash-verified

120 };
121
122 var buildPath = function(element, useAttributes) {
123 var path = getElementString(element, useAttributes);
124 if (!path) {
125 return '';
126 }
127 var parent = element.parentNode;
128
129 while (parent && parent.tagName) {
130 if (!useAttributes) {
131 if (element.id !== "") {
132 return "//" + element.tagName.toLowerCase() + "[@id='" + element.id + "']";
133 }
134 if (parent.id !== "") {
135 return "//" + parent.tagName.toLowerCase() + "[@id='" + parent.id + "']/" + path;
136 }
137 }
138 path = getElementString(parent, useAttributes) + "/" + path;
139 parent = parent.parentNode;
140 }
141
142 return path.replace(/^((\/){0,2}html)/, "/html");
143 };
144
145 return buildPath(element, useAttributes);
146}

Callers 1

getElementInfo_CustomFunction · 0.85

Calls 1

getElementStringFunction · 0.85

Tested by

no test coverage detected