| 52 | } |
| 53 | // function to get the XPath of an element |
| 54 | function getXPath(element) { |
| 55 | if (!element) return ''; |
| 56 | if (element.id !== '') return '//*[@id="' + element.id + '"]'; |
| 57 | if (element === document.body) return '/html/body'; |
| 58 | |
| 59 | let ix = 0; |
| 60 | const siblings = element.parentNode ? element.parentNode.childNodes : []; |
| 61 | for (let i = 0; i < siblings.length; i++) { |
| 62 | const sibling = siblings[i]; |
| 63 | if (sibling === element) { |
| 64 | return getXPath(element.parentNode) + '/' + element.tagName.toLowerCase() + '[' + (ix + 1) + ']'; |
| 65 | } |
| 66 | if (sibling.nodeType === 1 && sibling.tagName === element.tagName) { |
| 67 | ix++; |
| 68 | } |
| 69 | } |
| 70 | return ''; |
| 71 | } |
| 72 | return findInputs(document.body); |
| 73 | |
| 74 | function isElementDisplayed(element) { |