Skip to main content

getLocation

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

Usage
$(selector).getLocation(prop)
Parameters
NameTypeDetails
propstringcan be "x" or "y" to get a result value directly for easier assertions
Example
getLocation.js
it('should demonstrate the getLocation function', async () => {
await browser.url('http://github.com');
const logo = await $('.octicon-mark-github')
const location = await logo.getLocation();
console.log(location); // outputs: { x: 150, y: 20 }

const xLocation = await logo.getLocation('x')
console.log(xLocation); // outputs: 150

const yLocation = await logo.getLocation('y')
console.log(yLocation); // outputs: 20
});

Welcome! How can I help?

WebdriverIO AI Copilot