getLocationInView

Determine an element’s location on the screen once it has been scrolled into view.

Usage

1
browser.getLocationInView(selector);

Parameters

Param Type Details
selector String element with requested position offset

Example

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

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

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

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

Returns

  • <Object/Object[]>: The X and Y coordinates for the element on the page ({x:number, y:number})

Uses