I'm using watir-webdriver gem and recently came to a halt when trying to click some elements on firefox.
When trying to click an element that is out of viewport, the page scrolls and places the element at the top of the page. Which is essentially just:
require 'watir-scroll'
element = @browser.div({:id=>'potatoes'})
element.wait_until_present
@browser.scroll.to(element)
element.click
OR
$("div[id='potatoes']").scrollIntoView();
However this is causing me some issues as I have an overlaying banner running at the top of the page, which in turn causes the element to be "behind" it. Is there an easy way to attempt to scroll to an element, but instead of placing it at the top of the viewport, try to centre it.
Additionally I have used:
$("div[id='potatoes']").scrollIntoView(false);
to scroll to the element and place it at the bottom of the page, however it would be nice to have it centred, in case I wanted to have banners at the bottom of the page.
Regards