How to scroll a modal window in Capybara
Assuming your HTML snippet is incorrect and the button element is actually contained in the modal (as in your text description), then you can try something like
within('.modal') do btn = find(:button, 'TextOnButton', visible: :all) execute_script('arguments[0].scrollIntoView(true)', btn) btn.clickend
This work:
execute_script('arguments[0].scrollIntoView(true)', element)
I understand you are already executing code on the modal, but just wondering have you used driver.switchTo().window(handle) to switch to that modal first?