Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 | 4x 4x 3x 3x 3x 1x 4x 2x 2x | /**
*
* Determine an element’s location on the page. The point (0, 0) refers to
* the upper-left corner of the page.
*
* <example>
:getLocation.js
it('should demonstrate the getLocation function', () => {
browser.url('http://github.com');
const logo = $('.octicon-mark-github')
const location = logo.getLocation();
console.log(location); // outputs: { x: 150, y: 20 }
const xLocation = logo.getLocation('x')
console.log(xLocation); // outputs: 150
const yLocation = logo.getLocation('.octicon-mark-github', 'y')
console.log(yLocation); // outputs: 20
});
* </example>
*
* @alias element.getLocation
* @param {String} prop can be "x" or "y" to get a result value directly for easier assertions
* @return {Object|Number} The X and Y coordinates for the element on the page (`{x:number, y:number}`)
* @uses protocol/elementIdLocation
* @type property
*/
import { getElementRect } from '../../utils'
export default async function getLocation (prop) {
let location = {}
if (this.isW3C) {
location = await getElementRect(this)
delete location.width
delete location.height
} else {
location = await this.getElementLocation(this.elementId)
}
if (prop === 'x' || prop === 'y') {
return location[prop]
}
return location
}
|