.getLocation(options)
Retrieves x and y coordinates of element.
Usage
element(matcher).getLocation(options)
Parameters
options(Object?):options.relative(Boolean?): Determines if the location should be calculated relative to the viewpoint. Defaults to false.
Returns
Promise (Object):
x(Number): x coordinate of element.y(Number): y coordinate of element.
Support
| Platform | Supported |
|---|---|
| iOS | Yes |
| Android | Yes |
| Web | Yes |
Examples
Absolute x and y coordinates of element:
const { element, by, expect } = require("appdriver");
(async () => {
const location = await element(by.label("box"))
.getLocation();
return expect(location).toEqual({
x: 100,
y: 1400
});
})();
Relative x and y coordinates of element:
const { element, by, expect } = require("appdriver");
(async () => {
const location = await element(by.label("box"))
.getLocation({ relative: true });
return expect(location).toEqual({
x: 100,
y: 150
});
})();