Seeking the positions of a specific tag on a webpage using PhantomJS, such as <a>
tags, and aiming to obtain an array like this one:
[
{
tag: "a",
x: 12,
y: 32,
width: 100,
height: 30
},
...
]
The code I have written is as follows:
page.open(url, function(status){
....
....
var a_tags = page.evaluate(function() {
return document.getElementsByTagName('a');
});
for(index in a_tags){
console.log(a_tags[index].getBoundingClientRect());
}
....
....
})
However, running this code leads to the following error:
TypeError: null is not a function (evaluating 'a_tags[index].getBoundingClientRect()')
I am seeking guidance on how to retrieve this information from a webpage using PhantomJS and what might be causing the issue with my current code?