6

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 
        });

    });

  });
P.T.
  • 24,557
  • 7
  • 64
  • 95
Subtubes
  • 15,851
  • 22
  • 70
  • 105

1 Answers1

8

You can use getLocation() function:

element(by.id('section-executive-summary-anchor')).getLocation().then(function (location) {
    expect(location.y).toEqual(100);
});
alecxe
  • 462,703
  • 120
  • 1,088
  • 1,195