Saltar al contenido principal

getLocation

Determinar la ubicación de un elemento en la página. El punto (0, 0) se refiere a la esquina superior izquierda de la página.

Uso
$(selector).getLocation(prop)
Parámetros
NombreTipoDetalles
propstringpuede ser "x" o "y" para obtener un valor de resultado directamente para afirmaciones más sencillas
Ejemplo
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
});
Devuelve
  • <Object|Number> return: Las coordenadas X e Y del elemento en la página {x:number, y:number}

Welcome! How can I help?

WebdriverIO AI Copilot