отримати розмір
Отримати ширину і висоту DOM-елемента.
Використання
$(selector).getSize(prop)
Параметри
Назва | Тип | Деталі |
---|---|---|
prop необов'язковий | String | розмір для отримання [необов'язковий] ("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
})
Повертає
- <Object|Number>
return
: запитаний розмір елемента ({ width: <Number>, height: <Number> }
) або фактичну ширину/висоту як число, якщо вказано параметр prop