Zum Hauptinhalt springen

getLocation

Ermittle die Position eines Elements auf der Seite. Der Punkt (0, 0) bezieht sich auf die obere linke Ecke der Seite.

Usage
$(selector).getLocation(prop)
Parameters
NameTypeDetails
propstringkann "x" oder "y" sein, um direkt einen Ergebniswert für einfachere Überprüfungen zu erhalten
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
});
Returns
  • <Object|Number> return: Die X- und Y-Koordinaten für das Element auf der Seite {x:number, y:number}

Welcome! How can I help?

WebdriverIO AI Copilot