Saltar al contenido principal

getSize

Obtener el ancho y alto de un elemento DOM.

Uso
$(selector).getSize(prop)
Parámetros
NombreTipoDetalles
prop
opcional
Stringtamaño a recibir [opcional] ("width" o "height")
Ejemplo
getSize.js
it('should demonstrate the getSize command', async () => {
await browser.url('http://github.com')
const logo = await $('.octicon-mark-github')

const size = await logo.getSize()
console.log(size) // outputs: { width: 32, height: 32 }

const width = await logo.getSize('width')
console.log(width) // outputs: 32

const height = await logo.getSize('height')
console.log(height) // outputs: 32
})
Devuelve
  • <Object|Number> return: tamaño del elemento solicitado ({ width: <Number>, height: <Number> }) o ancho/alto real como número si se proporciona el parámetro prop

Welcome! How can I help?

WebdriverIO AI Copilot