getLocation
Ustal położenie elementu na stronie. Punkt (0, 0) odnosi się do lewego górnego rogu strony.
Użycie
$(selector).getLocation(prop)
Parametry
Nazwa | Typ | Szczegóły |
---|---|---|
prop | string | może być "x" lub "y", aby bezpośrednio uzyskać wartość wyniku dla łatwiejszych asercji |
Przykład
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
});
Zwraca
- <Object|Number>
return
: Współrzędne X i Y elementu na stronie{x:number, y:number}