跳至主要內容

getSize

取得 DOM 元素的寬度和高度。

用法
$(selector).getSize(prop)
參數
名稱類型詳細資訊
prop
選填
字串要接收的尺寸 [選填] ("width" 或 "height")
範例
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
})

歡迎!我能如何協助您?

WebdriverIO AI Copilot