Aller au contenu principal

getSize

Obtenir la largeur et la hauteur d'un élément DOM.

Utilisation
$(selector).getSize(prop)
Paramètres
NomTypeDétails
prop
optionnel
Stringtaille à recevoir [optionnel] ("width" ou "height")
Exemple
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
})
Retourne
  • <Object|Number> return: taille de l'élément demandé ({ width: <Number>, height: <Number> }) ou largeur/hauteur réelle sous forme de nombre si le paramètre prop est fourni

Welcome! How can I help?

WebdriverIO AI Copilot