Pular para o conteúdo principal

getSize

Obter a largura e altura de um elemento DOM.

Uso
$(selector).getSize(prop)
Parâmetros
NomeTipoDetalhes
prop
opcional
Stringtamanho a receber [opcional] ("width" ou "height")
Exemplo
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
})
Retorna
  • <Object|Number> return: tamanho do elemento solicitado ({ width: <Number>, height: <Number> }) ou largura/altura real como número se o parâmetro prop for fornecido

Welcome! How can I help?

WebdriverIO AI Copilot