انتقل إلى المحتوى الرئيسي

الحصول على الحجم

الحصول على العرض والارتفاع لعنصر 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

Welcome! How can I help?

WebdriverIO AI Copilot