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
})