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

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

تحديد موقع العنصر على الصفحة. النقطة (0، 0) تشير إلى الزاوية العلوية اليسرى من الصفحة.

الاستخدام
$(selector).getLocation(prop)
المعلمات
الاسمالنوعالتفاصيل
propstringيمكن أن تكون "x" أو "y" للحصول على قيمة نتيجة مباشرة لتسهيل عمليات التحقق
مثال
getLocation.js
it('should demonstrate the getLocation function', async () => {
await browser.url('http://github.com');
const logo = await $('.octicon-mark-github')
const location = await logo.getLocation();
console.log(location); // outputs: { x: 150, y: 20 }

const xLocation = await logo.getLocation('x')
console.log(xLocation); // outputs: 150

const yLocation = await logo.getLocation('y')
console.log(yLocation); // outputs: 20
});
العوائد
  • <Object|Number> return: إحداثيات X و Y للعنصر على الصفحة {x:number, y:number}

Welcome! How can I help?

WebdriverIO AI Copilot