دریافت موقعیت
تعیین موقعیت یک عنصر در صفحه. نقطه (0، 0) به گوشه بالا سمت چپ صفحه اشاره دارد.
استفاده
$(selector).getLocation(prop)
پارامترها
نام | نوع | جزئیات |
---|---|---|
prop | string | میتواند "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}