Selenium testing fixed bootstrap menu (Ruby Driver)
Recently we decided to implement our website UI using bootstrap 3 as a base. Along with this conversion came some really nice menus on the header and footer of the site. I didn’t think that this change would cause too many issues with our Selenium based testing. Generally speaking, it didn’t, except for one issue. The menu is fixed, so when the selenium driver tries to click on element below the fold of the page it encounters the following error.
Ugly business
This is because the automatic scrolling used by driver.find_element and similar method calls only scrolls the page up just high enough to bring the button or link into the containing window. I’m sure there is a better solution which probably involves monkey patching the ruby driver but for the time being (we have to launch in 2 days and I need my integration tests working) I wrote the following method.
This manual scrolling brings the element into view so that we no longer get the error, calling this code before calling driver.find_element solved my problem, hopefully it helps you as well. Let me know in the comments if this works for you.