getLocation
Bestäm ett elements position på sidan. Punkten (0, 0) avser det övre vänstra hörnet av sidan.
Usage
$(selector).getLocation(prop)
Parameters
Name | Type | Details |
---|---|---|
prop | string | kan vara "x" eller "y" för att få ett resultatvärde direkt för enklare kontroller |
Example
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
});
Returns
- <Object|Number>
return
: X- och Y-koordinaterna för elementet på sidan{x:number, y:number}