lundi 18 septembre 2017

Test an element is in viewport with protractor

I want to test if my app scrolled to a specific post inside a thread page.

Initially I thought isDisplayed might help, and coded something like:

element(by.id(postId)).isDisplayed().then((isDisplayed) => {
  expect(isDisplayed).toBe(true);
});

After a closer reading of the documentation, isDisplayed does not check if an element is inside the viewport.

A hacky way would be to calculate the positions of various elements, starting with the scrollable parent (which is not window in my case).

Is there a best practice for checking this?

Aucun commentaire:

Enregistrer un commentaire