Zum Hauptinhalt springen

getSize

Holt die Breite und Höhe für ein DOM-Element.

Verwendung
$(selector).getSize(prop)
Parameter
NameTypeDetails
prop
optional
StringGröße, die empfangen werden soll [optional] ("width" oder "height")
Beispiel
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
})
Rückgabewert
  • <Object|Number> return: angeforderte Elementgröße ({ width: <Number>, height: <Number> }) oder tatsächliche Breite/Höhe als Zahl, wenn der prop-Parameter angegeben ist

Welcome! How can I help?

WebdriverIO AI Copilot