(element, useAttributes)
| 89 | }; |
| 90 | |
| 91 | var getElementString = function(element, useAttributes) { |
| 92 | // Check if element has tagName property |
| 93 | if (!element || !element.tagName) { |
| 94 | return ''; |
| 95 | } |
| 96 | var tagName = element.tagName.toLowerCase(); |
| 97 | var siblingInfo = getSiblingInfo(element, useAttributes); |
| 98 | |
| 99 | if (useAttributes) { |
| 100 | var attributes = []; |
| 101 | var attrNames = ["@type=", "@class=", "@name=", "@id="]; |
| 102 | var attrValues = [element.type, element.className, element.name, element.id]; |
| 103 | |
| 104 | for (var i = attrNames.length - 1; i >= 0; i--) { |
| 105 | if (typeof attrValues[i] !== "undefined" && attrValues[i] !== "") { |
| 106 | attributes.push(attrNames[i] + "'" + attrValues[i] + "'"); |
| 107 | } |
| 108 | } |
| 109 | |
| 110 | if (attributes.length > 0) { |
| 111 | tagName += "[" + attributes.join(" and ") + "]"; |
| 112 | } |
| 113 | } |
| 114 | |
| 115 | if (siblingInfo.num > 0) { |
| 116 | tagName += "[" + siblingInfo.index + "]"; |
| 117 | } |
| 118 | |
| 119 | return tagName; |
| 120 | }; |
| 121 | |
| 122 | var buildPath = function(element, useAttributes) { |
| 123 | var path = getElementString(element, useAttributes); |
no test coverage detected