getLocation

Determine an element’s location on the page. The point (0, 0) refers to the upper-left corner of the page.

Usage

1
browser.getLocation(selector,property);

Parameters

Param Type Details
selector String element with requested position offset
property String can be “x” or “y” to get a result value directly for easier assertions

Example

getLocation.js
1
2
3
4
5
6
7
8
9
10
11
12
it('should get the location of one or multiple elements', function () {
browser.url('http://github.com');

var location = browser.getLocation('.octicon-mark-github');
console.log(location); // outputs: { x: 150, y: 20 }

var xLocation = browser.getLocation('.octicon-mark-github', 'x')
console.log(xLocation); // outputs: 150

var yLocation = browser.getLocation('.octicon-mark-github', 'y')
console.log(yLocation); // outputs: 20
});

Uses