I am trying to make sure the page scrolls to an element when a certain span is clicked. So I need to check the element's y
position. Can someone explain how I can get an element's position?
element.all(by.css('[scroll-to="section-executive-summary-anchor"]'))
.then(function (elem) {
elem[0].click().then(function () {
element(by.id('section-executive-summary-anchor'))
.then(function (el) {
// I need "el.position" or something along those lines
});
});
});
You can use getLocation()
function:
element(by.id('section-executive-summary-anchor')).getLocation().then(function (location) {
expect(location.y).toEqual(100);
});