How to check the visibility of items in a scroll combobox?

I have a bootstrap Angular dropdown, when you click on it, it makes the UL element visible whose overflow-y is set to auto, and therefore some of the elements inside are not visible, only after scrolling up or down.

I implemented a method of automatically scrolling to the selected element (the default behavior is to remember the last scroll position), so I would like to test it with Protractor.

I already tried the isDisplayed () method, turning it to true for all elements in this UL (although only 10 out of 20 are actually visible)

expect(item20.isDisplayed()).toBe(false); //returns true

After that I tried to click on them, expecting to throw an error "element is invisible", but they were all successfully pressed.

Any ideas on how to check if an element is in the visible part of this scroll?

Visible items

+4
source share
1 answer

It seems that for Protractor these elements are actually visible, so isDisplayed will return true for all of them.

Therefore, I used the getLocation () method to compare the start and end positions of scrolled elements and, therefore, verify their correct location.

expect(selectedElement.getLocation()).toEqual(selectedElementInitialLocation);
0
source

All Articles