enium.healenium-web.3.5.4.source-code.itemsWithAttributesCss.js Maven / Gradle / Ivy
The newest version!
var xpathElement = document.querySelector(arguments[0]);
var items = [];
var result = {items: null, url: null};
var a = xpathElement;
while (a != document) {
var child = a;
var i=0; while(child=child.previousElementSibling) i++;
var node = {tag:null,id:null,index:null,classes:[],other:{},innerText:""};
if (a.tagName !== undefined) {
node.tag = a.tagName.toLowerCase();
}
node.id = a.id;
node.index = i;
node.innerText = a.innerText;
if (a.hasAttribute("class")) {
node.classes = a.attributes.class.value.split(' ');
}
for (index = 0; index < a.attributes.length; ++index) {
var attrName = a.attributes[index].name;
if (["id","class"].indexOf(attrName) == -1){
node.other[attrName] = a.attributes[index].value;
}
};
items.unshift(node);
a = a.parentNode;
}
result.items = items;
result.url = window.location.href;
return {json: JSON.stringify(result), element: xpathElement};
© 2015 - 2024 Weber Informatics LLC | Privacy Policy