Reputation: 759
I am trying to get the x, y coordinates of an element in protractor Node.js. But it is returning the object.
this.dragAnddrop=function (LocatorFrom,LocatorTo ) {
var xCoord=LocatorFrom.getLocation();
var yCoord=LocatorTo.getLocation();
console.log("The location is "+xCoord+"and "+ yCoord);
}
output:
The location is [object Object]and [object Object]
Upvotes: 0
Views: 358
Reputation: 8978
right, because this is expected. positions of elements on the page have 2 coordinates: x
and y
. According to protractor's page the results of .getLocation is an object like this:
{
x: 15,
y: 20
}
So if to get x or y you should do this
var coords = LocatorFrom.getLocation();
console.log('x coord', coords.x)
console.log('y coord', coords.y)
Upvotes: 1