lefthandedgoat / canopy

f# web automation and testing library, built on top of Selenium (friendly to c# also)
http://lefthandedgoat.github.io/canopy/
MIT License
505 stars 117 forks source link

Elements obscured behind fixed navbar not being found #490

Open Pwntheon opened 4 years ago

Pwntheon commented 4 years ago

We do a run of our test suite on small resolution, and in some cases we get the following issue:

We check an element which causes the screen to scroll. It scrolls just enough for another element to still be inside the viewport, but behind the fixed top navbar. When we then try to click this second element, canopy won't scroll up to reveal it, it just fails with "Timed out!" after a bit.

We have started scrolling to the top of the page in a few of our tests, but as this has been happening quite a few times on different device sizes for different tests, it's starting to feel like we are polluting our code a bit.

Is there an elegant way to solve this? Or maybe make a change in canopy where if an item is inside the viewport but behind another element, try to scroll it to the middle of the viewport before interacting with it?

lefthandedgoat commented 4 years ago

It says 'Timed out!' because selenium is trying to click it but it can't because its obstructed by your floating header.

There are several ways to solve it, you can read what others do here: https://stackoverflow.com/questions/34532306/selenium-element-is-hidden-behind-floating-header

Personally I write a little js function to remove the header.